no SEGV for nth_ref & back_ref; close #152

This commit is contained in:
Yukihiro Matsumoto
2012-05-17 13:21:01 +09:00
parent b68e69aa32
commit 103ef78e59
2 changed files with 21 additions and 8 deletions
+18 -2
View File
@@ -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: