summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog27
-rw-r--r--ToDo2
-rw-r--r--configure12
-rw-r--r--configure.in20
-rw-r--r--eval.c56
-rw-r--r--keywords2
-rw-r--r--lex.c2
-rw-r--r--lib/debug.rb13
-rw-r--r--parse.y9
9 files changed, 102 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e3a423b7d..7c8817df29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* 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
for UCB make
diff --git a/ToDo b/ToDo
index adb8a6c07a..83a0841674 100644
--- a/ToDo
+++ b/ToDo
@@ -2,6 +2,7 @@ Language Spec.
- def foo; .. rescue .. end
- compile time string concatenation, "hello" "world" => "helloworld"
+- rescue modifier; a rescue b => begin a rescue; b end
* objectify symbols
* objectify characters
* ../... outside condition invokes operator method too.
@@ -34,6 +35,7 @@ Standard Libraries
- hash.fetch(key) raises exception if key is not found.
- Array#{first,last,at}
- Dir.glob(pat){|f|...}
+* Dir.glob("**/*.c") ala zsh
* Struct::new([name,]member,...) ??
* String#scanf(?)
* Object#fmt(?)
diff --git a/configure b/configure
index 8c97b5ba4c..d69f2a8c85 100644
--- a/configure
+++ b/configure
@@ -1352,7 +1352,7 @@ if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
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
cat > conftest.$ac_ext <<EOF
#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
else
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
cat > conftest.$ac_ext <<EOF
#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
else
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
cat > conftest.$ac_ext <<EOF
#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
else
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
cat > conftest.$ac_ext <<EOF
#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
else
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
cat > conftest.$ac_ext <<EOF
#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
else
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
cat > conftest.$ac_ext <<EOF
#line 1554 "configure"
diff --git a/configure.in b/configure.in
index 41d4fac0c7..415aae9d23 100644
--- a/configure.in
+++ b/configure.in
@@ -77,18 +77,18 @@ AC_CHECK_PROGS(AR, ar aal, ar)
AC_PROG_LN_S
AC_PROG_MAKE_SET
-AC_EXEEXT
-AC_OBJEXT
-
# checks for UNIX variants that set C preprocessor variables
AC_MINIX
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(void*)
-AC_CHECK_SIZEOF(float)
-AC_CHECK_SIZEOF(double)
+AC_EXEEXT
+AC_OBJEXT
+
+AC_CHECK_SIZEOF(int, 4)
+AC_CHECK_SIZEOF(short, 2)
+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_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_CONST
-AC_CHAR_UNSIGNED
+AC_C_CHAR_UNSIGNED
AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
[AC_TRY_RUN([
diff --git a/eval.c b/eval.c
index 75a2ddaf30..eb3687fd08 100644
--- a/eval.c
+++ b/eval.c
@@ -292,10 +292,15 @@ rb_enable_super(klass, name)
ID mid = rb_intern(name);
body = search_method(klass, mid, &origin);
- if (!body || !body->nd_body || origin != klass) {
+ if (!body) {
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
@@ -1696,7 +1701,7 @@ call_trace_func(event, file, line, self, id, klass)
prev = ruby_frame;
PUSH_FRAME();
- *ruby_frame = *_frame.prev;
+ *ruby_frame = *prev;
ruby_frame->prev = prev;
if (file) {
@@ -1858,8 +1863,9 @@ rb_eval(self, node)
tag = node->nd_head;
while (tag) {
if (trace_func) {
- call_trace_func("line", tag->nd_file, nd_line(tag),
- self, ruby_frame->last_func, 0);
+ call_trace_func("line", tag->nd_file, nd_line(tag), self,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
}
ruby_sourcefile = tag->nd_file;
ruby_sourceline = nd_line(tag);
@@ -2868,8 +2874,9 @@ rb_eval(self, node)
ruby_sourcefile = node->nd_file;
ruby_sourceline = node->nd_nth;
if (trace_func) {
- call_trace_func("line", ruby_sourcefile, ruby_sourceline,
- self, ruby_frame->last_func, 0);
+ call_trace_func("line", ruby_sourcefile, ruby_sourceline, self,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
}
node = node->nd_next;
goto again;
@@ -2923,8 +2930,9 @@ module_setup(module, node)
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
if (trace_func) {
- call_trace_func("class", file, line,
- ruby_class, ruby_frame->last_func, 0);
+ call_trace_func("class", file, line, ruby_class,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
}
result = rb_eval(ruby_class, node->nd_next);
}
@@ -2935,7 +2943,8 @@ module_setup(module, node)
ruby_frame = frame.tmp;
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);
@@ -3072,7 +3081,9 @@ rb_longjmp(tag, mesg)
rb_trap_restore_mask();
if (trace_func && tag != TAG_FATAL) {
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) {
error_print();
@@ -3838,7 +3849,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
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);
if ((state = EXEC_TAG()) == 0) {
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) {
call_trace_func("call", b2->nd_file, nd_line(b2),
- recv, ruby_frame->last_func, 0);
+ recv, id, klass);
}
result = rb_eval(recv, body);
}
@@ -3968,8 +3979,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
file = ruby_sourcefile;
line = ruby_sourceline;
}
- call_trace_func("return", file, line, recv,
- ruby_frame->last_func, klass);
+ call_trace_func("return", file, line, recv, id, klass);
}
switch (state) {
case 0:
@@ -4365,7 +4375,7 @@ rb_f_eval(argc, argv, self)
VALUE *argv;
VALUE self;
{
- VALUE src, scope, vfile, vline;
+ VALUE src, scope, vfile, vline, val;
char *file = "(eval)";
int line = 1;
@@ -4379,6 +4389,19 @@ rb_f_eval(argc, argv, self)
}
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);
}
@@ -5472,6 +5495,7 @@ rb_f_binding(self)
frame_dup(&data->frame);
if (ruby_frame->prev) {
data->frame.last_func = ruby_frame->prev->last_func;
+ data->frame.last_class = ruby_frame->prev->last_class;
}
if (data->iter) {
diff --git a/keywords b/keywords
index 1772de42b0..f5380382d3 100644
--- a/keywords
+++ b/keywords
@@ -27,7 +27,7 @@ nil, kNIL, kNIL, EXPR_END
not, kNOT, kNOT, EXPR_BEG
or, kOR, kOR, EXPR_BEG
redo, kREDO, kREDO, EXPR_END
-rescue, kRESCUE, kRESCUE, EXPR_MID
+rescue, kRESCUE, kRESCUE_MOD, EXPR_MID
retry, kRETRY, kRETRY, EXPR_END
return, kRETURN, kRETURN, EXPR_MID
self, kSELF, kSELF, EXPR_END
diff --git a/lex.c b/lex.c
index 62e1ef6f61..292760c359 100644
--- a/lex.c
+++ b/lex.c
@@ -79,7 +79,7 @@ rb_reserved_word (str, len)
{"module", kMODULE, kMODULE, EXPR_BEG},
{"elsif", kELSIF, kELSIF, EXPR_BEG},
{"def", kDEF, kDEF, EXPR_FNAME},
- {"rescue", kRESCUE, kRESCUE, EXPR_MID},
+ {"rescue", kRESCUE, kRESCUE_MOD, EXPR_MID},
{"not", kNOT, kNOT, EXPR_BEG},
{"then", kTHEN, kTHEN, EXPR_BEG},
{"yield", kYIELD, kYIELD, EXPR_END},
diff --git a/lib/debug.rb b/lib/debug.rb
index 0a6699f174..244db021e2 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -27,6 +27,7 @@ class DEBUGGER__
@last_file = nil
@last = [nil, nil]
@no_step = nil
+ @finish_pos = 0
end
DEBUG_LAST_CMD = []
@@ -256,9 +257,13 @@ class DEBUGGER__
STDOUT.printf "#%d %s\n", frame_pos, info
when /^fi(?:nish)?$/
- @finish_pos = @frames.size - frame_pos
- frame_pos = 0
- return
+ if frame_pos == 0
+ STDOUT.print "\"finish\" not meaningful in the outermost frame.\n"
+ else
+ @finish_pos = @frames.size - frame_pos
+ frame_pos = 0
+ return
+ end
when /^q(?:uit)?$/
input = readline("really quit? (y/n) ", false)
@@ -373,10 +378,10 @@ class DEBUGGER__
@frames.unshift binding
when 'return', 'end'
+ @frames.shift
if @frames.size == @finish_pos
@stop_next = 1
end
- @frames.shift
when 'raise'
excn_handle(file, line, id, binding)
diff --git a/parse.y b/parse.y
index b971b21ac7..435221d8d8 100644
--- a/parse.y
+++ b/parse.y
@@ -156,6 +156,7 @@ static void top_local_setup();
kUNLESS_MOD
kWHILE_MOD
kUNTIL_MOD
+ kRESCUE_MOD
kALIAS
kDEFINED
klBEGIN
@@ -212,7 +213,7 @@ static void top_local_setup();
%nonassoc kDO
%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
%right kNOT
%nonassoc kDEFINED
@@ -347,6 +348,10 @@ stmt : block_call
$$ = NEW_UNTIL(cond($3), $1, 1);
}
}
+ | stmt kRESCUE_MOD expr
+ {
+ $$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
+ }
| klBEGIN
{
if (cur_mid || in_single) {
@@ -607,7 +612,7 @@ reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
| kFOR | kIF_MOD | kIN | kMODULE | kNEXT | kNIL | kNOT
| kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER
| kTHEN | kTRUE | kUNDEF | kUNLESS_MOD | kUNTIL_MOD | kWHEN
- | kWHILE_MOD | kYIELD
+ | kWHILE_MOD | kYIELD | kRESCUE_MOD
arg : lhs '=' arg
{