* 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
This commit is contained in:
nobu 2002-12-17 10:34:30 +00:00
Родитель 3a20ed532b
Коммит 86db656415
5 изменённых файлов: 45 добавлений и 3 удалений

Просмотреть файл

@ -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.

18
eval.c
Просмотреть файл

@ -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;

2
node.h
Просмотреть файл

@ -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;
}