mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compiler: add no_return_value context flag for script optimization
when running scripts via mruby -e or file, return values are unused. this adds a no_return_value flag to skip generating unnecessary code. for parallel assignment like a,b = 1,2: - before: 18 bytes, 5 registers, creates temporary array - after: 5 bytes, 3 registers, direct register assignment, no RETURN the flag is set only for the main program, not for libraries loaded with -r option. eval() and mirb continue returning values correctly. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,7 @@ typedef struct mrb_ccontext {
|
||||
mrb_bool keep_lv:1;
|
||||
mrb_bool no_optimize:1;
|
||||
mrb_bool no_ext_ops:1;
|
||||
mrb_bool no_return_value:1;
|
||||
const struct RProc *upper;
|
||||
|
||||
size_t parser_nerr;
|
||||
@@ -125,6 +126,7 @@ struct mrb_parser_state {
|
||||
mrb_bool no_optimize:1;
|
||||
mrb_bool capture_errors:1;
|
||||
mrb_bool no_ext_ops:1;
|
||||
mrb_bool no_return_value:1;
|
||||
const struct RProc *upper;
|
||||
struct mrb_parser_message error_buffer[10];
|
||||
struct mrb_parser_message warn_buffer[10];
|
||||
|
||||
Reference in New Issue
Block a user