diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-05-17 13:21:01 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-05-17 13:21:01 +0900 |
| commit | 103ef78e59348d5aef4775759cfb651ae1b340ee (patch) | |
| tree | 66e66ebe3a4bb03a6ebda9dfa0ed410c889057fa /src/codegen.c | |
| parent | b68e69aa326c98fbe9676e00aea211a49c6ae361 (diff) | |
| download | mruby-103ef78e59348d5aef4775759cfb651ae1b340ee.tar.gz mruby-103ef78e59348d5aef4775759cfb651ae1b340ee.zip | |
no SEGV for nth_ref & back_ref; close #152
Diffstat (limited to 'src/codegen.c')
| -rw-r--r-- | src/codegen.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/codegen.c b/src/codegen.c index a943c607a..ae5eafdf7 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -1477,11 +1477,27 @@ codegen(codegen_scope *s, node *tree, int val) break; case NODE_BACK_REF: - codegen(s, tree, VAL); + { + char buf[4]; + int sym; + + snprintf(buf, 3, "$%c", (intptr_t)tree); + sym = new_sym(s, mrb_intern(s->mrb, buf)); + genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym)); + push(); + } break; case NODE_NTH_REF: - codegen(s, tree, VAL); + { + char buf[4]; + int sym; + + snprintf(buf, 3, "$%d", (intptr_t)tree); + sym = new_sym(s, mrb_intern(s->mrb, buf)); + genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym)); + push(); + } break; case NODE_ARG: |
