diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-06-08 18:52:34 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-12 16:21:07 +0900 |
| commit | ad15e59cd942486d87e2fb38d30993f15dc29433 (patch) | |
| tree | 504c26ae1d06d52c2d6d62335940a4613c16c7e5 /mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c | |
| parent | 71eb4b2b227c083f187c634212f5fc557f392fb9 (diff) | |
| download | mruby-ad15e59cd942486d87e2fb38d30993f15dc29433.tar.gz mruby-ad15e59cd942486d87e2fb38d30993f15dc29433.zip | |
Add `irep` C struct dump from `mrbc` with `-S` option.
But we need more work:
- recursive `irep` dump (`irep->reps`)
- pool values dump (`irep->pool`)
Diffstat (limited to 'mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c')
| -rw-r--r-- | mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c index 5cd9a27fc..3be40df76 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; @@ -36,6 +37,7 @@ usage(const char *name) "-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", @@ -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++; @@ -244,7 +249,12 @@ dump_file(mrb_state *mrb, FILE *wfp, const char *outfile, struct RProc *proc, st 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); } |
