Skip to content

Commit eb61189

Browse files
author
matz
committed
* eval.c (rb_clear_cache_by_class): new function.
* eval.c (set_method_visibility): should have clear cache forq updated visibility. * numeric.c (flo_to_s): default format precision to be "%.16g". * util.c (ruby_strtod): use own strtod(3) implementation to avoid locale hell. Due to this change "0xff".to_f no longer returns 255.0 * eval.c (avalue_to_yvalue): new function to distinguish yvalue (no-arg == Qundef) from svalue (no-arg == Qnil). * eval.c (rb_yield_0): use avalue_to_yvalue(). * eval.c (assign): warn if val == Qundef where it means rhs is void (e.g. yield without value or call without argument). * parse.y (value_expr): need not to warn for WHILE and UNTIL, since they can have return value (via valued break). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent c5d6a1b commit eb61189

34 files changed

+377
-70
lines changed

ChangeLog

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,24 @@ Tue May 14 14:49:05 2002 WATANABE Hirofumi <eban@ruby-lang.org>
44

55
* missing/strftime.c (timezone): it should take no argument on Cygwin.
66

7+
Tue May 14 03:07:35 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
8+
9+
* eval.c (rb_clear_cache_by_class): new function.
10+
11+
* eval.c (set_method_visibility): should have clear cache forq
12+
updated visibility.
13+
714
Mon May 13 14:38:33 2002 WATANABE Hirofumi <eban@ruby-lang.org>
815

916
* djgpp/config.hin, djgpp/config.sed: catch up with the latest change.
1017

18+
Mon May 13 01:59:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
19+
20+
* numeric.c (flo_to_s): default format precision to be "%.16g".
21+
22+
* util.c (ruby_strtod): use own strtod(3) implementation to avoid
23+
locale hell. Due to this change "0xff".to_f no longer returns 255.0
24+
1125
Sun May 12 03:01:08 2002 WATANABE Hirofumi <eban@ruby-lang.org>
1226

1327
* missing.h: add for missing/*.c.
@@ -26,6 +40,16 @@ Sat May 11 10:52:09 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
2640

2741
* dir.c (glob_helper): remove escaping backslashes.
2842

43+
Sat May 11 02:46:43 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
44+
45+
* eval.c (avalue_to_yvalue): new function to distinguish yvalue
46+
(no-arg == Qundef) from svalue (no-arg == Qnil).
47+
48+
* eval.c (rb_yield_0): use avalue_to_yvalue().
49+
50+
* eval.c (assign): warn if val == Qundef where it means rhs is
51+
void (e.g. yield without value or call without argument).
52+
2953
Fri May 10 19:00:47 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
3054

3155
* parse.y (here_document): preserve line number begins here
@@ -38,6 +62,11 @@ Fri May 10 01:55:44 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
3862

3963
* eval.c (rb_thread_join_m): new. and added optional argument.
4064

65+
Wed May 8 23:48:40 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
66+
67+
* parse.y (value_expr): need not to warn for WHILE and UNTIL,
68+
since they can have return value (via valued break).
69+
4170
Tue May 7 17:13:40 2002 WATANABE Hirofumi <eban@ruby-lang.org>
4271

4372
* configure.in: forgot to add '-Wl,' to the gcc option on Cygwin/MinGW.

Makefile.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ strftime.@OBJEXT@: $(srcdir)/missing/strftime.c
223223
strstr.@OBJEXT@: $(srcdir)/missing/strstr.c
224224
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strstr.c
225225

226-
strtod.@OBJEXT@: $(srcdir)/missing/strtod.c
227-
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtod.c
228-
229226
strtol.@OBJEXT@: $(srcdir)/missing/strtol.c
230227
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtol.c
231228

ToDo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Standard Libraries
9595
* new user-defined marshal scheme. _dump(dumper), _load(restorer)
9696
* library to load per-user profile seeking .ruby_profile or ruby.ini file.
9797
* warning framework (warn, warning for Ruby level)
98-
* marshal should not depend on sprintf/strtod (works bad with locale).
98+
* marshal should not depend on sprintf (works bad with locale).
9999
* ternary arg pow: a.pow(b,c) == a**b%c
100100
* new caller(), e.g. call_stack; needs better name.
101101
* remove dependency on MAXPATHLEN.

bignum.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
1111
**********************************************************************/
1212

13+
#include "ruby.h"
14+
1315
#include <math.h>
1416
#include <ctype.h>
15-
#include "ruby.h"
1617

1718
VALUE rb_cBignum;
1819

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ if test "$enable_shared" = 'yes'; then
987987
darwin*)
988988
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib'
989989
LIBRUBY_LDSHARED='cc -dynamiclib -undefined suppress -flat_namespace'
990-
LIBRUBY_DLDFLAGS='-install_name lib$(RUBY_INSTALL_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
990+
LIBRUBY_DLDFLAGS='-install_name $(prefix)/lib/lib$(RUBY_INSTALL_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
991991
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_INSTALL_NAME).dylib'
992992
;;
993993
*)

dln.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$Date$
77
created at: Tue Jan 18 17:05:06 JST 1994
88
9-
Copyright (C) 1993-2001 Yukihiro Matsumoto
9+
Copyright (C) 1993-2002 Yukihiro Matsumoto
1010
1111
**********************************************************************/
1212

dln.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$Date$
77
created at: Wed Jan 19 16:53:09 JST 1994
88
9-
Copyright (C) 1993-2001 Yukihiro Matsumoto
9+
Copyright (C) 1993-2002 Yukihiro Matsumoto
1010
1111
**********************************************************************/
1212

