Skip to content

Commit

Permalink
2000-03-23
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Mar 23, 2000
1 parent b54db85 commit e68f544
Show file tree
Hide file tree
Showing 17 changed files with 988 additions and 307 deletions.
52 changes: 51 additions & 1 deletion ChangeLog
@@ -1,3 +1,53 @@
Thu Mar 23 02:26:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>

* io.c (rb_io_fptr_finalize): fptr may be null.

* io.c (rb_io_s_new): now calls `initialize'.

* io.c (rb_io_initialize): actual open done in this method.

* io.c (rb_file_initialize): ditto.

* eval.c (rb_eval): class variables in singleton class definition
is now handled properly (I hope).

Wed Mar 22 21:49:36 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>

* st.c (st_delete_safe): skip already deleted entry.

* hash.c (rb_hash_delete): modify brace miss.

Wed Mar 22 08:53:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>

* eval.c (exec_under): do not push cbase if ruby_cbase == under.

* node.h (NEW_CREF0): preserve cbase nesting.

Tue Mar 21 12:57:50 2000 Yukihiro Matsumoto <matz@netlab.co.jp>

* object.c (rb_class_s_new): Class::new should call `inherited'.

Sat Mar 18 12:36:09 2000 Nobuyoshi Nakada <nobu.nokada@softhome.net>

* eval.c (rb_backtrace, make_backtrace): removed unsed variable
`lev'.

* eval.c (rb_attr): calls `method_added' at attribute definition.

* eval.c (rb_mod_modfunc): calls `singleton_method_added' while
`module_function'.

* eval.c (rb_eval): parameter to `method_added' and
`singleton_method_added' is Symbol.

* eval.c (Init_eval): caches IDs for `method_added' and
`singleton_method_added'.

Sat Mar 18 11:25:10 2000 Yukihiro Matsumoto <matz@netlab.co.jp>

* parse.y (rescue): allows `rescue Error in foo'. experimental.
which is better this or preparing alias `exception' for `$!'.

Fri Mar 17 15:02:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>

* variable.c (rb_autoload_id): defining new autoload should be
Expand Down Expand Up @@ -110,7 +160,7 @@ Tue Mar 7 01:44:27 2000 Yukihiro Matsumoto <matz@netlab.co.jp>

* io.c (set_outfile): ditto.

* re.c (Init_Regexp): new method Regexp#last_match added; it's a
* re.c (Init_Regexp): new method Regexp#last_match added; it's an
alternative for $~.

* configure.in (DEFAULT_KCODE): KCODE_NONE should be the default.
Expand Down
14 changes: 8 additions & 6 deletions ToDo
Expand Up @@ -5,7 +5,8 @@ Language Spec.
- rescue modifier; a rescue b => begin a rescue; b end
- %w(a\ b\ c abc) => ["a b c", "abc"]
- objectify symbols
- class variable (prefix @@) - still need work for singletons
- class variable (prefix @@)
- rescue RuntimeError in err ??
* operator !! for rescue. ???
* objectify characters
* ../... outside condition invokes operator method too.
Expand All @@ -21,6 +22,8 @@ Language Spec.
* I18N (or M17N) script/string/regexp
* Fixnum 0 as false ????
* discourage use of symbol variable (e.g. $/, etc.) in manual
* discourage use of Perlish features by giving warnings.
* `exception' method to be alternative for `$!'. ??

Hacking Interpreter

Expand All @@ -31,7 +34,7 @@ Hacking Interpreter
- remove end_proc registered out of require only
- all object made freezable
* non-blocking open (e.g. for named pipe) for thread
* avoid blocking with gethostbyname/gethostbyaddr
* avoid blocking with gethostbyname/gethostbyaddr (use fork ???)
* objectify interpreters
* remove rb_eval() recursions
* syntax tree -> bytecode ???
Expand All @@ -40,7 +43,7 @@ Hacking Interpreter

Standard Libraries

