From 897cf066952978ccbae1d57bbc14a03c7b98a1e1 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Wed, 1 Feb 1995 19:48:24 +0900 Subject: version 0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.65.tar.gz Wed Feb 1 19:48:24 1995 Yukihiro Matsumoto (matz@ix-02) * string.c(str_replace): 置き換える文字列の長さが等しい時メモリコ ピーをしない. * string.c(rindex): バグ修正. Mon Jan 30 11:23:05 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y(value_expr): ifのチェックを追加. * gc.c(gc_mark): free cellの扱いにバグ. * parse.y: 文法の変更(よりシンプルに).例外を減らした. Thu Jan 26 00:52:55 1995 Yukihiro Matsumoto (matz@dyna) * parse.y: 引数として連想配列を置くことができるように.この場合, 連想配列リテラルが最終引数となる. * parse.y: 配列参照の`[]'内が空でもよいことにした. Tue Jan 24 14:45:15 1995 Yukihiro Matsumoto (matz@ix-02) * class.c(rb_include_module): `-v'を指定した時にはincludeしたモジュー ルとクラス定数が衝突していないかチェックする. Mon Jan 23 10:42:09 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y(rb_class2name): メタクラスに関するbug fix. * dict.c: Dict[..]で辞書の生成が出来るように. * array.c: Array[..]で配列の生成が出来るように. * parse.y: 辞書の表現として{a,b,..}という形式も許すように. Fri Jan 20 10:28:38 1995 Yukihiro Matsumoto (matz@ix-02) * re.c(Regexp.quote): 正規表現をエスケープするメソッド. * 無駄なrb_intern()を減らした. * parse.y: `!', `!=', `!~'を特殊演算子にする.よってこれらは再定義 できなくなった. Wed Jan 18 13:20:41 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y: 文法の整理(unless,untilをなくした). Tue Jan 17 11:11:27 1995 Yukihiro Matsumoto (matz@ix-02) * eval.c: defでメソッド再定義時にはスーパークラスのメソッドの可視 性を継承する.最初の定義の時は今までと同じデフォルト(トップレベ ルで関数的,クラス定義内で通常メソッド). * object.c(Class::new): オブジェクトの生成時に関数的メ ソッドinit_objectが必ず呼ばれるように変更. * eval.c: 未定義のメソッドに対してunknownメソッドが呼ばれるように なった.エラー表示が今までと同じになるようにenvを調節している. Fri Jan 13 14:40:30 1995 Yukihiro Matsumoto (matz@ix-02) * gc.c: gcを若干書き換えて整理した.が,あまり変化はなかったようだ. * parse.y(yylex): symbolを\symから:symに変更した. Thu Jan 12 01:39:28 1995 Yukihiro Matsumoto (matz@dyna) * eval.c: 新規関数 rb_eval_string(). * gc.c: gc_mark()を一部非再帰化. * variable.c(rb_ivar_{get,set}): インスタンス変数のアクセス周りで チェックが足りなかった. * variable.c: クラス定数とインスタンス変数でハッシュテーブルを共有 するようにした. * ruby.h: iv_tblをRBasicからRObjectとRClassへ移動した.これにより, ObjectとClass,Moduleしかインスタンス変数を持てなくなる.が,メモ リ効率は若干向上する. --- C-IF | 35 +- ChangeLog | 86 ++++ MANIFEST | 67 ++++ Makefile.in | 4 +- ToDo | 6 +- array.c | 37 +- bignum.c | 2 +- class.c | 35 +- cons.c | 4 +- dbm.c | 9 +- dict.c | 36 +- dir.c | 6 +- dln.c | 8 +- enum.c | 11 +- error.c | 10 +- eval.c | 257 +++++++----- file.c | 6 +- gc.c | 166 ++++---- getopt1.c | 2 +- io.c | 10 +- missing/MANIFEST | 10 + node.h | 6 +- numeric.c | 14 +- object.c | 63 ++- parse.y | 759 ++++++++++++++++++----------------- process.c | 2 +- range.c | 3 +- re.c | 37 +- ruby.c | 2 +- ruby.h | 28 +- sample/Artistic | 117 ++++++ sample/MANIFEST | 63 +++ sample/biorhythm.rb | 201 ++++++++++ sample/blk.rb | 8 +- sample/clone.rb | 2 +- sample/dir.rb | 2 +- sample/evaldef.rb | 2 +- sample/export.rb | 6 +- sample/exyacc.rb | 22 + sample/gctest2.rb | 71 ++++ sample/list.rb | 19 +- sample/list2.rb | 6 +- sample/list3.rb | 6 +- sample/rcs.awk | 33 ++ sample/rcs.dat | 17 + sample/rcs.rb | 49 +++ sample/sieve.rb | 3 +- sample/uumerge.rb | 6 +- signal.c | 11 +- socket.c | 23 +- spec | 1109 +++++++++++++++++++++++++++++++-------------------- sprintf.c | 2 +- st.c | 20 +- string.c | 10 +- struct.c | 2 +- time.c | 12 +- variable.c | 146 ++++--- version.c | 4 +- version.h | 4 +- 59 files changed, 2422 insertions(+), 1275 deletions(-) create mode 100644 MANIFEST create mode 100644 missing/MANIFEST create mode 100644 sample/Artistic create mode 100644 sample/MANIFEST create mode 100644 sample/biorhythm.rb create mode 100644 sample/exyacc.rb create mode 100644 sample/gctest2.rb create mode 100644 sample/rcs.awk create mode 100644 sample/rcs.dat create mode 100644 sample/rcs.rb diff --git a/C-IF b/C-IF index 05f6edb638..5c66a20ddc 100644 --- a/C-IF +++ b/C-IF @@ -24,9 +24,6 @@ Ruby-C ѹϰʸselfͤΤΤѤäƤޤΤ, ̤ʻ ʤ¤ƤϤʤʤ. - : إåե"env.h"򥤥󥯥롼ɤƤʤեǤ, - QselfǤ, ʸˡ顼Ȥʤ. - TRUE : t֥(Υǥե) @@ -43,7 +40,7 @@ Ruby-C VALUE rb_define_module(char *name) - Ruby⥸塼. + Ruby⥸塼. void rb_include_module(VALUE class, VALUE module) @@ -67,8 +64,8 @@ Ruby-C void rb_global_variable(VALUE *var) - GCΤRubyϥʤ, Ruby֥Ȥޤ - ޡ. + GCΤᡤRubyץफϥʤ, Ruby֥ + ޤѿޡ. void rb_read_only_hook() @@ -87,20 +84,21 @@ Ruby-C ᥽åɤ. argcselfο. argc-1λ, ؿ ϰο(selfޤޤʤ)1, 2Ȥ - Ϳ. argc-2λ, self, args(argsϰޤruby - )ȤͿ. + Ϳ(3self). argc-2λ, self, args(args + ޤruby)ȤͿ. rb_define_single_method(VALUE class, char *name, VALUE (*func)(), int argc) ðۥ᥽åɤ. rb_define_method()Ʊ. - rb_scan_args(VALUE args, char *fmt, ...) + rb_scan_args(int atgc, VALUE *argv, char *fmt, ...) - argsͿ줿ʬ򤹤. fmtɬܰο, ղðο, - Ĥΰ뤫ꤹʸ, "*"ȤǤ. - 2 ܤο"*"Ϥ줾άǽǤ. 3ʹߤѿؤΥ - 󥿤, Ǥѿ˳Ǽ. ղðб - ͿƤʤѿQnil. + argc,argvͿ줿ʬ򤹤. fmtɬܰο, ղð + ο, Ĥΰ뤫ꤹʸ, "*"Ȥ + Ǥ. 2 ܤο"*"Ϥ줾άǽǤ. ɬܰ + ʤ0ꤹ롥3ʹߤѿؤΥݥ󥿤, + Ǥѿ˳Ǽ. ղðбͿƤ + ѿQnil. Ruby᥽åɸƤӽФ @@ -108,12 +106,13 @@ Ruby ᥽åɸƤӽФ. ʸ󤫤mid뤿ˤrb_intern()Ȥ. - rb_call_super(VALUE args) + VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv) + + ᥽åɸƤӽФ. argc,argvϤ - ѡ饹Υ᥽åɤƤӽФ. argsϰꥹȤȤʤ. - args QnilλϸߤΥ᥽åɤΰ򤽤ΤޤްѤ. + VALUE rb_eval_string(char *str) -ʸ <-> IDѴ + ʸrubyȥץȤƥѥ롦¹Ԥ롥 ID rb_intern(char *name) diff --git a/ChangeLog b/ChangeLog index f6246f3a0d..35d02ea51e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,91 @@ +Wed Feb 1 19:48:24 1995 Yukihiro Matsumoto (matz@ix-02) + + * string.c(str_replace): ֤ʸĹꥳ + ԡ򤷤ʤ + + * string.c(rindex): Х + +Mon Jan 30 11:23:05 1995 Yukihiro Matsumoto (matz@ix-02) + + * parse.y(value_expr): ifΥåɲá + + * gc.c(gc_mark): free cellΰ˥Х + + * parse.y: ʸˡѹ(ꥷץ)㳰򸺤餷 + +Thu Jan 26 00:52:55 1995 Yukihiro Matsumoto (matz@dyna) + + * parse.y: ȤϢ֤ȤǤ褦ˡξ硤 + Ϣƥ뤬ǽȤʤ롥 + + * parse.y: 󻲾Ȥ`[]'⤬Ǥ褤Ȥˤ + +Tue Jan 24 14:45:15 1995 Yukihiro Matsumoto (matz@ix-02) + + * class.c(rb_include_module): `-v'ꤷˤinclude⥸塼 + ȥ饹ͤƤʤå롥 + +Mon Jan 23 10:42:09 1995 Yukihiro Matsumoto (matz@ix-02) + + * parse.y(rb_class2name): ᥿饹˴ؤbug fix. + + * dict.c: Dict[..]Ǽ褦ˡ + + * array.c: Array[..]褦ˡ + + * parse.y: ɽȤ{a,b,..}Ȥ褦ˡ + +Fri Jan 20 10:28:38 1995 Yukihiro Matsumoto (matz@ix-02) + + * re.c(Regexp.quote): ɽ򥨥פ᥽åɡ + + * ̵̤rb_intern()򸺤餷 + + * parse.y: `!', `!=', `!~'ü黻Ҥˤ롥äƤϺ + Ǥʤʤä + +Wed Jan 18 13:20:41 1995 Yukihiro Matsumoto (matz@ix-02) + + * parse.y: ʸˡ(unless,untilʤ) + +Tue Jan 17 11:11:27 1995 Yukihiro Matsumoto (matz@ix-02) + + * eval.c: defǥ᥽åɺˤϥѡ饹Υ᥽åɤβĻ + Ѿ롥ǽλϺޤǤƱǥե(ȥåץ + ǴؿŪ饹̾᥽å) + + * object.c(Class::new): ֥Ȥ˴ؿŪ + åinit_objectɬƤФ褦ѹ + + * eval.c: ̤Υ᥽åɤФunknown᥽åɤƤФ褦 + ʤä顼ɽޤǤƱˤʤ褦envĴᤷƤ롥 + +Fri Jan 13 14:40:30 1995 Yukihiro Matsumoto (matz@ix-02) + + * gc.c: gc㴳񤭴ޤѲϤʤä褦 + + * parse.y(yylex): symbol\sym:symѹ + +Thu Jan 12 01:39:28 1995 Yukihiro Matsumoto (matz@dyna) + + * eval.c: ؿ rb_eval_string() + + * gc.c: gc_mark()Ƶ + + * variable.c(rb_ivar_{get,set}): 󥹥ѿΥ + å­ʤä + + * variable.c: 饹ȥ󥹥ѿǥϥåơ֥ͭ + 褦ˤ + + * ruby.h: iv_tblRBasicRObjectRClassذưˤꡤ + ObjectClass,Module󥹥ѿƤʤʤ롥 + Ψϼ㴳夹롥 + Tue Jan 10 00:58:20 1995 Yukihiro Matsumoto (matz@dyna) + * 0.64 released + * eval.c: 쥷ФȰϾiterǤϤʤ * cons.c(aref,aset): negative offsetб diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000000..429e921074 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,67 @@ +C-IF +ChangeLog +FAQ +MANIFEST +Makefile.in +README +ToDo +array.c +bignum.c +class.c +compar.c +configure +configure.in +cons.c +dbm.c +defines.h +dict.c +dir.c +dln.c +dln.h +enum.c +env.h +error.c +etc.c +eval.c +file.c +fnmatch.c +fnmatch.h +gc.c +getopt.c +getopt.h +getopt1.c +glob.c +gnuglob.c +ident.h +inits.c +io.c +io.h +main.c +math.c +node.h +numeric.c +object.c +pack.c +parse.y +process.c +random.c +range.c +re.c +re.h +regex.c +regex.h +ruby.1 +ruby.c +ruby.h +signal.c +socket.c +spec +sprintf.c +st.c +st.h +string.c +struct.c +time.c +variable.c +version.c +version.h diff --git a/Makefile.in b/Makefile.in index 477b4fdbd2..b0c6eb5ea9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -160,7 +160,7 @@ io.o: io.c ruby.h config.h defines.h io.h main.o: main.c math.o: math.c ruby.h config.h defines.h numeric.o: numeric.c ruby.h config.h defines.h env.h -object.o: object.c ruby.h config.h defines.h env.h node.h st.h +object.o: object.c ruby.h config.h defines.h env.h st.h pack.o: pack.c ruby.h config.h defines.h process.o: process.c ruby.h config.h defines.h st.h random.o: random.c ruby.h config.h defines.h @@ -174,5 +174,5 @@ st.o: st.c st.h string.o: string.c ruby.h config.h defines.h re.h regex.h struct.o: struct.c ruby.h config.h defines.h env.h time.o: time.c ruby.h config.h defines.h -variable.o: variable.c ruby.h config.h defines.h env.h node.h ident.h st.h +variable.o: variable.c ruby.h config.h defines.h env.h ident.h st.h version.o: version.c ruby.h config.h defines.h version.h diff --git a/ToDo b/ToDo index 5422040f45..5dcb005f52 100644 --- a/ToDo +++ b/ToDo @@ -1,10 +1,12 @@ +* Process Class +* 饹饤֥θľ(UNIX¸򸺤餹) * formatǽ * here document * perlΤ褦setuid check * trBSDɤ(ޤcopyrightϤäꤵ) * Ŭڤsignal handling -* dlnCOFFб +* dlnCOFFб(ޤdlopenб) * rubyѿhookμ¸ * write debugger for ruby -* re-write regex code for speeding +* re-write regex code for speed * byte code interpretor diff --git a/array.c b/array.c index 5a8f040723..28d755b73f 100644 --- a/array.c +++ b/array.c @@ -77,32 +77,33 @@ ary_new4(n, elts) return (VALUE)ary; } -#if 0 -VALUE -assoc_new(elm1, elm2) - VALUE elm1, elm2; +static VALUE +Sary_new(class) + VALUE class; { - struct RArray *ary; + NEWOBJ(ary, struct RArray); + OBJSETUP(ary, class, T_ARRAY); - ary = (struct RArray*)ary_new2(2); - ary->ptr[0] = elm1; - ary->ptr[1] = elm2; - ary->len = 2; + ary->len = 0; + ary->capa = ARY_DEFAULT_SIZE; + ary->ptr = ALLOC_N(VALUE, ARY_DEFAULT_SIZE); return (VALUE)ary; } -#endif static VALUE -Sary_new(class) +Sary_create(argc, argv, class) + int argc; + VALUE *argv; VALUE class; { NEWOBJ(ary, struct RArray); OBJSETUP(ary, class, T_ARRAY); - ary->len = 0; - ary->capa = ARY_DEFAULT_SIZE; - ary->ptr = ALLOC_N(VALUE, ARY_DEFAULT_SIZE); + ary->len = argc; + ary->capa = argc; + ary->ptr = ALLOC_N(VALUE, argc); + MEMCPY(ary->ptr, argv, VALUE, argc); return (VALUE)ary; } @@ -648,7 +649,10 @@ static int sort_2(a, b) VALUE *a, *b; { - VALUE retval = rb_funcall(*a, cmp, 1, *b); + VALUE retval; + + if (!cmp) cmp = rb_intern("<=>"); + retval = rb_funcall(*a, cmp, 1, *b); return NUM2INT(retval); } @@ -936,6 +940,7 @@ Init_Array() rb_include_module(C_Array, M_Enumerable); rb_define_single_method(C_Array, "new", Sary_new, 0); + rb_define_single_method(C_Array, "[]", Sary_create, -1); rb_define_method(C_Array, "to_s", Fary_to_s, 0); rb_define_method(C_Array, "_inspect", Fary_inspect, 0); rb_define_method(C_Array, "to_a", Fary_to_a, 0); @@ -976,6 +981,4 @@ Init_Array() rb_define_method(C_Array, "-", Fary_diff, 1); rb_define_method(C_Array, "&", Fary_and, 1); rb_define_method(C_Array, "|", Fary_or, 1); - - cmp = rb_intern("<=>"); } diff --git a/bignum.c b/bignum.c index 59667faaca..ef76fc532d 100644 --- a/bignum.c +++ b/bignum.c @@ -88,7 +88,7 @@ bignorm(x) while (len-- && !ds[len]) ; x->len = ++len; - + if (len*sizeof(USHORT) < sizeof(VALUE) || (len*sizeof(USHORT) == sizeof(VALUE) && ds[sizeof(VALUE)/sizeof(USHORT)-1] <= 0x3fff)) { diff --git a/class.c b/class.c index ba056a6283..6c790b79ee 100644 --- a/class.c +++ b/class.c @@ -3,7 +3,7 @@ class.c - $Author: matz $ - $Date: 1995/01/10 10:42:21 $ + $Date: 1995/01/12 08:54:44 $ created at: Tue Aug 10 15:05:44 JST 1993 Copyright (C) 1994 Yukihiro Matsumoto @@ -29,7 +29,6 @@ class_new(super) cls->super = super; cls->m_tbl = new_idhash(); - cls->c_tbl = Qnil; return (VALUE)cls; } @@ -69,13 +68,12 @@ single_class_clone(class) clone->super = class->super; clone->m_tbl = new_idhash(); st_foreach(class->m_tbl, clone_method, clone->m_tbl); - clone->c_tbl = Qnil; FL_SET(clone, FL_SINGLE); return (VALUE)clone; } } -VALUE +VALUE rb_define_class_id(id, super) ID id; struct RBasic *super; @@ -90,7 +88,7 @@ rb_define_class_id(id, super) return (VALUE)cls; } -VALUE +VALUE rb_define_class(name, super) char *name; VALUE super; @@ -106,12 +104,11 @@ module_new() mdl->super = Qnil; mdl->m_tbl = new_idhash(); - mdl->c_tbl = Qnil; return (VALUE)mdl; } -VALUE +VALUE rb_define_module_id(id) ID id; { @@ -121,7 +118,7 @@ rb_define_module_id(id) return (VALUE)mdl; } -VALUE +VALUE rb_define_module(name) char *name; { @@ -138,7 +135,7 @@ include_class_new(module, super) OBJSETUP(cls, C_Class, T_ICLASS); cls->m_tbl = module->m_tbl; - cls->c_tbl = module->c_tbl; + cls->iv_tbl = module->iv_tbl; cls->super = super; if (TYPE(module) == T_ICLASS) { RBASIC(cls)->class = RBASIC(module)->class; @@ -155,26 +152,30 @@ rb_include_module(class, module) struct RClass *class, *module; { struct RClass *p; - int added = FALSE; + + if (!module) return; Check_Type(module, T_MODULE); + if (BUILTIN_TYPE(class) == T_CLASS) { + rb_clear_cache2(class); + } + while (module) { - /* ignore if module included already in superclasses */ + /* ignore if the module included already in superclasses */ for (p = class->super; p; p = p->super) { if (BUILTIN_TYPE(p) == T_ICLASS && p->m_tbl == module->m_tbl) - goto ignore_module; + return; + } + + if (verbose) { + rb_const_check(class, module); } class->super = include_class_new(module, class->super); - added = TRUE; class = class->super; - ignore_module: module = module->super; } - if (added) { - rb_clear_cache2(class); - } } void diff --git a/cons.c b/cons.c index ac562814ca..bf755865c9 100644 --- a/cons.c +++ b/cons.c @@ -3,7 +3,7 @@ cons.c - $Author: matz $ - $Date: 1995/01/10 10:22:24 $ + $Date: 1995/01/10 10:30:37 $ created at: Fri Jan 6 10:10:36 JST 1995 Copyright (C) 1994 Yukihiro Matsumoto @@ -178,6 +178,7 @@ Fcons_hash(cons) { int key; + if (!hash) hash = rb_intern("hash"); key = rb_funcall(cons->car, hash, 0, 0); key ^= rb_funcall(cons->cdr, hash, 0, 0); return INT2FIX(key); @@ -253,7 +254,6 @@ Init_Cons() rb_define_method(C_Cons, "==", Fcons_equal, 1); rb_define_method(C_Cons, "hash", Fcons_hash, 0); - hash = rb_intern("hash"); rb_define_method(C_Cons, "length", Fcons_length, 0); rb_define_method(C_Cons, "to_s", Fcons_to_s, 0); diff --git a/dbm.c b/dbm.c index c0fd514e59..ed605614a0 100644 --- a/dbm.c +++ b/dbm.c @@ -31,6 +31,7 @@ closeddbm() #define GetDBM(obj, dbmp) {\ DBM **_dbm;\ + if (!id_dbm) id_dbm = rb_intern("dbm");\ Get_Data_Struct(obj, id_dbm, DBM*, _dbm);\ dbmp = *_dbm;\ if (dbmp == Qnil) closeddbm();\ @@ -156,7 +157,7 @@ Fdbm_delete(obj, keystr) Check_Type(keystr, T_STRING); key.dptr = RSTRING(keystr)->ptr; key.dsize = RSTRING(keystr)->len; - + GetDBM(obj, dbm); if (dbm_delete(dbm, key)) { Fail("dbm_delete failed"); @@ -338,7 +339,7 @@ Fdbm_has_key(obj, keystr) Check_Type(keystr, T_STRING); key.dptr = RSTRING(keystr)->ptr; key.dsize = RSTRING(keystr)->len; - + GetDBM(obj, dbm); val = dbm_fetch(dbm, key); if (val.dptr) return TRUE; @@ -355,7 +356,7 @@ Fdbm_has_value(obj, valstr) Check_Type(valstr, T_STRING); val.dptr = RSTRING(valstr)->ptr; val.dsize = RSTRING(valstr)->len; - + GetDBM(obj, dbm); for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) { val = dbm_fetch(dbm, key); @@ -412,7 +413,5 @@ Init_DBM() rb_define_method(C_DBM, "has_value", Fdbm_has_value, 1); rb_define_method(C_DBM, "to_a", Fdbm_to_a, 0); - - id_dbm = rb_intern("dbm"); } #endif /* USE_DBM */ diff --git a/dict.c b/dict.c index d6ccbca56e..fa4ffc04e3 100644 --- a/dict.c +++ b/dict.c @@ -41,7 +41,6 @@ static VALUE Sdic_new(class) VALUE class; { - int i, max; NEWOBJ(dic, struct RDict); OBJSETUP(dic, class, T_DICT); @@ -50,6 +49,40 @@ Sdic_new(class) return (VALUE)dic; } +static VALUE Fdic_clone(); + +static VALUE +Sdic_create(argc, argv, class) + int argc; + VALUE *argv; + VALUE class; +{ + struct RDict *dic; + int i; + + if (argc == 1 && TYPE(argv[0]) == T_DICT) { + if (class == CLASS_OF(argv[0])) return argv[0]; + else { + NEWOBJ(dic, struct RDict); + OBJSETUP(dic, class, T_DICT); + dic->tbl = (st_table*)st_copy(RDICT(argv[0])->tbl); + + return (VALUE)dic; + } + } + + if (argc % 2 != 0) { + Fail("odd number args for Dict"); + } + dic = (struct RDict*)Sdic_new(class); + + for (i=0; itbl, argv[i], argv[i+1]); + } + + return (VALUE)dic; +} + VALUE dic_new() { @@ -551,6 +584,7 @@ Init_Dict() rb_include_module(C_Dict, M_Enumerable); rb_define_single_method(C_Dict, "new", Sdic_new, 0); + rb_define_single_method(C_Dict, "[]", Sdic_create, -1); rb_define_method(C_Dict,"clone", Fdic_clone, 0); diff --git a/dir.c b/dir.c index 0baa13fdd1..755290fa0c 100644 --- a/dir.c +++ b/dir.c @@ -55,11 +55,12 @@ Sdir_open(dir_class, dirname) DIR *dirp, **d; Check_Type(dirname, T_STRING); - + dirp = opendir(dirname->ptr); if (dirp == NULL) Fail("Can't open directory %s", dirname->ptr); obj = obj_alloc(dir_class); + if (!id_dir) id_dir = rb_intern("dir"); Make_Data_Struct(obj, id_dir, DIR*, Qnil, free_dir, d); *d = dirp; @@ -74,6 +75,7 @@ closeddir() #define GetDIR(obj, dirp) {\ DIR **_dp;\ + if (!id_dir) id_dir = rb_intern("dir");\ Get_Data_Struct(obj, id_dir, DIR*, _dp);\ dirp = *_dp;\ if (dirp == NULL) closeddir();\ @@ -260,6 +262,4 @@ Init_Dir() rb_define_single_method(C_Dir,"rmdir", Sdir_rmdir, 1); rb_define_single_method(C_Dir,"delete", Sdir_rmdir, 1); rb_define_single_method(C_Dir,"unlink", Sdir_rmdir, 1); - - id_dir = rb_intern("dir"); } diff --git a/dln.c b/dln.c index 44179ec3e9..2e1ff5aed5 100644 --- a/dln.c +++ b/dln.c @@ -238,7 +238,7 @@ dln_load_reloc(fd, hdrp, disp) int size; lseek(fd, disp + N_TXTOFF(*hdrp) + hdrp->a_text + hdrp->a_data, 0); - + size = hdrp->a_trsize + hdrp->a_drsize; reloc = (struct relocation_info*)xmalloc(size); if (reloc == NULL) { @@ -251,7 +251,7 @@ dln_load_reloc(fd, hdrp, disp) free(reloc); return NULL; } - + return reloc; } @@ -681,7 +681,7 @@ static int dln_load_1(fd, disp, need_init) */ { struct relocation_info * rel = reloc; - struct relocation_info * rel_beg = reloc + + struct relocation_info * rel_beg = reloc + (hdr.a_trsize/sizeof(struct relocation_info)); struct relocation_info * rel_end = reloc + (hdr.a_trsize+hdr.a_drsize)/sizeof(struct relocation_info); @@ -772,7 +772,7 @@ static int dln_load_1(fd, disp, need_init) while (sym < end) { char *name = sym->n_un.n_name; if (name[0] == '_' && sym->n_value >= block - && ((bcmp (name, "_Init_", 6) == 0 + && ((bcmp (name, "_Init_", 6) == 0 || bcmp (name, "_init_", 6) == 0) && name[6] != '_')) { init_p = 1; ((int (*)())sym->n_value)(); diff --git a/enum.c b/enum.c index 5eaef855f1..a27c9860d2 100644 --- a/enum.c +++ b/enum.c @@ -19,6 +19,7 @@ void rb_each(obj) VALUE obj; { + if (!id_each) id_each = rb_intern("each"); rb_funcall(obj, id_each, 0, Qnil); } @@ -26,6 +27,7 @@ static void enum_grep(i, arg) VALUE i, *arg; { + if (!id_match) id_match = rb_intern("=~"); if (rb_funcall(arg[0], id_match, 1, i)) { ary_push(arg[1], i); } @@ -35,6 +37,7 @@ static void enum_grep2(i, pat) VALUE i, pat; { + if (!id_match) id_match = rb_intern("=~"); if (rb_funcall(pat, id_match, 1, i)) { rb_yield(i); } @@ -150,7 +153,7 @@ enum_all(i, ary) { ary_push(ary, i); } - + static VALUE Fenum_to_a(obj) VALUE obj; @@ -183,6 +186,7 @@ enum_min(i, min) if (*min == Qnil) *min = i; else { + if (!id_cmp) id_cmp = rb_intern("<=>"); cmp = rb_funcall(i, id_cmp, 1, *min); if (FIX2INT(cmp) < 0) *min = i; @@ -208,6 +212,7 @@ enum_max(i, max) if (*max == Qnil) *max = i; else { + if (!id_cmp) id_cmp = rb_intern("<=>"); cmp = rb_funcall(i, id_cmp, 1, *max); if (FIX2INT(cmp) > 0) *max = i; @@ -316,8 +321,4 @@ Init_Enumerable() rb_define_method(M_Enumerable,"index", Fenum_index, 1); rb_define_method(M_Enumerable,"includes", Fenum_includes, 1); rb_define_method(M_Enumerable,"length", Fenum_length, 0); - - id_each = rb_intern("each"); - id_match = rb_intern("=~"); - id_cmp = rb_intern("<=>"); } diff --git a/error.c b/error.c index 437d0baef3..e9626165fb 100644 --- a/error.c +++ b/error.c @@ -82,7 +82,7 @@ Warning(fmt, va_alist) char *fmt; va_dcl { - char buf[BUFSIZ]; + char buf[BUFSIZ]; va_list args; sprintf(buf, "warning: %s", fmt); @@ -108,7 +108,7 @@ Bug(fmt, va_alist) char *fmt; va_dcl { - char buf[BUFSIZ]; + char buf[BUFSIZ]; va_list args; sprintf(buf, "[BUG] %s", fmt); @@ -124,7 +124,7 @@ Fail(fmt, va_alist) va_dcl { va_list args; - char buf[BUFSIZ]; + char buf[BUFSIZ]; va_start(args); vsprintf(buf, fmt, args); @@ -132,7 +132,7 @@ Fail(fmt, va_alist) rb_fail(str_new2(buf)); } - + rb_sys_fail(mesg) char *mesg; { @@ -164,8 +164,6 @@ static char *builtin_types[] = { "Method", "Struct", "Bignum", - "Node", - "Scope", "Cons", "Data", }; diff --git a/eval.c b/eval.c index c54fa14e5e..1e00de909c 100644 --- a/eval.c +++ b/eval.c @@ -3,7 +3,7 @@ eval.c - $Author: matz $ - $Date: 1995/01/10 10:42:34 $ + $Date: 1995/01/12 08:54:45 $ created at: Thu Jun 10 14:22:17 JST 1993 Copyright (C) 1994 Yukihiro Matsumoto @@ -52,7 +52,7 @@ search_method(class, id, origin) if (class == Qnil) return Qnil; } - *origin = class; + if (origin) *origin = class; return body; } @@ -389,6 +389,7 @@ ruby_init(argc, argv, envp) static struct ENVIRON env; the_env = top_env = &env; + init_heap(); PUSH_SCOPE(); the_scope->local_vars = Qnil; the_scope->local_tbl = Qnil; @@ -414,13 +415,14 @@ ruby_init(argc, argv, envp) VALUE rb_readonly_hook(); static VALUE -Eval(toplevel) - int toplevel; +Eval() { VALUE result; NODE *tree; int state; + if (!eval_tree) return Qnil; + tree = eval_tree; eval_tree = Qnil; sourcefile = tree->file; @@ -441,7 +443,7 @@ ruby_run() if (nerrs > 0) exit(nerrs); - Init_stack(); + init_stack(); rb_define_variable("$!", &errstr, Qnil, Qnil, 0); errat = Qnil; /* clear for execution */ @@ -449,7 +451,7 @@ ruby_run() PUSH_ITER(ITER_NOT); if ((state = EXEC_TAG()) == 0) { the_class = (struct RClass*)C_Object; - Eval(1); + Eval(); } POP_ITER(); POP_TAG(); @@ -488,6 +490,38 @@ ruby_run() exit(0); } +static void +syntax_error() +{ + VALUE mesg; + + mesg = errstr; + nerrs = 0; + errstr = str_new2("syntax error in eval():\n"); + str_cat(errstr, RSTRING(mesg)->ptr, RSTRING(mesg)->len); + rb_fail(errstr); +} + +VALUE +rb_eval_string(str) + char *str; +{ + char *oldsrc = sourcefile; + VALUE result; + + lex_setsrc("(eval)", str, strlen(str)); + eval_tree = Qnil; + yyparse(); + sourcefile = oldsrc; + if (nerrs == 0) { + return Eval(); + } + else { + syntax_error(); + } + return Qnil; /* not reached */ +} + void rb_trap_eval(cmd) VALUE cmd; @@ -636,34 +670,9 @@ rb_eval(node) return rb_eval(node); } node = node->nd_next; - } - } - return Qnil; - - case NODE_EXNOT: - { - VALUE res; - - PUSH_TAG(); - switch (state = EXEC_TAG()) { - case 0: - res = rb_eval(node->nd_cond); - go_out = 0; - break; - - case TAG_FAIL: - res = Qnil; - go_out = 0; - break; - - default: - go_out = 1; } - POP_TAG(); - if (go_out) JUMP_TAG(state); - if (res) return FALSE; - return TRUE; } + return Qnil; case NODE_WHILE: PUSH_TAG(); @@ -828,6 +837,10 @@ rb_eval(node) node = node->nd_2nd; goto again; + case NODE_NOT: + if (rb_eval(node->nd_body)) return FALSE; + return TRUE; + case NODE_DOT3: if (node->nd_state == 0) { if (rb_eval(node->nd_beg)) { @@ -943,7 +956,8 @@ rb_eval(node) val = rb_apply(recv, aref, args); val = rb_funcall(val, node->nd_mid, 1, rb_eval(rval)); ary_push(args, val); - return rb_apply(recv, aset, args); + rb_apply(recv, aset, args); + return val; } case NODE_OP_ASGN2: @@ -957,7 +971,8 @@ rb_eval(node) id |= ID_ATTRSET; val = rb_eval(node->nd_value); - return rb_funcall(recv, id, 1, val); + rb_funcall(recv, id, 1, val); + return val; } case NODE_MASGN: @@ -1044,7 +1059,7 @@ rb_eval(node) key = rb_eval(list->nd_head); list = list->nd_next; if (list == Qnil) - Bug("odd number list for hash"); + Bug("odd number list for Dict"); val = rb_eval(list->nd_head); list = list->nd_next; Fdic_aset(hash, key, val); @@ -1122,39 +1137,42 @@ rb_eval(node) return rb_ivar_set(node->nd_vid, the_env->argv[0]); case NODE_DEFN: - { - if (node->nd_defn) { - rb_add_method(the_class,node->nd_mid,node->nd_defn, - node->nd_noex); + if (node->nd_defn) { + NODE *body; + VALUE origin; + int noex; + + body = search_method(the_class, node->nd_mid, &origin); + if (verbose && origin != (VALUE)the_class + && body->nd_noex != node->nd_noex) { + Warning("change method %s's scope", rb_id2name(node->nd_mid)); } + + if (body) noex = body->nd_noex; + else noex = node->nd_noex; /* default(1 for toplevel) */ + + rb_add_method(the_class, node->nd_mid, node->nd_defn, noex); } return Qnil; case NODE_DEFS: - { - if (node->nd_defn) { - VALUE recv = rb_eval(node->nd_recv); + if (node->nd_defn) { + VALUE recv = rb_eval(node->nd_recv); - if (recv == Qnil) { - Fail("Can't define method \"%s\" for nil", - rb_id2name(node->nd_mid)); - } - rb_add_method(rb_single_class(recv), - node->nd_mid, node->nd_defn, 0); + if (recv == Qnil) { + Fail("Can't define method \"%s\" for nil", + rb_id2name(node->nd_mid)); } + rb_add_method(rb_single_class(recv),node->nd_mid,node->nd_defn,0); } return Qnil; case NODE_UNDEF: - { - rb_add_method(the_class, node->nd_mid, Qnil, 0); - } + rb_add_method(the_class, node->nd_mid, Qnil, 0); return Qnil; case NODE_ALIAS: - { - rb_alias(the_class, node->nd_new, node->nd_old); - } + rb_alias(the_class, node->nd_new, node->nd_old); return Qnil; case NODE_CLASS: @@ -1492,7 +1510,7 @@ asign(lhs, val) break; default: - Bug("bug in iterator variable asignment"); + Bug("bug in variable asignment"); break; } } @@ -1614,28 +1632,62 @@ rb_ensure(b_proc, data1, e_proc, data2) return result; } -struct st_table *new_idhash(); +static int last_noex; -static void -rb_undefined(obj, id, noex) +static VALUE +Funknown(argc, argv, obj) + int argc; + VALUE *argv; VALUE obj; - ID id; - int noex; { - VALUE desc = obj_as_string(obj); + VALUE desc; + ID id; char *format; + struct ENVIRON *env; + + id = FIX2INT(argv[0]); + argc--; argv++; + desc = obj_as_string(obj); if (RSTRING(desc)->len > 160) { desc = Fkrn_to_s(obj); } - if (noex) + if (last_noex) format = "method `%s' not available for \"%s\"(%s)"; else format = "undefined method `%s' for \"%s\"(%s)"; + + /* fake environment */ + PUSH_ENV(); + env = the_env->prev; + MEMCPY(the_env, the_env->prev->prev, struct ENVIRON, 1); + the_env->prev = env; + Fail(format, rb_id2name(id), RSTRING(desc)->ptr, rb_class2name(CLASS_OF(obj))); + POP_ENV(); +} + +static VALUE +rb_undefined(obj, id, argc, argv, noex) + VALUE obj; + ID id; + int argc; + VALUE*argv; + int noex; +{ + VALUE *nargv; + + argc; + nargv = ALLOCA_N(VALUE, argc+1); + nargv[0] = INT2FIX(id); + MEMCPY(nargv+1, argv, VALUE, argc); + + last_noex = noex; + + return rb_funcall2(obj, rb_intern("unknown"), argc+1, nargv); } static VALUE @@ -1656,7 +1708,6 @@ rb_call(class, recv, mid, argc, argv, func) /* is it in the method cache? */ ent = cache + EXPR1(class, mid); if (ent->mid == mid && ent->class == class) { - /* if (ent->method == Qnil) rb_undefined(recv, mid, 0); */ class = ent->origin; mid = ent->mid; body = ent->method; @@ -1666,12 +1717,14 @@ rb_call(class, recv, mid, argc, argv, func) ID id = mid; if ((body = rb_get_method_body(&class, &id, &noex)) == Qnil) { - rb_undefined(recv, mid, 0); + return rb_undefined(recv, mid, argc, argv, 0); } mid = id; } - if (!func && noex) rb_undefined(recv, mid, 1); + if (!func && noex) { + return rb_undefined(recv, mid, argc, argv, 1); + } switch (iter->iter) { case ITER_PRE: @@ -1691,7 +1744,7 @@ rb_call(class, recv, mid, argc, argv, func) the_env->argv = argv; switch (nd_type(body)) { - case NODE_CFUNC: + case NODE_CFUNC: { int len = body->nd_argc; @@ -1806,6 +1859,8 @@ rb_call(class, recv, mid, argc, argv, func) /* for attr get/set */ case NODE_ATTRSET: case NODE_IVAR: + /* for exported method */ + case NODE_ZSUPER: return rb_eval(body); default: @@ -1915,17 +1970,19 @@ Fapply(argc, argv, recv) VALUE *argv; VALUE recv; { - VALUE vid, rest; + VALUE vid; ID mid; - rb_scan_args(argc, argv, "1*", &vid, &rest); + if (argc == 0) Fail("no method name given"); + + vid = argv[0]; argc--; argv++; if (TYPE(vid) == T_STRING) { mid = rb_intern(RSTRING(vid)->ptr); } else { mid = NUM2INT(vid); } - return rb_apply(recv, mid, rest); + return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1); } #include @@ -1958,6 +2015,16 @@ rb_funcall(recv, mid, n, va_alist) return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1); } +VALUE +rb_funcall2(recv, mid, argc, argv) + VALUE recv; + ID mid; + int argc; + VALUE *argv; +{ + return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1); +} + int rb_in_eval = 0; static VALUE @@ -1995,13 +2062,7 @@ Feval(obj, src) if (state) JUMP_TAG(state); if (nerrs > 0) { - VALUE mesg; - - mesg = errstr; - nerrs = 0; - errstr = str_new2("syntax error in eval():\n"); - str_cat(errstr, RSTRING(mesg)->ptr, RSTRING(mesg)->len); - rb_fail(errstr); + syntax_error(); } return result; @@ -2151,6 +2212,24 @@ addpath(path) extern VALUE C_Kernel; + +Init_eval() +{ + match = rb_intern("=~"); + each = rb_intern("each"); + + aref = rb_intern("[]"); + aset = rb_intern("[]="); + + rb_global_variable(&top_scope); + rb_global_variable(&eval_tree); + rb_define_private_method(C_Kernel, "exit", Fexit, -1); + rb_define_private_method(C_Kernel, "eval", Feval, 1); + rb_define_private_method(C_Kernel, "iterator_p", Fiterator_p, 0); + rb_define_method(C_Kernel, "apply", Fapply, -1); + rb_define_method(C_Kernel, "unknown", Funknown, -1); +} + Init_load() { char *path; @@ -2169,22 +2248,6 @@ Init_load() rb_define_private_method(C_Kernel, "require", Frequire, 1); } -Init_eval() -{ - match = rb_intern("=~"); - each = rb_intern("each"); - - aref = rb_intern("[]"); - aset = rb_intern("[]="); - - rb_global_variable(&top_scope); - rb_global_variable(&eval_tree); - rb_define_private_method(C_Kernel, "exit", Fexit, -1); - rb_define_private_method(C_Kernel, "eval", Feval, 1); - rb_define_private_method(C_Kernel, "iterator_p", Fiterator_p, 0); - rb_define_method(C_Kernel, "apply", Fapply, -1); -} - void scope_dup(scope) struct SCOPE *scope; @@ -2239,11 +2302,12 @@ Sblk_new(class) if (the_block->block) return the_block->block; blk = obj_alloc(class); + if (!blkdata) blkdata = rb_intern("blk"); Make_Data_Struct(blk, blkdata, struct BLOCK, Qnil, blk_free, data); MEMCPY(data, the_block, struct BLOCK, 1); data->env.argv = ALLOC_N(VALUE, data->env.argc); - MEMCPY(data->env.argv, the_block->env.argv, VALUE, data->env.argc); + MEMCPY(data->env.argv, the_block->env.argv, VALUE, data->env.argc); scope_dup(data->scope); @@ -2252,13 +2316,13 @@ Sblk_new(class) } VALUE -blk_new() +block_new() { return Sblk_new(C_Block); } static VALUE -Fblk_do(blk, args) +Fblk_call(blk, args) VALUE blk, args; { struct BLOCK *data; @@ -2318,6 +2382,5 @@ Init_Block() rb_define_single_method(C_Block, "new", Sblk_new, 0); - rb_define_method(C_Block, "do", Fblk_do, -2); - blkdata = rb_intern("blk"); + rb_define_method(C_Block, "call", Fblk_call, -2); } diff --git a/file.c b/file.c index bae2c3140b..6f10099c33 100644 --- a/file.c +++ b/file.c @@ -225,7 +225,7 @@ stat_new(st) "blksize", INT2FIX(0), #endif #ifdef HAVE_ST_BLOCKS - "blocks", INT2FIX((int)st->st_blocks), + "blocks", INT2FIX((int)st->st_blocks), #else "blocks", INT2FIX(0), #endif @@ -721,7 +721,7 @@ Sfile_type(obj, fname) t = "directory"; } else if (S_ISCHR(st.st_mode)) { t = "characterSpecial"; - } + } #ifdef S_ISBLK else if (S_ISBLK(st.st_mode)) { t = "blockSpecial"; @@ -730,7 +730,7 @@ Sfile_type(obj, fname) #ifndef S_ISFIFO else if (S_ISFIFO(st.st_mode)) { t = "fifo"; - } + } #endif #ifdef S_ISLNK else if (S_ISLNK(st.st_mode)) { diff --git a/gc.c b/gc.c index af6741f6ca..ec07c0fa95 100644 --- a/gc.c +++ b/gc.c @@ -3,7 +3,7 @@ gc.c - $Author: matz $ - $Date: 1995/01/10 10:42:37 $ + $Date: 1995/01/12 08:54:47 $ created at: Tue Oct 5 09:44:46 JST 1993 Copyright (C) 1994 Yukihiro Matsumoto @@ -164,7 +164,7 @@ rb_global_variable(var) Global_List = tmp; } -struct RVALUE { +typedef struct RVALUE { union { struct { UINT flag; /* always 0 for freed obj */ @@ -185,50 +185,53 @@ struct RVALUE { struct RCons cons; struct SCOPE scope; } as; -} *freelist = Qnil; +} RVALUE; -struct heap_block { - struct heap_block *next; - struct RVALUE *beg; - struct RVALUE *end; - struct RVALUE body[1]; -} *heap_link = Qnil; +RVALUE *freelist = Qnil; -#define SEG_SLOTS 10000 -#define SEG_SIZE (SEG_SLOTS*sizeof(struct RVALUE)) +#define HEAPS_INCREMENT 10 +static RVALUE **heaps; +static int heaps_length = 0; +static int heaps_used = 0; + +#define HEAP_SLOTS 10000 #define FREE_MIN 512 static void add_heap() { - struct heap_block *block; - struct RVALUE *p, *pend; - - block = (struct heap_block*)malloc(sizeof(*block) + SEG_SIZE); - if (block == Qnil) Fatal("can't alloc memory"); - block->next = heap_link; - block->beg = &block->body[0]; - block->end = block->beg + SEG_SLOTS; - p = block->beg; pend = block->end; + RVALUE *p, *pend; + + if (heaps_used == heaps_length) { + /* Realloc heaps */ + heaps_length += HEAPS_INCREMENT; + heaps = (heaps_used)? + (RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE)): + (RVALUE**)malloc(heaps_length*sizeof(RVALUE)); + if (heaps == Qnil) Fatal("can't alloc memory"); + } + + p = heaps[heaps_used++] = (RVALUE*)malloc(sizeof(RVALUE)*HEAP_SLOTS); + if (p == Qnil) Fatal("can't alloc memory"); + pend = p + HEAP_SLOTS; + while (p < pend) { p->as.free.flag = 0; p->as.free.next = freelist; freelist = p; p++; } - heap_link = block; } struct RBasic * newobj() { struct RBasic *obj; - if (heap_link == Qnil) add_heap(); if (freelist) { retry: obj = (struct RBasic*)freelist; freelist = freelist->as.free.next; - memset(obj, 0, sizeof(struct RVALUE)); + memset(obj, 0, sizeof(RVALUE)); return obj; } if (dont_gc) add_heap(); @@ -259,16 +262,17 @@ static VALUE *stack_start_ptr; static long looks_pointerp(p) - struct RVALUE *p; + register RVALUE *p; { - struct heap_block *heap = heap_link; - - if (FIXNUM_P(p)) return FALSE; - while (heap) { - if (heap->beg <= p && p < heap->end - && ((((char*)p)-((char*)heap->beg))%sizeof(struct RVALUE)) == 0) + register RVALUE *heap_org; + register long i, j, n; + + /* if p looks as a SCM pointer mark location */ + for (i=0; i < heaps_used; i++) { + heap_org = heaps[i]; + if (heap_org <= p && p < heap_org + HEAP_SLOTS + && ((((char*)p)-((char*)heap_org))%sizeof(RVALUE)) == 0) return TRUE; - heap = heap->next; } return FALSE; } @@ -349,11 +353,13 @@ gc_mark_maybe(obj) void gc_mark(obj) - register struct RVALUE *obj; + register RVALUE *obj; { - if (obj == Qnil) return; - if (FIXNUM_P(obj)) return; - if (obj->as.basic.flags & FL_MARK) return; + Top: + if (obj == Qnil) return; /* nil not marked */ + if (FIXNUM_P(obj)) return; /* fixnum not marked */ + if (obj->as.basic.flags == 0) return; /* free cell */ + if (obj->as.basic.flags & FL_MARK) return; /* marked */ obj->as.basic.flags |= FL_MARK; @@ -362,21 +368,34 @@ gc_mark(obj) case T_FIXNUM: Bug("gc_mark() called for broken object"); break; + + case T_NODE: + if (looks_pointerp(obj->as.node.u1.node)) { + gc_mark(obj->as.node.u1.node); + } + if (looks_pointerp(obj->as.node.u2.node)) { + gc_mark(obj->as.node.u2.node); + } + if (looks_pointerp(obj->as.node.u3.node)) { + obj = (RVALUE*)obj->as.node.u3.node; + goto Top; + } + return; /* no need to mark class. */ } + gc_mark(obj->as.basic.class); switch (obj->as.basic.flags & T_MASK) { case T_ICLASS: gc_mark(obj->as.class.super); - if (obj->as.class.c_tbl) mark_tbl(obj->as.class.c_tbl); + if (obj->as.class.iv_tbl) mark_tbl(obj->as.class.iv_tbl); mark_tbl(obj->as.class.m_tbl); break; case T_CLASS: gc_mark(obj->as.class.super); case T_MODULE: - if (obj->as.class.c_tbl) mark_tbl(obj->as.class.c_tbl); mark_tbl(obj->as.class.m_tbl); - gc_mark(obj->as.basic.class); + if (obj->as.class.iv_tbl) mark_tbl(obj->as.class.iv_tbl); break; case T_ARRAY: @@ -402,6 +421,9 @@ gc_mark(obj) break; case T_OBJECT: + if (obj->as.object.iv_tbl) mark_tbl(obj->as.object.iv_tbl); + break; + case T_REGEXP: case T_FLOAT: case T_BIGNUM: @@ -427,20 +449,12 @@ gc_mark(obj) case T_CONS: gc_mark(obj->as.cons.car); - gc_mark(obj->as.cons.cdr); - break; - - case T_NODE: - gc_mark_maybe(obj->as.node.u1.node); - gc_mark_maybe(obj->as.node.u2.node); - gc_mark_maybe(obj->as.node.u3.node); - return; /* no need to mark class & tbl */ + obj = (RVALUE*)obj->as.cons.cdr; + goto Top; default: Bug("gc_mark(): unknown data type %d", obj->as.basic.flags & T_MASK); } - if (obj->as.basic.iv_tbl) mark_tbl(obj->as.basic.iv_tbl); - gc_mark(obj->as.basic.class); } #define MIN_FREE_OBJ 512 @@ -450,19 +464,19 @@ static void obj_free(); static void gc_sweep() { - struct heap_block *heap = heap_link; int freed = 0; + int i; freelist = Qnil; - while (heap) { - struct RVALUE *p, *pend; - struct RVALUE *nfreelist; + for (i = 0; i < heaps_used; i++) { + RVALUE *p, *pend; + RVALUE *nfreelist; int n = 0; nfreelist = freelist; - p = heap->beg; pend = heap->end; + p = heaps[i]; pend = p + HEAP_SLOTS; + while (p < pend) { - if (!(p->as.basic.flags & FL_MARK)) { if (p->as.basic.flags) obj_free(p); p->as.free.flag = 0; @@ -470,31 +484,12 @@ gc_sweep() nfreelist = p; n++; } - RBASIC(p)->flags &= ~FL_MARK; + else + RBASIC(p)->flags &= ~FL_MARK; p++; } - if (n == SEG_SLOTS) { - struct heap_block *link = heap_link; - if (heap != link) { - while (link) { - if (link->next && link->next == heap) { - link->next = heap->next; - break; - } - link = link->next; - } - if (link == Qnil) { - Bug("non-existing heap at 0x%x", heap); - } - } - free(heap); - heap = link; - } - else { - freed += n; - freelist = nfreelist; - } - heap = heap->next; + freed += n; + freelist = nfreelist; } if (freed < FREE_MIN) { add_heap(); @@ -503,7 +498,7 @@ gc_sweep() static void obj_free(obj) - struct RVALUE *obj; + RVALUE *obj; { switch (obj->as.basic.flags & T_MASK) { case T_NIL: @@ -514,13 +509,13 @@ obj_free(obj) switch (obj->as.basic.flags & T_MASK) { case T_OBJECT: + if (obj->as.object.iv_tbl) st_free_table(obj->as.object.iv_tbl); break; case T_MODULE: case T_CLASS: rb_clear_cache2(obj); st_free_table(obj->as.class.m_tbl); - if (obj->as.class.c_tbl) - st_free_table(obj->as.class.c_tbl); + if (obj->as.object.iv_tbl) st_free_table(obj->as.object.iv_tbl); break; case T_STRING: if (obj->as.string.orig == Qnil) free(obj->as.string.ptr); @@ -570,7 +565,6 @@ obj_free(obj) default: Bug("gc_sweep(): unknown data type %d", obj->as.basic.flags & T_MASK); } - if (obj->as.basic.iv_tbl) st_free_table(obj->as.basic.iv_tbl); } void @@ -626,13 +620,21 @@ gc() dont_gc--; } -Init_stack() +void +init_stack() { VALUE start; stack_start_ptr = &start; } +void +init_heap() +{ + init_stack(); + add_heap(); +} + Init_GC() { M_GC = rb_define_module("GC"); diff --git a/getopt1.c b/getopt1.c index 7f824232d7..7a2bbae344 100644 --- a/getopt1.c +++ b/getopt1.c @@ -56,7 +56,7 @@ getopt_long (argc, argv, options, long_options, opt_index) but does match a short option, it is parsed as a short option instead. */ -int +int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; diff --git a/io.c b/io.c index c0f246b60c..288e86d4d9 100644 --- a/io.c +++ b/io.c @@ -802,7 +802,7 @@ next_argv() next_p = 0; if (RARRAY(Argv)->len > 0) { filename = ary_shift(Argv); - fn = RSTRING(filename)->ptr; + fn = RSTRING(filename)->ptr; if (RSTRING(filename)->len == 1 && fn[0] == '-') { file = rb_stdin; if (inplace) { @@ -938,12 +938,12 @@ struct timeval *time_timeval(); #ifdef STDSTDIO # define READ_PENDING(fp) ((fp)->_cnt != 0) -#else +#else # ifdef __SLBF # define READ_PENDING(fp) ((fp)->_r > 0) # else # ifdef __linux__ -# ifdef _other_gbase +# ifdef _other_gbase # define READ_PENDING(fp) ((fp)->_IO_read_ptr < (fp)->_IO_read_end) # else # define READ_PENDING(fp) ((fp)->_gptr < (fp)->_egptr) @@ -1009,7 +1009,7 @@ Fselect(argc, argv, obj) FD_SET(fileno(fptr->f), wp); if (max > fileno(fptr->f)) max = fileno(fptr->f); if (fptr->f2) { - FD_SET(fileno(fptr->f2), wp); + FD_SET(fileno(fptr->f2), wp); if (max < fileno(fptr->f2)) max = fileno(fptr->f2); } } @@ -1026,7 +1026,7 @@ Fselect(argc, argv, obj) FD_SET(fileno(fptr->f), ep); if (max < fileno(fptr->f)) max = fileno(fptr->f); if (fptr->f2) { - FD_SET(fileno(fptr->f2), ep); + FD_SET(fileno(fptr->f2), ep); if (max > fileno(fptr->f2)) max = fileno(fptr->f2); } } diff --git a/missing/MANIFEST b/missing/MANIFEST new file mode 100644 index 0000000000..52640c2720 --- /dev/null +++ b/missing/MANIFEST @@ -0,0 +1,10 @@ +MANIFEST +alloca.c +memmove.c +mkdir.c +strdup.c +strerror.c +strftime.c +strstr.c +strtol.c +strtoul.c diff --git a/node.h b/node.h index 9322417fa2..8137995d71 100644 --- a/node.h +++ b/node.h @@ -24,12 +24,12 @@ enum node_type { NODE_WHEN, NODE_WHILE, NODE_WHILE2, - NODE_EXNOT, NODE_ITER, NODE_FOR, NODE_PROT, NODE_AND, NODE_OR, + NODE_NOT, NODE_MASGN, NODE_LASGN, NODE_GASGN, @@ -181,13 +181,10 @@ typedef struct RNode { #define NEW_BLOCK(a) newnode(NODE_BLOCK,a,1,Qnil) #define NEW_IF(c,t,e) newnode(NODE_IF,c,t,e) #define NEW_EXNOT(c) newnode(NODE_EXNOT,c,Qnil,Qnil) -#define NEW_UNLESS(c,t,e) newnode(NODE_IF,NEW_EXNOT(c),t,e) #define NEW_CASE(h,b) newnode(NODE_CASE,h,b,Qnil) #define NEW_WHEN(c,t,e) newnode(NODE_WHEN,c,t,e) #define NEW_WHILE(c,b) newnode(NODE_WHILE,c,b,Qnil) -#define NEW_UNTIL(c,b) newnode(NODE_WHILE,NEW_EXNOT(c),b,Qnil) #define NEW_WHILE2(c,b) newnode(NODE_WHILE2,c,b,Qnil) -#define NEW_UNTIL2(c,b) newnode(NODE_WHILE2,NEW_EXNOT(c),b,Qnil) #define NEW_FOR(v,i,b) newnode(NODE_FOR,v,b,i) #define NEW_ITER(v,i,b) newnode(NODE_ITER,v,b,i) #define NEW_PROT(b,ex,en) newnode(NODE_PROT,b,ex,en) @@ -204,6 +201,7 @@ typedef struct RNode { #define NEW_HASH(a) newnode(NODE_HASH,a,Qnil,Qnil) #define NEW_AND(a,b) newnode(NODE_AND,a,b,Qnil) #define NEW_OR(a,b) newnode(NODE_OR,a,b,Qnil) +#define NEW_NOT(a) newnode(NODE_NOT,Qnil,a,Qnil) #define NEW_MASGN(l,r) newnode(NODE_MASGN,l,r,Qnil) #define NEW_GASGN(v,val) newnode(NODE_GASGN,v,val,rb_global_entry(v)) #define NEW_LASGN(v,val) newnode(NODE_LASGN,v,val,local_cnt(v)) diff --git a/numeric.c b/numeric.c index 5b88a35454..cab3c69db3 100644 --- a/numeric.c +++ b/numeric.c @@ -332,7 +332,7 @@ static VALUE Fflo_eq(x, y) struct RFloat *x, *y; { - switch (TYPE(y)) { + switch (TYPE(y)) { case T_NIL: return Qnil; case T_FIXNUM: @@ -676,7 +676,7 @@ Ffix_equal(x, y) VALUE x, y; { if (FIXNUM_P(y)) { - return (FIX2INT(x) == FIX2INT(y))?TRUE:FALSE; + return (FIX2INT(x) == FIX2INT(y))?TRUE:FALSE; } else if (NIL_P(y)) { return Qnil; @@ -692,7 +692,7 @@ Ffix_cmp(x, y) { if (FIXNUM_P(y)) { int a = FIX2INT(x), b = FIX2INT(y); - + if (a == b) return INT2FIX(0); if (a > b) return INT2FIX(1); return INT2FIX(-1); @@ -708,7 +708,7 @@ Ffix_gt(x, y) { if (FIXNUM_P(y)) { int a = FIX2INT(x), b = FIX2INT(y); - + if (a > b) return TRUE; return FALSE; } @@ -723,7 +723,7 @@ Ffix_ge(x, y) { if (FIXNUM_P(y)) { int a = FIX2INT(x), b = FIX2INT(y); - + if (a >= b) return TRUE; return FALSE; } @@ -738,7 +738,7 @@ Ffix_lt(x, y) { if (FIXNUM_P(y)) { int a = FIX2INT(x), b = FIX2INT(y); - + if (a < b) return TRUE; return FALSE; } @@ -753,7 +753,7 @@ Ffix_le(x, y) { if (FIXNUM_P(y)) { int a = FIX2INT(x), b = FIX2INT(y); - + if (a <= b) return TRUE; return FALSE; } diff --git a/object.c b/object.c index e71043fdde..a35e683cdd 100644 --- a/object.c +++ b/object.c @@ -3,7 +3,7 @@ object.c - $Author: matz $ - $Date: 1995/01/10 10:42:44 $ + $Date: 1995/01/12 08:54:49 $ created at: Thu Jul 15 12:01:24 JST 1993 Copyright (C) 1994 Yukihiro Matsumoto @@ -12,7 +12,6 @@ #include "ruby.h" #include "env.h" -#include "node.h" #include "st.h" #include @@ -31,6 +30,7 @@ VALUE obj_responds_to(); VALUE obj_alloc(); static ID eq, match; +static ID init_object; static VALUE P_true(obj) @@ -75,26 +75,6 @@ Fkrn_id(obj) return obj | FIXNUM_FLAG; } -static VALUE -Fkrn_noteq(obj, other) - VALUE obj, other; -{ - if (rb_equal(obj, other)) { - return FALSE; - } - return TRUE; -} - -static VALUE -Fkrn_nmatch(obj, other) - VALUE obj, other; -{ - if (rb_funcall(obj, match, 1, other)) { - return FALSE; - } - return TRUE; -} - static VALUE Fkrn_class(obj) struct RBasic *obj; @@ -145,7 +125,7 @@ obj_inspect(id, value, str) static VALUE Fobj_inspect(obj) - struct RBasic *obj; + struct RObject *obj; { VALUE str; char buf[256]; @@ -212,14 +192,21 @@ Fobj_clone(obj) Check_Type(obj, T_OBJECT); clone = obj_alloc(RBASIC(obj)->class); - if (RBASIC(obj)->iv_tbl) { - RBASIC(clone)->iv_tbl = st_copy(RBASIC(obj)->iv_tbl); + if (ROBJECT(obj)->iv_tbl) { + ROBJECT(clone)->iv_tbl = st_copy(ROBJECT(obj)->iv_tbl); } RBASIC(clone)->class = single_class_clone(RBASIC(obj)->class); return clone; } +static VALUE +Fobj_init_object(obj) + VALUE obj; +{ + return Qnil; +} + static VALUE Fnil_to_s(obj) VALUE obj; @@ -282,7 +269,10 @@ Fcls_new(argc, argv, class) VALUE *argv; VALUE class; { - return obj_alloc(class); + VALUE obj = obj_alloc(class); + + rb_funcall2(obj, init_object, argc, argv); + return obj; } static VALUE @@ -377,6 +367,13 @@ Fdo() return rb_yield(Qnil); } +Fforever() +{ + for (;;) { + rb_yield(Qnil); + } +} + VALUE TopSelf; VALUE TRUE = 1; @@ -424,16 +421,14 @@ Init_Object() * + All metaclasses are instances of the class `Class'. */ + rb_define_method(C_Kernel, "is_nil", P_false, 0); - rb_define_method(C_Kernel, "!", P_false, 0); rb_define_method(C_Kernel, "==", Fkrn_equal, 1); rb_define_alias(C_Kernel, "equal", "=="); rb_define_method(C_Kernel, "hash", Fkrn_id, 0); rb_define_method(C_Kernel, "id", Fkrn_id, 0); rb_define_method(C_Kernel, "class", Fkrn_class, 0); - rb_define_method(C_Kernel, "!=", Fkrn_noteq, 1); rb_define_alias(C_Kernel, "=~", "=="); - rb_define_method(C_Kernel, "!~", Fkrn_nmatch, 1); rb_define_method(C_Kernel, "to_a", Fkrn_to_a, 0); rb_define_method(C_Kernel, "to_s", Fkrn_to_s, 0); @@ -443,8 +438,11 @@ Init_Object() rb_define_alias(C_Kernel, "format", "sprintf"); rb_define_private_method(C_Kernel, "do", Fdo, 0); + rb_define_private_method(C_Kernel, "forever", Fforever, 0); - rb_define_method(C_Object, "_inspect", Fobj_inspect, 0); + rb_define_private_method(C_Object, "init_object", Fobj_init_object, -1); + + rb_define_method(C_Object, "clone", Fobj_clone, 0); rb_define_method(C_Object, "responds_to", obj_responds_to, 1); rb_define_method(C_Object, "is_member_of", obj_is_member_of, 1); @@ -465,7 +463,6 @@ Init_Object() rb_define_method(C_Nil, "class", Fnil_class, 0); rb_define_method(C_Nil, "is_nil", P_true, 0); - rb_define_method(C_Nil, "!", P_true, 0); /* default addition */ rb_define_method(C_Nil, "+", Fnil_plus, 1); @@ -475,7 +472,6 @@ Init_Object() rb_define_method(C_Data, "class", Fdata_class, 0); eq = rb_intern("=="); - match = rb_intern("=~"); Qself = TopSelf = obj_alloc(C_Object); rb_define_single_method(TopSelf, "to_s", Fmain_to_s, 0); @@ -484,5 +480,6 @@ Init_Object() rb_define_single_method(TRUE, "to_s", Ftrue_to_s, 0); rb_define_const(C_Kernel, "%TRUE", TRUE); rb_define_const(C_Kernel, "%FALSE", FALSE); -} + init_object = rb_intern("init_object"); +} diff --git a/parse.y b/parse.y index c4148d88d3..7c84221c8c 100644 --- a/parse.y +++ b/parse.y @@ -3,7 +3,7 @@ parse.y - $Author: matz $ - $Date: 1995/01/10 10:42:45 $ + $Date: 1995/01/12 08:54:50 $ created at: Fri May 28 18:02:42 JST 1993 Copyright (C) 1994 Yukihiro Matsumoto @@ -50,7 +50,7 @@ static enum lex_state { static ID cur_class = Qnil, cur_mid = Qnil; static int in_module, in_single; -static void value_expr(); +static int value_expr(); static NODE *cond(); static NODE *cond2(); @@ -96,8 +96,6 @@ static void setup_top_local(); ELSE CASE WHEN - UNLESS - UNTIL WHILE FOR IN @@ -120,9 +118,7 @@ static void setup_top_local(); _FILE_ _LINE_ IF_MOD - UNLESS_MOD WHILE_MOD - UNTIL_MOD ALIAS %token IDENTIFIER GVAR IVAR CONSTANT @@ -131,14 +127,14 @@ static void setup_top_local(); %type singleton inc_list %type literal numeric -%type compstmts stmts stmt stmt0 expr expr0 var_ref +%type compexpr exprs expr arg primary var_ref %type if_tail opt_else case_body cases resque ensure -%type call_args call_args0 args args2 array +%type call_args call_args0 args args2 opt_args %type f_arglist f_args assoc_list assocs assoc %type mlhs mlhs_head mlhs_tail lhs iter_var opt_iter_var %type superclass variable symbol %type fname op rest_arg -%type f_arg +%type f_arg %token UPLUS /* unary+ */ %token UMINUS /* unary- */ %token POW /* ** */ @@ -156,11 +152,13 @@ static void setup_top_local(); %token OP_ASGN /* +=, -= etc. */ %token ASSOC /* => */ %token LPAREN LBRACK LBRACE +%token SYMBEG /* * precedence table */ +%left IF_MOD WHILE_MOD %left OR %left AND %left YIELD RETURN FAIL @@ -186,91 +184,74 @@ program : { lex_state = EXPR_BEG; init_top_local(); } - compstmts + compexpr { eval_tree = block_append(eval_tree, $2); setup_top_local(); } -compstmts : stmts opt_term +compexpr : exprs opt_term -stmts : /* none */ +exprs : /* none */ { $$ = Qnil; } - | stmt - | stmts term stmt + | expr + | exprs term expr { $$ = block_append($1, $3); } - | stmts error + | exprs error { lex_state = EXPR_BEG; } - stmt + expr { yyerrok; $$ = block_append($1, $4); } -stmt : CLASS IDENTIFIER superclass +expr : mlhs '=' args2 { - if (cur_class || cur_mid || in_single) - Error("nested class definition"); - cur_class = $2; - push_local(); + value_expr($3); + $1->nd_value = $3; + $$ = $1; } - compstmts - END + | assocs { - $$ = NEW_CLASS($2, $5, $3); - pop_local(); - cur_class = Qnil; + $$ = NEW_HASH($1); } - | MODULE IDENTIFIER + | RETURN args2 { - if (cur_class != Qnil) - Error("nested module definition"); - cur_class = $2; - in_module = 1; - push_local(); + value_expr($2); + if (!cur_mid && !in_single) + Error("return appeared outside of method"); + $$ = NEW_RET($2); } - compstmts - END + | FAIL args2 { - $$ = NEW_MODULE($2, $4); - pop_local(); - cur_class = Qnil; - in_module = 0; + value_expr($2); + $$ = NEW_FAIL($2); } - | DEF fname + | YIELD args2 { - if (cur_mid || in_single) - Error("nested method definition"); - cur_mid = $2; - push_local(); + value_expr($2); + $$ = NEW_YIELD($2); } - f_arglist - compstmts - END + | IDENTIFIER call_args0 { - $$ = NEW_DEFN($2, NEW_RFUNC($4, $5), cur_class?0:1); - pop_local(); - cur_mid = Qnil; + $$ = NEW_CALL(Qnil, $1, $2); } - | DEF singleton '.' fname + | primary '.' IDENTIFIER call_args0 { - value_expr($2); - in_single++; - push_local(); + value_expr($1); + $$ = NEW_CALL($1, $3, $4); } - f_arglist - compstmts - END + | SUPER call_args0 { - $$ = NEW_DEFS($2, $4, NEW_RFUNC($6, $7)); - pop_local(); - in_single--; + if (!cur_mid && !in_single) + Error("super called outside of method"); + $$ = NEW_SUPER($2); } | UNDEF fname { @@ -286,100 +267,31 @@ stmt : CLASS IDENTIFIER superclass Error("include appeared in method definition"); $$ = $2; } - | stmt0 IF_MOD stmt0 + | expr IF_MOD expr { $$ = NEW_IF(cond($3), $1, Qnil); } - | stmt0 UNLESS_MOD stmt0 - { - $$ = NEW_UNLESS(cond($3), $1, Qnil); - } - | stmt0 WHILE_MOD stmt0 + | expr WHILE_MOD expr { $$ = NEW_WHILE2(cond($3), $1); } - | stmt0 UNTIL_MOD stmt0 - { - $$ = NEW_UNTIL2(cond($3), $1); - } - | stmt AND stmt + | expr AND expr { $$ = NEW_AND(cond($1), cond($3)); } - | stmt OR stmt + | expr OR expr { $$ = NEW_OR(cond($1), cond($3)); } - | stmt0 - -stmt0 : mlhs '=' args2 - { - $1->nd_value = $3; - $$ = $1; - } - | REDO - { - $$ = NEW_REDO(); - } - | BREAK - { - $$ = NEW_BREAK(); - } - | CONTINUE - { - $$ = NEW_CONT(); - } - | RETRY - { - $$ = NEW_RETRY(); - } - | RETURN args2 - { - value_expr($2); - if (!cur_mid && !in_single) - Error("return appeared outside of method"); - $$ = NEW_RET($2); - } - | RETURN - { - if (!cur_mid && !in_single) - Error("return appeared outside of method"); - $$ = NEW_RET(Qnil); - } - | FAIL args2 - { - value_expr($2); - $$ = NEW_FAIL($2); - } - | YIELD args2 - { - value_expr($2); - $$ = NEW_YIELD($2); - } - | IDENTIFIER call_args0 - { - $$ = NEW_CALL(Qnil, $1, $2); - } - | expr0 '.' IDENTIFIER call_args0 - { - value_expr($1); - $$ = NEW_CALL($1, $3, $4); - } - | SUPER call_args0 - { - if (!cur_mid && !in_single) - Error("super called outside of method"); - $$ = NEW_SUPER($2); - } - | expr + | arg mlhs : mlhs_head { - $$ = NEW_MASGN(NEW_LIST($1),Qnil); + $$ = NEW_MASGN(NEW_LIST($1), Qnil); } | mlhs_head '*' lhs { - $$ = NEW_MASGN(NEW_LIST($1),$3); + $$ = NEW_MASGN(NEW_LIST($1), $3); } | mlhs_head mlhs_tail { @@ -390,18 +302,7 @@ mlhs : mlhs_head $$ = NEW_MASGN(list_concat(NEW_LIST($1),$2),$5); } -mlhs_head : variable comma - { - $$ = asignable($1, Qnil); - } - | expr0 '[' args rbracket comma - { - $$ = aryset($1, $3, Qnil); - } - | expr0 '.' IDENTIFIER comma - { - $$ = attrset($1, $3, Qnil); - } +mlhs_head : lhs comma mlhs_tail : lhs { @@ -416,24 +317,15 @@ lhs : variable { $$ = asignable($1, Qnil); } - | expr0 '[' args rbracket + | primary '[' opt_args rbracket { $$ = aryset($1, $3, Qnil); } - | expr0 '.' IDENTIFIER + | primary '.' IDENTIFIER { $$ = attrset($1, $3, Qnil); } -superclass : /* none */ - { - $$ = Qnil; - } - | ':' IDENTIFIER - { - $$ = $2; - } - inc_list : IDENTIFIER { $$ = NEW_INC($1); @@ -467,9 +359,7 @@ op : COLON2 { $$ = COLON2; } | '&' { $$ = '&'; } | CMP { $$ = CMP; } | EQ { $$ = EQ; } - | NEQ { $$ = NEQ; } | MATCH { $$ = MATCH; } - | NMATCH { $$ = NMATCH; } | '>' { $$ = '>'; } | GEQ { $$ = GEQ; } | '<' { $$ = '<'; } @@ -482,119 +372,26 @@ op : COLON2 { $$ = COLON2; } | '/' { $$ = '/'; } | '%' { $$ = '%'; } | POW { $$ = POW; } - | '!' { $$ = '!'; } | '~' { $$ = '~'; } | UPLUS { $$ = UMINUS; } | UMINUS { $$ = UPLUS; } | AREF { $$ = AREF; } | ASET { $$ = ASET; } -f_arglist : '(' f_args rparen - { - $$ = $2; - } - | term - { - $$ = NEW_ARGS(0, -1); - } - -f_args : /* no arg */ - { - $$ = NEW_ARGS(0, -1); - } - | f_arg - { - $$ = NEW_ARGS($1, -1); - } - | f_arg comma rest_arg - { - $$ = NEW_ARGS($1, $3); - } - | rest_arg - { - $$ = NEW_ARGS(Qnil, $1); - } - | f_arg error - { - lex_state = EXPR_BEG; - $$ = NEW_ARGS($1, -1); - } - | error - { - lex_state = EXPR_BEG; - $$ = NEW_ARGS(0, -1); - } - -f_arg : IDENTIFIER - { - if (!is_local_id($1)) - Error("formal argument must be local variable"); - local_cnt($1); - $$ = 1; - } - | f_arg comma IDENTIFIER - { - if (!is_local_id($3)) - Error("formal argument must be local variable"); - local_cnt($3); - $$ += 1; - } - -rest_arg : '*' IDENTIFIER - { - if (!is_local_id($2)) - Error("rest argument must be local variable"); - $$ = local_cnt($2); - } - -singleton : var_ref - { - if (nd_type($1) == NODE_SELF) { - $$ = NEW_SELF(); - } - else if (nd_type($1) == NODE_NIL) { - Error("Can't define single method for nil."); - $$ = Qnil; - } - else { - $$ = $1; - } - } - | LPAREN compstmts rparen - { - switch (nd_type($2)) { - case NODE_STR: - case NODE_STR2: - case NODE_XSTR: - case NODE_XSTR2: - case NODE_DREGX: - case NODE_DGLOB: - case NODE_LIT: - case NODE_ARRAY: - case NODE_ZARRAY: - Error("Can't define single method for literals."); - default: - break; - } - $$ = $2; - } - -expr : variable '=' expr +arg : variable '=' arg { value_expr($3); $$ = asignable($1, $3); } - | expr0 '[' args rbracket '=' expr + | primary '[' opt_args rbracket '=' arg { - value_expr($6); $$ = aryset($1, $3, $6); } - | expr0 '.' IDENTIFIER '=' expr + | primary '.' IDENTIFIER '=' arg { - value_expr($5); $$ = attrset($1, $3, $5); } - | variable OP_ASGN expr + | variable OP_ASGN arg { NODE *val; @@ -613,27 +410,31 @@ expr : variable '=' expr } $$ = asignable($1, call_op(val, $2, 1, $3)); } - | expr0 '[' args rbracket OP_ASGN expr + | primary '[' opt_args rbracket OP_ASGN arg { - $$ = NEW_OP_ASGN1($1,$5,list_concat(NEW_LIST($6),$3)); + NODE *args = NEW_LIST($6); + + if ($3) list_concat(args, $3); + $$ = NEW_OP_ASGN1($1, $5, args); } - | expr0 '.' IDENTIFIER OP_ASGN expr + | primary '.' IDENTIFIER OP_ASGN arg { $$ = NEW_OP_ASGN2($1, $4, $5); } - | expr DOT2 expr + | arg DOT2 arg { $$ = call_op($1, DOT2, 1, $3); } - | expr DOT3 expr + | arg DOT3 arg { $$ = NEW_DOT3(cond2($1), cond2($3)); } - | expr '+' expr + | arg '+' arg { $$ = Qnil; if ($1 && $3 - && (nd_type($3) == NODE_LIT || nd_type($3) == NODE_STR) + && (nd_type($3) == NODE_LIT + || nd_type($3) == NODE_STR) && nd_type($1) == NODE_CALL && $1->nd_mid == '+') { if ($1->nd_args->nd_head == Qnil) Bug("bad operand for `+'"); @@ -648,87 +449,87 @@ expr : variable '=' expr $$ = call_op($1, '+', 1, $3); } } - | expr '-' expr + | arg '-' arg { $$ = call_op($1, '-', 1, $3); } - | expr '*' expr + | arg '*' arg { $$ = call_op($1, '*', 1, $3); } - | expr '/' expr + | arg '/' arg { $$ = call_op($1, '/', 1, $3); } - | expr '%' expr + | arg '%' arg { $$ = call_op($1, '%', 1, $3); } - | expr POW expr + | arg POW arg { $$ = call_op($1, POW, 1, $3); } - | UPLUS expr + | UPLUS arg { $$ = call_op($2, UPLUS, 0); } - | UMINUS expr + | UMINUS arg { $$ = call_op($2, UMINUS, 0); } - | expr '|' expr + | arg '|' arg { $$ = call_op($1, '|', 1, $3); } - | expr '^' expr + | arg '^' arg { $$ = call_op($1, '^', 1, $3); } - | expr '&' expr + | arg '&' arg { $$ = call_op($1, '&', 1, $3); } - | expr CMP expr + | arg CMP arg { $$ = call_op($1, CMP, 1, $3); } - | expr '>' expr + | arg '>' arg { $$ = call_op($1, '>', 1, $3); } - | expr GEQ expr + | arg GEQ arg { $$ = call_op($1, GEQ, 1, $3); } - | expr '<' expr + | arg '<' arg { $$ = call_op($1, '<', 1, $3); } - | expr LEQ expr + | arg LEQ arg { $$ = call_op($1, LEQ, 1, $3); } - | expr EQ expr + | arg EQ arg { $$ = call_op($1, EQ, 1, $3); } - | expr NEQ expr + | arg NEQ arg { - $$ = call_op($1, NEQ, 1, $3); + $$ = NEW_NOT(call_op($1, EQ, 1, $3)); } - | expr MATCH expr + | arg MATCH arg { $$ = NEW_CALL($1, MATCH, NEW_LIST($3)); } - | expr NMATCH expr + | arg NMATCH arg { - $$ = NEW_CALL($1, NMATCH, NEW_LIST($3)); + $$ = NEW_NOT(NEW_CALL($1, MATCH, NEW_LIST($3))); } - | '!' expr + | '!' arg { - $$ = call_op($2, '!', 0); + $$ = NEW_NOT(cond($2)); } - | '~' expr + | '~' arg { if ($2 && (nd_type($2) == NODE_STR @@ -741,27 +542,27 @@ expr : variable '=' expr $$ = call_op($2, '~', 0); } } - | expr LSHFT expr + | arg LSHFT arg { $$ = call_op($1, LSHFT, 1, $3); } - | expr RSHFT expr + | arg RSHFT arg { $$ = call_op($1, RSHFT, 1, $3); } - | expr COLON2 expr + | arg COLON2 arg { $$ = call_op($1, COLON2, 1, $3); } - | expr ANDOP expr + | arg ANDOP arg { $$ = NEW_AND(cond($1), cond($3)); } - | expr OROP expr + | arg OROP arg { $$ = NEW_OR(cond($1), cond($3)); } - |expr0 + | primary { $$ = $1; } @@ -771,23 +572,37 @@ call_args : /* none */ $$ = Qnil; } | call_args0 - | '*' expr + | '*' arg { $$ = $2; } call_args0 : args - | args comma '*' expr + | assocs + { + $$ = NEW_LIST(NEW_HASH($1)); + } + | args comma assocs + { + $$ = list_append($1, NEW_HASH($3)); + } + | args comma '*' arg { $$ = call_op($1, '+', 1, $4); } -args : expr +opt_args : /* none */ + { + $$ = Qnil; + } + | args + +args : arg { value_expr($1); $$ = NEW_LIST($1); } - | args comma expr + | args comma arg { value_expr($3); $$ = list_append($1, $3); @@ -803,7 +618,7 @@ args2 : args } } -expr0 : literal +primary : literal { $$ = NEW_LIT($1); } @@ -820,10 +635,6 @@ expr0 : literal | DREGEXP | DGLOB | var_ref - | IDENTIFIER '(' call_args rparen - { - $$ = NEW_CALL(Qnil, $1, $3); - } | SUPER '(' call_args rparen { if (!cur_mid && !in_single) @@ -836,13 +647,12 @@ expr0 : literal Error("super called outside of method"); $$ = NEW_ZSUPER(); } - - | expr0 '[' args rbracket + | primary '[' opt_args rbracket { value_expr($1); $$ = NEW_CALL($1, AREF, $3); } - | LBRACK array rbracket + | LBRACK opt_args rbracket { if ($2 == Qnil) $$ = NEW_ZARRAY(); /* zero length array*/ @@ -854,8 +664,33 @@ expr0 : literal { $$ = NEW_HASH($2); } + | REDO + { + $$ = NEW_REDO(); + } + | BREAK + { + $$ = NEW_BREAK(); + } + | CONTINUE + { + $$ = NEW_CONT(); + } + | RETRY + { + $$ = NEW_RETRY(); + } + | RETURN + { + if (!cur_mid && !in_single) + Error("return appeared outside of method"); + $$ = NEW_RET(Qnil); + } | FAIL '(' args2 ')' { + if (nd_type($3) == NODE_ARRAY) { + Error("wrong number of argument to fail(0 or 1)"); + } value_expr($3); $$ = NEW_FAIL($3); } @@ -880,7 +715,7 @@ expr0 : literal { $$ = NEW_YIELD(Qnil); } - | expr0 '{' opt_iter_var '|' compstmts rbrace + | primary '{' opt_iter_var '|' compexpr rbrace { if (nd_type($1) == NODE_LVAR || nd_type($1) == NODE_MVAR) { @@ -888,52 +723,47 @@ expr0 : literal } $$ = NEW_ITER($3, $1, $5); } - | expr0 '.' IDENTIFIER '(' call_args rparen + | IDENTIFIER '(' call_args rparen + { + $$ = NEW_CALL(Qnil, $1, $3); + } + | primary '.' IDENTIFIER '(' call_args rparen { value_expr($1); $$ = NEW_CALL($1, $3, $5); } - | expr0 '.' IDENTIFIER + | primary '.' IDENTIFIER { value_expr($1); $$ = NEW_CALL($1, $3, Qnil); } - | IF stmt0 then - compstmts + | IF expr then + compexpr if_tail END { $$ = NEW_IF(cond($2), $4, $5); } - | UNLESS stmt0 then - compstmts opt_else END - { - $$ = NEW_UNLESS(cond($2), $4, $5); - } - | WHILE stmt0 term compstmts END + | WHILE expr term compexpr END { $$ = NEW_WHILE(cond($2), $4); } - | UNTIL stmt0 term compstmts END - { - $$ = NEW_UNTIL(cond($2), $4); - } - | CASE compstmts + | CASE compexpr case_body END { value_expr($2); $$ = NEW_CASE($2, $3); } - | FOR iter_var IN stmt0 term - compstmts + | FOR iter_var IN expr term + compexpr END { value_expr($4); $$ = NEW_FOR($2, $4, $6); } | PROTECT - compstmts + compexpr resque ensure END @@ -946,18 +776,77 @@ expr0 : literal $$ = NEW_PROT($2, $3, $4); } } - | LPAREN compstmts rparen + | LPAREN compexpr rparen { $$ = $2; } + | CLASS IDENTIFIER superclass + { + if (cur_class || cur_mid || in_single) + Error("nested class definition"); + cur_class = $2; + push_local(); + } + compexpr + END + { + $$ = NEW_CLASS($2, $5, $3); + pop_local(); + cur_class = Qnil; + } + | MODULE IDENTIFIER + { + if (cur_class != Qnil) + Error("nested module definition"); + cur_class = $2; + in_module = 1; + push_local(); + } + compexpr + END + { + $$ = NEW_MODULE($2, $4); + pop_local(); + cur_class = Qnil; + in_module = 0; + } + | DEF fname + { + if (cur_mid || in_single) + Error("nested method definition"); + cur_mid = $2; + push_local(); + } + f_arglist + compexpr + END + { + $$ = NEW_DEFN($2, NEW_RFUNC($4, $5), cur_class?0:1); + pop_local(); + cur_mid = Qnil; + } + | DEF singleton '.' fname + { + value_expr($2); + in_single++; + push_local(); + } + f_arglist + compexpr + END + { + $$ = NEW_DEFS($2, $4, NEW_RFUNC($6, $7)); + pop_local(); + in_single--; + } then : term | THEN | term THEN if_tail : opt_else - | ELSIF stmt0 then - compstmts + | ELSIF expr then + compexpr if_tail { $$ = NEW_IF(cond($2), $4, $5); @@ -967,7 +856,7 @@ opt_else : /* none */ { $$ = Qnil; } - | ELSE compstmts + | ELSE compexpr { $$ = $2; } @@ -982,7 +871,7 @@ opt_iter_var : /* none */ | iter_var case_body : WHEN args then - compstmts + compexpr cases { $$ = NEW_WHEN($2, $4, $5); @@ -990,7 +879,7 @@ case_body : WHEN args then cases : opt_else | WHEN args then - compstmts + compexpr cases { $$ = NEW_WHEN($2, $4, $5); @@ -1000,7 +889,7 @@ resque : /* none */ { $$ = Qnil; } - | RESQUE compstmts + | RESQUE compexpr { if ($2 == Qnil) $$ = (NODE*)1; @@ -1012,26 +901,19 @@ ensure : /* none */ { $$ = Qnil; } - | ENSURE compstmts + | ENSURE compexpr { $$ = $2; } -array : /* none */ - { - $$ = Qnil; - } - | args - literal : numeric - | '\\' symbol + | SYMBEG symbol { $$ = INT2FIX($2); } | REGEXP | GLOB - symbol : fname | IVAR | GVAR @@ -1058,11 +940,121 @@ var_ref : variable $$ = gettable($1); } +superclass : term + { + $$ = Qnil; + } + | colon + { + lex_state = EXPR_BEG; + } + IDENTIFIER + { + $$ = $3; + } + +f_arglist : '(' f_args rparen + { + $$ = $2; + } + | term + { + $$ = NEW_ARGS(0, -1); + } + +f_args : /* no arg */ + { + $$ = NEW_ARGS(0, -1); + } + | f_arg + { + $$ = NEW_ARGS($1, -1); + } + | f_arg comma rest_arg + { + $$ = NEW_ARGS($1, $3); + } + | rest_arg + { + $$ = NEW_ARGS(Qnil, $1); + } + | f_arg error + { + lex_state = EXPR_BEG; + $$ = NEW_ARGS($1, -1); + } + | error + { + lex_state = EXPR_BEG; + $$ = NEW_ARGS(0, -1); + } + +f_arg : IDENTIFIER + { + if (!is_local_id($1)) + Error("formal argument must be local variable"); + local_cnt($1); + $$ = 1; + } + | f_arg comma IDENTIFIER + { + if (!is_local_id($3)) + Error("formal argument must be local variable"); + local_cnt($3); + $$ += 1; + } + +rest_arg : '*' IDENTIFIER + { + if (!is_local_id($2)) + Error("rest argument must be local variable"); + $$ = local_cnt($2); + } + +singleton : var_ref + { + if (nd_type($1) == NODE_SELF) { + $$ = NEW_SELF(); + } + else if (nd_type($1) == NODE_NIL) { + Error("Can't define single method for nil."); + $$ = Qnil; + } + else { + $$ = $1; + } + } + | LPAREN compexpr rparen + { + switch (nd_type($2)) { + case NODE_STR: + case NODE_STR2: + case NODE_XSTR: + case NODE_XSTR2: + case NODE_DREGX: + case NODE_DGLOB: + case NODE_LIT: + case NODE_ARRAY: + case NODE_ZARRAY: + Error("Can't define single method for literals."); + default: + break; + } + $$ = $2; + } + assoc_list : /* none */ { $$ = Qnil; } | assocs + | args + { + if ($1->nd_alen%2 != 0) { + Error("odd number list for Dict"); + } + $$ = $1; + } assocs : assoc | assocs comma assoc @@ -1070,12 +1062,11 @@ assocs : assoc $$ = list_concat($1, $3); } -assoc : expr ASSOC expr +assoc : arg ASSOC arg { $$ = list_append(NEW_LIST($1), $3); } - opt_term : /* none */ | term @@ -1085,6 +1076,9 @@ term : sc sc : ';' { yyerrok; } nl : '\n' { yyerrok; } +colon : ':' + | SYMBEG + rparen : ')' { yyerrok; } rbracket : ']' { yyerrok; } rbrace : '}' { yyerrok; } @@ -1196,10 +1190,6 @@ parse_regx() else if (in_brack && c == 'b') { tokadd('\b'); } - else if (isdigit(c)) { - tokadd('\\'); - tokadd(c); - } else { pushback(); read_escape(LEAVE_BS); @@ -1348,8 +1338,6 @@ static struct kwtable { "super", SUPER, EXPR_END, "then", THEN, EXPR_BEG, "undef", UNDEF, EXPR_FNAME, - "unless", UNLESS, EXPR_BEG, - "until", UNTIL, EXPR_BEG, "when", WHEN, EXPR_BEG, "while", WHILE, EXPR_BEG, "yield", YIELD, EXPR_END, @@ -1406,13 +1394,6 @@ retry: return '*'; case '!': - if (lex_state == EXPR_FNAME) { - if ((c = nextc()) == '@') { - lex_state = EXPR_BEG; - return '!'; - } - pushback(); - } lex_state = EXPR_BEG; if ((c = nextc()) == '=') { return NEQ; @@ -1737,12 +1718,15 @@ retry: return c; case ':': - lex_state = EXPR_BEG; - if (nextc() == ':') { + c = nextc(); + if (c == ':') { + lex_state = EXPR_BEG; return COLON2; } pushback(); - return ':'; + if (isspace(c)) + return ':'; + return SYMBEG; case '/': if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { @@ -1786,7 +1770,6 @@ retry: return c; case '[': - if (lex_state == EXPR_BEG || lex_state == EXPR_MID) c = LBRACK; else if (lex_state == EXPR_FNAME) { @@ -1811,8 +1794,10 @@ retry: case '\\': c = nextc(); - if (c == '\n') goto retry; /* skip \\n */ - lex_state = EXPR_FNAME; + if (c == '\n') { + sourceline++; + goto retry; /* skip \\n */ + } pushback(); return '\\'; @@ -1910,9 +1895,7 @@ retry: lex_state = mid->state; if (state != EXPR_BEG) { if (mid->id == IF) return IF_MOD; - if (mid->id == UNLESS) return UNLESS_MOD; if (mid->id == WHILE) return WHILE_MOD; - if (mid->id == UNTIL) return UNTIL_MOD; } return mid->id; } @@ -2444,6 +2427,7 @@ aryset(recv, idx, val) NODE *recv, *idx, *val; { value_expr(recv); + value_expr(val); return NEW_CALL(recv, ASET, list_append(idx, val)); } @@ -2453,18 +2437,19 @@ attrset(recv, id, val) ID id; { value_expr(recv); + value_expr(val); id &= ~ID_SCOPE_MASK; id |= ID_ATTRSET; - return NEW_CALL(recv, id, NEW_ARRAY(val)); + return NEW_CALL(recv, id, NEW_LIST(val)); } -static void +static int value_expr(node) NODE *node; { - if (node == Qnil) return; + if (node == Qnil) return TRUE; switch (nd_type(node)) { case NODE_RETURN: @@ -2472,25 +2457,29 @@ value_expr(node) case NODE_BREAK: case NODE_REDO: case NODE_RETRY: + case NODE_FAIL: case NODE_WHILE: case NODE_WHILE2: case NODE_INC: case NODE_CLASS: case NODE_MODULE: + case NODE_DEFN: + case NODE_DEFS: Error("void value expression"); + return FALSE; break; case NODE_BLOCK: while (node->nd_next) { node = node->nd_next; } - if (node) { - value_expr(node->nd_head); - } - break; + return value_expr(node->nd_head); + + case NODE_IF: + return value_expr(node->nd_body) && value_expr(node->nd_else); default: - break; + return TRUE; } } @@ -2635,8 +2624,8 @@ init_top_local() lvtbl->cnt = 0; } if (lvtbl->cnt > 0) { - lvtbl->tbl = ALLOC_N(ID, lvtbl->cnt); - MEMCPY(lvtbl->tbl, the_scope->local_tbl, VALUE, lvtbl->cnt); + lvtbl->tbl = ALLOC_N(ID, lvtbl->cnt+1); + MEMCPY(lvtbl->tbl, the_scope->local_tbl, ID, lvtbl->cnt); } else { lvtbl->tbl = Qnil; @@ -2892,7 +2881,7 @@ rb_class2name(class) Fail("0x%x is not a class/module", class); } - if (FL_TEST(class, FL_SINGLE)) { + while (FL_TEST(class, FL_SINGLE)) { class = (struct RClass*)class->super; } @@ -2906,3 +2895,23 @@ rb_class2name(class) } Bug("class 0x%x not named", class); } + +static int +const_check(id, val, class) + ID id; + VALUE val; + struct RClass *class; +{ + if (is_const_id(id) && rb_const_bound(class, id)) { + Warning("constant redefined for %s", rb_class2name(class)); + return ST_STOP; + } + return ST_CONTINUE; +} + +void +rb_const_check(class, module) + struct RClass *class, *module; +{ + st_foreach(module->iv_tbl, const_check, class); +} diff --git a/process.c b/process.c index f6de89d855..e8bcaaa3a6 100644 --- a/process.c +++ b/process.c @@ -507,7 +507,7 @@ Init_process() rb_define_module_function(M_Process, "getpriority", Fproc_getpriority, 2); rb_define_module_function(M_Process, "setpriority", Fproc_setpriority, 3); - + rb_define_const(M_Process, "%PRIO_PROCESS", INT2FIX(PRIO_PROCESS)); rb_define_const(M_Process, "%PRIO_PGRP", INT2FIX(PRIO_PGRP)); rb_define_const(M_Process, "%PRIO_USER", INT2FIX(PRIO_USER)); diff --git a/range.c b/range.c index 6274170522..97e68bdf80 100644 --- a/range.c +++ b/range.c @@ -15,7 +15,7 @@ VALUE M_Comparable; VALUE C_Range; -static ID next, eq; +static ID next; static VALUE Srng_new(class, start, end) @@ -156,6 +156,5 @@ Init_Range() rb_define_method(C_Range, "end", Frng_end, 0); rb_define_method(C_Range, "to_s", Frng_to_s, 0); - eq = rb_intern("=="); next = rb_intern("next"); } diff --git a/re.c b/re.c index cdff895aa2..d631d0c165 100644 --- a/re.c +++ b/re.c @@ -76,7 +76,7 @@ str_cicmp(str1, str2) len = min(str1->len, str2->len); p1 = str1->ptr; p2 = str2->ptr; - + for (i = 0; i < len; i++, p1++, p2++) { if (casetable[*p1] != casetable[*p2]) return casetable[*p1] - casetable[*p2]; @@ -97,7 +97,7 @@ int len; /* Build a copy of the string (in dest) with the escaped characters translated, and generate the regex - from that. + from that. */ rp = ALLOC(Regexp); @@ -194,7 +194,7 @@ re_match_post() struct match *match; if (last_match.regs.start[0] == -1) return Qnil; - return str_new(last_match.ptr+last_match.regs.end[0], + return str_new(last_match.ptr+last_match.regs.end[0], last_match.len-last_match.regs.end[0]); } @@ -400,6 +400,36 @@ Sreg_new(argc, argv, self) return Qnil; } +static VALUE +Sreg_quote(re, str) + VALUE re; + struct RString *str; +{ + char *s, *send, *t; + char *tmp; + + Check_Type(str, T_STRING); + + tmp = ALLOCA_N(char, str->len*2); + + s = str->ptr; send = s + str->len; + t = tmp; + + for (; s != send; s++) { + if (*s == '[' || *s == ']' + || *s == '{' || *s == '}' + || *s == '(' || *s == ')' + || *s == '*' || *s == '.' || *s == '\\' + || *s == '?' || *s == '+' + || *s == '^' || *s == '$') { + *t++ = '\\'; + } + *t++ = *s; + } + + return str_new(tmp, t - tmp); +} + static VALUE Freg_clone(re) struct RRegexp *re; @@ -549,6 +579,7 @@ Init_Regexp() C_Regexp = rb_define_class("Regexp", C_Object); rb_define_single_method(C_Regexp, "new", Sreg_new, -1); rb_define_single_method(C_Regexp, "compile", Sreg_new, -1); + rb_define_single_method(C_Regexp, "quote", Sreg_quote, 1); rb_define_method(C_Regexp, "=~", Freg_match, 1); rb_define_method(C_Regexp, "~", Freg_match2, 0); diff --git a/ruby.c b/ruby.c index e22f0b15ce..8029a3e026 100644 --- a/ruby.c +++ b/ruby.c @@ -262,7 +262,7 @@ readin(fd, fname) if (xflag) { char *s = p; - *pend = '\0'; + *pend = '\0'; xflag = FALSE; while (p < pend) { while (s < pend && *s != '\n') s++; diff --git a/ruby.h b/ruby.h index 086c112084..b52bd3c46d 100644 --- a/ruby.h +++ b/ruby.h @@ -1,13 +1,13 @@ /************************************************ - + ruby.h - - + $Author: matz $ - $Date: 1995/01/10 10:42:52 $ + $Date: 1995/01/12 08:54:52 $ created at: Thu Jun 10 14:26:32 JST 1993 - + Copyright (C) 1994 Yukihiro Matsumoto - + *************************************************/ #ifndef RUBY_H @@ -100,13 +100,12 @@ extern VALUE C_Data; #define T_DICT 0x0a #define T_STRUCT 0x0b #define T_BIGNUM 0x0c - -#define T_NODE 0x0d -#define T_SCOPE 0x0e #define T_CONS 0x0f - #define T_DATA 0x10 +#define T_SCOPE 0xfe +#define T_NODE 0xff + #define T_MASK 0xff #define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK) @@ -128,17 +127,17 @@ int num2int(); struct RBasic { UINT flags; VALUE class; - struct st_table *iv_tbl; }; struct RObject { struct RBasic basic; + struct st_table *iv_tbl; }; struct RClass { struct RBasic basic; + struct st_table *iv_tbl; struct st_table *m_tbl; - struct st_table *c_tbl; struct RClass *super; }; @@ -181,7 +180,7 @@ struct RData { #define DATA_PTR(dta) (RDATA(dta)->data) -VALUE data_new(); +VALUE data_new(); VALUE rb_ivar_get_1(); VALUE rb_ivar_set_1(); @@ -222,6 +221,9 @@ struct RCons { VALUE car, cdr; }; +#define CAR(c) (RCONS(c)->car) +#define CDR(c) (RCONS(c)->cdr) + #define R_CAST(st) (struct st*) #define RBASIC(obj) (R_CAST(RBasic)(obj)) #define ROBJECT(obj) (R_CAST(RObject)(obj)) @@ -291,7 +293,9 @@ void rb_define_attr(); ID rb_intern(); char *rb_id2name(); +VALUE rb_eval_string(); VALUE rb_funcall(); +VALUE rb_funcall2(); int rb_scan_args(); VALUE rb_yield(); diff --git a/sample/Artistic b/sample/Artistic new file mode 100644 index 0000000000..fbf7989775 --- /dev/null +++ b/sample/Artistic @@ -0,0 +1,117 @@ + + + + + The "Artistic License" + + Preamble + +The intent of this document is to state the conditions under which a +Package may be copied, such that the Copyright Holder maintains some +semblance of artistic control over the development of the package, +while giving the users of the package the right to use and distribute +the Package in a more-or-less customary fashion, plus the right to make +reasonable modifications. + +Definitions: + + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder. + + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. + + "You" is you, if you're thinking about copying or distributing + this Package. + + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications +derived from the Public Domain or from the Copyright Holder. A Package +modified in such a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided +that you insert a prominent notice in each changed file stating how and +when you changed that file, and provided that you do at least ONE of the +following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or + an equivalent medium, or placing the modifications on a major archive + site such as uunet.uu.net, or by allowing the Copyright Holder to include + your modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and provide + a separate manual page for each non-standard executable that clearly + documents how it differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or +executable form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where + to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) accompany any non-standard executables with their corresponding + Standard Version executables, giving the non-standard executables + non-standard names, and clearly documenting the differences in manual + pages (or equivalent), together with instructions on where to get + the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this Package. +You may not charge a fee for this Package itself. However, +you may distribute this Package in aggregate with other (possibly +commercial) programs as part of a larger (possibly commercial) software +distribution provided that you do not advertise this Package as a +product of your own. + +6. The scripts and library files supplied as input to or produced as +output from the programs of this Package do not automatically fall +under the copyright of this Package, but belong to whomever generated +them, and may be sold commercially, and may be aggregated with this +Package. + +7. C subroutines supplied by you and linked into this Package in order +to emulate subroutines and variables of the language defined by this +Package shall not be considered part of this Package, but are the +equivalent of input as in Paragraph 6, provided these subroutines do +not change the language in any way that would cause it to fail the +regression tests for the language. + +8. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End diff --git a/sample/MANIFEST b/sample/MANIFEST new file mode 100644 index 0000000000..c54adf31ef --- /dev/null +++ b/sample/MANIFEST @@ -0,0 +1,63 @@ +MANIFEST +Artistic +aset.rb +attr.rb +biorhythm.rb +blk.rb +case.rb +cat.rb +cat2.rb +cbreak.rb +clnt.rb +clone.rb +const.rb +dbm.rb +dir.rb +evaldef.rb +export.rb +exyacc.rb +fib.awk +fib.pl +fib.rb +fib.scm +freq.rb +fullpath.pl +fullpath.rb +gctest.rb +gctest2.rb +getopts.rb +getopts.test +hash.rb +io.rb +less.rb +list.rb +list2.rb +list3.rb +math.rb +mpart.rb +occur.pl +occur.rb +occur2.rb +opt_s.rb +opt_x.rb +parsearg.rb +rcs.awk +rcs.dat +rcs.rb +ruby-mode.el +samp.rb +sieve.rb +split.rb +struct.rb +svr.rb +system.rb +t1.rb +t2.rb +test.rb +time.rb +trap.pl +trap.rb +trojan.pl +trojan.rb +tt.rb +uumerge.rb diff --git a/sample/biorhythm.rb b/sample/biorhythm.rb new file mode 100644 index 0000000000..eb14ca7365 --- /dev/null +++ b/sample/biorhythm.rb @@ -0,0 +1,201 @@ +#!/mp/free/bin/ruby +# +# biorhythm.rb - +# $Release Version: $ +# $Revision: 1.6 $ +# $Date: 1994/02/24 10:23:34 $ +# by Yasuo OHBA(STAFS Development Room) +# +# -- +# +# +# + +$RCS_ID="$Header: /var/ohba/RCS/biorhythm.rb,v 1.6 1994/02/24 10:23:34 ohba Exp ohba $" + +include Math +load("parsearg.rb") + +$wochentag = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] +monatstag1 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] +monatstag2 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + +def usage() + print("Usage:\n") + print("biorhythm.rb [options]\n") + print(" options...\n") + print(" -D YYYYMMDD(birthday) : ٤ default ͤȤ. \n") + print(" --sdate | --date YYYYMMDD : system date ⤷ϻꤷդȤ.\n") + print(" --birthday YYYYMMDD : λ򤹤. \n") + print(" -v | -g : Values or Graph λ. \n") + print(" --days DAYS : ֤λ򤹤(Graph λΤͭ). \n") + print(" --help : help\n") +end +$USAGE = 'usage' + +def leapyear(y) + ta = 0 + if ((y % 4.0) == 0); ta = 1; end + if ((y % 100.0) == 0); ta = 0; end + if ((y % 400.0) == 0); ta = 1; end + return ta +end + +def bcalc(tt, m, j) + ta = 0 + if (m <= 2) + ta = (m - 1) * 31 + else + ta = leapyear(j) + ta = ta + ((306 * m - 324) / 10.0).to_i + end + ta = ta + (j - 1) * 365 + ((j - 1) / 4.0).to_i + ta = ta - ((j - 1) / 100) + ((j - 1) / 400.0).to_i + ta = ta + tt + return ta +end + +def printHeader(tg, mg, jg, gtag, tage) + print("\n") + print(" Biorhythm\n") + print(" =========\n") + print("\n") + printf("The birthday %04d.%02d.%02d is a %s\n", jg, mg, tg, $wochentag[gtag]) + printf("Age in days: [%d]\n", tage) +end + +def getPosition(z) + pi = 3.14159265 + $phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi / 180.0))).to_i + $emot = (50.0 * (1.0 + sin((z / 28.0 - (z / 28)) * 360.0 * pi / 180.0))).to_i + $geist =(50.0 * (1.0 + sin((z / 33.0 - (z / 33)) * 360.0 * pi / 180.0))).to_i +end + +# +# main program +# +parseArgs(0, nil, "vg", "D:", "sdate", "date:", "birthday:", "days:") + +printf($stderr, "\n") +printf($stderr, "Biorhythm (c) 1987-1994 V3.0\n") +printf($stderr, "\n") +if ($OPT_D) + dtmp = Time.now.strftime("%Y%m%d") + jh = dtmp[0,4].to_i + mh = dtmp[4,2].to_i + th = dtmp[6,2].to_i + dtmp = $OPT_D + jg = dtmp[0,4].to_i + mg = dtmp[4,2].to_i + tg = dtmp[6,2].to_i + gtag = bcalc(tg, mg, jg) % 7 + ausgabeart = "g" +else + if ($OPT_birthday) + dtmp = $OPT_birthday + else + printf($stderr, "Birthday (YYYYMMDD) : ") + dtmp = $stdin.gets.chop + end + if (dtmp.length != 8) + printf($stderr, "BAD Input Birthday!!\n") + exit() + end + jg = dtmp[0,4].to_i + mg = dtmp[4,2].to_i + tg = dtmp[6,2].to_i + + gtag = bcalc(tg, mg, jg) % 7 + + if ($OPT_sdate) + dtmp = Time.now.strftime("%Y%m%d") + elsif ($OPT_date) + dtmp = $OPT_date + else + printf($stderr, "Date [ for Systemdate] (YYYYMMDD) : ") + dtmp = $stdin.gets.chop + end + if (dtmp.length != 8) + dtmp = Time.now.strftime("%Y%m%d") + end + jh = dtmp[0,4].to_i + mh = dtmp[4,2].to_i + th = dtmp[6,2].to_i + + if ($OPT_v) + ausgabeart = "v" + elsif ($OPT_g) + ausgabeart = "g" + else + printf($stderr, "Values for today or Graph (v/g) [default g] : ") + ausgabeart = $stdin.gets.chop + end +end +if (ausgabeart == "v") + tag = bcalc(tg, mg, jg) + tah = bcalc(th, mh, jh) + tage = tah - tag + printHeader(tg, mg, jg, gtag, tage) + print("\n") + + getPosition(tage) + printf("Biorhythm: %04d.%02d.%02d\n", jh, mh, th) + printf("Physical: %d%%\n", $phys) + printf("Emotional: %d%%\n", $emot) + printf("Mental: %d%%\n", $geist) + print("\n") +else + if ($OPT_days) + ktage = $OPT_days.to_i + else + if ($OPT_D) + ktage = 9 + else + printf($stderr, "Graph for how many days [default 10] : ") + ktage = $stdin.gets.chop + if (ktage == "") + ktage = 9 + else + ktage = ktage.to_i - 1 + end + end + end + tag = bcalc(tg, mg, jg) + tah = bcalc(th, mh, jh) + tage = tah - tag + printHeader(tg, mg, jg, gtag, tage) + print(" P=physical, E=emotional, M=mental\n") + print(" -------------------------+-------------------------\n") + print(" Bad Condition | Good Condition\n") + print(" -------------------------+-------------------------\n") + + for z in tage..(tage + ktage) + getPosition(z) + + printf("%04d.%02d.%02d : ", jh, mh, th) + p = ($phys / 2.0 + 0.5).to_i + e = ($emot / 2.0 + 0.5).to_i + g = ($geist / 2.0 + 0.5).to_i + graph = "." * 51 + graph[25] = ?| + graph[p] = ?P + graph[e] = ?E + graph[g] = ?M + print(graph, "\n") + th = th + 1 + if (leapyear(jh) == 0) + $MONATSTAG = monatstag1 + else + $MONATSTAG = monatstag2 + end + if (th > $MONATSTAG[mh - 1]) + mh = mh + 1 + th = 1 + end + if (mh > 12) + jh = jh + 1 + mh = 1 + end + end + print(" -------------------------+-------------------------\n\n") +end diff --git a/sample/blk.rb b/sample/blk.rb index 4e618bce2d..12d1038fd0 100644 --- a/sample/blk.rb +++ b/sample/blk.rb @@ -2,8 +2,8 @@ def foo() $block = Block.new end -foo(){i | print "i = ", i, "\n"} -$block.do(2) +foo(){i| print "i = ", i, "\n"} +$block.call(2) -foo(){i | print "i*2 = ", i*2, "\n"} -$block.do(2) +foo(){i| print "i*2 = ", i*2, "\n"} +$block.call(2) diff --git a/sample/clone.rb b/sample/clone.rb index 69d2f1d52b..e7d6b00a31 100644 --- a/sample/clone.rb +++ b/sample/clone.rb @@ -3,7 +3,7 @@ # test2 # test # test -# clone.rb:13: undefined method `test2' for "#"(Object) +# clone.rb:18: undefined method `test2' for "#"(Object) foo = Object.new def foo.test print("test\n") diff --git a/sample/dir.rb b/sample/dir.rb index f269c568ba..3349dc7b6d 100644 --- a/sample/dir.rb +++ b/sample/dir.rb @@ -3,7 +3,7 @@ dirp = Dir.open(".") dirp.rewind for f in dirp - unless (~/^\./ || ~/~$/ || ~/\.o/) + if !(~/^\./ || ~/~$/ || ~/\.o/) print f, "\n" end end diff --git a/sample/evaldef.rb b/sample/evaldef.rb index 021f65800a..1d77a3c008 100644 --- a/sample/evaldef.rb +++ b/sample/evaldef.rb @@ -1,7 +1,7 @@ # method definition by eval() # output: # bar -# (eval):21: method `baz' not available for "#"(foo) +# (eval):26: method `baz' not available for "#"(foo) class foo def foo diff --git a/sample/export.rb b/sample/export.rb index be7b6bc797..03b9492e5a 100644 --- a/sample/export.rb +++ b/sample/export.rb @@ -4,7 +4,7 @@ # foo class foo - export(\printf) + export :printf end def foobar @@ -12,7 +12,7 @@ def foobar end f = foo.new -#foo.unexport(\printf) -foo.export(\foobar) +#foo.unexport :printf +foo.export :foobar f.foobar f.printf "%s\n", foo diff --git a/sample/exyacc.rb b/sample/exyacc.rb new file mode 100644 index 0000000000..ad6191c03d --- /dev/null +++ b/sample/exyacc.rb @@ -0,0 +1,22 @@ +#! /usr/local/bin/ruby -Cn +# usage: exyacc.rb [yaccfiles] +# this is coverted from exyacc.pl in the camel book + +$/ = nil + +while gets() + sbeg = $_.index("\n%%") + 1 + send = $_.rindex("\n%%") + 1 + $_ = $_[sbeg, send-sbeg] + sub(/.*\n/, "") + gsub(/'{'/, "'\001'") + gsub(/'}'/, "'\002'") + gsub('\*/', "\003\003") + gsub("/\\*[^\003]*\003\003", '') + while gsub(/{[^}{]*}/, ''); end + gsub(/'\001'/, "'{'") + gsub(/'\002'/, "'}'") + while gsub(/^[ \t]*\n(\s)/, '\1'); end + gsub(/([:|])[ \t\n]+(\w)/, '\1 \2') + print $_ +end diff --git a/sample/gctest2.rb b/sample/gctest2.rb new file mode 100644 index 0000000000..851d14f217 --- /dev/null +++ b/sample/gctest2.rb @@ -0,0 +1,71 @@ +# GC stress test +def cons(car, cdr) + car::cdr +end + +def car(x) + x.car +end + +def cdr(x) + x.cdr +end + +def reverse1(x, y) + if x == nil then + y + else + reverse1(cdr(x), cons(car(x), y)) + end +end + +def reverse(x) + reverse1(x, nil) +end + +def ints(low, up) + if low > up + nil + else + cons(low, ints(low+1, up)) + end +end + +def print_int_list(x) + if x == nil + print("NIL\n") + else + print(car(x)) + if cdr(x) + print(", ") + print_int_list(cdr(x)) + else + print("\n") + end + end +end + +print("start\n") + +a = ints(1, 100) +print_int_list(a) +b = ints(1, 50) +print_int_list(b) +print_int_list(reverse(a)) +print_int_list(reverse(b)) +for i in 1 .. 100 + b = reverse(reverse(b)) +# print(i, ": ") +# print_int_list(b) +end +print("a: ") +print_int_list(a) +print("b: ") +print_int_list(b) +print("reverse(a): ") +print_int_list(reverse(a)) +print("reverse(b): ") +print_int_list(reverse(b)) +a = b = nil +print("finish\n") +GC.start() diff --git a/sample/list.rb b/sample/list.rb index 1a20c954d0..fa145f4627 100644 --- a/sample/list.rb +++ b/sample/list.rb @@ -1,19 +1,10 @@ # Linked list example class MyElem - #饹᥽å() - def MyElem.new(item) - # ѡ饹Υ᥽åɤθƤӽФ(ξϥ饹Class) - elm = super # ѿפʤ - #elmФ᥽åɤθƤӽФ - elm.init(item) - end - - # ̾Υ᥽å - def init(item) + # ֥˼ưŪ˸ƤФ᥽å + def init_object(item) # @ѿϥ󥹥ѿ(פʤ) @data = item @next = nil - self end def data @@ -63,11 +54,7 @@ class MyList end class Point - def Point.new(x, y) - super.init(x, y) - end - - def init(x, y) + def init_object(x, y) @x = x; @y = y self end diff --git a/sample/list2.rb b/sample/list2.rb index fef9d35a84..1c2ca08150 100644 --- a/sample/list2.rb +++ b/sample/list2.rb @@ -1,10 +1,6 @@ # Linked list example -- short version class Point - def Point.new(x, y) - super.init(x, y) - end - - def init(x, y) + def init_object(x, y) @x = x; @y = y self end diff --git a/sample/list3.rb b/sample/list3.rb index c6278574bf..6bedc6ced9 100644 --- a/sample/list3.rb +++ b/sample/list3.rb @@ -2,11 +2,7 @@ # using _inspect class Point - def Point.new(x, y) - super.init(x, y) - end - - def init(x, y) + def init_object(x, y) @x = x; @y = y self end diff --git a/sample/rcs.awk b/sample/rcs.awk new file mode 100644 index 0000000000..08979285c9 --- /dev/null +++ b/sample/rcs.awk @@ -0,0 +1,33 @@ +BEGIN { + sw = 40.0; + dw = 78.0; + hdw = dw / 2.0; + w = 20.0; + h =1.0; + d = 0.2; + ss="abcdefghijklmnopqrstuvwxyz0123456789!#$%^&*()-=\\[];'`,./"; + rnd = srand(); +} + +{ + xr = -hdw; y = h * 1.0; maxxl = -999; + s = ""; + while (xr < hdw) { + x = xr * (1 + y) - y * w / 2; + i = (x / (1 + h) + sw /2); + c = (0 < i && i < length($0)) ? substr($0, i, 1) : "0"; + y = h - d * c; + xl = xr - w * y / (1 + y); + if (xl < -hdw || xl >= hdw || xl <= maxxl) { + t = rand() * length(ss); + c = substr(ss, t, 1); + } + else { + c = substr(s, xl + hdw, 1); + maxxl = xl; + } + s = s c; + xr = xr + 1; + } + print s; +} diff --git a/sample/rcs.dat b/sample/rcs.dat new file mode 100644 index 0000000000..61c88bff89 --- /dev/null +++ b/sample/rcs.dat @@ -0,0 +1,17 @@ +0000000000000000220000000000000000 +0000000000000111221110000000000000 +0000000000111112222111110000000000 +0000000111111112222111111110000000 +0000111111111122222211111111110000 +0111111111111222222221111111111110 +2222222222222222222222222222222222 +1122222222222222222222222222222211 +0111122222222222222222222222211110 +0011111122222222222222222211111100 +0001111111222222222222221111111000 +0000111112222222222222222111110000 +0000011122222222112222222211100000 +0000001122222221111222222211000000 +0000000122221111111111222210000000 +0000000221111111111111111220000000 +0000000000000000000000000000000000 diff --git a/sample/rcs.rb b/sample/rcs.rb new file mode 100644 index 0000000000..faa4606788 --- /dev/null +++ b/sample/rcs.rb @@ -0,0 +1,49 @@ +# random dot steraogram +# usage: rcs.rb rcs.dat + +sw = 40.0 # ̃p^[̕ +dw = 78.0 # Random Character Streogram ̕ +hdw = dw / 2.0 +w = 20.0 # ̕ +h =1.0 # ʂƊʂ̋ +d = 0.2 # Pʓ̕オ +ss="abcdefghijklmnopqrstuvwxyz0123456789!#$%^&*()-=\\[];'`,./" +rnd = srand() + +while gets() +# print($_) + xr = -hdw; y = h * 1.0; maxxl = -999 + s = ""; + while xr < hdw + x = xr * (1 + y) - y * w / 2 + i = (x / (1 + h) + sw /2) + if (1 < i && i < $_.length); + c = $_[i, 1].to_i + else + c = 0 + end + y = h - d * c + xl = xr - w * y / (1 + y); + if xl < -hdw || xl >= hdw || xl <= maxxl + tt = rand(ss.length) + c = ss[tt, 1] + else + c = s[xl + hdw, 1] + maxxl = xl + end + s += c + xr += 1 + end + print(s, "\n") +end + + + + + + + + + + + diff --git a/sample/sieve.rb b/sample/sieve.rb index 192a5865d8..eaf4e33e2c 100644 --- a/sample/sieve.rb +++ b/sample/sieve.rb @@ -1,6 +1,6 @@ # sieve of Eratosthenes sieve = [] -unless max = $ARGV.shift; max = 100; end +if ! max = $ARGV.shift; max = 100; end max = max.to_i print "1" @@ -15,3 +15,4 @@ for i in 2 .. max resque end end +print "\n" diff --git a/sample/uumerge.rb b/sample/uumerge.rb index 420a3924b6..d0bd016036 100755 --- a/sample/uumerge.rb +++ b/sample/uumerge.rb @@ -8,7 +8,7 @@ while gets() end end -fail "missing begin" unless $sawbegin; +fail "missing begin" if !$sawbegin; OUT = open($file, "w") if $file != ""; while gets() @@ -18,10 +18,10 @@ while gets() end sub(/[a-z]+$/, ""); # handle stupid trailing lowercase letters continue if /[a-z]/ - continue unless ((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4 + continue if !(((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4) OUT << $_.unpack("u"); end -fail "missing end" unless $sawend; +fail "missing end" if ! $sawend; File.chmod $mode.oct, $file; exit 0; diff --git a/signal.c b/signal.c index f711436f1c..c0173d8e1c 100644 --- a/signal.c +++ b/signal.c @@ -168,23 +168,30 @@ Fkill(argc, argv) { int sig; int i; + char *s; if (argc < 2) Fail("wrong # of arguments -- kill(sig, pid...)"); switch (TYPE(argv[0])) { case T_FIXNUM: sig = FIX2UINT(argv[0]); + if (sig >= NSIG) { + s = rb_id2name(sig); + if (!s) Fail("Bad signal"); + goto str_signal; + } break; case T_STRING: { int negative = 0; - char *s = RSTRING(argv[0])->ptr; - if (*s == '-') { + s = RSTRING(argv[0])->ptr; + if (s[0] == '-') { negative++; s++; } + str_signal: if (strncmp("SIG", s, 3) == 0) s += 3; if((sig = signm2signo(s)) == 0) diff --git a/socket.c b/socket.c index b691e7e1c8..58a2a8e9e7 100644 --- a/socket.c +++ b/socket.c @@ -82,7 +82,6 @@ Fbsock_setopt(sock, lev, optname, val) level = NUM2INT(lev); option = NUM2INT(optname); Check_Type(val, T_STRING); - GetOpenFile(sock, fptr); if (setsockopt(fileno(fptr->f), level, option, val->ptr, val->len) < 0) @@ -104,7 +103,7 @@ Fbsock_getopt(sock, lev, optname) len = 256; val = (struct RString*)str_new(0, len); Check_Type(val, T_STRING); - + GetOpenFile(sock, fptr); if (getsockopt(fileno(fptr->f), level, option, val->ptr, &len) < 0) rb_sys_fail(fptr->path); @@ -163,7 +162,7 @@ open_inet(class, h, serv, server) if (hostent == NULL) { hostaddr = inet_addr(host); if (hostaddr == -1) { - if (server && !strlen(host)) + if (server && !strlen(host)) hostaddr = INADDR_ANY; else rb_sys_fail(host); @@ -193,9 +192,9 @@ open_inet(class, h, serv, server) } protoent = getprotobyname(servent->s_proto); if (protoent == NULL) Fail("no such proto %s", servent->s_proto); - + fd = socket(PF_INET, SOCK_STREAM, protoent->p_proto); - + sockaddr.sin_family = AF_INET; if (h == Qnil) { sockaddr.sin_addr.s_addr = INADDR_ANY; @@ -293,7 +292,7 @@ open_unix(class, path, server) char *syscall; VALUE sock; OpenFile *fptr; - + Check_Type(path, T_STRING); fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd < 0) rb_sys_fail("socket(2)"); @@ -361,7 +360,7 @@ Ftcp_addr(sock) int len = sizeof addr; GetOpenFile(sock, fptr); - + if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0) rb_sys_fail("getsockname(2)"); return tcp_addr(&addr); @@ -376,7 +375,7 @@ Ftcp_peeraddr(sock) int len = sizeof addr; GetOpenFile(sock, fptr); - + if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0) rb_sys_fail("getsockname(2)"); return tcp_addr(&addr); @@ -443,7 +442,7 @@ Funix_addr(sock) int len = sizeof addr; GetOpenFile(sock, fptr); - + if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0) rb_sys_fail("getsockname(2)"); return unix_addr(&addr); @@ -458,7 +457,7 @@ Funix_peeraddr(sock) int len = sizeof addr; GetOpenFile(sock, fptr); - + if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0) rb_sys_fail("getsockname(2)"); return unix_addr(&addr); @@ -642,7 +641,7 @@ Fsock_send(argc, argv, sock) fd = fileno(f); if (to) { Check_Type(to, T_STRING); - n = sendto(fd, msg->ptr, msg->len, NUM2INT(flags), + n = sendto(fd, msg->ptr, msg->len, NUM2INT(flags), (struct sockaddr*)to->ptr, to->len); } else { @@ -678,7 +677,7 @@ sock_recv(sock, argc, argv, from) GetOpenFile(sock, fptr); fd = fileno(fptr->f); - if ((str->len = recvfrom(fd, str->ptr, str->len, flags, + if ((str->len = recvfrom(fd, str->ptr, str->len, flags, (struct sockaddr*)buf, &alen)) < 0) { rb_sys_fail("recvfrom(2)"); } diff --git a/spec b/spec index 75bd5e8065..b7c374db64 100644 --- a/spec +++ b/spec @@ -1,6 +1,6 @@ .\" spec - -*- Indented-Text -*- created at: Tue May 25 15:18:26 JST 1993 -* Ϥ(ʤRuby?) +* Ϥ RubyϡUNIXǼڤ˥֥Ȼظץߥ󥰡פ򤷤Ȥ˾ ¸뤿ޤ줿ΤɬפȻפ줿: @@ -41,57 +41,75 @@ Ruby 󥯤Ǥ뤷ǤʤƤRubyƥѥ뤷Ȥ߹ߥ ɲäΤưפǤ(PerlʤɤϤ뤫ưפǤ) -* Rubyʸˡ +* Lexical structure -ǤRubyʸˡ⤹롥RubyδŪʬϾʸˡ -ʤΤǿȤˤĤΤϤۤ񤷤ʤ +ߤrubyμϥ饯åȤȤASCIIѤ롥rubyʸ +ʸ̤롥̻ҤǤʤǤդΤȤ˶ʸ򤪤 +Ȥ롥ʸϥڡ(space)(tab)ľ(vertical +tab) CR(carriage return)(form feed)Ǥ롥(newline) +˼³ˤ϶ʸȤơʳǤʸζڤȤƲ +ᤵ롥 + +̻Ҥϱʸ("_"ޤ)Ϥޤꡤѿ³ΤǤ롥ruby +̻ҤŤϤʤߤμϼ̻ҤȤƥޥХȥ +(EUC,SJIS)̤ʤ + +Хѿ̾"$"³̻Ҥޤϵ1ʸ󥹥ѿ +"@"³̻ҡ饹"%"³̻ҤǤ롥᥽å̾ +ѿ̾ȥ饹̾ñʤ뼱̻ҤѤ롥 ** -ץȸνˤʤ餤ʸʳ'#'ޤǤϥ -ȸʤ +ץȸνˤʤ餤ʸʸɽ(?#)ʳ`#' +ޤǤϥȤȸʤ + +** ͽ + +ͽϰʲ̤Ǥ + + alias else in resque when + and elsif include retry while + break end module return yield + case ensure nil self __END__ + class fail or super __FILE__ + continue for protect then __LINE__ + def if redo undef -** ڤ국 +ͽϥ饹̾᥽å̾ѿ̾ʤɤѤ뤳ȤϤǤʤ -ʸ(֤ȥڡ)Ӳ(\n)ڤ국Ȥʤ롥 -Ԥ +** ڤʸ + +ʸʤɤΥƥʳξζʸ(֤ȥڡ)Ӳ +(\n)ڤ국Ȥʤ롥˲Ԥ a + b -Τ褦˹Ԥ(ʸ)ǽꡤιԤ³Ȥʾʳʸ -ڤȤƤǧ롥 +Τ褦˹ԤǽꡤιԤ³Ȥʾζ +ڤȤƤǧ롥 -** ͽ +* ץ -ͽϰʲ̤Ǥ +: - alias elsif module self yield - and end nil super __END__ - break ensure or then __FILE__ - case fail protect undef __LINE__ - class for redo unless - continue if resque until - def in retry when - else include return while + print "hello world!\n" -ͽϥ饹̾᥽å̾ѿ̾ʤɤѤ뤳ȤϤǤʤ +ץϼ¤٤ΤǤ롥ȼδ֤ϥߥ(`;')ޤϲ +ԤǶڤ() -** + ιԤ˷³뤳ȤʻˤϲԤϼζڤˤʤʤ -RubyץǤϼʸǤ롥ޤ⤹롥 +* -*** ƥ +RubyǤnilʳɾ롥CPerl ʤɤȤϰۤʤꡤ0 +""(ʸ)ϵȤɾʤΤǵĤ뤳ȡ -ץľܵҤǤ륪֥ȤƥȸƤ֡RubyΥƥ -ˤʸɽͤȤƥ뤬롥 - -**** ʸƥ +** ʸ "..." # ХååβѿŸ '...' # Хååβʤ(\\\'ϲ᤹) -**** Хåå嵭ˡ +Хåå嵭ˡ \t (0x09) \n ʸ(0x0a) @@ -108,14 +126,21 @@ Ruby \M-c ᥿ʸ(c|0x80) \ʳ ʸΤ -**** ѿŸ +ѿŸ ֥륯(`"')ǰϤޤ줿ʸɽǤ `#{ѿ̾}'Ȥ ѿƤŸ뤳ȤǤ롥ѿѿ(`$',`@',`%') ǻϤޤˤ`#ѿ̾'ȤǤŸǤ롥ʸ`#'³ʸ `{',`$',`@',`%'ǤʤСΤޤ`#'ȤƲᤵ롥 -**** ɽƥ +** ޥɽ + +RubyǤshΤ褦˥ޥɤμ¹Է̤ʸƥΤ褦˻ȤȤ +Ǥ롥``ǰϤޤ줿ʸϡ֥륯ȤƱͤ˥Хåå嵭 +ˡβѿŸԤʤ줿塤ޥɤȤƼ¹Ԥ졤μ¹Է +ʸȤͿ롥ޥɤɾ뤿Ӥ˼¹Ԥ롥 + +** ɽ /.../ @@ -139,18 +164,20 @@ Ruby | ( ) ɽޤȤ -¾ʸƱХåå嵭ˡͭǤ롥 +¾ʸƱХåå嵭ˡѿŸͭǤ롥 -**** 磻ɥɥƥ +** 磻ɥɼ <...> * Ǥդʸ(ʸޤ)Ȱ ? Ǥդ1ʸȰ [ ] []Τ줫1ʸȰ - {..} {}Τ줫ʸȰ + {..} {}(ޤǶڤ줿)줫ʸȰ + +¾ʸƱХåå嵭ˡѿŸͭǤ롥 -**** ͥƥ +** ͥƥ 123 -123 (Ĥ) @@ -164,19 +191,12 @@ Ruby ?\M-a ᥿aΥ(225) ?\M-\C-a ᥿-ȥaΥ(129) - \ܥ ̻/ѿ̾Ȱабapplyʤɤǥ᥽ - ɤꤹΤ˻Ȥ + :ܥ ̻/ѿ̾/黻ҤȰабapplyʤ + ǥ᥽åɤꤹʤɤ˻Ȥ ?ɽǤƤΥХåå嵭ˡͭǤ롥 -*** ޥɤν - -RubyǤshΤ褦˥ޥɤμ¹Է̤ʸƥΤ褦˻ȤȤ -Ǥ롥``ǰϤޤ줿ʸϡ֥륯ȤƱͤ˥Хåå嵭 -ˡβѿŸԤʤ줿塤ޥɤȤƼ¹Ԥ졤μ¹Է -ʸȤͿ롥ޥɤɾ뤿Ӥ˼¹Ԥ롥 - -*** ѿ +** ѿ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤 μѿ̾κǽΰʸǷꤵ롥̾ѿ2ʸܰʹߤ @@ -184,20 +204,35 @@ Ruby ѿ롥ѿ̾Ĺ˴ؤ̤¤Ϥʤ ѿΥפ˴ؤ餺Ƥʤѿ򻲾Ȥͤnil -Ǥ롥 +Ǥ롥μѿɬפʤ -**** Хѿ +*** Хѿ + +: + + $foobar + $/ `$'ǻϤޤѿΥפϥХǤꡤץΤɤǤ ȤǤ롥μ̿ϥץμ̿ -**** 󥹥ѿ +*** 󥹥ѿ + +: + + @foobar `@'ǻϤޤѿϥ󥹥ѿǤꡤΥ饹ޤϥ֥饹 ᥽åɤ黲ȤǤ롥פϥ᥽åǤꡤμ̿ϥ֥ Ȥμ̿ -**** 饹̾/⥸塼̾/ѿ +*** 饹̾/⥸塼̾/ѿ + +: + + Array + Math + foobar ե٥åȤޤ`_'ǻϤޤѿϼ̻ҤȤƤФ졤ѿ 饹̾ޤϥ⥸塼̾Ǥ롥 @@ -231,15 +266,18 @@ Ruby ѿΥפ̿⤽Υ֥åνޤ(ȥåץ٥Υ ѿϥץνλޤ)Ǥ롥 -**** 饹ѿ() +*** 饹 -`%'ǻϤޤѿϥ饹ѿǤꡤΥ饹ƤΥ֥饹Υ -󥹤黲ȤǤ롥ѿؤϥȥåץ٥롤ʤ᥽ -ɤǤ٥ǤΤ߲ǽǤ롥ѿϥ饹֤ͤͭ졤 -ȥ᥽åɤͤѹ뤳ȤǤʤΤǡȤ -Ѥ롥 +: + + %foobar + +`%'ǻϤޤѿϥ饹ǤꡤΥ饹ƤΥ֥饹Υ +󥹤黲ȤǤ롥ؤϥȥåץ٥롤ʤ᥽åɤ +Ǥ٥ǤΤǽǤ롥ѿϥ饹֤ͤͭ졤 +ͤѹ뤳ȤǤʤ -**** ѿ +*** ѿ ̾ѿʳ˵ѿȸƤФüѿ4Ĥ롥 @@ -251,31 +289,109 @@ Ruby εѿˤäƤͤѹ뤳ȤϤǤʤ ѿؤ㳰ȯ롥 -*** å +** ̤ˤ륰롼ԥ + +: + + (1+2)*3 + (foo();bar()) + +ϳ̤ˤäƥ롼ԥ󥰤뤳ȤǤ롥 + + `(' `)' + +̤ˤñʤ뼰ǤϤʤ¤(ץ)֤Ȥ +롥 + + `(' `;' ... `)' + +¤ӤͤϺǸɾͤǤ롥ĤޤͤϺǸɾ +ͤˤʤ롥 + +** + +: + + [1, 2, 3] + +Array饹Υ󥹥󥹤Ǥ롥뼰ϰʲη +롥 + + `[' , ... `]' + +줾μɾ̤ޤ֤ǿ0ζ +뤿ˤ϶ + + `[' `]' + +Ѥ롥 + +** Ϣ + +: + + {1=>2, 2=>4, 3=>6} + +ϢȤǤդΥ֥Ȥ򥭡(ź)ȤƻǤ롥Ruby +ϢDict()饹Υ󥹥󥹤Ǥ롥ܺ٤ϥ饹Dictι +򻲾Ȥ줿ϢϢ󼰤ϰʲηǤ롥 + + `{' `=>' ... `}' + +줾μɾ̤򥭡ͤȤϢ󥪥֥Ȥ֤ +ǿ0Ϣ뤿ˤ϶Ϣ + + `{' `}' + +Ѥ롥Ǥ1İʾ夢硤ۣǤʤ`{', `}'ϾάǤ롥 + +** ᥽åɸƽм + +: + + foo.bar() + foo.bar + bar() ֥Ȥ˥åŪʹʸåǤꡤδ ܷϰʲ̤Ǥ롥 - 1 '.' ᥽å̾ '(' 1... [',' '*' n ]')' + 1 `.' ᥽å̾ `(' 1... [`,' `*' n ]`)' 1ɾ륪֥ȤΡ̻Ҥǻꤵ᥽åɤƤ -ФֺǸΰ'*'³(ñ)Ǥ硤μɾ -(Ǥɬפ)ŸơȤɲä롥 +ФֺǸΰ`*'³(ñ)Ǥ硤μɾ +(ǤʤѴ)ŸơȤɲä롥 + +åǡ쥷Фselfξ硤쥷Фά̾Υץ +ߥ󥰸ˤؿΤ褦ʷǥ᥽åɤƤӽФȤǤ롥 -Ĥʤˤϳ̤άǤ롥 +᥽åɸƤӽФǤۣ椵ʤˤϳ̤άǤ롥ۣ椵 +ȤʲʸޤͽǻϤޤǤ롥 + + (, [, {, <, /, %, +, -, if, while + +㡧 + foo bar+baz # ᥽åɸƤӽФfoo(bar+baz) + foo (1+2)*5 # ᥽åɸƤӽФ(foo(1+2)) * 5 + foo 1 # ᥽åɸƤӽФfoo(1) + foo -1 # ѿfoo - 1 + +쥷Фꤷ᥽åɸƤӽФǤϤξ1Ĥʤˤ +άǤ롥 ᥽å̾ȤƤǤդμ̻ҤѤ뤳ȤǤ롥ѿ̾Ȥϼ̻Ҥ ֤̾㤦ΤǽʣƤ⹽ʤ -åǡ쥷Фselfξ硤쥷Фά̾Υץ -ߥ󥰸ˤؿΤ褦ʷǥ᥽åɤƤӽФȤǤ롥 -ξ1ĤʤǤ̤ξάϤǤʤ - -饹ʸγǻꤵ줿᥽åɤȥ饹Modulenoexport᥽åɤ +饹ʸγǻꤵ줿᥽åɤȥ饹Moduleunexport᥽åɤ ꤵ줿᥽åɤϴؿŪ᥽åɤȸƤФ졤ؿǤƤӽФ -Ǥʤ +Ǥʤ(DEF) + +** SUPER -*** ѡ饹Υ᥽åɸƤӽФ +: + + super + super(1,2,3) åüʥȤƥѡ饹Υ᥽åɤθƤӽФ 롥ηϥ᥽åɤ˥ѡ饹Ѥ뤿 @@ -284,70 +400,106 @@ Ruby super ߤΥ᥽åɤͿ줿Τޤޥѥ饹Ʊ̾Υ᥽åɤƤ -Ф +ФȤͿ줿ѿͤѹƤ⡤ϤΤϸΰ +ͤǤ롥 - super'(' ... ')' + super`(' ... `)' ȤȤ˥ѡ饹Ʊ̾Υ᥽åɤƤӽФֺǸΰ -`*'³̾Υ᥽åɸƤӽФƱͤϤ롥 +`*'³̾Υ᥽åɸƤӽФƱͤŸϤ롥 -*** /Ϣ +** -Υ֥Ȥ뼰ηϰʲηǤ롥 +: - '[' , ... ']' + foo = bar + foo[0] = bar + foo.bar = baz -줾μɾ̤ޤ֤ǿ0ζ -뤿ˤ϶ +ˤѿФ()ȡץñˤ뤿Υ +å奬ȤƤ롥ϰʲηǤ롥 - '[' ']' + ѿ `=' -Ѥ롥 +ϼɾѿͤȤ롥饹⥸塼䵿ѿ +ˤǤʤ饹⥸塼ѹ뤿ˤclass +moduleѤ롥ϱ黻ҷȤäƤ뤬᥽åɤǤϤʤ +Ǻ뤳ȤϤǤʤ -** Ϣ +󥿥å奬ȤƤϰʲΤΤ롥 -ϢȤǤդΥ֥Ȥ򥭡(ź)ȤƻƤǤ롥Ruby -ǤϢSmalltalkѸڤDict()ȤƤФ롥ܺ٤ϥ -饹Dictι򻲾Ȥ줿ϢϢ󼰤ϰʲη -롥 +Ǥؤ - '{' '=>' ... '}' + 1`[' 2... `]' `=' n -줾μɾ̤򥭡ͤȤϢ󥪥֥Ȥ֤ -ǿ0Ϣ뤿ˤ϶Ϣ +1ɾ륪֥Ȥˡ2鼰nޤǤȤơ"[]=" +Ȥ᥽åɤƤӽФ - '{' '}' +° -Ѥ롥 + 1 `.' ̻ `=' 2 + +1ɾ륪֥(쥷Фά줿`self') +Фơ"̻="Ȥ᥽åɤ 2ȤƸƤӽФ + +** + +: + + foo += 12 + +ͤΤΤ˱黻ä뤿˼롥 + + 1 op= 2 # 1ǽǤʤФʤʤ + +ηŪˡּ1 = 1 op 2פƱͤɾ롥1 +1󤷤ɾʤΤǡ1Ѥϡּ1 = 1 op 2 +Ȥưۤʤ̤Ȥʤ롥opȤƻȤ黻Ҥ + + +, -, *, /, %, **, &, |, ^, <<, >> + +11Ǥ롥黻Ҥ`='δ֤˥ڡƤϤʤ -*** 󻲾ȡ +** ¿ -(Ϣޤ)ǤλȤϰʲηǹԤʤ +: - 1 '[' 2... ']' + foo, bar, baz = 1, 2, 3 + foo, = list() + foo, *rest = list2() -ηŪˡ1"[]"ȤåȲᤵ롥 -ư򵿻ŪʥɤǵҤаʲΤ褦ˤʤ롥 +ƱʣѿԤʤȤǤ롥ηϰʲ̤Ǥ롥 - 1"[]"(2...) + `,' [ `,' ...] [`*' ]= [, ...] -Ǥ +դμĤʤϡͤȤ(ɬפʤto_a᥽ +ɤѴ)Ǥ򤽤줾캸դ롥ʳξˤϡ +줾μͤդ롥դοȱդǤοʤ +ˤ­ʤѿˤ nil졤;äǤ̵뤵롥¿ +κǸǤ`*'硤ĤưȤ롥 - 1 '[' 2... ']' '=' n + foo, bar = [1, 2] # foo = 1; bar = 2 + foo, bar = 1, 2 # foo = 1; bar = 2 + foo, bar = 1 # foo = 1; bar = nil + + foo, bar, baz = 1, 2 # foo = 1; bar = 2; baz = nil + foo, bar = 1, 2, 3 # foo = 1; bar = 2 + foo,*bar = 1, 2, 3 # foo = 1; bar = [2, 3] -ȤǹԤʤ졤 +¿ͤ(Ѵ줿)դǤ롥 - 1."[]="(2...) +** 黻Ҽ -ȤȤƲᤵ롥 +: -*** 黻ҷ + 1+2*3/4 ץߥ󥰤ؤΤ˰Υ᥽åɸƤӽФ湽¤ϱ黻ҷ Ȥ롥Rubyˤϰʲˤ黻Ҥ롥ΤΤۤɷ̤ Ʊα黻Ҥη̤ƱǤ롥 - -(unary) +(unary) ! ~ + [](󻲾), []=() + -(unary) +(unary) ! ~ ** * / % + - @@ -362,110 +514,77 @@ Ruby :: =() (+=, -=, ..) and - or + or + if while ۤȤɤα黻ˤϥ᥽åɸƤӽФȤƲᤵ(饹˺ Ǥ)ǤʤüʤΤ롥Ǥʤü黻 Ҥ - &&(), ||(), =(), ...(ϰϻ), and, or + =(), ...(ϰ), !(), &&(), and, |(), or, + if, while -6ĤǤ롥 +9Ĥα黻ҤȤȤȤ߹碌ˤʤ !=, !~ Ӽ黻 +Ǥ롥 -Ǥü黻Ұʳα黻ҷϥ᥽åɸƤӽФȸʤ롥 -ñ黻(+, -, !, ~) - - 1."黻"() - -Ȥˡʳ2黻Ҥ - - 1."黻"(2) - -˲ᤵ롥 - -** +Ǥü黻Ұʳα黻ҷϰʲΤ褦ʥ᥽åɸƤӽФȸ +ʤ롥 -ˤѿФ()ȡץñˤ뤿Υ -å奬ȤƤ롥ϰʲηǤ롥 - - ѿ '=' +ñ黻(+, -, ~) -ϼɾѿͤȤ롥饹⥸塼䵿ѿ -ˤǤʤ饹⥸塼ѹ뤿ˤclassʸ -moduleʸѤ롥ϱ黻ҷȤäƤ뤬᥽åɤǤϤʤ -Ǻ뤳ȤϤǤʤ + 1. 黻 () -󥿥å奬ȤƤϰʲΤΤ롥 +(Ϣޤ)Ǥλ(1 `[' 2... `]') -Ǥؤ + 1. `[]' (2...) - 1'[' 2... ' ]' '=' n +Ǥ( 1 `[' 2... `]' `=' n) -1ɾ륪֥Ȥˡ2鼰nޤǤȤơ"[]=" -Ȥ᥽åɤƤӽФ + 1. `[]=' (2...) -° +ʳ2黻( 黻 ) - 1 '.' ̻ '=' 2 + 1. 黻 (2) -1ɾ륪֥ȤФ"̻="Ȥ᥽åɤ򡤼 -2ȤƸƤӽФ +ϤޤǤ⤽Υ᥽åɸƤӽФȤƲᤵȤ +ǡrubyץǤҤȤ櫓ǤϤʤ - - - 1 op= 2 # 1ǽǤʤФʤʤ - -ηŪˡּ1 = 1 op 2פƱͤɾ롥1 -1󤷤ɾʤΤǡ1Ѥϡּ1 = 1 op 2 -Ȥưۤʤ̤Ȥʤ롥opȤƻȤ黻Ҥ - - +, -, *, /, %, **, &, |, ^, <<, >> - -11Ǥ롥黻Ҥ`='δ֤˥ڡƤϤʤ - -*** ʬ - -ͤˤäʬ뼰ϰʲ˼ifunlesscaseʣʸ -3ȱ黻ҷ3ढ롥RubyǤnilʳɾ롥 -CPerlʤɤȤϰۤʤꡤ0 ""(ʸ)ϵȤɾʤΤǵ -뤳ȡ - -if +** IF if 1 [then] - ʸ1 + 1 [elsif 2 [then] - ʸ2 ]... + 2 ]... [else - ʸn ] + n ] end -ȽǼ1ξʸ1ɾ롥ʳξʸ2ɾ +ȽǼ1ξ˼1ɾ롥ʳξϼ2ɾ 롥Rubyifelse ifǤelifǤʤelsififϢ³ԤʤȤ դ뤳ȡ -unless +ifξȽμǤʸɽƥϼ$_=~ ƥפ +άǤȤߤʤ롥 - unless 1 [then] - ʸ1 - [else - ʸ2 ] - end +** IF + + if -1(nil)֤2ɾ㳰ȯʸ1ɾ롥 -ʳξʸ2ɾ롥 +、(if)μԤ뼰äɾ롥ưбif +ƱͤǤ롥ifҤΤĤͤϾ郎Ωˤϼ͡ +ΩξˤnilǤ롥 -case +** CASE case 0 [when 1 [, 2]... [then] - ʸ1 ].. + 1 ].. [else - ʸn ] + n ] end ʬCswitchPascalcase˻Ƥ롥breakæФ뤳Ȥ -ʸ˷³뤳ȤʤΤա +μ˷³뤳ȤʤΤա ΰפϡּn =~ 0]ǹԤʤ롥Ĥޤꡤ @@ -478,7 +597,7 @@ case stmt3 end -ϰʲifʸȤۤǤ롥 +ϰʲifȤۤǤ롥 _tmp = expr0 if expr1 =~ _tmp || expr2 =~ _tmp @@ -489,67 +608,77 @@ case stmt3 end -黻ҷ +** AND - 1 '&&' 2 - 1 'and' 2 + 1 `&&' 2 + 1 `and' 2 1ɾͤ(nilʳ)ǤС2ɾ롥`and'ͥ ̤㤤̾Ǥ롥 - 1 '||' 2 +andξդμǤʸɽƥϼ$_=~ ƥפξά +Ȥߤʤ롥 + +** OR + + 1 `||' 2 1 'or 2 1ɾͤǤС2ɾ롥`or'̤ͥ㤤 ̾Ǥ롥 - 1 '...' 2 +orξդμǤʸɽƥϼ$_=~ ƥפξά +Ȥߤʤ롥 -1ˤʤޤǤϵ֤θϼ2֤ޤǤϿ֤2 -ˤʤо֤ϵ +** ϰϻ꼰 -*** ֤(ñ㷿) + 1 `...' 2 -롼פ뼰μͤϾnilǤ롥֥Ȥ˹ -롼פԤʤˤϼ˽Ҥ٤륤ƥ졼Ѥ롥 +1ˤʤޤǤϵ֤θϼ2֤ޤǤϿ֤2 +ˤʤо֤ϵ롥 -while +黻`...'ξդϾPǤꡤ `...'ξդμǤʸ +ɽƥϼ$_=~ ƥפξά$.==פξά +Ȳᤵ롥 - while - ʸ - end +** NOT -郎δ֡ʸ򷫤֤¹Ԥ롥 + `!' -until +ǤеǤп֤ - until - ʸ - end - 1 until 2 +`!'Ǥʸɽƥϼ$_=~ ƥפξάǤȤ +ʤ롥 -(nil)֤ɾ㳰ȯ֡ʸ򷫤֤¹Ԥ -롥 -*** PˤĤ + 1 `!=' 2 + +!(1 == 2)פξά -ifunlesswhileuntilξȽμü黻`&&', `||', -`...'ξդμϾPȸƤФ롥PǤʸɽƥ -ϼ$_=~ƥפξάǤȤߤʤ롥˱黻`...'ξդ -$.==פξάȲᤵ롥P˸`!'黻Ҥ -ڥɤPȤߤʤ롥 + 1 `!~' 2 -: 黻`!'ü黻ҤǤϤʤΤǡԤʤ˵Ĥ -뤳ȡP +!(1 ~= 2)פξά + +** WHILE + + while + + end - ! ʸƥ - ! ɽƥ +ɾͤδ֡򷫤֤¹Ԥ롥whileͤnilǤ롥 -ηǸƤӽФ᥽åɤΰϡƥɽ֥ȤǤϤʤ -嵭Ӥη̤Ϳ롥Τᡤ§Ū`!'᥽åɤϺ -ʤɤ +whileξȽμǤʸɽƥϼ$_=~ ƥ +ξάǤȤߤʤ롥 -*** ƥ졼(֤) +** WHILE + + ñ㼰 while + +֤(while)ϤޤԤ뼰ɾƤPɾ +ǡ٤ϼ¹Ԥ뤳Ȥˤʤ롥whileҤΤĤͤnil +롥 + +** ƥ졼(֤) ƥ졼Ȥ湽¤(ä˥롼)ݲΤѤ᥽åɤ Ǥ롥ɤ(֥åȸƤФ)ꤷƥƥ졼Ƥ @@ -561,205 +690,122 @@ if ƥ졼Ȥ湽¤(ä˥롼)ݲΤѤ᥽åɤ Ǥ롥ƥ졼θƤӽФϰʲιʸǹԤʤ롥 - '{' ѿ... '|' ʸ... '}' + `{' ѿ... `|' ... `}' -ʸפ֥åȤꤷּפΥ᥽åɤ򥤥ƥ졼Ȥɾ +ּפ֥åȤꤷּפΥ᥽åɤ򥤥ƥ졼Ȥɾ 롥ּפΥȥåץ٥Υ᥽åɤƥ졼ȤƸƤӽФ졤 쥷Фɽ䡤μϥƥ졼ȤƤϸƤӽФʤּ ʣμޤơƥ졼Ȥƽ˸ƤФ롥 -ƥ졼yieldʸ¹Ԥȡǻꤵ줿ͤdoʸǻꤵ +ƥ졼yield¹Ԥȡǻꤵ줿ͤdoǻꤵ 줿ѿ졤֥å¹Ԥ롥֥åμ¹ԤλȤ -ͤ yieldʸͤȤ֤롥᥽åɤƥ졼ȤƸƤӽ +ͤ yieldͤȤ֤롥᥽åɤƥ졼ȤƸƤӽ 줿ɤϥ᥽åiterator_p()ͤΤ뤳ȤǤ롥ˤ Enumerable⥸塼grep᥽åɤΤ褦˥ƥ졼ȤƸƤФ줿 ̤Υ᥽åɤȤƸƤФ줿Ȥưۤʤ᥽åɤ⤢롥 +** FOR + ֥ȤγǤФԤʤη󶡤Ƥ롥 ϰʲ̤ꡥ for ѿ.. in - ʸ + end -γǤФʸ¹Ԥ롥ϰʲμǤ롥 +γǤФ¹Ԥ롥ϰʲμǤ롥 - ().each '{' ѿ.. '|' ʸ '}' + ().each `{' ѿ.. `|' `}' äƼͤΥ֥Ȥ᥽åeachʤ硤for¹Ԥ 㳰ȯ롥 -*** ƥ졼ǤΥ֥åƤӽФ +** YIELD - yield '(' [ [',' ...]]) + yield `(' [ [`,' ...]]) yield ƥ졼ǥ֥åθƤӽФԤʤyield¹Ԥ᥽åɤ ƥ졼ȤƸƤӽФƤʤˤ㳰ȯ롥yield ͤϥ åͤǤ롥 -*** 㳰 +yieldΰγ̤ۣǤʤ¤άǤ롥 + +** FAIL + + fail `(' [å] `)' + +㳰ȯ롥åͿ줿ˤȯե +ֹ̾򥷥ƥѿ`$@'ˡå`$!'˥åȤ롥 + +failΰγ̤ۣǤʤ¤άǤ롥 + +** PROTECT ͽʤ֤ȯˤ㳰ȯ롥RubyǤ㳰 ªơƻԤꡤԤʤäꤹ뤳ȤǤ롥 protect - ʸ1 + 1 [resque - ʸ2 ] + 2 ] [ensure - ʸ3] + 3] end -ʸ1¹Ԥμ¹㳰ȯresqueǻꤵ줿ʸ2¹ -롥ensure᤬¸ߤprotectʸλɬ(ェλ -Ǥʤ㳰, return, break, continue, redoʤɤˤæФǤ)ʸ3 +1¹Ԥμ¹㳰ȯresqueǻꤵ줿2¹ +롥ensure᤬¸ߤprotectλɬ(ェλ +Ǥʤ㳰, return, break, continue, redoʤɤˤæФǤ)3 ¹Ԥ롥 -unlessʸuntilʸϾɾ㳰ȯ硤ɾ̤ -ǤȸʤΤǡۤ㳰ԤʤäƤ뤳Ȥˤʤ롥 - -*** 롼ԥ - -ϳ̤ˤäƥ롼ԥ󥰤뤳ȤǤ롥 - - '(' ')' - -˳̤Ѥơʸ(ޤʸ¤)򼰤ˤ뤳ȤǤ롥 - - '(' ʸ ';' ʸ... ')' - -ʸ¤ӤͤϺǸɾͤǤ롥ĤޤͤϺǸɾʸ -ͤˤʤ롥 - -** ʸ - -Rubyץ⤦ĤǤʸǤ롥ʸˤñʸʸ -ʸ롥̤ʸͤѤ뤳ȤϤʤȤѤ -⤢Τǡͤġ̾ʸͤnilǤ롥 - -*** - -ñʸǤ롥 - -*** ¿ - -ƱʣѿԤʤȤǤ롥ηϰʲ̤Ǥ롥 - - ѿ ',' [ѿ ',' ...] ['*' ѿ]= [, ...] - -դμĤʤϡͤȤ(ɬפʤto_a᥽ -ɤѴ)Ǥ򤽤줾ѿ롥ʳξˤϡ -줾μͤѿ롥դѿοȱդǤο -ʤˤ­ʤѿˤ nil졤;äǤ̵뤵롥¿ -κǸǤ`*'硤ĤưȤ -롥 - - foo, bar = [1, 2] # foo = 1; bar = 2 - foo, bar = 1, 2 # foo = 1; bar = 2 - foo, bar = 1 # foo = 1; bar = nil - - foo, bar, baz = 1, 2 # foo = 1; bar = 2; baz = nil - foo, bar = 1, 2, 3 # foo = 1; bar = 2 - foo,*bar = 1, 2, 3 # foo = 1; bar = [2, 3] - -¿ñʸǤ롥ͤ(Ѵ줿)դǤ롥 - -*** ʸ - -ήѹʲʸ롥ñʸǤ롥 +** RETURN -returnʸ - - return [[',' ...]] + return [[`,' ...]] ͤͤȤƥ᥽åɤμ¹Ԥλ롥2İʾͿ줿 ˤϡǤȤ᥽åɤͤȤ롥Ĥʤ ˤ nil ͤȤʤ롥 -롼ʸ +** BREAK - continue - redo break -嵭3Ĥϥ롼ǻȤ - -continueϤäȤ¦Υ롼פμη֤Ϥ롥redoϥ롼׾ -ΥåԤʤ鷺ߤη֤ľbreak ϥ롼פæФ -롥CȰ㤤breakϤäȤ¦Υ롼פæФѤcase -ȴѤϻʤ - -retryʸ +break ϥ롼פæФ롥CȰ㤤breakϤäȤ¦Υ롼פæФ +Ѥcase ȴѤϻʤ - retry - -protectʸresqueǻȤprotectʸϤᤫ¹Ԥ롥㳰Ԥʤ -ƤƻԤΤ˻ȤresqueʳretryѤ줿㳰ȯ -롥 - -failʸ - - fail '(' [å] ')' - fail [å] - -㳰ȯ롥åͿ줿ˤȯե -ֹ̾򥷥ƥѿ`$@'ˡå`$!'˥åȤ롥 - -yieldʸ - - yield [',' ...] - -ʸȤyieldѤ뤳ȤǤ롥ξϼ̤dzɬפϤʤ - -*** ᥽åɸƤӽФʸ - -1İʾΰĥ᥽åɸƤӽФˤۣ椵ʤС -̤dzɬפϤʤηϰʲ̤Ǥ롥 - - '.' ᥽å̾ 1 ',' [2...]['*' n] - ᥽å̾ 1 ',' [2...]['*' n] - super 1 ',' [2... ]['*' n] - -ʸϻˡΤ褦˲ǤϼȤƤβ᤬ͥ褵롥 +** CONTINUE + continue - foo bar+baz # ᥽åɸƤӽФfoo(bar+baz) - foo (bar)+baz # ᥽åɸƤӽФfoo(bar) + bar - foo 1 # ᥽åɸƤӽФfoo(1) - foo -1 # ѿfoo - 1 +continueϤäȤ¦Υ롼פμη֤Ϥ롥 -̤Τʤ᥽åɸƤӽФʸñʸǤ롥 +** REDO -*** 潤 + redo -ñʸ潤ҤղäΤʸǤ(ñʸǤϤʤ)Ҥϰ -4Ǥ롥 +redoϥ롼׾ΥåԤʤ鷺ߤη֤ľ - ñʸ if - ñʸ unless - ñʸ while - ñʸ until +** RETRY -、(if/unless)μԤʸäɾ롥ưб -ʬƱͤǤ롥 + retry -֤(while/until)ϤޤԤʸɾƤPɾ -Τǡ٤ʸ¹Ԥ뤳Ȥˤʤ롥 +protectresqueǻȤprotectϤᤫ¹Ԥ롥㳰Ԥʤ +ƤƻԤΤ˻ȤresqueʳretryѤ줿㳰ȯ +롥 -*** 饹ʸ +** 饹 -饹빽ʸϰʲ̤Ǥ롥 +饹빽ϰʲ̤Ǥ롥 - class 饹̾ [':' ѡ饹̾ ] + class 饹̾ [`:' ѡ饹̾ ] end 饹̾Ǥդμ̻ҤǤ(ʸǻϤ뤳Ȥ侩)饹 -ΥͥȤϤǤʤΤ¾ʸǤϥ饹Ǥʤ +ΥͥȤϤǤʤΤ¾Ǥϥ饹Ǥʤ -*** ⥸塼ʸ +** ⥸塼 -⥸塼빽ʸϰʲ̤Ǥ롥 +⥸塼빽ϰʲ̤Ǥ롥 module 饹̾ @@ -768,27 +814,13 @@ yieldʸ ⥸塼̾ʸǻϤޤ뼱̻ҤǤ롥饹Ʊ͡⥸塼 ͥȤǤʤ -*** 󥯥롼ʸ - -⥸塼򥤥󥯥롼ɤ뤳Ȥˤäơ饹ޤϥ⥸塼˵ǽ -ɲäǤ롥⥸塼򥤥󥯥롼ɤ硤Υ⥸塼( -Υ⥸塼뤬˥󥯥롼ɤƤ⥸塼)ƤΥ᥽åɤ -Ѥ̤Τ򤹤Х󥯥롼ɤϸꤵ줿¿ŷѾȤ롥 - -¾Υ⥸塼򥤥󥯥롼ɤ빽ʸϰʲ̤Ǥ롥 - - include ⥸塼̾ [',' ⥸塼̾...] - -ߤΥ饹ޤϥ⥸塼(ȥåץ٥ǤObject饹)˻ -ꤷ⥸塼򥤥󥯥롼ɤ롥 - -*** ᥽åʸ +** ᥽å ̾(ðۥ᥽åɤǤʤ)᥽åηϰʲ̤Ǥ롥̾᥽ -ϥͥȤǤʤΤǡ᥽åʸǤϥ᥽åʸƤӸ +ϥͥȤǤʤΤǡ᥽åǤϥ᥽åƤӸ ӽФʤ - def ᥽å̾ ['(' [',' ...][',' '*' ] ')'] + def ᥽å̾ [`(' [`,' ...][`,' `*' ] `)'] end @@ -798,17 +830,22 @@ yieldʸ ᥽åɤˤϴؿŪ᥽åɤ̾᥽åɤ롥ؿŪ᥽åɤϴؿ ǤƤӽФȤǤäƳ륯饹ȤΥ֥饹Υ -åɤ餷ƤӽФȤǤʤ饹ʸγˤdefʸϴ -Ū᥽åɤ饹ʸˤdefʸ̾Υ᥽åɤ -롥᥽åɤβĻModule饹export/noexport᥽åɤȤ -ѹ롥 +åɤ餷ƤӽФȤǤʤ + +˥᥽åɤ硤饹γˤdefϴؿŪ᥽ +ɤ饹ˤdef̾Υ᥽åɤ롥 +ѡ饹Υ᥽åɤˤ᥽åɤβĻϥ +ѡ饹Υ᥽åɤΤΤѤ -** ðۥ᥽åʸ +᥽åɤβĻѹˤModule饹export/unexport᥽ +ɤѤ롥 + +** ðۥ᥽å ᥽åˤϤ⤦ðۥ᥽åɤ롥ðۥ᥽åɤȤϤ Υ֥Ȥ˸ͭΥ᥽åɤǤ롥ϰʲ̤Ǥ롥 - def '.' ᥽å̾ ['(' [',' ...][',' '*' ] ')'] + def `.' ᥽å̾ [`(' [`,' ...][`,' `*' ] `)'] end @@ -821,7 +858,21 @@ yieldʸ Υ֥饹ˤѾ롥ؤХ饹ðۥ᥽åɤ¾Υ Ȼظƥˤ륯饹᥽åɤƯ򤹤롥 -*** ᥽åɤ̾ʸ +** INCLUDE + +⥸塼򥤥󥯥롼ɤ뤳Ȥˤäơ饹ޤϥ⥸塼˵ǽ +ɲäǤ롥⥸塼򥤥󥯥롼ɤ硤Υ⥸塼( +Υ⥸塼뤬˥󥯥롼ɤƤ⥸塼)ƤΥ᥽åɤ +Ѥ̤Τ򤹤Х󥯥롼ɤϸꤵ줿¿ŷѾȤ롥 + +¾Υ⥸塼򥤥󥯥롼ɤ빽ϰʲ̤Ǥ롥 + + include ⥸塼̾ [`,' ⥸塼̾...] + +ߤΥ饹ޤϥ⥸塼(ȥåץ٥ǤObject饹)˻ +ꤷ⥸塼򥤥󥯥롼ɤ롥 + +** ALIAS ʲηǥ᥽åɤ̾Ĥ뤳ȤǤ롥 @@ -831,28 +882,20 @@ yieldʸ åɤƤ⡤Ť᥽åɤƤӽФ줿ΤƱƯ 롥 -*** ᥽åäʸ +** UNDEF ᥽åɤäˤundefѤ롥 undef ᥽å̾ -̻Ҥޤʸǻꤷ᥽åɤä +ꤷ᥽åɤä defˤ̾undefˤäȤȥ饹Υ󥿥ե -򥹡ѡ饹Ωѹ뤳ȤǤ롥᥽åɤself -˥åäƤˤϤ褯դʤȴ¸Υ᥽åɤư -ʤʤǽ롥 - -------------------------------------------------------- -* RubyȤ߹ߵǽ +򥹡ѡ饹Ωѹ뤳ȤǤ롥᥽åɤself +˥åäƤ⤢Τǡ褯դʤȴ¸Υ᥽å +ưʤʤǽ롥 -Rubyץߥ󥰤δܤϥ饹⥸塼ȤΥ᥽åɤνǤ롥 -RubyˤϽϤΤΤ˰ʲεǽȤ߹ޤƤ롥饤֥ -ɤ뤳ȤˤäƵǽ뤬˴ؤƤϤ줾Υ饤֥ -ΥɥȤ򻲾ȤƤ餤 - -** ؿ +* Ȥ߹ߴؿ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ ̾說饹ؿǸƤӽФΤ)ؿŪѤ롥ؿŪ @@ -1081,7 +1124,7 @@ Ruby ƤʤޥǤflagsϤĤnilޤ0ǤʤФ ʤ -** ƥѿ +* Ȥ߹ѿ $! 顼åfailꤹ롥 @@ -1180,7 +1223,6 @@ Ruby $VERSION rubyΥС򼨤ʸ -** ƥ %TRUE t %FALSE nil @@ -1201,9 +1243,9 @@ Ruby ϴˤƱǤϤʤ%FALSE˴ؤƤϡΤ褦 ʤ -** 饹/⥸塼 +* Ȥ߹ߥ饹ȥ⥸塼 -*** Array(饹) +** Array(饹) źȤΥ饹Ǥ롥ϰŪˤ``[...]'' Ԥʤ롥 @@ -1385,7 +1427,13 @@ Methods: objƬɲä롥 -*** Bignum(饹) +Single Methods: + + Array[item...] + + ǤȤ롥 + +** Bignum(饹) ̵¿ĹΥ饹黻η̤FixnumϰǤˤϼ ưŪ˥饹FixnumѴ롥ŪRubyץǤFixnum @@ -1425,7 +1473,7 @@ Methods: Ⱦ;2Ǥ֤ -*** Block(饹) +** Block(饹) ƥ졼Ϥ³ޤȤ᤿֥ȡ¹Ԥ륳ɤ ʤƥ(ѿ)ʤɤ¸롥 @@ -1434,7 +1482,7 @@ SuperClass: Object Methods: - do(arg[, ...]) + call(arg[, ...]) ֥å¹Ԥ롥 @@ -1446,7 +1494,7 @@ Single Methods: ƤФȡλǼ¹Ԥ٤ɤ߹֥ (Block)롥 -*** Class(饹) +** Class(饹) 饹Υ饹긷̩ȥ饹ðۥ᥽åɤѾ뤿 ˡ줾᥿饹ȸƤФ̾Τʤ饹򥯥饹Ȥƻ @@ -1472,7 +1520,7 @@ Methods: 饹ðۥ᥽åɤˤäƥС饤ɤ졤饹ˤäư ۤʤ롥 -*** Comparable(⥸塼) +** Comparable(⥸塼) ӱ黻饹ΤMixinΥ⥸塼򥤥󥯥롼ɤ뤳 Ȥˤäơ`<=>'黻Ҥ¾α黻ҤϤѤ @@ -1504,7 +1552,7 @@ Methods: selfminmaxϰˤ֤ -*** Cons(饹) +** Cons(饹) ǡ(ڥ)ɽ륯饹̾`::'黻ҤѤƹԤʤ 롥LispCONSڥƱͤListѤ뤳Ȥ⤢롥 @@ -1561,7 +1609,7 @@ Methods: CONSڥʤꥹȤγǤͿ륤ƥ졼 -*** DBM(饹) +** DBM(饹) NDBMե򥢥륯饹ǡȤʸǤʤФ ʤȤ¤ȡǡե¸ȤƤ @@ -1657,7 +1705,7 @@ Single Methods: 롥modeξάͤ0666Ǥ롥modeȤnilꤹȥǡ ١¸ߤʤˤϿ˥ץ󤻤nil֤ -*** Dict(饹) +** Dict(饹) 񤢤뤤ϢǤդΥ֥ȤźȤǤΥ饹Ǥ 롥HashȤ̾Ǥ⥢Ǥ롥Ϣ󥪥֥Ȥϰ @@ -1740,11 +1788,15 @@ Methods: Single Methods: + Dict[key, value...] + + ܤΰkeyܤΰvalueȤ뼭롥 + new ()񥪥֥Ȥ֤ -*** Directory(饹) +** Directory(饹) ǥ쥯ȥǤ֤ǥ쥯ȥꥹȥ꡼ΤΥ饹 DirȤ̾Ǥ⥢Ǥ롥 @@ -1808,7 +1860,7 @@ Single Methods: pathǻꤵ줿ǥ쥯ȥ롥ǥ쥯ȥ϶Ǥ ɬפ롥 -*** Enumerable(⥸塼) +** Enumerable(⥸塼) ǤФ뷫֤Ԥʤ饹ΤMixinΥ⥸塼򥤥 롼ɤ뤿ˤϡ᥽å`each'ɬפ롥 @@ -1866,7 +1918,7 @@ Methods: ƤǤ򥽡Ȥ֤ -*** Etc(⥸塼) +** Etc(⥸塼) /etcǥ쥯ȥʲξ뤿Υ⥸塼롥饹˥󥯥롼 ƻȤȤǤ롥 @@ -1938,7 +1990,7 @@ Single Methods: Ƥpasswdȥ˥뤿Υƥ졼 -*** File(饹) +** File(饹) ե륢ΤΥ饹᥽åopen()롥ޤ 饹ðۥ᥽åɤȤtestΥեƥȱ黻Υ᥽åɤ @@ -2097,7 +2149,7 @@ Single Methods: ʳFileTest⥸塼Υ᥽åɤðۥ᥽åɤȤƻġ -*** FileTest(⥸塼) +** FileTest(⥸塼) եƥѥ᥽åɤ򽸤᤿⥸塼롥󥯥롼ɤѤ뤳 Ǥ롥 @@ -2203,7 +2255,7 @@ Single Methods: filenameΥե뤬¸ߤ礭0Ǥ֤ -*** Fixnum(饹) +** Fixnum(饹) 31bit(ޥlongĹ-1 bit)Υ饹builtin classǤ롥 饹pointer¨ͤǤ뤿call by valueǸƤӽФħŪ @@ -2268,7 +2320,7 @@ Methods: ƥ졼selfmaxޤǷ֤ -*** Float(饹) +** Float(饹) ưΥ饹 @@ -2309,7 +2361,7 @@ Single Methods: floatƱͤĿFloat֥Ȥ֤ -*** GC(⥸塼) +** GC(⥸塼) RubyȤ߹ߤgarbage collectorԤʤΥ⥸塼롥Υ 塼Υ᥽åɤѤ뤳ȤˤäơŪGCߤ᤿ꡤGCε @@ -2335,7 +2387,7 @@ Single Methods: GC򳫻Ϥ롥 -*** Glob(饹) +** Glob(饹) 磻ɥɤΥ饹磻ɥɤΥƥ<...>ȤǤ 롥ɽȤۤƱ褦˻Ȥ뤬ϵǽʤ @@ -2362,7 +2414,7 @@ Single Methods: ʸ磻ɥɤѴ֥Ȥ֤ -*** Integer(饹) +** Integer(饹) 饹ºݤϤ礭ˤäFixnumBignumĤΥ֥饹 Ǽ¸Ƥ롥IntegerϤΥѡ饹Ȥʤݥ饹Ǥ @@ -2392,7 +2444,7 @@ Methods: Ĥ⿿֤ -*** IO(饹) +** IO(饹) ϤΤδܥ饹 @@ -2493,7 +2545,7 @@ Methods: strϤ롥ϤХȿ֤ -*** Kernel(饹) +** Kernel(饹) ƤΥ饹δ쥯饹RubyȤ߹ߤƤδؿ᥽åɤϤΥ饹 Ƥ롥ؿ᥽åɤˤĤƤϡִؿפιܤ򻲾ȤΤȡ @@ -2565,7 +2617,7 @@ Methods: ˤɬ⤽˹碌ƺ뤳ȡ -*** Math(⥸塼) +** Math(⥸塼) ư黻򥵥ݡȤ륯饹Math⥸塼ƱΥ᥽å ðۥ᥽åɤȤξƤΤǡðۥ᥽åɤƤӽФƻ @@ -2610,7 +2662,7 @@ Single Methods: xΩ֤ -*** Module(饹) +** Module(饹) ⥸塼Υ饹 @@ -2665,7 +2717,7 @@ Methods: nameǻꤵ줿᥽åɤؿǤƤӽФǽˤ롥 Ǥ˴ؿ᥽åɤǤˤϲ⤷ʤ -*** Nil(饹) +** Nil(饹) ɽ֥nilΥ饹ѿ()nilNil饹ͣΥ 󥹥󥹤Ǥ롥 @@ -2686,7 +2738,7 @@ Methods: ˿֤ -*** Numeric(饹) +** Numeric(饹) ̤ɽݥ饹 @@ -2717,7 +2769,7 @@ Methods: ο֤οȤϤοۤǾǤ롥 -*** Object(饹) +** Object(饹) Ƥ̾說饹Υѥ饹̾說饹Υ󥹥󥹤ΰŪʿ Ƥ롥Υ饹Υ֥饹Ǥʤ饹KernelNilȡ @@ -2727,6 +2779,9 @@ SuperClass: Builtin Methods: + init_object + + is_member_of(class) ֥self饹classΥ󥹥󥹤Ǥ֤ @@ -2752,7 +2807,7 @@ Methods: ֥ȤѴ롥ͥ륯饹Ƥ եȤϡΥ֥ȼȤޤ1Ǥ֤ -*** Process(⥸塼) +** Process(⥸塼) ץ˴ؤԤʤΥ⥸塼롥Math⥸塼Ʊͤ ƤΥ᥽åɤðۥ᥽åɤȤƤ̾Υ᥽åɤȤƤȤ롥 @@ -2827,7 +2882,7 @@ Single Methods: ץθߤμUIDuid˥åȤ. -*** Range(饹) +** Range(饹) ϰϥ֥ȤΥ饹ϰϥ֥Ȥ`..'黻Ҥˤä졤 ŪˤϰʲΤ褦ʻȤ򤹤 @@ -2855,7 +2910,7 @@ Methods: self =~ other selfotherƱ饹Фϰϥ֥Ȥǡϰ - other(start <= other <= end)֤caseʸ + other(start <= other <= end)֤case ϰϻꤹǤ롥㤨 case i @@ -2867,7 +2922,7 @@ Methods: each - ϰ¸ߤ륪֥ȤͿ륤ƥ졼forʸΤ + ϰ¸ߤ륪֥ȤͿ륤ƥ졼forΤ Ѥ롥 end @@ -2878,7 +2933,7 @@ Methods: ϰϤλ֤ -*** Socket(饹) +** Socket(饹) SuperClass: BasicSocket @@ -2938,7 +2993,8 @@ Single Methods: åȤΥڥ֤λ openƱǤ롥 -*** Regexp(饹) + +** Regexp(饹) ɽΥ饹ɽΥƥ/.../ȤɽưŪ 뤿ˤ @@ -2974,7 +3030,12 @@ Single Methods: ̤롥ꤵʤϥޥåԤʤäΥƥѿ `$='ͤˤäƶ̤뤫ʤꤵ롥 -*** BasicSocket(饹) + quote(str) + + ʸɽǰ̣ʸ򥨥פ롥ʸ + ֤ + +** BasicSocket(饹) åȤɽݥ饹Ūʥåϥ֥饹롥 㤨Х󥿡ͥåȥɥᥤξTCPsocketѤ롥 @@ -3008,7 +3069,7 @@ Methods: how1Ǥϡʹߤݤ롥how2λˤϡ ʹߤȤ˵ݤ롥shutdown(2)򻲾ȡ -*** String(饹) +** String(饹) ʸ󥯥饹Rubyʸϥ̥륿ߥ͡ȤǤϤʤΤǡХʥǡ ⰷ롥äƤɤ餫ȤñʤʸȤХǤ롥 @@ -3323,7 +3384,7 @@ Single Methods: stringƱƤĿʸ֤ -*** Struct(饹) +** Struct(饹) ¤Υ饹ʣΥǡޤȤѤ(: Time::times) ǡޤȤˤ󥯥饹Ѥ뤳Ȥ⤢뤬(: select) @@ -3386,7 +3447,7 @@ Single Methods: Фǻꤵ줿̾ðۥ᥽åɤƤơΥ᥽å ˤäƥФƤ뤳ȤǤ롥 -*** TCPserver(饹) +** TCPserver(饹) TCP/IPȥ꡼෿³Υ¦ΥåȤΥ饹Υ饹ˤä ñ˥åȤѤФΥץߥ󥰤Ǥ롥㤨echo @@ -3432,7 +3493,7 @@ Single Methods: ³դ롥άƤΥۥȤ³׵ 롥 -*** TCPsocket +** TCPsocket 󥿡ͥåȥɥᥤΥȥ꡼෿åȤΥ饹̾IO饹 ֥饹ƱͤϤǤ롥Υ饹ˤäƥåȤѤ @@ -3470,7 +3531,7 @@ Single Methods: service/etc/services(ޤNIS)ϿƤ륵 ̾ݡֹǤ롥 -*** Time(饹) +** Time(饹) ֤ɽ饹羮ӤʤɤǤ롥Time.nowǸߤλ֤뤳 Ǥ롥ޤեΥॹפ᥽åɤͤ⤳Υ @@ -3593,7 +3654,7 @@ Single Methods: ֤ñ̤äǤꡤưͿ롥ܺ٤ times(3)򻲾ȤΤȡ -*** UNIXserver +** UNIXserver UNIXȥ꡼෿³Υ¦ΥåȤΥ饹 @@ -3606,7 +3667,7 @@ Methods: 饤Ȥ³׵դ³UNIXsocketΥ 󥹤֤ -*** UNIXsocket +** UNIXsocket UNIXɥᥤΥȥ꡼෿åȤΥ饹̾IO饹Υ֥饹 ƱͤϤǤ롥 @@ -3636,6 +3697,210 @@ Single Methods: pathǻꤷѥ̾Ѥ³åȤ֤ +* CȤΥ󥿥ե + +rubyCȤΥ󥿡ե󶡤C줫Υ饹⥸塼 +CǵҤ᥽åɤrubyΥ᥽åɤθƤӽФ +졼θƤӽФ㳰ʤɤԤʤȤ롥ޤOSм +ԻCǽ񤫤줿⥸塼ɤ뤳Ȥ롥 + +Ūʥ󥿥ե˴ؤƤϡ̥ɥ(źեե C-IF) +ȤΤȡ + +* ʸˡ + +ʲϵBNFǵҤrubyʸˡǤ롥ΤʵҤparse.y򻲾 +줿 + +PROGRAM : COMPEXPR + +COMPEXPR : EXPR (TERM EXPR)* [TERM] + +EXPR : MLHS `=' ARGS + | ASSOCS + | return ARGS + | fail ARGS + | yield ARGS + | identifier CALL_ARGS + | PRIMARY `.' identifier CALL_ARGS + | super CALL_ARGS + | undef FNAME + | alias FNAME FNAME + | include identifier (`,' identifier)* + | EXPR if EXPR + | EXPR while EXPR + | EXPR and EXPR + | EXPR or EXPR + | ARG + +ARG : LHS `=' ARG + | LHS OP_ASGN ARG + | ARG `..' ARG + | ARG `...' ARG + | ARG `+' ARG + | ARG `-' ARG + | ARG `*' ARG + | ARG `/' ARG + | ARG `%' ARG + | ARG `**' ARG + | `+' ARG + | `-' ARG + | ARG `|' ARG + | ARG `^' ARG + | ARG `&' ARG + | ARG `<=>' ARG + | ARG `>' ARG + | ARG `>=' ARG + | ARG `<' ARG + | ARG `<=' ARG + | ARG `==' ARG + | ARG `!=' ARG + | ARG `=~' ARG + | ARG `!~' ARG + | `!' ARG + | `~' ARG + | ARG `<<' ARG + | ARG `>>' ARG + | ARG `::' ARG + | ARG `&&' ARG + | ARG `||' ARG + | PRIMARY + +PRIMARY : LITERAL + | VARIABLE + | super `(' [CALL_ARGS] `)' + | super + | PRIMARY `[' [ARGS] `]' + | `[' [ARGS] `]' + | `{' ARGS `}' + | `{' ASSOCS `}' + | redo + | break + | continue + | retry + | return + | fail `(' ARGS `)' + | fail `(' `)' + | fail + | yield `(' ARGS `)' + | yield `(' `)' + | yield + | PRIMARY `{' [ITER_VAR] `|' COMPEXPR `}' + | identifier `(' [CALL_ARGS] `)' + | PRIMARY `.' identifier `(' [CALL_ARGS] `)' + | PRIMARY `.' identifier + | if EXPR THEN + COMPEXPR + (elsif EXPR THEN COMPEXPR)* + [else COMPEXPR] + end + | while EXPR TERM COMPEXPR end + | case COMPEXPR + (when ARGS THEN)+ + [else COMPEXPR] + end + | for ITER_VAR in EXPR TERM + COMPEXPR + end + | protect + COMPEXPR + [resque COMPEXPR] + [ensure COMPEXPR] + end + | `(' COMPEXPR `)' + | class identifier `:' identifier + COMPEXPR + end + | module identifier + COMPEXPR + end + | def FNAME ARGLIST + COMPEXPR + end + | def SINGLETON `.' FNAME ARGLIST + COMPEXPR + end + +THEN : TERM + | then + | TERM then + +ITER_VAR : LHS + | MLHS + +MLHS : LHS `,' [LHS (`,' LHS)*] [`*' LHS] + +LHS : VARIABLE + | PRIMARY `[' [ARGS] `]' + | PRIMARY `.' identifier + +CALL_ARGS : ARGS + | ASSOCS + | ARGS `,' ASSOCS + | ARGS `,' `*' ARG + +ARGS : ARG + | ARGS `,' ARG + +ARGLIST : `('[identifier(`,'identifier)*][`*'identifier]`)' + | TERM + +SINGLETON : VARIABLE + | `(' COMPEXPR `)' + +ASSOCS : ASSOC (`,' ASSOC)* + +ASSOC : ARG `=>' ARG + +VARIABLE : identifier + | VARNAME + | nil + | self + | `__FILE__' + | `__LINE__' + +LITERAL : numeric + | SYMBOL + | STRING + | REGEXP + | GLOB + +TERM : `;' + | `\n' + +겼ϻǧ롥 + +SYMBOL : `:'FNAME + | `:'VARNAME + +FNAME : identifier | `::' | `..' | `|' | `^' | `&' + | `<=>' | `==' | `=~' | `>' | `>=' | `<' | `<=' + | `<<' | `>>' | `+' | `-' | `*' | `/' | `%' | `**' + | `~' | `+@' | `-@' | `[]' | `[]=' + +VARNAME : GLOBAL + | `@'identifier + | `%'identifier + +GLOBAL : `$'identifier + | `$'any_char + +STRING : `"' any_char* `"' + | `'' any_char* `'' + | ``' any_char* ``' + +REGEXP : `/' any_char* `/' + +GLOB : `<' any_char* `>' + +* ռ + +RubyθͤC, Perl, EiffelγƸˤν˱ƶƤ. +¾˱ƶȤƤtcl, AWK, bourne shell, CLU, Sather, +Icon, Smalltalk, Emacs Lispʤɤ. ޤrubyθͤꤹ뤿 +˶ϤƲäʲˤ(ɾά): ͷ +ƣϺ¼ΣţáغDECʤ@ֺ.ٻ̡ + ------------------------------------------------------- Local variables: fill-column: 70 diff --git a/sprintf.c b/sprintf.c index 278b16607c..c74ec080ff 100644 --- a/sprintf.c +++ b/sprintf.c @@ -282,7 +282,7 @@ Fsprintf(argc, argv) blen += strlen(&buf[blen]); } break; - + case 'd': case 'D': case 'O': diff --git a/st.c b/st.c index 80f08e9fb6..eb3ad92871 100644 --- a/st.c +++ b/st.c @@ -58,7 +58,7 @@ int reorder_flag; tbl->grow_factor = grow_factor; tbl->reorder_flag = reorder_flag; tbl->num_bins = size; - tbl->bins = + tbl->bins = (st_table_entry **) Calloc((unsigned)size, sizeof(st_table_entry *)); return tbl; } @@ -122,11 +122,11 @@ char **value; hash_val = do_hash(key, table); FIND_ENTRY(table, ptr, hash_val); - + if (ptr == nil(st_table_entry)) { return 0; } else { - if (value != nil(char *)) *value = ptr->record; + if (value != nil(char *)) *value = ptr->record; return 1; } } @@ -176,7 +176,7 @@ char *value; { int hash_val; st_table_entry *tbl; - + hash_val = do_hash(key, table); ADD_DIRECT(table, key, value, hash_val, tbl); } @@ -210,13 +210,13 @@ register st_table *table; int i, old_num_bins = table->num_bins, hash_val; table->num_bins = table->grow_factor*old_num_bins; - + if (table->num_bins%2 == 0) { table->num_bins += 1; } - + table->num_entries = 0; - table->bins = + table->bins = (st_table_entry **) Calloc((unsigned) table->num_bins, sizeof(st_table_entry *)); @@ -245,9 +245,9 @@ st_table *old_table; if (new_table == nil(st_table)) { return nil(st_table); } - + *new_table = *old_table; - new_table->bins = + new_table->bins = (st_table_entry **) Calloc((unsigned) num_bins, sizeof(st_table_entry *)); @@ -357,7 +357,7 @@ int modulus; { register int val = 0; register int c; - + while ((c = *string++) != '\0') { val = val*997 + c; } diff --git a/string.c b/string.c index 3861f71d32..aacc6f621c 100644 --- a/string.c +++ b/string.c @@ -489,7 +489,7 @@ Fstr_rindex(argc, argv, str) Check_Type(sub, T_STRING); if (pos > str->len) return Qnil; /* substring longer than string */ - sbeg = str->ptr; s = s + pos - sub->len; + sbeg = str->ptr; s = sbeg + pos - sub->len; t = sub->ptr; len = sub->len; while (sbeg <= s) { @@ -535,7 +535,7 @@ Fstr_next(orig) char c = -1; str = (struct RString*)str_new(orig->ptr, orig->len); - + sbeg = str->ptr; s = sbeg + str->len - 1; while (sbeg <= s) { @@ -642,7 +642,9 @@ str_replace(str, beg, len, val) REALLOC_N(str->ptr, char, str->len+val->len-len+1); } - memmove(str->ptr+beg+val->len, str->ptr+beg+len, str->len-(beg+len)); + if (len != val->len) { + memmove(str->ptr+beg+val->len, str->ptr+beg+len, str->len-(beg+len)); + } memcpy(str->ptr+beg, val->ptr, val->len); str->len += val->len - len; str->ptr[str->len] = '\0'; @@ -830,7 +832,7 @@ Fsub(obj, pat, val) Check_Type(rb_lastline, T_STRING); return Fstr_sub_internal(rb_lastline, pat, val, 1); } - + static VALUE Fgsub(obj, pat, val) VALUE obj, pat, val; diff --git a/struct.c b/struct.c index 819b3526da..a368605965 100644 --- a/struct.c +++ b/struct.c @@ -167,7 +167,7 @@ Fstruct_aref(s, idx) if (TYPE(idx) == T_STRING) return struct_find(rb_intern(RSTRING(idx)->ptr)); - + i = NUM2INT(idx); if (s->len <= i) Fail("offset %d too large for struct(size:%d)", i, s->len); diff --git a/time.c b/time.c index b6c1bd26cb..73f3837ec5 100644 --- a/time.c +++ b/time.c @@ -30,9 +30,13 @@ struct time_object { static ID id_tv; -#define GetTimeval(obj, tobj) \ - Get_Data_Struct(obj, id_tv, struct time_object, tobj) +#define GetTimeval(obj, tobj) {\ + if (!id_tv) id_tv = rb_intern("tv");\ + Get_Data_Struct(obj, id_tv, struct time_object, tobj);\ +} + #define MakeTimeval(obj,tobj) {\ + if (!id_tv) id_tv = rb_intern("tv");\ Make_Data_Struct(obj, id_tv, struct time_object, Qnil, Qnil, tobj);\ tobj->tm_got=0;\ } @@ -118,7 +122,7 @@ time_timeval(time) static VALUE Stime_at(class, time) VALUE class, time; -{ +{ VALUE obj; int sec, usec; struct time_object *tobj; @@ -557,6 +561,4 @@ Init_Time() rb_define_method(C_Time, "usec", Ftime_usec, 0); rb_define_method(C_Time, "strftime", Ftime_strftime, 1); - - id_tv = rb_intern("tv"); } diff --git a/variable.c b/variable.c index 88a306841f..bdfca0a2cf 100644 --- a/variable.c +++ b/variable.c @@ -3,14 +3,13 @@ variable.c - $Author: matz $ - $Date: 1995/01/10 10:43:03 $ + $Date: 1995/01/12 08:54:53 $ created at: Tue Apr 19 23:55:15 JST 1994 ************************************************/ #include "ruby.h" #include "env.h" -#include "node.h" #include "ident.h" #include "st.h" @@ -209,58 +208,6 @@ rb_gvar_get(entry) return Qnil; } -VALUE -rb_ivar_get_1(obj, id) - struct RBasic *obj; - ID id; -{ - VALUE val; - - if (obj->iv_tbl == Qnil) - return Qnil; - if (st_lookup(obj->iv_tbl, id, &val)) - return val; - if (verbose) - Warning("instance var %s not initialized", rb_id2name(id)); - return Qnil; -} - -VALUE -rb_ivar_get(id) - ID id; -{ - return rb_ivar_get_1(Qself, id); -} - -VALUE -rb_mvar_get(id) - ID id; -{ - VALUE val; - - if (st_lookup(class_tbl, id, &val)) return val; - if (verbose) - Warning("local var %s not initialized", rb_id2name(id)); - return Qnil; -} - -VALUE -rb_const_get(id) - ID id; -{ - struct RClass *class = (struct RClass*)CLASS_OF(Qself); - VALUE value; - - while (class) { - if (class->c_tbl && st_lookup(class->c_tbl, id, &value)) { - return value; - } - class = class->super; - } - Fail("Uninitialized constant %s", rb_id2name(id)); - /* not reached */ -} - VALUE rb_gvar_set(entry, val) struct global_entry *entry; @@ -300,14 +247,68 @@ rb_gvar_set2(name, val) return val; } +VALUE +rb_mvar_get(id) + ID id; +{ + VALUE val; + + if (st_lookup(class_tbl, id, &val)) return val; + if (verbose) + Warning("local var %s not initialized", rb_id2name(id)); + return Qnil; +} + +VALUE +rb_ivar_get_1(obj, id) + struct RObject *obj; + ID id; +{ + VALUE val; + + switch (TYPE(obj)) { + case T_OBJECT: + case T_CLASS: + case T_MODULE: + if (obj->iv_tbl && st_lookup(obj->iv_tbl, id, &val)) + return val; + return Qnil; + default: + Fail("class %s can not have instance variables", + rb_class2name(CLASS_OF(obj))); + break; + } + if (verbose) { + Warning("instance var %s not initialized", rb_id2name(id)); + } + return Qnil; +} + +VALUE +rb_ivar_get(id) + ID id; +{ + return rb_ivar_get_1(Qself, id); +} + VALUE rb_ivar_set_1(obj, id, val) - struct RBasic *obj; + struct RObject *obj; ID id; VALUE val; { - if (obj->iv_tbl == Qnil) obj->iv_tbl = new_idhash(); - st_insert(obj->iv_tbl, id, val); + switch (TYPE(obj)) { + case T_OBJECT: + case T_CLASS: + case T_MODULE: + if (obj->iv_tbl == Qnil) obj->iv_tbl = new_idhash(); + st_insert(obj->iv_tbl, id, val); + break; + default: + Fail("class %s can not have instance variables", + rb_class2name(CLASS_OF(obj))); + break; + } return val; } @@ -319,13 +320,30 @@ rb_ivar_set(id, val) return rb_ivar_set_1(Qself, id, val); } -static VALUE -const_bound(class, id) +VALUE +rb_const_get(id) + ID id; +{ + struct RClass *class = (struct RClass*)CLASS_OF(Qself); + VALUE value; + + while (class) { + if (class->iv_tbl && st_lookup(class->iv_tbl, id, &value)) { + return value; + } + class = class->super; + } + Fail("Uninitialized constant %s", rb_id2name(id)); + /* not reached */ +} + +VALUE +rb_const_bound(class, id) struct RClass *class; ID id; { while (class) { - if (class->c_tbl && st_lookup(class->c_tbl, id, Qnil)) { + if (class->iv_tbl && st_lookup(class->iv_tbl, id, Qnil)) { return TRUE; } class = class->super; @@ -339,13 +357,11 @@ rb_const_set(class, id, val) ID id; VALUE val; { - if (const_bound(class, id)) + if (rb_const_bound(class, id)) Fail("already initialized constnant"); - if (class->c_tbl == Qnil) - class->c_tbl = new_idhash(); - - st_insert(class->c_tbl, id, val); + if (class->iv_tbl == Qnil) class->iv_tbl = new_idhash(); + st_insert(class->iv_tbl, id, val); } void diff --git a/version.c b/version.c index aa9028b0e4..27a3182f9c 100644 --- a/version.c +++ b/version.c @@ -3,8 +3,8 @@ version.c - $Author: matz $ - $Revision: 1.4 $ - $Date: 1994/12/19 08:30:17 $ + $Revision: 1.5 $ + $Date: 1995/01/12 08:54:54 $ created at: Thu Sep 30 20:08:01 JST 1993 Copyright (C) 1994 Yukihiro Matsumoto diff --git a/version.h b/version.h index ef005b1692..d24ad99a31 100644 --- a/version.h +++ b/version.h @@ -1,2 +1,2 @@ -#define RUBY_VERSION "0.64" -#define VERSION_DATE "95/01/10" +#define RUBY_VERSION "0.65" +#define VERSION_DATE "95/02/08" -- cgit v1.2.1