summaryrefslogtreecommitdiffhomepage
path: root/src/codegen.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-05-17 13:21:01 +0900
committerYukihiro Matsumoto <[email protected]>2012-05-17 13:21:01 +0900
commit103ef78e59348d5aef4775759cfb651ae1b340ee (patch)
tree66e66ebe3a4bb03a6ebda9dfa0ed410c889057fa /src/codegen.c
parentb68e69aa326c98fbe9676e00aea211a49c6ae361 (diff)
downloadmruby-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.c20
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: