diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-12-17 10:34:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-12-17 10:34:30 +0000 |
commit | 86db656415a2e05b573d95d813d6ca5a26b55d07 (patch) | |
tree | 379c349bd378072c2907f4e6579b677573a2e087 | |
parent | 3a20ed532b57da1e58287a5c53abe14400a085f4 (diff) | |
download | ruby-86db656415a2e05b573d95d813d6ca5a26b55d07.tar.gz |
* node.h (NODE_ATTRASGN): new node, assignment to attribute.
[ruby-core:00637].
* eval.c (is_defined, rb_eval): ditto.
* parse.y (attrset, node_assign): ditto.
* string.c (rb_str_substr): tail sharing. [ruby-core:00650]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | eval.c | 18 | ||||
-rw-r--r-- | node.h | 2 | ||||
-rw-r--r-- | parse.y | 3 | ||||
-rw-r--r-- | string.c | 14 |
5 files changed, 45 insertions, 3 deletions
@@ -1,3 +1,14 @@ +Tue Dec 17 19:29:45 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> + + * node.h (NODE_ATTRASGN): new node, assignment to attribute. + [ruby-core:00637]. + + * eval.c (is_defined, rb_eval): ditto. + + * parse.y (attrset, node_assign): ditto. + + * string.c (rb_str_substr): tail sharing. [ruby-core:00650] + Tue Dec 17 04:03:45 2002 Tanaka Akira <akr@m17n.org> * lib/open-uri.rb: new file. @@ -1881,6 +1881,7 @@ is_defined(self, node, buf) goto check_bound; case NODE_CALL: + case NODE_ATTRASGN: PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { val = rb_eval(self, node->nd_recv); @@ -2742,6 +2743,23 @@ rb_eval(self, n) rb_eval(self, node->nd_body)); break; + case NODE_ATTRASGN: + { + VALUE recv; + int argc; VALUE *argv; /* used in SETUP_ARGS */ + TMP_PROTECT; + + BEGIN_CALLARGS; + recv = rb_eval(self, node->nd_recv); + SETUP_ARGS(node->nd_args); + END_CALLARGS; + + SET_CURRENT_SOURCE(); + rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0); + result = argv[argc-1]; + } + break; + case NODE_CALL: { VALUE recv; @@ -123,6 +123,7 @@ enum node_type { NODE_MEMO, NODE_IFUNC, NODE_DSYM, + NODE_ATTRASGN, NODE_LAST }; @@ -332,6 +333,7 @@ typedef struct RNode { #define NEW_POSTEXE() rb_node_newnode(NODE_POSTEXE,0,0,0) #define NEW_DMETHOD(b) rb_node_newnode(NODE_DMETHOD,0,0,b) #define NEW_BMETHOD(b) rb_node_newnode(NODE_BMETHOD,0,0,b) +#define NEW_ATTRASGN(r,m,a) rb_node_newnode(NODE_ATTRASGN,r,m,a) #define NOEX_PUBLIC 0 #define NOEX_NOSUPER 1 @@ -4705,7 +4705,7 @@ attrset(recv, id) ID id; { value_expr(recv); - return NEW_CALL(recv, rb_id_attrset(id), 0); + return NEW_ATTRASGN(recv, rb_id_attrset(id), 0); } static void @@ -4765,6 +4765,7 @@ node_assign(lhs, rhs) lhs->nd_value = rhs; break; + case NODE_ATTRASGN: case NODE_CALL: lhs->nd_args = arg_add(lhs->nd_args, rhs); break; @@ -474,8 +474,18 @@ rb_str_substr(str, beg, len) } if (len == 0) return rb_str_new5(str,0,0); - str2 = rb_str_new5(str,RSTRING(str)->ptr+beg, len); - OBJ_INFECT(str2, str); + if (len > sizeof(struct RString)/2 && + beg + len == RSTRING(str)->len && + !FL_TEST(str, STR_ASSOC)) { + if (!FL_TEST(str, ELTS_SHARED)) str = rb_str_new4(str); + str2 = rb_str_new3(str); + RSTRING(str2)->ptr += beg; + RSTRING(str2)->len = len; + } + else { + str2 = rb_str_new5(str, RSTRING(str)->ptr+beg, len); + OBJ_INFECT(str2, str); + } return str2; } |