From 369fe1e8394b494c78d56aedfe6b0b809d7d1c10 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 19 May 1998 07:39:57 +0000 Subject: 1.1b9_22 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 18 ++++++++++++++++++ eval.c | 44 ++++++++++++++++++++++++++++++-------------- lib/e2mmap.rb | 26 +++++++++++++++++--------- lib/tracer.rb | 54 ++++++++++++++++++++++++++++++++++++++++++++++-------- numeric.c | 16 +++++++++++++++- parse.y | 8 ++++---- version.h | 4 ++-- 7 files changed, 132 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4e4719c57..0ab407ebe2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Tue May 19 16:36:26 1998 Yukihiro Matsumoto + + * experimental release 1.1b9_22. + +Tue May 19 16:31:57 1998 Yukihiro Matsumoto + + * parse.y (assignable): specification changed for in-block + variable definition. + + * eval.c (dyna_var_asgn): error in in-block variables' compile + time definition. + + * parse.y (str_extend): wrong nesting detection. + +Tue May 19 09:47:55 1998 WATANABE Hirofumi + + * numeric.c (num2int): re-defined (extensions may use this). + Mon May 18 16:40:50 1998 MAEDA shugo * error.c (get_syserr): BeOS support. diff --git a/eval.c b/eval.c index a0a1ba5767..73d085304e 100644 --- a/eval.c +++ b/eval.c @@ -460,15 +460,15 @@ new_dvar(id, value) vars->id = id; vars->val = value; vars->next = the_dyna_vars; - if (id == 0) { - vars->id = (ID)value; - vars->val = 0; - the_dyna_vars = vars; - } - else if (the_dyna_vars) { + if (the_dyna_vars) { vars->next = the_dyna_vars->next; the_dyna_vars->next = vars; } + else { + vars->id = id; + vars->val = 0; + the_dyna_vars = vars; + } return vars; } @@ -2252,7 +2252,7 @@ rb_eval(self, node) list->nd_head = compile(list->nd_head->nd_lit,0); rb_in_eval--; if (nerrs > 0) { - compile_error("string expand"); + compile_error("string expansion"); } } str2 = rb_eval(self, list->nd_head); @@ -3818,6 +3818,8 @@ eval(self, src, scope, file, line) PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { eval_tree = 0; + sourcefile = file; + sourceline = line; compile(src, file); if (nerrs > 0) { compile_error(0); @@ -3927,17 +3929,21 @@ static VALUE eval_under_i(args) VALUE *args; { - return eval(args[0], args[1], Qnil, 0, 0); + return eval(args[0], args[1], Qnil, (char*)args[2], (int)args[3]); } static VALUE -eval_under(under, self, src) +eval_under(under, self, src, file, line) VALUE under, self, src; + char *file; + int line; { - VALUE args[2]; + VALUE args[4]; args[0] = self; args[1] = src; + args[2] = (VALUE)file; + args[3] = (VALUE)line; return exec_under(eval_under_i, under, args); } @@ -3961,13 +3967,18 @@ obj_instance_eval(argc, argv, self) VALUE *argv; VALUE self; { + char *file = 0; + int line = 0; + if (argc == 0) { if (!iterator_p()) { ArgError("block not supplied"); } } - else if (argc == 1) { + else if (argc < 4) { Check_SafeStr(argv[0]); + if (argc > 1) file = STR2CSTR(argv[1]); + if (argc > 2) line = NUM2INT(argv[2]); } else { ArgError("Wrong # of arguments: %s(src) or %s{..}", @@ -3979,7 +3990,7 @@ obj_instance_eval(argc, argv, self) return yield_under(rb_singleton_class(self), self); } else { - return eval_under(rb_singleton_class(self), self, argv[0]); + return eval_under(rb_singleton_class(self), self, argv[0], file, line); } } @@ -3989,13 +4000,18 @@ mod_module_eval(argc, argv, mod) VALUE *argv; VALUE mod; { + char *file = 0; + int line = 0; + if (argc == 0) { if (!iterator_p()) { ArgError("block not supplied"); } } - else if (argc == 1) { + else if (argc < 4) { Check_SafeStr(argv[0]); + if (argc > 1) file = STR2CSTR(argv[1]); + if (argc > 2) line = NUM2INT(argv[2]); } else { ArgError("Wrong # of arguments: %s(src) or %s{..}", @@ -4007,7 +4023,7 @@ mod_module_eval(argc, argv, mod) return yield_under(mod, mod); } else { - return eval_under(mod, mod, argv[0]); + return eval_under(mod, mod, argv[0], file, line); } } diff --git a/lib/e2mmap.rb b/lib/e2mmap.rb index d9acf5603a..307b07dfbe 100644 --- a/lib/e2mmap.rb +++ b/lib/e2mmap.rb @@ -1,8 +1,8 @@ # # e2mmap.rb - for ruby 1.1 # $Release Version: 1.1$ -# $Revision: 1.4 $ -# $Date: 1997/08/18 07:12:12 $ +# $Revision: 1.7 $ +# $Date: 1998/05/19 04:38:33 $ # by Keiju ISHITSUKA # # -- @@ -13,10 +13,10 @@ if VERSION < "1.1" else module Exception2MessageMapper - RCS_ID='-$Header: /home/keiju/var/src/var.lib/ruby/RCS/e2mmap.rb,v 1.4 1997/08/18 07:12:12 keiju Exp keiju $-' + RCS_ID='-$Header: /home/keiju/var/src/var.lib/ruby/RCS/e2mmap.rb,v 1.7 1998/05/19 04:38:33 keiju Exp keiju $-' E2MM = Exception2MessageMapper - + def E2MM.extend_object(cl) super cl.bind(self) @@ -37,16 +37,16 @@ else def bind(cl) self.module_eval %q^ - E2MM_ErrorMSG = {} + E2MM_ErrorMSG = {} unless self.const_defined?(:E2MM_ErrorMSG) # fail(err, *rest) # err: 例外 # rest: メッセージに渡すパラメータ # def self.fail(err = nil, *rest) - $@ = caller(0) if $@.nil? - $@.shift if form = E2MM_ErrorMSG[err] $! = err.new(sprintf(form, *rest)) + $@ = caller(0) if $@.nil? + $@.shift # e2mm_fail() raise() # elsif self == Exception2MessageMapper @@ -72,13 +72,21 @@ else # def_exception(c, m) # n: exception_name # m: message_form - # s: 例外スーパークラス(デフォルト: StandardError) + # s: 例外スーパークラス(デフォルト: Exception) # 例外名``c''をもつ例外を定義し, そのメッセージをmとする. # #def def_exception(n, m) - def self.def_exception(n, m, s = StandardError) + def self.def_exception(n, m, s = nil) n = n.id2name if n.kind_of?(Fixnum) + unless s + if defined?(StandardError) + s = StandardError + else + s = Exception + end + end e = Class.new(s) + const_set(n, e) E2MM_ErrorMSG[e] = m # const_get(:E2MM_ErrorMSG)[e] = m diff --git a/lib/tracer.rb b/lib/tracer.rb index 032557d10c..b7ef536269 100644 --- a/lib/tracer.rb +++ b/lib/tracer.rb @@ -1,8 +1,9 @@ +#!/usr/local/bin/ruby # # tracer.rb - # $Release Version: 0.2$ -# $Revision: 1.1.1.1.4.1 $ -# $Date: 1998/02/03 10:02:57 $ +# $Revision: 1.8 $ +# $Date: 1998/05/19 03:42:49 $ # by Keiju ISHITSUKA(Nippon Rational Inc.) # # -- @@ -14,9 +15,15 @@ # tracer main class # class Tracer - RCS_ID='-$Id: tracer.rb,v 1.1.1.1.4.1 1998/02/03 10:02:57 matz Exp $-' + @RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-' + + class << self + attr :verbose, TRUE + alias verbose? verbose + end + verbose = TRUE - MY_FILE_NAME = caller(0)[0].scan(/^(.*):[0-9]+$/)[0] + MY_FILE_NAME = caller(0)[0].scan(/^(.*):[0-9]+$/)[0][0] EVENT_SYMBOL = { "line" => "-", @@ -33,7 +40,10 @@ class Tracer @threads[Thread.current.id] = 0 end - @sources = Hash.new + @get_line_procs = {} + @sources = {} + + @filters = [] end def on @@ -48,16 +58,28 @@ class Tracer set_trace_func proc{|event, file, line, id, binding| trace_func event, file, line, id, binding } - print "Trace on\n" + print "Trace on\n" if Tracer.verbose? end end def off set_trace_func nil - print "Trace off\n" + print "Trace off\n" if Tracer.verbose? + end + + def add_filter(p = proc) + @filters.push p + end + + def set_get_line_procs(file, p = proc) + @get_line_procs[file] = p end def get_line(file, line) + if p = @get_line_procs[file] + return p.call line + end + unless list = @sources[file] # print file if $DEBUG begin @@ -90,6 +112,10 @@ class Tracer return if file == MY_FILE_NAME #printf "Th: %s\n", Thread.current.inspect + for p in @filters + return unless p.call event, file, line, id, binding + end + Thread.critical = TRUE printf("#%d:%s:%d:%s: %s", get_thread_no, @@ -102,13 +128,25 @@ class Tracer Single = new def Tracer.on - Single.on + if iterator? + Single.on{yield} + else + Single.on + end end def Tracer.off Single.off end + def Tracer.set_get_line_procs(file_name, p = proc) + Single.set_get_line_procs(file_name, p) + end + + def Tracer.add_filter(p = proc) + Single.add_filter(p) + end + end if caller(0).size == 1 diff --git a/numeric.c b/numeric.c index 9127a0de2b..75ff41da80 100644 --- a/numeric.c +++ b/numeric.c @@ -667,7 +667,7 @@ int num2int(val) VALUE val; { - long num = num2int(val); + long num = num2long(val); if (num < INT_MIN || INT_MAX < num) { ArgError("integer %d too big to convert to `int'.", num); @@ -686,6 +686,20 @@ fix2int(val) } return (int)num; } +#else +int +num2int(val) + VALUE val; +{ + return num2long(val); +} + +int +fix2int(val) + VALUE val; +{ + return FIX2INT(val); +} #endif VALUE diff --git a/parse.y b/parse.y index ae966e8002..c8a54907b4 100644 --- a/parse.y +++ b/parse.y @@ -3031,7 +3031,8 @@ str_extend(list, term) NODE *list; char term; { - int c, brace; + int c; + int brace = -1; VALUE ss; NODE *node; int nest; @@ -3134,7 +3135,6 @@ str_extend(list, term) } return (NODE*)-1; case '}': - case ')': if (c == brace) { if (nest == 0) break; nest--; @@ -3146,7 +3146,7 @@ str_extend(list, term) tokadd(c); goto loop_again; case '{': - if (brace == c) nest++; + if (brace != -1) nest++; case '\"': case '/': case '`': @@ -3434,7 +3434,7 @@ assignable(id, val) } else{ if (!dyna_var_defined(id)) { - dyna_var_asgn(0, id); + dyna_var_asgn(id, 0); } lhs = NEW_DASGN(id, val); } diff --git a/version.h b/version.h index ec57adc885..c671a12e83 100644 --- a/version.h +++ b/version.h @@ -1,2 +1,2 @@ -#define RUBY_VERSION "1.1b9_21" -#define VERSION_DATE "98/05/18" +#define RUBY_VERSION "1.1b9_22" +#define VERSION_DATE "98/05/19" -- cgit v1.2.3