mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y (arg): "||=" should not warn for uninitialized instance
variables. * eval.c (rb_eval): ditto. * eval.c (eval): preserve and restore ruby_cref as well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
075169f071
commit
13cbec33c1
10 changed files with 71 additions and 58 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,8 +1,26 @@
|
||||||
|
Mon May 7 15:58:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y (arg): "||=" should not warn for uninitialized instance
|
||||||
|
variables.
|
||||||
|
|
||||||
|
* eval.c (rb_eval): ditto.
|
||||||
|
|
||||||
|
* eval.c (eval): preserve and restore ruby_cref as well.
|
||||||
|
|
||||||
Mon May 7 15:45:48 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
Mon May 7 15:45:48 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* lib/ftools.rb (syscopy): chmod destination file only if
|
* lib/ftools.rb (syscopy): chmod destination file only if
|
||||||
it does not exist.
|
it does not exist.
|
||||||
|
|
||||||
|
Mon May 7 14:35:57 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (rb_obj_is_instance_of): takes only class/module as an
|
||||||
|
argument.
|
||||||
|
|
||||||
|
Sun May 6 16:27:29 2001 Koji Arai <JCA02266@nifty.ne.jp>
|
||||||
|
|
||||||
|
* eval.c (is_defined): rb_reg_nth_defined() may return Qnil.
|
||||||
|
|
||||||
Thu May 3 03:15:06 2001 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
|
Thu May 3 03:15:06 2001 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
|
||||||
|
|
||||||
* configure.in: get --enable-shared to work on MacOS X.
|
* configure.in: get --enable-shared to work on MacOS X.
|
||||||
|
|
|
@ -125,7 +125,7 @@ realclean: distclean
|
||||||
test: miniruby$(EXEEXT)
|
test: miniruby$(EXEEXT)
|
||||||
@./miniruby$(EXEEXT) $(srcdir)/rubytest.rb
|
@./miniruby$(EXEEXT) $(srcdir)/rubytest.rb
|
||||||
|
|
||||||
rbconfig.rb: miniruby$(EXEEXT)
|
rbconfig.rb: miniruby$(EXEEXT) $(srcdir)/mkconfig.rb config.status
|
||||||
@@MINIRUBY@ $(srcdir)/mkconfig.rb rbconfig.rb
|
@@MINIRUBY@ $(srcdir)/mkconfig.rb rbconfig.rb
|
||||||
|
|
||||||
fake.rb: miniruby$(EXEEXT)
|
fake.rb: miniruby$(EXEEXT)
|
||||||
|
|
26
eval.c
26
eval.c
|
@ -1847,14 +1847,14 @@ is_defined(self, node, buf)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_NTH_REF:
|
case NODE_NTH_REF:
|
||||||
if (rb_reg_nth_defined(node->nd_nth, MATCH_DATA)) {
|
if (RTEST(rb_reg_nth_defined(node->nd_nth, MATCH_DATA))) {
|
||||||
sprintf(buf, "$%d", node->nd_nth);
|
sprintf(buf, "$%d", node->nd_nth);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_BACK_REF:
|
case NODE_BACK_REF:
|
||||||
if (rb_reg_nth_defined(0, MATCH_DATA)) {
|
if (RTEST(rb_reg_nth_defined(0, MATCH_DATA))) {
|
||||||
sprintf(buf, "$%c", node->nd_nth);
|
sprintf(buf, "$%c", node->nd_nth);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -2637,10 +2637,12 @@ rb_eval(self, n)
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
case NODE_OP_ASGN_OR:
|
case NODE_OP_ASGN_OR:
|
||||||
result = rb_eval(self, node->nd_head);
|
if ((node->nd_aid && !rb_ivar_defined(self, node->nd_aid)) ||
|
||||||
if (RTEST(result)) break;
|
!RTEST(result = rb_eval(self, node->nd_head))) {
|
||||||
node = node->nd_value;
|
node = node->nd_value;
|
||||||
goto again;
|
goto again;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case NODE_MASGN:
|
case NODE_MASGN:
|
||||||
result = massign(self, node, rb_eval(self, node->nd_value),0);
|
result = massign(self, node, rb_eval(self, node->nd_value),0);
|
||||||
|
@ -4737,6 +4739,7 @@ eval(self, src, scope, file, line)
|
||||||
struct SCOPE * volatile old_scope;
|
struct SCOPE * volatile old_scope;
|
||||||
struct BLOCK * volatile old_block;
|
struct BLOCK * volatile old_block;
|
||||||
struct RVarmap * volatile old_dyna_vars;
|
struct RVarmap * volatile old_dyna_vars;
|
||||||
|
VALUE volatile old_cref;
|
||||||
int volatile old_vmode;
|
int volatile old_vmode;
|
||||||
struct FRAME frame;
|
struct FRAME frame;
|
||||||
char *filesave = ruby_sourcefile;
|
char *filesave = ruby_sourcefile;
|
||||||
|
@ -4767,6 +4770,8 @@ eval(self, src, scope, file, line)
|
||||||
ruby_dyna_vars = data->dyna_vars;
|
ruby_dyna_vars = data->dyna_vars;
|
||||||
old_vmode = scope_vmode;
|
old_vmode = scope_vmode;
|
||||||
scope_vmode = data->vmode;
|
scope_vmode = data->vmode;
|
||||||
|
old_cref = (VALUE)ruby_cref;
|
||||||
|
ruby_cref = (NODE*)ruby_frame->cbase;
|
||||||
|
|
||||||
self = data->self;
|
self = data->self;
|
||||||
ruby_frame->iter = data->iter;
|
ruby_frame->iter = data->iter;
|
||||||
|
@ -4802,6 +4807,7 @@ eval(self, src, scope, file, line)
|
||||||
if (!NIL_P(scope)) {
|
if (!NIL_P(scope)) {
|
||||||
int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE;
|
int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE;
|
||||||
|
|
||||||
|
ruby_cref = (NODE*)old_cref;
|
||||||
ruby_frame = frame.tmp;
|
ruby_frame = frame.tmp;
|
||||||
ruby_scope = old_scope;
|
ruby_scope = old_scope;
|
||||||
ruby_block = old_block;
|
ruby_block = old_block;
|
||||||
|
@ -5023,17 +5029,16 @@ specific_eval(argc, argv, klass, self)
|
||||||
else {
|
else {
|
||||||
char *file = "(eval)";
|
char *file = "(eval)";
|
||||||
int line = 1;
|
int line = 1;
|
||||||
VALUE src = argv[0];
|
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
rb_raise(rb_eArgError, "block not supplied");
|
rb_raise(rb_eArgError, "block not supplied");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (ruby_safe_level >= 4) {
|
if (ruby_safe_level >= 4) {
|
||||||
StringValue(src);
|
StringValue(argv[0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SafeStringValue(src);
|
SafeStringValue(argv[0]);
|
||||||
}
|
}
|
||||||
if (argc > 3) {
|
if (argc > 3) {
|
||||||
rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
|
rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
|
||||||
|
@ -5041,8 +5046,7 @@ specific_eval(argc, argv, klass, self)
|
||||||
rb_id2name(ruby_frame->last_func));
|
rb_id2name(ruby_frame->last_func));
|
||||||
}
|
}
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
src = argv[1];
|
file = StringValuePtr(argv[1]);
|
||||||
file = StringValuePtr(src);
|
|
||||||
}
|
}
|
||||||
if (argc > 2) line = NUM2INT(argv[2]);
|
if (argc > 2) line = NUM2INT(argv[2]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ static VALUE mReadline;
|
||||||
#ifndef READLINE_42_OR_LATER
|
#ifndef READLINE_42_OR_LATER
|
||||||
# define rl_filename_completion_function filename_completion_function
|
# define rl_filename_completion_function filename_completion_function
|
||||||
# define rl_username_completion_function username_completion_function
|
# define rl_username_completion_function username_completion_function
|
||||||
|
# define rl_completion_matches completion_matches
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -327,8 +328,8 @@ filename_completion_proc_call(self, str)
|
||||||
char **matches;
|
char **matches;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
matches = completion_matches(StringValuePtr(str),
|
matches = rl_completion_matches(StringValuePtr(str),
|
||||||
rl_filename_completion_function);
|
rl_filename_completion_function);
|
||||||
if (matches) {
|
if (matches) {
|
||||||
result = rb_ary_new();
|
result = rb_ary_new();
|
||||||
for (i = 0; matches[i]; i++) {
|
for (i = 0; matches[i]; i++) {
|
||||||
|
@ -354,8 +355,8 @@ username_completion_proc_call(self, str)
|
||||||
char **matches;
|
char **matches;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
matches = completion_matches(StringValuePtr(str),
|
matches = rl_completion_matches(StringValuePtr(str),
|
||||||
rl_username_completion_function);
|
rl_username_completion_function);
|
||||||
if (matches) {
|
if (matches) {
|
||||||
result = rb_ary_new();
|
result = rb_ary_new();
|
||||||
for (i = 0; matches[i]; i++) {
|
for (i = 0; matches[i]; i++) {
|
||||||
|
|
4
gc.c
4
gc.c
|
@ -1220,12 +1220,12 @@ run_final(obj)
|
||||||
args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */
|
args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */
|
||||||
for (i=0; i<RARRAY(finalizers)->len; i++) {
|
for (i=0; i<RARRAY(finalizers)->len; i++) {
|
||||||
args[0] = RARRAY(finalizers)->ptr[i];
|
args[0] = RARRAY(finalizers)->ptr[i];
|
||||||
rb_protect(run_single_final, (VALUE)args, &status);
|
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
|
||||||
}
|
}
|
||||||
if (finalizer_table && st_delete(finalizer_table, &obj, &table)) {
|
if (finalizer_table && st_delete(finalizer_table, &obj, &table)) {
|
||||||
for (i=0; i<RARRAY(table)->len; i++) {
|
for (i=0; i<RARRAY(table)->len; i++) {
|
||||||
args[0] = RARRAY(table)->ptr[i];
|
args[0] = RARRAY(table)->ptr[i];
|
||||||
rb_protect(run_single_final, (VALUE)args, &status);
|
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,10 +202,7 @@ class Date
|
||||||
alias_method :__#{id.to_i}__, :#{id.id2name}
|
alias_method :__#{id.to_i}__, :#{id.id2name}
|
||||||
private :__#{id.to_i}__
|
private :__#{id.to_i}__
|
||||||
def #{id.id2name}(*args, &block)
|
def #{id.id2name}(*args, &block)
|
||||||
unless defined? @__#{id.to_i}__
|
(@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0]
|
||||||
@__#{id.to_i}__ = __#{id.to_i}__(*args, &block)
|
|
||||||
end
|
|
||||||
@__#{id.to_i}__
|
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
24
lib/mkmf.rb
24
lib/mkmf.rb
|
@ -12,12 +12,13 @@ SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
|
||||||
$config_cache = CONFIG["compile_dir"]+"/ext/config.cache"
|
$config_cache = CONFIG["compile_dir"]+"/ext/config.cache"
|
||||||
|
|
||||||
$srcdir = CONFIG["srcdir"]
|
$srcdir = CONFIG["srcdir"]
|
||||||
$libdir = CONFIG["libdir"]+"/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
$libdir = CONFIG["libdir"]
|
||||||
$archdir = $libdir+"/"+CONFIG["arch"]
|
$rubylibdir = CONFIG["rubylibdir"]
|
||||||
$sitelibdir = CONFIG["sitedir"]+"/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
$archdir = CONFIG["archdir"]
|
||||||
$sitearchdir = $sitelibdir+"/"+CONFIG["arch"]
|
$sitelibdir = CONFIG["sitelibdir"]
|
||||||
|
$sitearchdir = CONFIG["sitearchdir"]
|
||||||
|
|
||||||
if File.exist? $archdir + "/ruby.h"
|
if File.exist? Config::CONFIG["archdir"] + "/ruby.h"
|
||||||
$hdrdir = $archdir
|
$hdrdir = $archdir
|
||||||
elsif File.exist? $srcdir + "/ruby.h"
|
elsif File.exist? $srcdir + "/ruby.h"
|
||||||
$hdrdir = $srcdir
|
$hdrdir = $srcdir
|
||||||
|
@ -438,6 +439,8 @@ LIBPATH = #{libpath}
|
||||||
|
|
||||||
RUBY_INSTALL_NAME = #{CONFIG["RUBY_INSTALL_NAME"]}
|
RUBY_INSTALL_NAME = #{CONFIG["RUBY_INSTALL_NAME"]}
|
||||||
RUBY_SO_NAME = #{CONFIG["RUBY_SO_NAME"]}
|
RUBY_SO_NAME = #{CONFIG["RUBY_SO_NAME"]}
|
||||||
|
arch = #{CONFIG["arch"]}
|
||||||
|
ruby_version = #{Config::CONFIG["ruby_version"]}
|
||||||
#{
|
#{
|
||||||
if destdir = CONFIG["prefix"].scan(drive)[0] and !destdir.empty?
|
if destdir = CONFIG["prefix"].scan(drive)[0] and !destdir.empty?
|
||||||
"\nDESTDIR = " + destdir
|
"\nDESTDIR = " + destdir
|
||||||
|
@ -446,11 +449,12 @@ else
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
prefix = $(DESTDIR)#{CONFIG["prefix"].sub(drive, '')}
|
prefix = $(DESTDIR)#{CONFIG["prefix"].sub(drive, '')}
|
||||||
exec_prefix = $(DESTDIR)#{CONFIG["exec_prefix"].sub(drive, '')}
|
exec_prefix = #{CONFIG["exec_prefix"].sub(drive, '')}
|
||||||
libdir = $(DESTDIR)#{$libdir.sub(drive, '')}#{target_prefix}
|
libdir = #{$libdir.sub(drive, '')}#{target_prefix}
|
||||||
archdir = $(DESTDIR)#{$archdir.sub(drive, '')}#{target_prefix}
|
rubylibdir = #{$rubylibdir.sub(drive, '')}#{target_prefix}
|
||||||
sitelibdir = $(DESTDIR)#{$sitelibdir.sub(drive, '')}#{target_prefix}
|
archdir = #{$archdir.sub(drive, '')}#{target_prefix}
|
||||||
sitearchdir = $(DESTDIR)#{$sitearchdir.sub(drive, '')}#{target_prefix}
|
sitelibdir = #{$sitelibdir.sub(drive, '')}#{target_prefix}
|
||||||
|
sitearchdir = #{$sitearchdir.sub(drive, '')}#{target_prefix}
|
||||||
|
|
||||||
#### End of system configuration section. ####
|
#### End of system configuration section. ####
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ File.foreach "config.status" do |line|
|
||||||
next if $so_name and /^RUBY_SO_NAME$/ =~ name
|
next if $so_name and /^RUBY_SO_NAME$/ =~ name
|
||||||
v = " CONFIG[\"" + name + "\"] = " +
|
v = " CONFIG[\"" + name + "\"] = " +
|
||||||
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) {
|
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) {
|
||||||
"\#{CONFIG[\\\"#{$1}\\\"]}"
|
"$(#{$1})"
|
||||||
} + "\n"
|
} + "\n"
|
||||||
if fast[name]
|
if fast[name]
|
||||||
v_fast << v
|
v_fast << v
|
||||||
|
@ -89,6 +89,11 @@ end
|
||||||
|
|
||||||
print v_fast, v_others
|
print v_fast, v_others
|
||||||
print <<EOS
|
print <<EOS
|
||||||
|
CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
|
||||||
|
CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
|
||||||
|
CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
|
||||||
|
CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
|
||||||
|
CONFIG["sitearchdir"] = "$(sitelibdir)/$(arch)"
|
||||||
CONFIG["compile_dir"] = "#{Dir.pwd}"
|
CONFIG["compile_dir"] = "#{Dir.pwd}"
|
||||||
MAKEFILE_CONFIG = {}
|
MAKEFILE_CONFIG = {}
|
||||||
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
|
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
|
||||||
|
@ -96,7 +101,7 @@ print <<EOS
|
||||||
val.gsub!(/\\$\\(([^()]+)\\)/) do |var|
|
val.gsub!(/\\$\\(([^()]+)\\)/) do |var|
|
||||||
key = $1
|
key = $1
|
||||||
if CONFIG.key? key
|
if CONFIG.key? key
|
||||||
"\#{Config::expand(CONFIG[\\\"\#{key}\\\"])}"
|
Config::expand(CONFIG[key])
|
||||||
else
|
else
|
||||||
var
|
var
|
||||||
end
|
end
|
||||||
|
|
11
object.c
11
object.c
|
@ -220,17 +220,6 @@ rb_obj_is_instance_of(obj, c)
|
||||||
case T_CLASS:
|
case T_CLASS:
|
||||||
case T_ICLASS:
|
case T_ICLASS:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_NIL:
|
|
||||||
if (NIL_P(obj)) return Qtrue;
|
|
||||||
return Qfalse;
|
|
||||||
|
|
||||||
case T_FALSE:
|
|
||||||
return RTEST(obj) ? Qfalse : Qtrue;
|
|
||||||
|
|
||||||
case T_TRUE:
|
|
||||||
return RTEST(obj) ? Qtrue : Qfalse;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rb_raise(rb_eTypeError, "class or module required");
|
rb_raise(rb_eTypeError, "class or module required");
|
||||||
}
|
}
|
||||||
|
|
21
parse.y
21
parse.y
|
@ -411,15 +411,15 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
||||||
{
|
{
|
||||||
$$ = node_assign($1, $3);
|
$$ = node_assign($1, $3);
|
||||||
}
|
}
|
||||||
| expr
|
| mlhs '=' mrhs
|
||||||
|
|
||||||
expr : mlhs '=' mrhs
|
|
||||||
{
|
{
|
||||||
value_expr($3);
|
value_expr($3);
|
||||||
$1->nd_value = $3;
|
$1->nd_value = $3;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| kRETURN ret_args
|
| expr
|
||||||
|
|
||||||
|
expr : kRETURN ret_args
|
||||||
{
|
{
|
||||||
if (!compile_for_eval && !in_def && !in_single)
|
if (!compile_for_eval && !in_def && !in_single)
|
||||||
yyerror("return appeared outside of method");
|
yyerror("return appeared outside of method");
|
||||||
|
@ -671,6 +671,9 @@ arg : lhs '=' arg
|
||||||
if ($2 == tOROP) {
|
if ($2 == tOROP) {
|
||||||
$<node>3->nd_value = $4;
|
$<node>3->nd_value = $4;
|
||||||
$$ = NEW_OP_ASGN_OR(gettable($1), $<node>3);
|
$$ = NEW_OP_ASGN_OR(gettable($1), $<node>3);
|
||||||
|
if (is_instance_id($1)) {
|
||||||
|
$$->nd_aid = $1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ($2 == tANDOP) {
|
else if ($2 == tANDOP) {
|
||||||
$<node>3->nd_value = $4;
|
$<node>3->nd_value = $4;
|
||||||
|
@ -903,14 +906,10 @@ arg : lhs '=' arg
|
||||||
}
|
}
|
||||||
|
|
||||||
aref_args : none
|
aref_args : none
|
||||||
| command_call opt_nl
|
| command opt_nl
|
||||||
{
|
{
|
||||||
$$ = NEW_LIST($1);
|
$$ = NEW_LIST($1);
|
||||||
}
|
}
|
||||||
| args ',' command_call opt_nl
|
|
||||||
{
|
|
||||||
$$ = list_append($1, $3);
|
|
||||||
}
|
|
||||||
| args trailer
|
| args trailer
|
||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
|
@ -954,10 +953,6 @@ call_args : command
|
||||||
{
|
{
|
||||||
$$ = NEW_LIST($1);
|
$$ = NEW_LIST($1);
|
||||||
}
|
}
|
||||||
| args ',' command
|
|
||||||
{
|
|
||||||
$$ = list_append($1, $3);
|
|
||||||
}
|
|
||||||
| args opt_block_arg
|
| args opt_block_arg
|
||||||
{
|
{
|
||||||
$$ = arg_blk_pass($1, $2);
|
$$ = arg_blk_pass($1, $2);
|
||||||
|
|
Loading…
Add table
Reference in a new issue