1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-11-10 06:47:11 +00:00
parent 2841285182
commit 04c7225b78
9 changed files with 102 additions and 41 deletions

View file

@ -1,8 +1,33 @@
Wed Nov 10 08:28:53 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_call0): supply class parameter for each invocation.
Tue Nov 9 13:21:04 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* configure.in: AC_MINIX move to before AC_EXEEXT and AC_OBJEXT.
Mon Nov 8 19:52:29 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* configure.in: Renamed AC_CHAR_UNSIGNED to AC_C_CHAR_UNSIGNED.
* configure.in: Added default to AC_CHECK_SIZEOF().
Mon Nov 8 14:28:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (stmt): rescue modifier added to the syntax.
* keywords: kRESCUE_MOD added.
* eval.c (rb_f_eval): fake outer scope when eval() called without
bindings.
* eval.c (rb_f_binding): should copy last_class in the outer frame too.
Sun Nov 7 18:31:04 1999 Yasuhiro Fukuma <yasuf@big.or.jp> Sun Nov 7 18:31:04 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
* eval.c (is_defined): last_class may be 0. * eval.c (is_defined): last_class may be 0.
Sat Nov 6 19:26:55 1999 EGUCHI Osamu <eguchi@triton2.> Sat Nov 6 19:26:55 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* Makefile.in: Added depend entry make parse.@OBJEXT@ from parse.c * Makefile.in: Added depend entry make parse.@OBJEXT@ from parse.c
for UCB make for UCB make

2
ToDo
View file

@ -2,6 +2,7 @@ Language Spec.
- def foo; .. rescue .. end - def foo; .. rescue .. end
- compile time string concatenation, "hello" "world" => "helloworld" - compile time string concatenation, "hello" "world" => "helloworld"
- rescue modifier; a rescue b => begin a rescue; b end
* objectify symbols * objectify symbols
* objectify characters * objectify characters
* ../... outside condition invokes operator method too. * ../... outside condition invokes operator method too.
@ -34,6 +35,7 @@ Standard Libraries
- hash.fetch(key) raises exception if key is not found. - hash.fetch(key) raises exception if key is not found.
- Array#{first,last,at} - Array#{first,last,at}
- Dir.glob(pat){|f|...} - Dir.glob(pat){|f|...}
* Dir.glob("**/*.c") ala zsh
* Struct::new([name,]member,...) ?? * Struct::new([name,]member,...) ??
* String#scanf(?) * String#scanf(?)
* Object#fmt(?) * Object#fmt(?)

12
configure vendored
View file

@ -1352,7 +1352,7 @@ if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } ac_cv_sizeof_int=4
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1359 "configure" #line 1359 "configure"
@ -1391,7 +1391,7 @@ if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } ac_cv_sizeof_short=2
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1398 "configure" #line 1398 "configure"
@ -1430,7 +1430,7 @@ if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } ac_cv_sizeof_long=4
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1437 "configure" #line 1437 "configure"
@ -1469,7 +1469,7 @@ if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } ac_cv_sizeof_voidp=4
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1476 "configure" #line 1476 "configure"
@ -1508,7 +1508,7 @@ if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } ac_cv_sizeof_float=4
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1515 "configure" #line 1515 "configure"
@ -1547,7 +1547,7 @@ if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } ac_cv_sizeof_double=8
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1554 "configure" #line 1554 "configure"

View file

@ -77,18 +77,18 @@ AC_CHECK_PROGS(AR, ar aal, ar)
AC_PROG_LN_S AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_EXEEXT
AC_OBJEXT
# checks for UNIX variants that set C preprocessor variables # checks for UNIX variants that set C preprocessor variables
AC_MINIX AC_MINIX
AC_CHECK_SIZEOF(int) AC_EXEEXT
AC_CHECK_SIZEOF(short) AC_OBJEXT
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void*) AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(float) AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(double) AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(void*, 4)
AC_CHECK_SIZEOF(float, 4)
AC_CHECK_SIZEOF(double, 8)
AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes, AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
[AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);], [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
@ -253,7 +253,7 @@ test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"
AC_C_BIGENDIAN AC_C_BIGENDIAN
AC_C_CONST AC_C_CONST
AC_CHAR_UNSIGNED AC_C_CHAR_UNSIGNED
AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign, AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
[AC_TRY_RUN([ [AC_TRY_RUN([

56
eval.c
View file

@ -292,10 +292,15 @@ rb_enable_super(klass, name)
ID mid = rb_intern(name); ID mid = rb_intern(name);
body = search_method(klass, mid, &origin); body = search_method(klass, mid, &origin);
if (!body || !body->nd_body || origin != klass) { if (!body) {
print_undef(klass, mid); print_undef(klass, mid);
} }
body->nd_noex &= ~NOEX_UNDEF; if (!body->nd_body) {
remove_method(klass, mid);
}
else {
body->nd_noex &= ~NOEX_UNDEF;
}
} }
static void static void
@ -1696,7 +1701,7 @@ call_trace_func(event, file, line, self, id, klass)
prev = ruby_frame; prev = ruby_frame;
PUSH_FRAME(); PUSH_FRAME();
*ruby_frame = *_frame.prev; *ruby_frame = *prev;
ruby_frame->prev = prev; ruby_frame->prev = prev;
if (file) { if (file) {
@ -1858,8 +1863,9 @@ rb_eval(self, node)
tag = node->nd_head; tag = node->nd_head;
while (tag) { while (tag) {
if (trace_func) { if (trace_func) {
call_trace_func("line", tag->nd_file, nd_line(tag), call_trace_func("line", tag->nd_file, nd_line(tag), self,
self, ruby_frame->last_func, 0); ruby_frame->last_func,
ruby_frame->last_class);
} }
ruby_sourcefile = tag->nd_file; ruby_sourcefile = tag->nd_file;
ruby_sourceline = nd_line(tag); ruby_sourceline = nd_line(tag);
@ -2868,8 +2874,9 @@ rb_eval(self, node)
ruby_sourcefile = node->nd_file; ruby_sourcefile = node->nd_file;
ruby_sourceline = node->nd_nth; ruby_sourceline = node->nd_nth;
if (trace_func) { if (trace_func) {
call_trace_func("line", ruby_sourcefile, ruby_sourceline, call_trace_func("line", ruby_sourcefile, ruby_sourceline, self,
self, ruby_frame->last_func, 0); ruby_frame->last_func,
ruby_frame->last_class);
} }
node = node->nd_next; node = node->nd_next;
goto again; goto again;
@ -2923,8 +2930,9 @@ module_setup(module, node)
PUSH_TAG(PROT_NONE); PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
if (trace_func) { if (trace_func) {
call_trace_func("class", file, line, call_trace_func("class", file, line, ruby_class,
ruby_class, ruby_frame->last_func, 0); ruby_frame->last_func,
ruby_frame->last_class);
} }
result = rb_eval(ruby_class, node->nd_next); result = rb_eval(ruby_class, node->nd_next);
} }
@ -2935,7 +2943,8 @@ module_setup(module, node)
ruby_frame = frame.tmp; ruby_frame = frame.tmp;
if (trace_func) { if (trace_func) {
call_trace_func("end", file, line, 0, ruby_frame->last_func, 0); call_trace_func("end", file, line, 0,
ruby_frame->last_func, ruby_frame->last_class);
} }
if (state) JUMP_TAG(state); if (state) JUMP_TAG(state);
@ -3072,7 +3081,9 @@ rb_longjmp(tag, mesg)
rb_trap_restore_mask(); rb_trap_restore_mask();
if (trace_func && tag != TAG_FATAL) { if (trace_func && tag != TAG_FATAL) {
call_trace_func("raise", ruby_sourcefile, ruby_sourceline, call_trace_func("raise", ruby_sourcefile, ruby_sourceline,
ruby_frame->self, ruby_frame->last_func, 0); ruby_frame->self,
ruby_frame->last_func,
ruby_frame->last_class);
} }
if (!prot_tag) { if (!prot_tag) {
error_print(); error_print();
@ -3838,7 +3849,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
line = ruby_sourceline; line = ruby_sourceline;
} }
call_trace_func("c-call", 0, 0, 0, id, 0); call_trace_func("c-call", 0, 0, 0, id, klass);
PUSH_TAG(PROT_FUNC); PUSH_TAG(PROT_FUNC);
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
result = call_cfunc(body->nd_cfnc, recv, len, argc, argv); result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
@ -3950,7 +3961,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
if (trace_func) { if (trace_func) {
call_trace_func("call", b2->nd_file, nd_line(b2), call_trace_func("call", b2->nd_file, nd_line(b2),
recv, ruby_frame->last_func, 0); recv, id, klass);
} }
result = rb_eval(recv, body); result = rb_eval(recv, body);
} }
@ -3968,8 +3979,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
file = ruby_sourcefile; file = ruby_sourcefile;
line = ruby_sourceline; line = ruby_sourceline;
} }
call_trace_func("return", file, line, recv, call_trace_func("return", file, line, recv, id, klass);
ruby_frame->last_func, klass);
} }
switch (state) { switch (state) {
case 0: case 0:
@ -4365,7 +4375,7 @@ rb_f_eval(argc, argv, self)
VALUE *argv; VALUE *argv;
VALUE self; VALUE self;
{ {
VALUE src, scope, vfile, vline; VALUE src, scope, vfile, vline, val;
char *file = "(eval)"; char *file = "(eval)";
int line = 1; int line = 1;
@ -4379,6 +4389,19 @@ rb_f_eval(argc, argv, self)
} }
Check_SafeStr(src); Check_SafeStr(src);
if (NIL_P(scope) && ruby_frame->prev) {
struct FRAME *prev;
VALUE val;
prev = ruby_frame;
PUSH_FRAME();
*ruby_frame = *prev->prev;
ruby_frame->prev = prev;
val = eval(self, src, scope, file, line);
POP_FRAME();
return val;
}
return eval(self, src, scope, file, line); return eval(self, src, scope, file, line);
} }
@ -5472,6 +5495,7 @@ rb_f_binding(self)
frame_dup(&data->frame); frame_dup(&data->frame);
if (ruby_frame->prev) { if (ruby_frame->prev) {
data->frame.last_func = ruby_frame->prev->last_func; data->frame.last_func = ruby_frame->prev->last_func;
data->frame.last_class = ruby_frame->prev->last_class;
} }
if (data->iter) { if (data->iter) {

View file

@ -27,7 +27,7 @@ nil, kNIL, kNIL, EXPR_END
not, kNOT, kNOT, EXPR_BEG not, kNOT, kNOT, EXPR_BEG
or, kOR, kOR, EXPR_BEG or, kOR, kOR, EXPR_BEG
redo, kREDO, kREDO, EXPR_END redo, kREDO, kREDO, EXPR_END
rescue, kRESCUE, kRESCUE, EXPR_MID rescue, kRESCUE, kRESCUE_MOD, EXPR_MID
retry, kRETRY, kRETRY, EXPR_END retry, kRETRY, kRETRY, EXPR_END
return, kRETURN, kRETURN, EXPR_MID return, kRETURN, kRETURN, EXPR_MID
self, kSELF, kSELF, EXPR_END self, kSELF, kSELF, EXPR_END

2
lex.c
View file

@ -79,7 +79,7 @@ rb_reserved_word (str, len)
{"module", kMODULE, kMODULE, EXPR_BEG}, {"module", kMODULE, kMODULE, EXPR_BEG},
{"elsif", kELSIF, kELSIF, EXPR_BEG}, {"elsif", kELSIF, kELSIF, EXPR_BEG},
{"def", kDEF, kDEF, EXPR_FNAME}, {"def", kDEF, kDEF, EXPR_FNAME},
{"rescue", kRESCUE, kRESCUE, EXPR_MID}, {"rescue", kRESCUE, kRESCUE_MOD, EXPR_MID},
{"not", kNOT, kNOT, EXPR_BEG}, {"not", kNOT, kNOT, EXPR_BEG},
{"then", kTHEN, kTHEN, EXPR_BEG}, {"then", kTHEN, kTHEN, EXPR_BEG},
{"yield", kYIELD, kYIELD, EXPR_END}, {"yield", kYIELD, kYIELD, EXPR_END},

View file

@ -27,6 +27,7 @@ class DEBUGGER__
@last_file = nil @last_file = nil
@last = [nil, nil] @last = [nil, nil]
@no_step = nil @no_step = nil
@finish_pos = 0
end end
DEBUG_LAST_CMD = [] DEBUG_LAST_CMD = []
@ -256,9 +257,13 @@ class DEBUGGER__
STDOUT.printf "#%d %s\n", frame_pos, info STDOUT.printf "#%d %s\n", frame_pos, info
when /^fi(?:nish)?$/ when /^fi(?:nish)?$/
@finish_pos = @frames.size - frame_pos if frame_pos == 0
frame_pos = 0 STDOUT.print "\"finish\" not meaningful in the outermost frame.\n"
return else
@finish_pos = @frames.size - frame_pos
frame_pos = 0
return
end
when /^q(?:uit)?$/ when /^q(?:uit)?$/
input = readline("really quit? (y/n) ", false) input = readline("really quit? (y/n) ", false)
@ -373,10 +378,10 @@ class DEBUGGER__
@frames.unshift binding @frames.unshift binding
when 'return', 'end' when 'return', 'end'
@frames.shift
if @frames.size == @finish_pos if @frames.size == @finish_pos
@stop_next = 1 @stop_next = 1
end end
@frames.shift
when 'raise' when 'raise'
excn_handle(file, line, id, binding) excn_handle(file, line, id, binding)

View file

@ -156,6 +156,7 @@ static void top_local_setup();
kUNLESS_MOD kUNLESS_MOD
kWHILE_MOD kWHILE_MOD
kUNTIL_MOD kUNTIL_MOD
kRESCUE_MOD
kALIAS kALIAS
kDEFINED kDEFINED
klBEGIN klBEGIN
@ -212,7 +213,7 @@ static void top_local_setup();
%nonassoc kDO %nonassoc kDO
%nonassoc kDO2 %nonassoc kDO2
%left kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD %left kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD kRESCUE_MOD
%left kOR kAND %left kOR kAND
%right kNOT %right kNOT
%nonassoc kDEFINED %nonassoc kDEFINED
@ -347,6 +348,10 @@ stmt : block_call
$$ = NEW_UNTIL(cond($3), $1, 1); $$ = NEW_UNTIL(cond($3), $1, 1);
} }
} }
| stmt kRESCUE_MOD expr
{
$$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
}
| klBEGIN | klBEGIN
{ {
if (cur_mid || in_single) { if (cur_mid || in_single) {
@ -607,7 +612,7 @@ reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
| kFOR | kIF_MOD | kIN | kMODULE | kNEXT | kNIL | kNOT | kFOR | kIF_MOD | kIN | kMODULE | kNEXT | kNIL | kNOT
| kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER | kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER
| kTHEN | kTRUE | kUNDEF | kUNLESS_MOD | kUNTIL_MOD | kWHEN | kTHEN | kTRUE | kUNDEF | kUNLESS_MOD | kUNTIL_MOD | kWHEN
| kWHILE_MOD | kYIELD | kWHILE_MOD | kYIELD | kRESCUE_MOD
arg : lhs '=' arg arg : lhs '=' arg
{ {