Skip to content

Commit

Permalink
* enum.c (enum_inject): new method.
Browse files Browse the repository at this point in the history
* gc.c (rb_gc_call_finalizer_at_exit): clear klass member of
  terminating object.

* eval.c (rb_call): raise exception for terminated object.

* bignum.c (bigdivrem): t2 might be too big for signed long; do
  not use rb_int2big(), but rb_uint2big().

* error.c (rb_load_fail): new func to report LoadError.

* ruby.c (load_file): use rb_load_fail.

* eval.c (ruby_finalize): should enclosed by PUSH_TAG/POP_TAG.

* gc.c (rb_gc_mark): link 2 of NODE_IFUNC should not be explicitly
  marked.  it may contain non object pointer.

* re.c (reg_s_last_match): Regexp::last_match(nth) returns nth
  substring of the match  (alternative for $& and $<digit>).

* eval.c (rb_mod_define_method): wrong comparison for blocks.

* gc.c (id2ref): should handle Symbol too.

* gc.c (id2ref): should print original ptr value

* eval.c (rb_iterate): NODE_CFUNC does not protect its data
  (nd_tval), so create new node NODE_IFUNC for iteration C
  function.

* eval.c (rb_yield_0): use NODE_IFUNC.

* gc.c (rb_gc_mark): support NODE_IFUNC.

* gc.c (mem_error): prohibit recursive mem_error().
  (ruby-bugs-ja:PR#36)

* eval.c (rb_thread_fd_writable): should not switch context if
  rb_thread_critical is set.

* eval.c (rb_thread_wait_fd): ditto.

* eval.c (rb_thread_wait_for): ditto.

* eval.c (rb_thread_select): ditto.

* eval.c (rb_thread_join): join during critical section causes
  deadlock.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Jan 9, 2001
1 parent 3971148 commit 87beea4
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 87 deletions.
44 changes: 44 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
Tue Jan 9 16:22:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* enum.c (enum_inject): new method.

Tue Jan 9 02:16:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* gc.c (rb_gc_call_finalizer_at_exit): clear klass member of
terminating object.

* eval.c (rb_call): raise exception for terminated object.

Mon Jan 8 21:24:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* bignum.c (bigdivrem): t2 might be too big for signed long; do
not use rb_int2big(), but rb_uint2big().

Mon Jan 8 03:09:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* error.c (rb_load_fail): new func to report LoadError.

* ruby.c (load_file): use rb_load_fail.

Sat Jan 6 00:17:18 2001 WATANABE Hirofumi <eban@ruby-lang.org>

* pack.c (pack_pack): avoid infinite loop(pack 'm2').

Fri Jan 5 01:02:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (ruby_finalize): should enclosed by PUSH_TAG/POP_TAG.

* gc.c (rb_gc_mark): link 2 of NODE_IFUNC should not be explicitly
marked. it may contain non object pointer.

Tue Jan 2 00:20:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* re.c (reg_s_last_match): Regexp::last_match(nth) returns nth
substring of the match (alternative for $& and $<digit>).

Sun Dec 31 01:39:16 2000 Guy Decoux <decoux@moulon.inra.fr>

* eval.c (rb_mod_define_method): wrong comparison for blocks.

Sat Dec 30 19:28:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* gc.c (id2ref): should handle Symbol too.

* gc.c (id2ref): should print original ptr value

Sat Dec 30 03:14:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_iterate): NODE_CFUNC does not protect its data
Expand Down
7 changes: 4 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ clean:; @rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES) $(MAINOBJ)
@-@MINIRUBY@ -Cext extmk.rb clean 2> /dev/null || true
@rm -f $(PROGRAM) miniruby$(EXEEXT)

distclean: clean
distclean:; @-@MINIRUBY@ -Cext extmk.rb distclean 2> /dev/null || true
$(MAKE) clean
@rm -f Makefile ext/extmk.rb config.h
@rm -f ext/config.cache config.cache config.log config.status
@rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp

realclean: distclean
realclean: distclean
@rm -f parse.c
@rm -f lex.c

Expand All @@ -142,7 +143,7 @@ fake.rb: miniruby$(EXEEXT)
config.status: $(srcdir)/configure
$(SHELL) ./config.status --recheck

$(srcdir)/configure: $(srcdir)/configure.in
$(srcdir)/configure: $(srcdir)/configure.in
cd $(srcdir) && $(AUTOCONF)

.c.@OBJEXT@:
Expand Down
52 changes: 7 additions & 45 deletions ToDo
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
Language Spec.

- def foo; .. rescue .. end
- compile time string concatenation, "hello" "world" => "helloworld"
- rescue modifier; a rescue b => begin a rescue; b end
- %w(a\ b\ c abc) => ["a b c", "abc"]
- objectify symbols
- class variable (prefix @@)
- rescue RuntimeError => err
* operator !! for rescue. ???
* objectify characters
* ../... outside condition invokes operator method too.
Expand All @@ -31,15 +24,11 @@ Language Spec.
* a +1 to be a+1, not a(+1).
* unify == and eql? again
* to_i returns nil if str contains no digit.
* raise exception by ``