- hash[key] = nil may not remove entry; hashes may have nil as the value.
- hash[key] = nil does not remove entry; hashes may have nil as the value.
- hash.fetch(key) raises exception if key is not found.
- Array#{first,last,at}
- Dir.glob(pat){|f|...}
Expand All @@ -53,13 +56,13 @@ Standard Libraries
- debugger for thread programming
- SyntaxError, NameError, LoadError and NotImplementError are subclasses of
ScriptError<Exception, not StandardError.
- String's bang methods return string always
- Thread::start gives arguments, not a thread object to the block
- regexp: (?>..), \G
- Struct::new([name,]member,...)
- IO#reopen accepts path as well
- Kernel#scan
- call initialize for builtin class too (not yet: Regexp, IO, etc)
- call initialize for builtin class too (not yet: Regexp, etc)
- performance tune for String's non-bang methods.
* String#scanf(?)
* Object#fmt(?)
* Integer#{bin,oct,hex,heX}
Expand All @@ -69,7 +72,6 @@ Standard Libraries
* Stream or Port, abstract superclass of IO ?
* String#{pred,prev}, String#downto
* optional stepsize argument for succ()
* performance tune for String's non-bang methods.
* Ruby module -- Ruby::Version, Ruby::Interpreter

Extension Libraries
Expand Down
83 changes: 41 additions & 42 deletions eval.c
Expand Up @@ -420,6 +420,8 @@ rb_method_boundp(klass, id, ex)
return Qfalse;
}

static ID init, eqq, each, aref, aset, match, missing, added, singleton_added;

void
rb_attr(klass, id, read, write, ex)
VALUE klass;
Expand Down Expand Up @@ -454,15 +456,16 @@ rb_attr(klass, id, read, write, ex)
attriv = rb_intern(buf);
if (read) {
rb_add_method(klass, id, NEW_IVAR(attriv), noex);
rb_funcall(klass, added, 1, ID2SYM(id));
}
sprintf(buf, "%s=", name);
id = rb_intern(buf);
if (write) {
rb_add_method(klass, id, NEW_ATTRSET(attriv), noex);
rb_funcall(klass, added, 1, ID2SYM(id));
}
}

static ID init, eqq, each, aref, aset, match, missing;
VALUE ruby_errinfo = Qnil;
extern NODE *ruby_eval_tree_begin;
extern NODE *ruby_eval_tree;
Expand Down Expand Up @@ -1294,7 +1297,7 @@ superclass(self, node)
case NODE_COLON2:
rb_raise(rb_eTypeError, "undefined superclass `%s'",
rb_id2name(node->nd_mid));
case NODE_CVAR:
case NODE_CONST:
rb_raise(rb_eTypeError, "undefined superclass `%s'",
rb_id2name(node->nd_vid));
default:
Expand All @@ -1310,7 +1313,7 @@ superclass(self, node)
return val;
}

#define ruby_cbase (((NODE*)ruby_frame->cbase)->nd_clss)
#define ruby_cbase (RNODE(ruby_frame->cbase)->nd_clss)

