summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-24 08:36:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-24 08:36:53 +0000
commit2314b80d4c5ed712308f6b32aa8bf865d8d9ffff (patch)
tree8a531352ebd8b352e6c1b5cadeeb7d49d28da147 /compile.c
parent8ac52a95d577d00ed7b783fde8bca5b2b76cb404 (diff)
Feature #7035
* compile.c (defined_expr), insns.def (defined): share single frozen strings. [EXPERIMENTAL] [ruby-core:47558][Feature #7035] * iseq.c (rb_iseq_defined_string): make expression strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/compile.c b/compile.c
index fc6453ad1a..2f8cbb51cd 100644
--- a/compile.c
+++ b/compile.c
@@ -2701,23 +2701,23 @@ static int
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
NODE *node, LABEL **lfinish, VALUE needstr)
{
- const char *estr = 0;
+ enum defined_type expr_type = 0;
enum node_type type;
switch (type = nd_type(node)) {
/* easy literals */
case NODE_NIL:
- estr = "nil";
+ expr_type = DEFINED_NIL;
break;
case NODE_SELF:
- estr = "self";
+ expr_type = DEFINED_SELF;
break;
case NODE_TRUE:
- estr = "true";
+ expr_type = DEFINED_TRUE;
break;
case NODE_FALSE:
- estr = "false";
+ expr_type = DEFINED_FALSE;
break;
case NODE_ARRAY:{
@@ -2738,13 +2738,13 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
case NODE_AND:
case NODE_OR:
default:
- estr = "expression";
+ expr_type = DEFINED_EXPR;
break;
/* variables */
case NODE_LVAR:
case NODE_DVAR:
- estr = "local-variable";
+ expr_type = DEFINED_LVAR;
break;
case NODE_IVAR:
@@ -2866,16 +2866,14 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
case NODE_CDECL:
case NODE_CVDECL:
case NODE_CVASGN:
- estr = "assignment";
+ expr_type = DEFINED_ASGN;
break;
}
- if (estr != 0) {
+ if (expr_type) {
if (needstr != Qfalse) {
- VALUE str = rb_str_new2(estr);
- hide_obj(str);
- ADD_INSN1(ret, nd_line(node), putstring, str);
- iseq_add_mark_object_compile_time(iseq, str);
+ VALUE str = rb_iseq_defined_string(expr_type);
+ ADD_INSN1(ret, nd_line(node), putobject, str);
}
else {
ADD_INSN1(ret, nd_line(node), putobject, Qtrue);