Hacking Interpreter

- use eban's fnmatch
- RUBYOPT environment variable
- alias $defout $>
- retrieve STACK_LEVEL_MAX from users' limit.
- remove end_proc registered out of require only
- all object made freezable
- generational GC
* non-blocking open (e.g. for named pipe) for thread
* avoid blocking with gethostbyname/gethostbyaddr (use fork ???)
* objectify interpreters ???
Expand All @@ -48,41 +37,16 @@ Hacking Interpreter
* scrambled script, or script filter
* setuid ruby
* performance tune for in-block (dynamic) local variables.
* generational GC
* give warnings to assign magic variables.
* export rb_io_{addstr,printf,puts,print}
* autoload should work with threads [ruby-talk:4589]
* remove stdio dependency from IOs.
* warn for inconsistent local variable usage (lv m and method m at the same time).
* MicroRuby

Standard Libraries

- 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|...}
- sprintf/printf's $ to specify argument order
- Dir.glob("**/*.c") ala zsh
- Remove Enumerable#{size,length}
- Array#slice, Array#slice!
- String#slice, String#slice!
- Marshal should handle generic instance variables.
- debugger for thread programming
- SyntaxError, NameError, LoadError and NotImplementedError are subclasses of
ScriptError<Exception, not StandardError.
- 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 classes too
- performance tune for String's non-bang methods.
- 'w' template for pack/unpack
- alternative for interator? => block_given?
- regex - /p (made obsolete), /m (new)
- consistent /, %, divmod
- unbound method object
- integrate final.rb into the core.
- Module#define_method which takes a name and a body (block, proc or method).
* Enumerable#sort_by for Schwartzian transformation
* String#scanf(?)
* Object#fmt(?)
Expand All @@ -98,31 +62,29 @@ Standard Libraries
* Process::waitall [ruby-talk:4557]
* synchronized method - synchronized{...}, synchronized :foo, :bar
* move Time::times to Process.
- Module#define_method which takes a name and a body (block, proc or method).
* IO#for_fd in general
* Array#&, Array#| to allow duplication. ???
- fork_and_kill_other_threads.
* fork_and_kill_other_threads.
* way to specify immortal (fork endurance) thread;
* or raise ForkException to every thread but fork caller.
* Array#fetch
* Hash::new{default} or recommend Hash#fetch?
* Enume#inject

Extension Libraries

- FastCGI ruby
* ptk.rb pTk wrapper that is compatible to tk.rb
* Berkeley DB extension
* BitVector

Ruby Libraries

- net/http.rb
* add uri.rb
* urllib.rb, nttplib.rb, etc.
* format like perl's

Tools

- extension library maker using SWIG
* freeze or undump to bundle everything

Misc
Expand Down
6 changes: 4 additions & 2 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,10 @@ bigdivrem(x, y, divp, modp)
t2 %= dd;
}
RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
if (!RBIGNUM(x)->sign) t2 = -(long)t2;
if (modp) *modp = rb_int2big((long)t2);
if (modp) {
*modp = rb_uint2big((unsigned long)t2);
RBIGNUM(*modp)->sign = RBIGNUM(x)->sign;
}
if (divp) *divp = z;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions dln.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ dln_strerror()
}


#if defined(_AIX)
#if defined(_AIX) && ! defined(_IA64)
static void
aix_loaderror(const char *pathname)
{
Expand Down Expand Up @@ -1310,7 +1310,7 @@ dln_load(file)
}
#endif /* hpux */

#if defined(_AIX)
#if defined(_AIX) && ! defined(_IA64)
#define DLN_DEFINED
{
void (*init_fct)();
Expand Down
19 changes: 19 additions & 0 deletions enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,24 @@ enum_collect(obj)
return tmp;
}

static VALUE
inject_i(i, np)
VALUE i;
VALUE *np;
{
*np = rb_yield(rb_assoc_new(*np, i));
return Qnil;
}

static VALUE
enum_inject(obj, n)
VALUE obj, n;
{
rb_iterate(rb_each, obj, inject_i, (VALUE)&n);

return n;
}

static VALUE
enum_sort(obj)
VALUE obj;
Expand Down Expand Up @@ -339,6 +357,7 @@ Init_Enumerable()
rb_define_method(rb_mEnumerable,"reject", enum_reject, 0);
rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
rb_define_method(rb_mEnumerable,"map", enum_collect, 0);
rb_define_method(rb_mEnumerable,"inject", enum_inject, 1);
rb_define_method(rb_mEnumerable,"min", enum_min, 0);
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
Expand Down
9 changes: 7 additions & 2 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,6 @@ Init_Exception()
rb_eNameError = rb_define_class("NameError", rb_eScriptError);
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
/* backward compatibility -- will be removed in the future */
rb_define_global_const("NotImplementError", rb_eNotImpError);

rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError);
Expand Down Expand Up @@ -694,6 +692,13 @@ rb_sys_fail(mesg)
rb_exc_raise(ee);
}

void
rb_load_failed(path)
char *path;
{
rb_loaderror("%s -- %s", strerror(errno), path);
}

