summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-06-28 23:35:17 +0900
committerYukihiro Matsumoto <[email protected]>2012-06-28 23:35:17 +0900
commit4a98d5c8fd56119a5e30f8e371fd4aac1866895d (patch)
tree39d58a1546965ad3f4e818e38b0aaf2375358dd5 /src
parent4fd932548ef4aa92a089a6a7dc412cd09eb2284e (diff)
downloadmruby-4a98d5c8fd56119a5e30f8e371fd4aac1866895d.tar.gz
mruby-4a98d5c8fd56119a5e30f8e371fd4aac1866895d.zip
allow string interpolation in symbols like :"a=#{15}"
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c9
-rw-r--r--src/parse.y14
2 files changed, 16 insertions, 7 deletions
diff --git a/src/codegen.c b/src/codegen.c
index fb0006625..2654fcbe3 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -1711,6 +1711,15 @@ codegen(codegen_scope *s, node *tree, int val)
}
break;
+ case NODE_DSYM:
+ codegen(s, tree, val);
+ if (val) {
+ pop();
+ genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern(s->mrb, "intern")), 0));
+ push();
+ }
+ break;
+
case NODE_SELF:
if (val) {
genop(s, MKOP_A(OP_LOADSELF, cursp()));
diff --git a/src/parse.y b/src/parse.y
index 069a97412..af8b93cfa 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -527,13 +527,6 @@ new_strsym(parser_state *p, node* str)
return mrb_intern2(p->mrb, s, len);
}
-// (:sym . a)
-static node*
-new_dsym(parser_state *p, node *a)
-{
- return cons((node*)NODE_DSYM, a);
-}
-
// (:lvar . a)
static node*
new_lvar(parser_state *p, mrb_sym sym)
@@ -705,6 +698,13 @@ new_dstr(parser_state *p, node *a)
return cons((node*)NODE_DSTR, a);
}
+// (:dsym . a)
+static node*
+new_dsym(parser_state *p, node *a)
+{
+ return cons((node*)NODE_DSYM, new_dstr(p, a));
+}
+
// (:backref . n)
static node*
new_back_ref(parser_state *p, int n)