static VALUE
ev_const_defined(cref, id)
Expand Down Expand Up @@ -1375,7 +1378,7 @@ ev_const_set(cref, id, val)
static VALUE
rb_mod_nesting()
{
NODE *cbase = (NODE*)ruby_frame->cbase;
NODE *cbase = RNODE(ruby_frame->cbase);
VALUE ary = rb_ary_new();

while (cbase && cbase->nd_clss != rb_cObject) {
Expand All @@ -1388,7 +1391,7 @@ rb_mod_nesting()
static VALUE
rb_mod_s_constants()
{
NODE *cbase = (NODE*)ruby_frame->cbase;
NODE *cbase = RNODE(ruby_frame->cbase);
VALUE ary = rb_ary_new();

while (cbase && cbase->nd_clss != rb_cObject) {
Expand Down Expand Up @@ -1682,8 +1685,8 @@ is_defined(self, node, buf)
}
break;

case NODE_CVAR:
if (ev_const_defined((NODE*)ruby_frame->cbase, node->nd_vid)) {
case NODE_CONST:
if (ev_const_defined(RNODE(ruby_frame->cbase), node->nd_vid)) {
return "constant";
}
break;
Expand Down Expand Up @@ -2494,11 +2497,11 @@ rb_eval(self, node)
break;

case NODE_CASGN:
if (NIL_P(ruby_class)) {
if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no class/module to define constant");
}
result = rb_eval(self, node->nd_value);
ev_const_set((NODE*)ruby_frame->cbase, node->nd_vid, result);
ev_const_set(RNODE(ruby_frame->cbase), node->nd_vid, result);
break;

case NODE_CDECL:
Expand All @@ -2509,20 +2512,20 @@ rb_eval(self, node)
rb_const_set(ruby_class, node->nd_vid, result);
break;

case NODE_SHASGN:
if (NIL_P(ruby_class)) {
rb_raise(rb_eTypeError, "no class/module to define shared variable");
case NODE_CVASGN:
if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no class/module to define class variable");
}
result = rb_eval(self, node->nd_value);
rb_shared_variable_set(ruby_cbase, node->nd_vid, result);
rb_cvar_set(ruby_cbase, node->nd_vid, result);
break;

case NODE_SHDECL:
if (NIL_P(ruby_class)) {
rb_raise(rb_eTypeError, "no class/module to define shared variable");
case NODE_CVDECL:
if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no class/module to define class variable");
}
result = rb_eval(self, node->nd_value);
rb_shared_variable_declare(ruby_class, node->nd_vid, result);
rb_cvar_declare(ruby_cbase, node->nd_vid, result);
break;

case NODE_LVAR:
Expand All @@ -2544,12 +2547,12 @@ rb_eval(self, node)
result = rb_ivar_get(self, node->nd_vid);
break;

case NODE_CVAR:
result = ev_const_get((NODE*)ruby_frame->cbase, node->nd_vid);
case NODE_CONST:
result = ev_const_get(RNODE(ruby_frame->cbase), node->nd_vid);
break;

case NODE_SHVAR:
result = rb_shared_variable_get(ruby_cbase, node->nd_vid);
case NODE_CVAR:
result = rb_cvar_get(ruby_cbase, node->nd_vid);
break;

case NODE_BLOCK_ARG:
Expand Down Expand Up @@ -2760,17 +2763,14 @@ rb_eval(self, node)
if (scope_vmode == SCOPE_MODFUNC) {
rb_add_method(rb_singleton_class(ruby_class),
node->nd_mid, node->nd_defn, NOEX_PUBLIC);
rb_funcall(ruby_class, rb_intern("singleton_method_added"),
1, INT2FIX(node->nd_mid));
rb_funcall(ruby_class, singleton_added, 1, ID2SYM(node->nd_mid));
}
if (FL_TEST(ruby_class, FL_SINGLETON)) {
rb_funcall(rb_iv_get(ruby_class, "__attached__"),
rb_intern("singleton_method_added"),
1, INT2FIX(node->nd_mid));
singleton_added, 1, ID2SYM(node->nd_mid));
}
else {
rb_funcall(ruby_class, rb_intern("method_added"),
1, INT2FIX(node->nd_mid));
rb_funcall(ruby_class, added, 1, ID2SYM(node->nd_mid));
}
result = Qnil;
}
Expand Down Expand Up @@ -2805,8 +2805,7 @@ rb_eval(self, node)
rb_clear_cache_by_id(node->nd_mid);
rb_add_method(klass, node->nd_mid, node->nd_defn,
NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
rb_funcall(recv, rb_intern("singleton_method_added"),
1, INT2FIX(node->nd_mid));
rb_funcall(recv, singleton_added, 1, ID2SYM(node->nd_mid));
result = Qnil;
}
break;
Expand All @@ -2824,8 +2823,7 @@ rb_eval(self, node)
rb_raise(rb_eTypeError, "no class to make alias");
}
rb_alias(ruby_class, node->nd_new, node->nd_old);
rb_funcall(ruby_class, rb_intern("method_added"),
1, INT2FIX(node->nd_mid));
rb_funcall(ruby_class, added, 1, ID2SYM(node->nd_mid));
result = Qnil;
break;

Expand Down Expand Up @@ -3507,16 +3505,16 @@ assign(self, lhs, val, check)
break;

case NODE_CASGN:
ev_const_set((NODE*)ruby_frame->cbase, lhs->nd_vid, val);
ev_const_set(RNODE(ruby_frame->cbase), lhs->nd_vid, val);
break;

case NODE_CDECL:
rb_const_set(ruby_class, lhs->nd_vid, val);
break;

case NODE_SHDECL:
case NODE_SHASGN:
rb_shared_variable_set(ruby_cbase, lhs->nd_vid, val);
case NODE_CVDECL:
case NODE_CVASGN:
rb_cvar_set(ruby_cbase, lhs->nd_vid, val);
break;

case NODE_MASGN:
Expand Down Expand Up @@ -4397,10 +4395,9 @@ rb_f_caller(argc, argv)
void
rb_backtrace()
{
int i, lev;
int i;
VALUE ary;

lev = INT2FIX(0);
ary = backtrace(-1);
for (i=0; i<RARRAY(ary)->len; i++) {
printf("\tfrom %s\n", RSTRING(RARRAY(ary)->ptr[i])->ptr);
Expand All @@ -4410,9 +4407,6 @@ rb_backtrace()
static VALUE
make_backtrace()
{
VALUE lev;

lev = INT2FIX(0);
return backtrace(-1);
}

Expand Down Expand Up @@ -4598,7 +4592,6 @@ exec_under(func, under, args)
VALUE val; /* OK */
int state;
int mode;
VALUE cbase = ruby_frame->cbase;

PUSH_CLASS();
ruby_class = under;
Expand All @@ -4607,7 +4600,10 @@ exec_under(func, under, args)
ruby_frame->last_class = _frame.prev->last_class;
ruby_frame->argc = _frame.prev->argc;
ruby_frame->argv = _frame.prev->argv;
ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,under,0,cbase);
if (ruby_cbase != under) {
ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,under,0,ruby_frame->cbase);
}

mode = scope_vmode;
SCOPE_SET(SCOPE_PUBLIC);
PUSH_TAG(PROT_NONE);
Expand Down Expand Up @@ -5129,6 +5125,7 @@ rb_mod_modfunc(argc, argv, module)
}
rb_clear_cache_by_id(id);
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
rb_funcall(module, singleton_added, 1, ID2SYM(id));
}
return module;
}
Expand Down Expand Up @@ -5398,6 +5395,8 @@ Init_eval()
aset = rb_intern("[]=");
match = rb_intern("=~");
missing = rb_intern("method_missing");
added = rb_intern("method_added");
singleton_added = rb_intern("singleton_method_added");

rb_global_variable((VALUE*)&top_scope);
rb_global_variable((VALUE*)&ruby_eval_tree_begin);
Expand Down
9 changes: 5 additions & 4 deletions hash.c
Expand Up @@ -411,10 +411,11 @@ rb_hash_delete(hash, key)
VALUE val;

rb_hash_modify(hash);
if (RHASH(hash)->iter_lev > 0 &&
st_delete_safe(RHASH(hash)->tbl, &key, &val, Qundef)) {
FL_SET(hash, HASH_DELETED);
return val;
if (RHASH(hash)->iter_lev > 0) {
if (st_delete_safe(RHASH(hash)->tbl, &key, &val, Qundef)) {
FL_SET(hash, HASH_DELETED);
return val;
}
}
else if (st_delete(RHASH(hash)->tbl, &key, &val))
return val;
Expand Down

0 comments on commit e68f544

Please sign in to comment.