summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-bin-mrbc
diff options
context:
space:
mode:
Diffstat (limited to 'mrbgems/mruby-bin-mrbc')
-rw-r--r--mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c20
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);
}