void
rb_error_frozen(what)
char *what;
Expand Down
19 changes: 14 additions & 5 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,9 +1122,15 @@ void rb_exec_end_proc _((void));
void
ruby_finalize()
{
rb_trap_exit();
rb_exec_end_proc();
rb_gc_call_finalizer_at_exit();
int state;

PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
rb_trap_exit();
rb_exec_end_proc();
rb_gc_call_finalizer_at_exit();
}
POP_TAG();
}

void
Expand Down Expand Up @@ -3526,7 +3532,7 @@ rb_yield_0(val, self, klass, acheck)
if (!node) {
result = Qnil;
}
else if (nd_type(node) == NODE_IFUNC) {
else if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
if (val == Qundef) val = rb_ary_new2(0);
result = (*node->nd_cfnc)(val, node->nd_tval, self);
}
Expand Down Expand Up @@ -4417,6 +4423,9 @@ rb_call(klass, recv, mid, argc, argv, scope)
ID id = mid;
struct cache_entry *ent;

if (!klass) {
rb_raise(rb_eNotImpError, "method call on terminated obejct");
}
/* is it in the method cache? */
ent = cache + EXPR1(klass, mid);
if (ent->mid == mid && ent->klass == klass) {
Expand Down Expand Up @@ -6635,7 +6644,7 @@ rb_mod_define_method(argc, argv, mod)
if (RDATA(body)->dmark == (RUBY_DATA_FUNC)bm_mark) {
rb_add_method(mod, id, NEW_DMETHOD(method_unbind(body)), NOEX_PUBLIC);
}
else if (RDATA(body)->dmark != (RUBY_DATA_FUNC)blk_mark) {
else if (RDATA(body)->dmark == (RUBY_DATA_FUNC)blk_mark) {
rb_add_method(mod, id, NEW_BMETHOD(body), NOEX_PUBLIC);
}
else {
Expand Down
10 changes: 8 additions & 2 deletions ext/extmk.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ elsif ARGV[0] == 'install'
$destdir = ARGV[1] || ''
ARGV.shift
elsif ARGV[0] == 'clean'
$clean = true
$clean = "clean"
ARGV.shift
elsif ARGV[0] == 'distclean'
$clean = "distclean"
ARGV.shift
elsif ARGV[0] == 'realclean'
$clean = "realclean"
ARGV.shift
end

Expand Down Expand Up @@ -625,7 +631,7 @@ def extmake(target)
if $install
system "#{$make} install DESTDIR=#{$destdir}"
elsif $clean
system "#{$make} clean"
system "#{$make} #{$clean}"
else
unless system "#{$make} all"
if ENV["MAKEFLAGS"] != "k" and ENV["MFLAGS"] != "-k"
Expand Down
13 changes: 7 additions & 6 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ rb_gc_mark(ptr)
case NODE_OP_ASGN_AND:
rb_gc_mark(obj->as.node.u1.node);
/* fall through */
case NODE_IFUNC:
case NODE_METHOD: /* 2 */
case NODE_NOT:
case NODE_GASGN:
Expand Down Expand Up @@ -1232,7 +1231,8 @@ rb_gc_call_finalizer_at_exit()
p = heaps[i]; pend = p + HEAP_SLOTS;
while (p < pend) {
if (FL_TEST(p, FL_FINALIZE)) {
p->as.free.flag = 0;
FL_UNSET(p, FL_FINALIZE);
p->as.basic.klass = 0;
run_final((VALUE)p);
}
p++;
Expand Down Expand Up @@ -1260,21 +1260,22 @@ static VALUE
id2ref(obj, id)
VALUE obj, id;
{
unsigned long ptr;
unsigned long ptr, p0;

rb_secure(4);
ptr = NUM2UINT(id);
p0 = ptr = NUM2UINT(id);
if (FIXNUM_P(ptr)) return (VALUE)ptr;
if (SYMBOL_P(ptr)) return (VALUE)ptr;
if (ptr == Qtrue) return Qtrue;
if (ptr == Qfalse) return Qfalse;
if (ptr == Qnil) return Qnil;

ptr = id ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
if (!is_pointer_to_heap(ptr)) {
rb_raise(rb_eRangeError, "0x%x is not id value", ptr);
rb_raise(rb_eRangeError, "0x%x is not id value", p0);
}
if (BUILTIN_TYPE(ptr) == 0) {
rb_raise(rb_eRangeError, "0x%x is recycled object", ptr);
rb_raise(rb_eRangeError, "0x%x is recycled object", p0);
}
return (VALUE)ptr;
}
Expand Down
2 changes: 1 addition & 1 deletion intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ VALUE rb_exc_new3 _((VALUE, VALUE));
void rb_loaderror __((const char*, ...)) NORETURN;
void rb_compile_error __((const char*, ...));
void rb_compile_error_append __((const char*, ...));
void rb_error_frozen _((char*));
void rb_error_frozen _((char*)) NORETURN;
/* eval.c */
void rb_exc_raise _((VALUE)) NORETURN;
void rb_exc_fatal _((VALUE)) NORETURN;
Expand Down
Loading

0 comments on commit 87beea4

Please sign in to comment.