diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-15 18:31:06 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-10-15 18:31:06 +0900 |
| commit | 9cebddf9fe83ae0acde6f64f291fa3c9fc22880f (patch) | |
| tree | 6f9ca4f2941c3da48a504c937719adca36e4cdfe /mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c | |
| parent | 8c276f95be2f4e9deed73f08125a23a6746cb517 (diff) | |
| parent | 21e07d61138a87891dc780efaa28e6c76a39378f (diff) | |
| download | mruby-9cebddf9fe83ae0acde6f64f291fa3c9fc22880f.tar.gz mruby-9cebddf9fe83ae0acde6f64f291fa3c9fc22880f.zip | |
Merge pull request #5084 from mruby/mruby3
Mruby3
Diffstat (limited to 'mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c')
| -rw-r--r-- | mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c index 4d984e773..acad28bd8 100644 --- a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +++ b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c @@ -20,6 +20,7 @@ struct mrbc_args { const char *prog; const char *outfile; const char *initname; + mrb_bool dump_struct : 1; mrb_bool check_syntax : 1; mrb_bool verbose : 1; mrb_bool remove_lv : 1; @@ -32,10 +33,11 @@ usage(const char *name) static const char *const usage_msg[] = { "switches:", "-c check syntax only", - "-o<outfile> place the output into <outfile>", + "-o<outfile> place the output into <outfile>; required for multi-files", "-v print version number, then turn on verbose mode", "-g produce debugging information", "-B<symbol> binary <symbol> output in C language format", + "-S dump C struct (requires -B)", "--remove-lv remove local variables", "--verbose run at verbose mode", "--version print the version", @@ -44,7 +46,7 @@ usage(const char *name) }; const char *const *p = usage_msg; - printf("Usage: %s [switches] programfile\n", name); + printf("Usage: %s [switches] programfile...\n", name); while (*p) printf(" %s\n", *p++); } @@ -105,6 +107,9 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args) args->outfile = get_outfilename(mrb, argv[i] + 2, ""); } break; + case 'S': + args->dump_struct = TRUE; + break; case 'B': if (argv[i][2] == '\0' && argv[i+1]) { i++; @@ -238,13 +243,18 @@ static int dump_file(mrb_state *mrb, FILE *wfp, const char *outfile, struct RProc *proc, struct mrbc_args *args) { int n = MRB_DUMP_OK; - mrb_irep *irep = proc->body.irep; + const mrb_irep *irep = proc->body.irep; if (args->remove_lv) { - mrb_irep_remove_lv(mrb, irep); + mrb_irep_remove_lv(mrb, (mrb_irep*)irep); } if (args->initname) { - n = mrb_dump_irep_cfunc(mrb, irep, args->flags, wfp, args->initname); + if (args->dump_struct) { + n = mrb_dump_irep_cstruct(mrb, irep, args->flags, wfp, args->initname); + } + else { + n = mrb_dump_irep_cfunc(mrb, irep, args->flags, wfp, args->initname); + } if (n == MRB_DUMP_INVALID_ARGUMENT) { fprintf(stderr, "%s: invalid C language symbol name\n", args->initname); } |
