Skip to content

Commit

Permalink
* eval.c (rb_clear_cache_by_class): new function.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
matz committed May 14, 2002
1 parent c5d6a1b commit eb61189
Show file tree
Hide file tree
Showing 34 changed files with 377 additions and 70 deletions.
29 changes: 29 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,24 @@ Tue May 14 14:49:05 2002 WATANABE Hirofumi <[email protected]>

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

Tue May 14 03:07:35 2002 Yukihiro Matsumoto <[email protected]>

* eval.c (rb_clear_cache_by_class): new function.

* eval.c (set_method_visibility): should have clear cache forq
updated visibility.

Mon May 13 14:38:33 2002 WATANABE Hirofumi <[email protected]>

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

Mon May 13 01:59:55 2002 Yukihiro Matsumoto <[email protected]>

* 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

Sun May 12 03:01:08 2002 WATANABE Hirofumi <[email protected]>

* missing.h: add for missing/*.c.
Expand All @@ -26,6 +40,16 @@ Sat May 11 10:52:09 2002 Nobuyoshi Nakada <[email protected]>

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

Sat May 11 02:46:43 2002 Yukihiro Matsumoto <[email protected]>

* 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).

Fri May 10 19:00:47 2002 Nobuyoshi Nakada <[email protected]>

* parse.y (here_document): preserve line number begins here
Expand All @@ -38,6 +62,11 @@ Fri May 10 01:55:44 2002 Nobuyoshi Nakada <[email protected]>

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

Wed May 8 23:48:40 2002 Yukihiro Matsumoto <[email protected]>

* parse.y (value_expr): need not to warn for WHILE and UNTIL,
since they can have return value (via valued break).

Tue May 7 17:13:40 2002 WATANABE Hirofumi <[email protected]>

* configure.in: forgot to add '-Wl,' to the gcc option on Cygwin/MinGW.
Expand Down
3 changes: 0 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ strftime.@OBJEXT@: $(srcdir)/missing/strftime.c
strstr.@OBJEXT@: $(srcdir)/missing/strstr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strstr.c

strtod.@OBJEXT@: $(srcdir)/missing/strtod.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtod.c

strtol.@OBJEXT@: $(srcdir)/missing/strtol.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtol.c

Expand Down
2 changes: 1 addition & 1 deletion ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Standard Libraries
* new user-defined marshal scheme. _dump(dumper), _load(restorer)
* library to load per-user profile seeking .ruby_profile or ruby.ini file.
* warning framework (warn, warning for Ruby level)
* marshal should not depend on sprintf/strtod (works bad with locale).
* marshal should not depend on sprintf (works bad with locale).
* ternary arg pow: a.pow(b,c) == a**b%c
* new caller(), e.g. call_stack; needs better name.
* remove dependency on MAXPATHLEN.
Expand Down
3 changes: 2 additions & 1 deletion bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
**********************************************************************/

#include "ruby.h"

#include <math.h>
#include <ctype.h>
#include "ruby.h"

VALUE rb_cBignum;

Expand Down
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ if test "$enable_shared" = 'yes'; then
darwin*)
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib'
LIBRUBY_LDSHARED='cc -dynamiclib -undefined suppress -flat_namespace'
LIBRUBY_DLDFLAGS='-install_name lib$(RUBY_INSTALL_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
LIBRUBY_DLDFLAGS='-install_name $(prefix)/lib/lib$(RUBY_INSTALL_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_INSTALL_NAME).dylib'
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion dln.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 18 17:05:06 JST 1994
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/

Expand Down
2 changes: 1 addition & 1 deletion dln.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$Date$
created at: Wed Jan 19 16:53:09 JST 1994
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/

Expand Down
2 changes: 1 addition & 1 deletion env.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$Date$
created at: Mon Jul 11 11:53:03 JST 1994
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/

Expand Down
62 changes: 49 additions & 13 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ rb_clear_cache_by_id(id)
}
}

static void
rb_clear_cache_by_class(klass)
VALUE klass;
{
struct cache_entry *ent, *end;

ent = cache; end = ent + CACHE_SIZE;
while (ent < end) {
if (ent->origin == klass) {
ent->mid = 0;
}
ent++;
}
}

void
rb_add_method(klass, mid, node, noex)
VALUE klass;
Expand Down Expand Up @@ -2111,11 +2126,28 @@ avalue_to_svalue(v)
return v;
}

static VALUE
avalue_to_yvalue(v)
VALUE v;
{
if (TYPE(v) != T_ARRAY) {
v = rb_ary_to_ary(v);
}
if (RARRAY(v)->len == 0) {
return Qundef;
}
if (RARRAY(v)->len == 1) {
return RARRAY(v)->ptr[0];
}
return v;
}

static VALUE
svalue_to_mvalue(v)
VALUE v;
{
if (NIL_P(v)) return rb_ary_new2(0);
if (v == Qnil || v == Qundef)
return rb_ary_new2(0);
if (TYPE(v) == T_ARRAY) {
return v;
}
Expand Down Expand Up @@ -2511,10 +2543,10 @@ rb_eval(self, n)

case NODE_YIELD:
if (node->nd_stts) {
result = avalue_to_svalue(rb_eval(self, node->nd_stts));
result = avalue_to_yvalue(rb_eval(self, node->nd_stts));
}
else {
result = Qnil;
result = Qundef; /* no arg */
}
result = rb_yield_0(result, 0, 0, 0);
break;
Expand Down Expand Up @@ -3745,21 +3777,21 @@ rb_yield_0(val, self, klass, pcall)
RARRAY(val)->len);
}
}
else if (nd_type(block->var) == NODE_MASGN) {
massign(self, block->var, val, pcall);
}
else {
if (nd_type(block->var) == NODE_MASGN) {
massign(self, block->var, val, pcall);
}
else {
if (pcall) val = avalue_to_svalue(val);
assign(self, block->var, val, pcall);
if (pcall) {
val = avalue_to_yvalue(val);
}
assign(self, block->var, val, pcall);
}
}
POP_TAG();
if (state) goto pop_state;
}
else if (pcall) {
val = avalue_to_svalue(val);
val = avalue_to_yvalue(val);
}

