- Timestamp:
- Jul 9, 2020, 8:51:43 AM (4 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-2.1.1
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-2.1.1/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
r331 r439 1 #include <stdio.h> 1 #include <mruby.h> 2 3 #ifdef MRB_DISABLE_STDIO 4 # error mruby-bin-mrbc conflicts 'MRB_DISABLE_STDIO' configuration in your 'build_config.rb' 5 #endif 6 2 7 #include <stdlib.h> 3 8 #include <string.h> 4 #include <mruby.h>5 9 #include <mruby/compile.h> 6 10 #include <mruby/dump.h> … … 19 23 mrb_bool check_syntax : 1; 20 24 mrb_bool verbose : 1; 25 mrb_bool remove_lv : 1; 21 26 unsigned int flags : 4; 22 27 }; … … 34 39 "-e generate little endian iseq data", 35 40 "-E generate big endian iseq data", 41 "--remove-lv remove local variables", 36 42 "--verbose run at verbose mode", 37 43 "--version print the version", … … 70 76 parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args) 71 77 { 72 char *outfile = NULL;73 78 static const struct mrbc_args args_zero = { 0 }; 74 79 int i; … … 85 90 if (args->outfile) { 86 91 fprintf(stderr, "%s: an output file is already specified. (%s)\n", 87 args->prog, outfile);92 args->prog, args->outfile); 88 93 return -1; 89 94 } … … 143 148 exit(EXIT_SUCCESS); 144 149 } 150 else if (strcmp(argv[i] + 2, "remove-lv") == 0) { 151 args->remove_lv = TRUE; 152 break; 153 } 145 154 return -1; 146 155 default: … … 179 188 } 180 189 fn = args->argv[args->idx++]; 181 p->f = fopen(fn, "r ");190 p->f = fopen(fn, "rb"); 182 191 if (p->f == NULL) { 183 192 fprintf(stderr, "%s: cannot open program file. (%s)\n", args->prog, fn); … … 206 215 else { 207 216 need_close = TRUE; 208 if ((infile = fopen(input, "r ")) == NULL) {217 if ((infile = fopen(input, "rb")) == NULL) { 209 218 fprintf(stderr, "%s: cannot open program file. (%s)\n", args->prog, input); 210 219 return mrb_nil_value(); … … 233 242 mrb_irep *irep = proc->body.irep; 234 243 244 if (args->remove_lv) { 245 mrb_irep_remove_lv(mrb, irep); 246 } 235 247 if (args->initname) { 236 248 n = mrb_dump_irep_cfunc(mrb, irep, args->flags, wfp, args->initname);
Note:
See TracChangeset
for help on using the changeset viewer.