* gc.c (Init_stack): avoid __builtin_frame_address(2) to retrieve

stack bottom line.

* st.c (numhash): should shuffle bits by dividing by prime number.

* eval.c (rb_eval): multiple assignment behavior fixed, which
  results "*a = nil" makes "a == []" now.

* eval.c (rb_f_require): should set SCOPE_PUBLIC before calling
  dln_load().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-06-08 14:20:58 +00:00
Родитель 1b6b6ef2d6
Коммит 46e8ae1104
9 изменённых файлов: 170 добавлений и 21 удалений

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

@ -1,3 +1,22 @@
Fri Jun 8 22:37:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (Init_stack): avoid __builtin_frame_address(2) to retrieve
stack bottom line.
Fri Jun 8 18:14:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* st.c (numhash): should shuffle bits by dividing by prime number.
Fri Jun 8 17:05:21 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): multiple assignment behavior fixed, which
results "*a = nil" makes "a == []" now.
Fri Jun 8 15:25:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_f_require): should set SCOPE_PUBLIC before calling
dln_load().
Thu Jun 7 17:28:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (yylex): exclude kDO_BLOCK too much by false condition.

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

@ -2344,6 +2344,7 @@ rb_eval(self, n)
break;
case NODE_RESTARGS:
case NODE_RESTARY:
result = rb_eval(self, node->nd_head);
if (TYPE(result) != T_ARRAY) {
result = rb_Array(result);
@ -2355,7 +2356,10 @@ rb_eval(self, n)
if (TYPE(result) != T_ARRAY) {
result = rb_Array(result);
}
if (RARRAY(result)->len == 1) {
if (RARRAY(result)->len == 0) {
result = Qnil;
}
else if (RARRAY(result)->len == 1) {
result = RARRAY(result)->ptr[0];
}
break;
@ -3724,7 +3728,7 @@ massign(self, node, val, check)
NODE *list;
int i = 0, len;
if (val == Qundef) {
if (val == Qundef || val == Qnil) {
val = rb_ary_new2(0);
}
else if (TYPE(val) != T_ARRAY) {
@ -5425,17 +5429,22 @@ rb_f_require(obj, fname)
load_dyna:
rb_provide(feature);
{
int volatile old_vmode = scope_vmode;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
void *handle;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
void *handle;
load = rb_str_new2(file);
file = RSTRING(load)->ptr;
handle = dln_load(file);
rb_ary_push(ruby_dln_librefs, INT2NUM((long)handle));
SCOPE_SET(SCOPE_PUBLIC);
load = rb_str_new2(file);
file = RSTRING(load)->ptr;
handle = dln_load(file);
rb_ary_push(ruby_dln_librefs, INT2NUM((long)handle));
}
POP_TAG();
SCOPE_SET(old_vmode);
}
POP_TAG();
if (state) JUMP_TAG(state);
return Qtrue;

2
gc.c
Просмотреть файл

@ -1019,8 +1019,6 @@ Init_stack(addr)
#if defined(__human68k__)
extern void *_SEND;
rb_gc_stack_start = _SEND;
#elif defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS)
rb_gc_stack_start = __builtin_frame_address(2);
#else
VALUE start;

7
hash.c
Просмотреть файл

@ -94,8 +94,11 @@ rb_any_hash(a)
default:
DEFER_INTS;
hval = rb_funcall(a, hash, 0);
if (!FIXNUM_P(hval)) {
hval = rb_funcall(hval, '%', 1, INT2FIX(65439));
if (FIXNUM_P(hval)) {
hval %= 536870917;
}
else {
hval = rb_funcall(hval, '%', 1, INT2FIX(536870917));
}
ENABLE_INTS;
return (int)FIX2LONG(hval);

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

@ -89,6 +89,7 @@ enum node_type {
NODE_ARGSCAT,
NODE_ARGSPUSH,
NODE_RESTARGS,
NODE_RESTARY,
NODE_REXPAND,
NODE_BLOCK_ARG,
NODE_BLOCK_PASS,
@ -305,6 +306,7 @@ typedef struct RNode {
#define NEW_ARGSCAT(a,b) rb_node_newnode(NODE_ARGSCAT,a,b,0)
#define NEW_ARGSPUSH(a,b) rb_node_newnode(NODE_ARGSPUSH,a,b,0)
#define NEW_RESTARGS(a) rb_node_newnode(NODE_RESTARGS,a,0,0)
#define NEW_RESTARY(a) rb_node_newnode(NODE_RESTARY,a,0,0)
#define NEW_REXPAND(a) rb_node_newnode(NODE_REXPAND,a,0,0)
#define NEW_BLOCK_ARG(v) rb_node_newnode(NODE_BLOCK_ARG,v,0,local_cnt(v))
#define NEW_BLOCK_PASS(b) rb_node_newnode(NODE_BLOCK_PASS,0,b,0)

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

@ -426,9 +426,6 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
}
| lhs '=' mrhs_basic
{
if (nd_type($3) == NODE_RESTARGS) {
nd_set_type($3, NODE_REXPAND);
}
$$ = node_assign($1, $3);
}
| mlhs '=' mrhs
@ -954,7 +951,7 @@ aref_args : none
| tSTAR arg opt_nl
{
value_expr($2);
$$ = NEW_RESTARGS($2);
$$ = NEW_RESTARY($2);
}
paren_args : '(' none ')'
@ -1150,7 +1147,7 @@ mrhs_basic : args ',' arg
| tSTAR arg
{
value_expr($2);
$$ = NEW_RESTARGS($2);
$$ = NEW_REXPAND($2);
}
primary : literal

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

@ -42,6 +42,126 @@ cc = 5
cc &&=44
test_ok(cc == 44)
a = nil; test_ok(a == nil)
a = 1; test_ok(a == 1)
a = []; test_ok(a == [])
a = [1]; test_ok(a == [1])
a = [nil]; test_ok(a == [nil])
a = [[]]; test_ok(a == [[]])
a = [*[]]; test_ok(a == [])
a = [*[1]]; test_ok(a == [1])
a = [*[1,2]]; test_ok(a == [1,2])
a = *nil; test_ok(a == nil)
a = *1; test_ok(a == 1)
a = *[]; test_ok(a == nil)
a = *[1]; test_ok(a == 1)
a = *[nil]; test_ok(a == nil)
a = *[[]]; test_ok(a == [])
a = *[*[]]; test_ok(a == nil)
a = *[*[1]]; test_ok(a == 1)
a = *[*[1,2]]; test_ok(a == [1,2])
*a = nil; test_ok(a == [])
*a = 1; test_ok(a == [1])
*a = []; test_ok(a == [])
*a = [1]; test_ok(a == [1])
*a = [nil]; test_ok(a == [nil])
*a = [[]]; test_ok(a == [[]])
*a = [*[]]; test_ok(a == [])
*a = [*[1]]; test_ok(a == [1])
*a = [*[1,2]]; test_ok(a == [1,2])
*a = *nil; test_ok(a == [])
*a = *1; test_ok(a == [1])
*a = *[]; test_ok(a == [])
*a = *[1]; test_ok(a == [1])
*a = *[nil]; test_ok(a == [])
*a = *[[]]; test_ok(a == [])
*a = *[*[]]; test_ok(a == [])
*a = *[*[1]]; test_ok(a == [1])
*a = *[*[1,2]]; test_ok(a == [1,2])
a,b,*c = nil; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = 1; test_ok([a,b,c] == [1, nil, []])
a,b,*c = []; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = [1]; test_ok([a,b,c] == [1, nil, []])
a,b,*c = [nil]; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = [[]]; test_ok([a,b,c] == [[], nil, []])
a,b,*c = [*[]]; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = [*[1]]; test_ok([a,b,c] == [1, nil, []])
a,b,*c = [*[1,2]]; test_ok([a,b,c] == [1, 2, []])
a,b,*c = *nil; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = *1; test_ok([a,b,c] == [1, nil, []])
a,b,*c = *[]; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = *[1]; test_ok([a,b,c] == [1, nil, []])
a,b,*c = *[nil]; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = *[[]]; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = *[*[]]; test_ok([a,b,c] == [nil, nil, []])
a,b,*c = *[*[1]]; test_ok([a,b,c] == [1, nil, []])
a,b,*c = *[*[1,2]]; test_ok([a,b,c] == [1, 2, []])
def f; yield nil; end; f {|a| test_ok(a == nil)}
def f; yield 1; end; f {|a| test_ok(a == 1)}
def f; yield []; end; f {|a| test_ok(a == [])}
def f; yield [1]; end; f {|a| test_ok(a == [1])}
def f; yield [nil]; end; f {|a| test_ok(a == [nil])}
def f; yield [[]]; end; f {|a| test_ok(a == [[]])}
def f; yield [*[]]; end; f {|a| test_ok(a == [])}
def f; yield [*[1]]; end; f {|a| test_ok(a == [1])}
def f; yield [*[1,2]]; end; f {|a| test_ok(a == [1,2])}
def f; yield *nil; end; f {|a| test_ok(a == nil)}
def f; yield *1; end; f {|a| test_ok(a == 1)}
def f; yield *[]; end; f {|a| test_ok(a == nil)}
def f; yield *[1]; end; f {|a| test_ok(a == 1)}
def f; yield *[nil]; end; f {|a| test_ok(a == nil)}
def f; yield *[[]]; end; f {|a| test_ok(a == [])}
def f; yield *[*[]]; end; f {|a| test_ok(a == nil)}
def f; yield *[*[1]]; end; f {|a| test_ok(a == 1)}
def f; yield *[*[1,2]]; end; f {|a| test_ok(a == [1,2])}
def f; yield nil; end; f {|*a| test_ok(a == [])}
def f; yield 1; end; f {|*a| test_ok(a == [1])}
def f; yield []; end; f {|*a| test_ok(a == [])}
def f; yield [1]; end; f {|*a| test_ok(a == [1])}
def f; yield [nil]; end; f {|*a| test_ok(a == [nil])}
def f; yield [[]]; end; f {|*a| test_ok(a == [[]])}
def f; yield [*[]]; end; f {|*a| test_ok(a == [])}
def f; yield [*[1]]; end; f {|*a| test_ok(a == [1])}
def f; yield [*[1,2]]; end; f {|*a| test_ok(a == [1,2])}
def f; yield *nil; end; f {|*a| test_ok(a == [])}
def f; yield *1; end; f {|*a| test_ok(a == [1])}
def f; yield *[]; end; f {|*a| test_ok(a == [])}
def f; yield *[1]; end; f {|*a| test_ok(a == [1])}
def f; yield *[nil]; end; f {|*a| test_ok(a == [])}
def f; yield *[[]]; end; f {|*a| test_ok(a == [])}
def f; yield *[*[]]; end; f {|*a| test_ok(a == [])}
def f; yield *[*[1]]; end; f {|*a| test_ok(a == [1])}
def f; yield *[*[1,2]]; end; f {|*a| test_ok(a == [1,2])}
def f; yield nil; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield 1; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
def f; yield []; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield [1]; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
def f; yield [nil]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield [[]]; end; f {|a,b,*c| test_ok([a,b,c] == [[], nil, []])}
def f; yield [*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield [*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
def f; yield [*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1, 2, []])}
def f; yield *nil; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield *1; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
def f; yield *[]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield *[1]; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
def f; yield *[nil]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield *[[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield *[*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
def f; yield *[*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
def f; yield *[*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1, 2, []])}
test_check "condition"
$x = '0';
@ -768,7 +888,7 @@ test_ok(a == [1, 2, 3])
test_ok(a == [4])
*a = nil
test_ok(a == [nil])
test_ok(a == [])
test_check "call"
def aaa(a, b=100, *rest)

2
st.c
Просмотреть файл

@ -558,5 +558,5 @@ static int
numhash(n)
long n;
{
return n;
return n / 7;
}

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

@ -73,6 +73,7 @@ fc_i(key, value, res)
if (!rb_is_const_id(key)) return ST_CONTINUE;
printf("fc: %s\n", rb_id2name(key));
if (value == res->klass) {
res->path = fc_path(res, key);
return ST_STOP;