1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* gc.c (rb_gc_call_finalizer_at_exit): should finalize objects in

deferred_final_list too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-01-23 09:55:10 +00:00
parent 17fe2159b4
commit 0cabf4acd0
6 changed files with 134 additions and 121 deletions

View file

@ -1,7 +1,20 @@
Tue Jan 23 18:51:57 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (rb_gc_call_finalizer_at_exit): should finalize objects in
deferred_final_list too.
Mon Jan 22 16:33:16 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* mkconfig.rb: autoconf 2.49 support.
Sat Jan 20 03:54:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (yylex): fixed serious syntax misbehavior. do's
preceding was too high. a block in `foo bar do .. end' should
be passed to `foo', not `bar'.
* parse.y (block_call): syntax restructure.
Fri Jan 19 04:04:31 2001 Akinori MUSHA <knu@iDaemons.org>
* lib/irb/ruby-lex.rb: Merge from HEAD: rev.1.4

33
gc.c
View file

@ -719,7 +719,7 @@ gc_sweep()
during_gc = 0;
/* clear finalization list */
if (need_call_final && final_list) {
if (final_list) {
RVALUE *tmp;
if (rb_prohibit_interrupt || ruby_in_compile) {
@ -1214,9 +1214,9 @@ run_final(obj)
args[0] = RARRAY(finalizers)->ptr[i];
rb_protect(run_single_final, (VALUE)args, &status);
}
if (finalizer_table && st_lookup(finalizer_table, obj, &table)) {
st_delete(finalizer_table, &obj, 0);
if (finalizer_table && st_delete(finalizer_table, &obj, &table)) {
for (i=0; i<RARRAY(table)->len; i++) {
printf("n finals=>%d\n", finalizer_table->num_entries);
args[0] = RARRAY(table)->ptr[i];
rb_protect(run_single_final, (VALUE)args, &status);
}
@ -1230,15 +1230,26 @@ rb_gc_call_finalizer_at_exit()
int i;
/* run finalizers */
for (i = 0; i < heaps_used; i++) {
p = heaps[i]; pend = p + HEAP_SLOTS;
while (p < pend) {
if (FL_TEST(p, FL_FINALIZE)) {
FL_UNSET(p, FL_FINALIZE);
p->as.basic.klass = 0;
run_final((VALUE)p);
if (need_call_final) {
if (deferred_final_list) {
p = deferred_final_list;
while (p) {
RVALUE *tmp = p;
p = p->as.free.next;
run_final((VALUE)tmp);
}
}
for (i = 0; i < heaps_used; i++) {
p = heaps[i]; pend = p + HEAP_SLOTS;
while (p < pend) {
if (FL_TEST(p, FL_FINALIZE)) {
FL_UNSET(p, FL_FINALIZE);
p->as.basic.klass = 0;
printf("%p\n", p);
run_final((VALUE)p);
}
p++;
}
p++;
}
}
/* run data object's finaliers */

View file

@ -1,5 +1,5 @@
# date.rb: Written by Tadayoshi Funaba 1998-2000
# $Id: date.rb,v 1.22 2000-07-16 10:23:40+09 tadf Exp $
# date2.rb: Written by Tadayoshi Funaba 1998-2001
# $Id: date2.rb,v 1.23 2001-01-18 12:09:47+09 tadf Exp $
class Date
@ -128,16 +128,15 @@ class Date
end
if d < 0
ny, nm = clfloor(y * 12 + m, 12)
nm, = clfloor(m + 1, 1)
la = nil
31.downto 1 do |z|
break if la = exist3?(y, m, z, sg)
end
ns = ns?(la, sg)
d = jd_to_civil(civil_to_jd(ny, nm, 1, ns) + d, ns)[-1]
nm, = clfloor(nm + 1, 1)
jd = civil_to_jd(ny, nm, d + 1, sg)
ns = ns?(jd, sg)
return unless [y, m] == jd_to_civil(jd, sg)[0..1]
return unless [ny, nm, 1] == jd_to_civil(jd - d, ns)
else
jd = civil_to_jd(y, m, d, sg)
return unless [y, m, d] == jd_to_civil(jd, sg)
end
jd = civil_to_jd(y, m, d, sg)
return unless [y, m, d] == jd_to_civil(jd, sg)
jd
end
@ -154,16 +153,15 @@ class Date
def exist2? (y, d, sg=ITALY)
if d < 0
ny = y + 1
la = nil
366.downto 1 do |z|
break if la = exist2?(y, z, sg)
end
ns = ns?(la, sg)
d = jd_to_ordinal(ordinal_to_jd(ny, 1, ns) + d, ns)[-1]
ny, = clfloor(y + 1, 1)
jd = ordinal_to_jd(ny, d + 1, sg)
ns = ns?(jd, sg)
return unless [y] == jd_to_ordinal(jd, sg)[0..0]
return unless [ny, 1] == jd_to_ordinal(jd - d, ns)
else
jd = ordinal_to_jd(y, d, sg)
return unless [y, d] == jd_to_ordinal(jd, sg)
end
jd = ordinal_to_jd(y, d, sg)
return unless [y, d] == jd_to_ordinal(jd, sg)
jd
end

View file

@ -1,5 +1,5 @@
# parsedate.rb: Written by Tadayoshi Funaba 2000
# $Id: parsedate.rb,v 1.2 2000-04-01 12:16:56+09 tadf Exp $
# parsedate3.rb: Written by Tadayoshi Funaba 2000, 2001
# $Id: parsedate3.rb,v 1.3 2001-01-18 12:09:47+09 tadf Exp $
module ParseDate
@ -46,7 +46,12 @@ module ParseDate
hour = $1.to_i
min = $2.to_i
sec = $3.to_i if $3
hour += 12 if $4 and $4.downcase == 'p'
if $4
hour %= 12
if $4.downcase == 'p'
hour += 12
end
end
zone = $5
end

View file

@ -537,12 +537,12 @@ rb_mod_clone(module)
}
static VALUE
rb_mod_dup(module)
VALUE module;
rb_mod_dup(mod)
VALUE mod;
{
VALUE dup = rb_mod_clone(module);
OBJSETUP(dup, RBASIC(module)->klass, BUILTIN_TYPE(module));
if (FL_TEST(module, FL_SINGLETON)) {
VALUE dup = rb_mod_clone(mod);
OBJSETUP(dup, RBASIC(mod)->klass, BUILTIN_TYPE(mod));
if (FL_TEST(mod, FL_SINGLETON)) {
FL_SET(dup, FL_SINGLETON);
}
return dup;

150
parse.y
View file

@ -49,7 +49,6 @@ static int yyerror();
static enum lex_state {
EXPR_BEG, /* ignore newline, +/- is a sign. */
EXPR_END, /* newline significant, +/- is a operator. */
EXPR_PAREN, /* almost like EXPR_END, `do' works as `{'. */
EXPR_ARG, /* newline significant, +/- is a operator. */
EXPR_MID, /* newline significant, +/- is a operator. */
EXPR_FNAME, /* ignore newline, no reserved words. */
@ -67,7 +66,7 @@ static unsigned long cond_stack = 0;
cond_nest--;\
cond_stack >>= 1;\
} while (0)
#define IN_COND (cond_nest > 0 && (cond_stack&1))
#define COND_P() (cond_nest > 0 && (cond_stack&1))
static int class_nest = 0;
static int in_single = 0;
@ -184,11 +183,11 @@ static void top_local_setup();
%type <node> singleton string
%type <val> literal numeric
%type <node> compstmt stmts stmt expr arg primary command_call method_call
%type <node> compstmt stmts stmt expr arg primary command command_call method_call
%type <node> if_tail opt_else case_body cases rescue exc_list exc_var ensure
%type <node> opt_call_args call_args ret_args args when_args
%type <node> aref_args opt_block_arg block_arg stmt_rhs
%type <node> mrhs mrhs_basic superclass generic_call block_call var_ref
%type <node> args ret_args when_args call_args paren_args opt_paren_args
%type <node> aref_args opt_block_arg block_arg var_ref
%type <node> mrhs mrhs_basic superclass generic_call block_call call_block
%type <node> f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg
%type <node> assoc_list assocs assoc undef_list backref
%type <node> block_var opt_block_var brace_block do_block lhs none
@ -295,8 +294,7 @@ stmts : none
$$ = $2;
}
stmt : block_call
| kALIAS fitem {lex_state = EXPR_FNAME;} fitem
stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
{
if (cur_mid || in_single)
yyerror("alias within method");
@ -396,12 +394,12 @@ stmt : block_call
$$ = NEW_ITER(0, NEW_POSTEXE(), $3);
}
| lhs '=' stmt_rhs
| lhs '=' command_call
{
value_expr($3);
$$ = node_assign($1, $3);
}
| mlhs '=' stmt_rhs
| mlhs '=' command_call
{
value_expr($3);
$1->nd_value = $3;
@ -445,7 +443,22 @@ expr : mlhs '=' mrhs
}
| arg
command_call : operation call_args
command_call : command
| block_call
block_call : call_block
| call_block '.' operation2 call_args
{
value_expr($1);
$$ = new_call($1, $3, $4);
}
| call_block tCOLON2 operation2 call_args
{
value_expr($1);
$$ = new_call($1, $3, $4);
}
command : operation call_args
{
$$ = new_fcall($1, $2);
fixpos($$, $2);
@ -897,14 +910,6 @@ aref_args : none
{
$$ = list_append($1, $3);
}
| block_call opt_nl
{
$$ = NEW_LIST($1);
}
| args ',' block_call opt_nl
{
$$ = list_append($1, $3);
}
| args trailer
{
$$ = $1;
@ -924,22 +929,31 @@ aref_args : none
$$ = NEW_RESTARGS($2);
}
opt_call_args : none
| call_args opt_nl
| block_call opt_nl
paren_args : '(' none ')'
{
$$ = NEW_LIST($1);
$$ = $2;
}
| args ',' block_call
| '(' call_args opt_nl ')'
{
$$ = list_append($1, $3);
$$ = $2;
}
| '(' block_call opt_nl ')'
{
$$ = NEW_LIST($2);
}
| '(' args ',' block_call opt_nl ')'
{
$$ = list_append($2, $4);
}
call_args : command_call
opt_paren_args : none
| paren_args
call_args : command
{
$$ = NEW_LIST($1);
}
| args ',' command_call
| args ',' command
{
$$ = list_append($1, $3);
}
@ -953,10 +967,6 @@ call_args : command_call
$$ = arg_concat($1, $4);
$$ = arg_blk_pass($$, $5);
}
| assocs ','
{
$$ = NEW_LIST(NEW_HASH($1));
}
| assocs opt_block_arg
{
$$ = NEW_LIST(NEW_HASH($1));
@ -973,10 +983,6 @@ call_args : command_call
$$ = list_append($1, NEW_HASH($3));
$$ = arg_blk_pass($$, $4);
}
| args ',' assocs ','
{
$$ = list_append($1, NEW_HASH($3));
}
| args ',' assocs ',' tSTAR arg opt_block_arg
{
value_expr($6);
@ -1341,7 +1347,7 @@ then : term
| term kTHEN
do : term
| kDO
| kDO2
if_tail : opt_else
| kELSIF expr then
@ -1401,19 +1407,6 @@ brace_block : '{'
fixpos($$, $4);
dyna_pop($<vars>2);
}
| kDO2
{
$<vars>$ = dyna_push();
}
opt_block_var
compstmt
kEND
{
$$ = NEW_ITER($3, 0, $4);
fixpos($$, $4);
dyna_pop($<vars>2);
}
generic_call : tIDENTIFIER
{
@ -1430,7 +1423,8 @@ generic_call : tIDENTIFIER
| method_call
| command_call
block_call : generic_call do_block
call_block : generic_call do_block
{
if ($1 && nd_type($1) == NODE_BLOCK_PASS) {
rb_compile_error("both block arg and actual block given");
@ -1439,28 +1433,32 @@ block_call : generic_call do_block
$$ = $2;
fixpos($$, $2);
}
| call_block '.' operation2 opt_paren_args
{
value_expr($1);
$$ = new_call($1, $3, $4);
}
| call_block tCOLON2 operation2 opt_paren_args
{
value_expr($1);
$$ = new_call($1, $3, $4);
}
method_call : operation '(' opt_call_args close_paren
method_call : operation paren_args
{
$$ = new_fcall($1, $3);
fixpos($$, $3);
$$ = new_fcall($1, $2);
fixpos($$, $2);
}
| primary '.' operation2 '(' opt_call_args close_paren
| primary '.' operation2 opt_paren_args
{
value_expr($1);
$$ = new_call($1, $3, $5);
$$ = new_call($1, $3, $4);
fixpos($$, $1);
}
| primary '.' operation2
| primary tCOLON2 operation2 paren_args
{
value_expr($1);
$$ = new_call($1, $3, 0);
fixpos($$, $1);
}
| primary tCOLON2 operation2 '(' opt_call_args close_paren
{
value_expr($1);
$$ = new_call($1, $3, $5);
$$ = new_call($1, $3, $4);
fixpos($$, $1);
}
| primary tCOLON2 operation3
@ -1468,12 +1466,12 @@ method_call : operation '(' opt_call_args close_paren
value_expr($1);
$$ = new_call($1, $3, 0);
}
| kSUPER '(' opt_call_args close_paren
| kSUPER paren_args
{
if (!compile_for_eval && !cur_mid &&
!in_single && !in_defined)
yyerror("super called outside of method");
$$ = new_super($3);
$$ = new_super($2);
}
| kSUPER
{
@ -1483,14 +1481,6 @@ method_call : operation '(' opt_call_args close_paren
$$ = NEW_ZSUPER();
}
close_paren : ')'
{
if (!IN_COND) lex_state = EXPR_PAREN;
}
stmt_rhs : block_call
| command_call
case_body : kWHEN when_args then
compstmt
cases
@ -2794,7 +2784,7 @@ arg_ambiguous()
rb_warning("ambiguous first argument; make sure");
}
#ifndef strtod
#if !defined(strtod) && !defined(HAVE_STDLIB_H)
double strtod ();
#endif
@ -2919,8 +2909,7 @@ yylex()
case '<':
c = nextc();
if (c == '<' &&
lex_state != EXPR_END && lex_state != EXPR_PAREN &&
lex_state != EXPR_CLASS &&
lex_state != EXPR_END && lex_state != EXPR_CLASS &&
(lex_state != EXPR_ARG || space_seen)) {
int c2 = nextc();
int indent = 0;
@ -2979,7 +2968,7 @@ yylex()
return parse_qstring(c,0);
case '?':
if (lex_state == EXPR_END || lex_state == EXPR_PAREN) {
if (lex_state == EXPR_END) {
lex_state = EXPR_BEG;
return '?';
}
@ -3306,7 +3295,7 @@ yylex()
return tCOLON2;
}
pushback(c);
if (lex_state == EXPR_END || lex_state == EXPR_PAREN || ISSPACE(c)) {
if (lex_state == EXPR_END || ISSPACE(c)) {
lex_state = EXPR_BEG;
return ':';
}
@ -3391,7 +3380,6 @@ yylex()
case '{':
if (lex_state != EXPR_END &&
lex_state != EXPR_PAREN &&
lex_state != EXPR_ARG)
c = tLBRACE;
lex_state = EXPR_BEG;
@ -3616,9 +3604,7 @@ yylex()
if (state == EXPR_FNAME) {
yylval.id = rb_intern(kw->name);
}
if (kw->id[0] == kDO &&
(state == EXPR_PAREN ||
(!IN_COND && state == EXPR_ARG))) {
if (kw->id[0] == kDO && COND_P()) {
return kDO2;
}
return kw->id[state != EXPR_BEG];