env.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$Date$
77
created at: Mon Jul 11 11:53:03 JST 1994
88
9-
Copyright (C) 1993-2001 Yukihiro Matsumoto
9+
Copyright (C) 1993-2002 Yukihiro Matsumoto
1010
1111
**********************************************************************/
1212

eval.c

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ rb_clear_cache_by_id(id)
217217
}
218218
}
219219

220+
static void
221+
rb_clear_cache_by_class(klass)
222+
VALUE klass;
223+
{
224+
struct cache_entry *ent, *end;
225+
226+
ent = cache; end = ent + CACHE_SIZE;
227+
while (ent < end) {
228+
if (ent->origin == klass) {
229+
ent->mid = 0;
230+
}
231+
ent++;
232+
}
233+
}
234+
220235
void
221236
rb_add_method(klass, mid, node, noex)
222237
VALUE klass;
@@ -2111,11 +2126,28 @@ avalue_to_svalue(v)
21112126
return v;
21122127
}
21132128

2129+
static VALUE
2130+
avalue_to_yvalue(v)
2131+
VALUE v;
2132+
{
2133+
if (TYPE(v) != T_ARRAY) {
2134+
v = rb_ary_to_ary(v);
2135+
}
2136+
if (RARRAY(v)->len == 0) {
2137+
return Qundef;
2138+
}
2139+
if (RARRAY(v)->len == 1) {
2140+
return RARRAY(v)->ptr[0];
2141+
}
2142+
return v;
2143+
}
2144+
21142145
static VALUE
21152146
svalue_to_mvalue(v)
21162147
VALUE v;
21172148
{
2118-
if (NIL_P(v)) return rb_ary_new2(0);
2149+
if (v == Qnil || v == Qundef)
2150+
return rb_ary_new2(0);
21192151
if (TYPE(v) == T_ARRAY) {
21202152
return v;
21212153
}
@@ -2511,10 +2543,10 @@ rb_eval(self, n)
25112543

25122544
case NODE_YIELD:
25132545
if (node->nd_stts) {
2514-
result = avalue_to_svalue(rb_eval(self, node->nd_stts));
2546+
result = avalue_to_yvalue(rb_eval(self, node->nd_stts));
25152547
}
25162548
else {
2517-
result = Qnil;
2549+
result = Qundef; /* no arg */
25182550
}
25192551
result = rb_yield_0(result, 0, 0, 0);
25202552
break;
@@ -3745,21 +3777,21 @@ rb_yield_0(val, self, klass, pcall)
37453777
RARRAY(val)->len);
37463778
}
37473779
}
3780+
else if (nd_type(block->var) == NODE_MASGN) {
3781+
massign(self, block->var, val, pcall);
3782+
}
37483783
else {
3749-
if (nd_type(block->var) == NODE_MASGN) {
3750-
massign(self, block->var, val, pcall);
3751-
}
3752-
else {
3753-
if (pcall) val = avalue_to_svalue(val);
3754-
assign(self, block->var, val, pcall);
3784+
if (pcall) {
3785+
val = avalue_to_yvalue(val);
37553786
}
3787+
assign(self, block->var, val, pcall);
37563788
}
37573789
}
37583790
POP_TAG();
37593791
if (state) goto pop_state;
37603792
}
37613793
else if (pcall) {
3762-
val = avalue_to_svalue(val);
3794+
val = avalue_to_yvalue(val);
37633795
}
37643796

37653797
PUSH_ITER(block->iter);
@@ -3849,7 +3881,7 @@ static VALUE
38493881
rb_f_loop()
38503882
{
38513883
for (;;) {
3852-
rb_yield_0(Qnil, 0, 0, 0);
3884+
rb_yield_0(Qundef, 0, 0, 0);
38533885
CHECK_INTS;
38543886
}
38553887
return Qnil; /* dummy */
@@ -3912,7 +3944,10 @@ assign(self, lhs, val, pcall)
39123944
VALUE val;
39133945
int pcall;
39143946
{
3915-
if (val == Qundef) val = Qnil;
3947+
if (val == Qundef) {
3948+
rb_warning("assigning void value");
3949+
val = Qnil;
3950+
}
39163951
switch (nd_type(lhs)) {
39173952
case NODE_GASGN:
39183953
rb_gvar_set(lhs->nd_entry, val);
@@ -5623,6 +5658,7 @@ set_method_visibility(self, argc, argv, ex)
56235658
for (i=0; i<argc; i++) {
56245659
rb_export_method(self, rb_to_id(argv[i]), ex);
56255660
}
5661+
rb_clear_cache_by_class(self);
56265662
}
56275663

56285664
static VALUE
@@ -6470,7 +6506,7 @@ proc_invoke(proc, args, pcall, self)
64706506
ruby_frame->iter = ITER_CUR;
64716507

64726508
if (!pcall) {
6473-
args = avalue_to_svalue(args);
6509+
args = avalue_to_yvalue(args);
64746510
}
64756511
PUSH_TAG(PROT_NONE);
64766512
state = EXEC_TAG();

file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$Date$
77
created at: Mon Nov 15 12:24:34 JST 1993
88
9-
Copyright (C) 1993-2001 Yukihiro Matsumoto
9+
Copyright (C) 1993-2002 Yukihiro Matsumoto
1010
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
1111
Copyright (C) 2000 Information-technology Promotion Agency, Japan
1212

0 commit comments

Comments
 (0)