diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-07-03 21:49:06 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-07-03 21:49:06 +0900 |
| commit | a1af20baa9f9a96c2a8cd6a9a1505fe53799e9c9 (patch) | |
| tree | 2fcf6c5f4a179c2b67e50ffc571a0af0bedd8c48 /tools/mirb | |
| parent | be8181a99a664d226b08d9d1f8348260c6e2bb95 (diff) | |
| download | mruby-a1af20baa9f9a96c2a8cd6a9a1505fe53799e9c9.tar.gz mruby-a1af20baa9f9a96c2a8cd6a9a1505fe53799e9c9.zip | |
use mrbc_context; free parser for each iteration; close #312
Diffstat (limited to 'tools/mirb')
| -rw-r--r-- | tools/mirb/mirb.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c index a9c0f26d2..d46bcff3c 100644 --- a/tools/mirb/mirb.c +++ b/tools/mirb/mirb.c @@ -132,6 +132,7 @@ main(void) { char last_char, ruby_code[1024], last_code_line[1024]; int char_index; + mrbc_context *cxt; struct mrb_parser_state *parser; mrb_state *mrb; mrb_value result; @@ -147,8 +148,8 @@ main(void) return EXIT_FAILURE; } - /* new parser instance */ - parser = mrb_parser_new(mrb); + cxt = mrbc_context_new(mrb); + cxt->capture_errors = 1; memset(ruby_code, 0, sizeof(*ruby_code)); memset(last_code_line, 0, sizeof(*last_code_line)); @@ -192,11 +193,11 @@ main(void) } /* parse code */ + parser = mrb_parser_new(mrb); parser->s = ruby_code; parser->send = ruby_code + strlen(ruby_code); - parser->capture_errors = 1; parser->lineno = 1; - mrb_parser_parse(parser, NULL); + mrb_parser_parse(parser, cxt); code_block_open = is_code_block_open(parser); if (code_block_open) { @@ -227,12 +228,13 @@ main(void) mrb_p(mrb, result); } } - memset(ruby_code, 0, sizeof(*ruby_code)); memset(ruby_code, 0, sizeof(*last_code_line)); } + mrb_pool_close(parser->pool); } } + mrbc_context_free(mrb, cxt); mrb_close(mrb); return 0; |