PUSH_ITER(block->iter);
Expand Down Expand Up @@ -3849,7 +3881,7 @@ static VALUE
rb_f_loop()
{
for (;;) {
rb_yield_0(Qnil, 0, 0, 0);
rb_yield_0(Qundef, 0, 0, 0);
CHECK_INTS;
}
return Qnil; /* dummy */
Expand Down Expand Up @@ -3912,7 +3944,10 @@ assign(self, lhs, val, pcall)
VALUE val;
int pcall;
{
if (val == Qundef) val = Qnil;
if (val == Qundef) {
rb_warning("assigning void value");
val = Qnil;
}
switch (nd_type(lhs)) {
case NODE_GASGN:
rb_gvar_set(lhs->nd_entry, val);
Expand Down Expand Up @@ -5623,6 +5658,7 @@ set_method_visibility(self, argc, argv, ex)
for (i=0; i<argc; i++) {
rb_export_method(self, rb_to_id(argv[i]), ex);
}
rb_clear_cache_by_class(self);
}

static VALUE
Expand Down Expand Up @@ -6470,7 +6506,7 @@ proc_invoke(proc, args, pcall, self)
ruby_frame->iter = ITER_CUR;

if (!pcall) {
args = avalue_to_svalue(args);
args = avalue_to_yvalue(args);
}
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
Expand Down
2 changes: 1 addition & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$Date$
created at: Mon Nov 15 12:24:34 JST 1993
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 1993-2002 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
Expand Down
13 changes: 1 addition & 12 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,18 +1128,7 @@ rb_gc()
struct gc_list *list;
struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug?? */
jmp_buf save_regs_gc_mark;
#ifdef C_ALLOCA
VALUE stack_end;
alloca(0);
# define STACK_END (&stack_end)
#else
# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS)
VALUE *stack_end = __builtin_frame_address(0);
# else
VALUE *stack_end = alloca(1);
# endif
# define STACK_END (stack_end)
#endif
SET_STACK_END;

if (dont_gc || during_gc) {
if (!freelist || malloc_memories > GC_MALLOC_LIMIT) {
Expand Down
2 changes: 1 addition & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$Date$
created at: Mon Nov 22 18:51:18 JST 1993
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 1993-2002 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
Expand Down
6 changes: 1 addition & 5 deletions marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
#include "ruby.h"
#include "rubyio.h"
#include "st.h"

#if !defined(atof) && !defined(HAVE_STDLIB_H)
double strtod();
#endif
#include "util.h"

#define BITSPERSHORT (2*CHAR_BIT)
#define SHORTMASK ((1<<BITSPERSHORT)-1)
Expand Down Expand Up @@ -884,7 +881,6 @@ r_object(arg)
d = -1.0 / t;
}
else {
/* xxx: should not use system's strtod(3) */
d = strtod(buf, 0);
}
v = rb_float_new(d);
Expand Down
11 changes: 7 additions & 4 deletions misc/ruby-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
(defvar ruby-indent-level 2
"*Indentation of ruby statements.")

(defvar ruby-deep-arglist t
"*Deep indent argument lists when non-nil.")

(eval-when-compile (require 'cl))
(defun ruby-imenu-create-index ()
(let ((index-alist '())
Expand Down Expand Up @@ -366,18 +369,18 @@ The variable ruby-indent-level controls the amount of indentation.
(forward-line 1)
(goto-char (point))
)
((looking-at "(")
((and (looking-at "(") ruby-deep-arglist)
(setq nest (cons (cons (char-after (point)) pnt) nest))
(setq pcol (cons (cons pnt depth) pcol))
(setq depth 0)
(goto-char pnt)
)
((looking-at "[\\[{]")
((looking-at "[\\[{(]")
(setq nest (cons (cons (char-after (point)) pnt) nest))
(setq depth (1+ depth))
(goto-char pnt)
)
((looking-at ")")
((and (looking-at ")") ruby-deep-arglist)
(setq nest (cdr nest))
(setq depth (cdr (car pcol)))
(setq pcol (cdr pcol))
Expand Down Expand Up @@ -478,7 +481,7 @@ The variable ruby-indent-level controls the amount of indentation.
(setq indent nil)) ; do nothing
((car (nth 1 state)) ; in paren
(goto-char (cdr (nth 1 state)))
(if (eq (car (nth 1 state)) ?\( )
(if (and (eq (car (nth 1 state)) ?\( ) ruby-deep-arglist)
(let ((column (current-column))
(s (ruby-parse-region (point) indent-point)))
(cond
Expand Down
2 changes: 1 addition & 1 deletion missing.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/************************************************
missing.h - prototype for missing/*.c
missing.h - prototype for *.c in ./missing
$Author$
$Date$
Expand Down
2 changes: 1 addition & 1 deletion node.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$Date$
created at: Fri May 28 15:14:02 JST 1993
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 1993-2002 Yukihiro Matsumoto
**********************************************************************/

Expand Down
Loading

0 comments on commit eb61189

Please sign in to comment.