[#15357] Regexp literal and Regexp.new() — TAKAHASHI Masayoshi <maki@...>

高橋征義です。

14 messages 2001/12/05
[#15358] Regexp in UTF-8 (Re: Regexp literal and Regexp.new()) — TAKAHASHI Masayoshi <maki@...> 2001/12/05

高橋征義です。むーん、問題のありかが違ったかも。

[#15435] Time#utcoff — Tanaka Akira <akr@...17n.org>

In article <hvosnahj702.fsf@coulee.a02.aist.go.jp>,

20 messages 2001/12/13
[#15436] Re: Time#utcoff — matz@... (Yukihiro Matsumoto) 2001/12/14

まつもと ゆきひろです

[#15505] ERb — m_seki@...

74 messages 2001/12/20
[#15560] Re: ERb — Tanaka Akira <akr@...17n.org> 2001/12/27

In article <20011220114249J.seki@mr.nasu.toshiba.co.jp>,

[#15879] Re: ERb — m_seki@... 2002/02/12

[#15884] Re: ERb — Tanaka Akira <akr@...17n.org> 2002/02/14

In article <m3eljr5o9m.wl@edwin.mva.biglobe.ne.jp>,

[#15885] Re: ERb — m_seki@... 2002/02/14

[#15886] Re: ERb — m_seki@... 2002/02/14

[#15887] Re: ERb — TAKAHASHI Masayoshi <maki@...> 2002/02/14

高橋征義です。

[#15888] Re: ERb — m_seki@... 2002/02/14

[#15896] Re: ERb — Tanaka Akira <akr@...17n.org> 2002/02/15

In article <20020215085405G.seki@mr.nasu.toshiba.co.jp>,

[#15898] Re: ERb — m_seki@... 2002/02/15

[#15900] Re: ERb — TADA Tadashi <sho@...> 2002/02/16

ただただしです。

[#15901] Re: ERb — m_seki@... 2002/02/16

[#15906] Re: ERb — matz@... (Yukihiro Matsumoto) 2002/02/17

まつもと ゆきひろです

[#15909] 1.6 の寿命 (Re: Re: ERb) — Koji Arai <JCA02266@...> 2002/02/17

新井です。

[#15507] fileutils (2) — Minero Aoki <aamine@...>

あおきです。

30 messages 2001/12/20
[#15512] Re: fileutils (2) — TAKAHASHI Masayoshi <maki@...> 2001/12/20

高橋征義です。

[#15513] Re: fileutils (2) — Minero Aoki <aamine@...> 2001/12/21

あおきです。

[#15515] Re: fileutils (2) — TAKAHASHI Masayoshi <maki@...> 2001/12/21

高橋征義です。結論は最後に。

[#15516] Re: fileutils (2) — Minero Aoki <aamine@...> 2001/12/21

あおきです。

[#15533] Re: fileutils (2) — TAKAHASHI Masayoshi <maki@...> 2001/12/22

高橋征義です。

[#15536] Re: fileutils (2) — Minero Aoki <aamine@...> 2001/12/24

あおきです。

[#15540] Re: fileutils (2) — TAKAHASHI Masayoshi <maki@...> 2001/12/24

高橋征義です。

[#15545] Re: fileutils (2) — Minero Aoki <aamine@...> 2001/12/24

あおきです。

[#15557] Re: fileutils (2) — TAKAHASHI Masayoshi <maki@...> 2001/12/26

高橋征義です。

[#15567] Re: fileutils (2) — Minero Aoki <aamine@...> 2001/12/27

あおきです。

[#15573] [patch] resolv.rb for win32 platform — Tietew <tietew-ml-ruby-dev@...>

Tietew です。

22 messages 2001/12/28

[ruby-dev:15434] [EXP] private instance variable

From: nobu.nakada@...
Date: 2001-12-13 15:53:10 UTC
List: ruby-dev #15434
なかだです。

ふと思い立って以前話にあがっていたprivate instance variable(で
いいんだっけ)を作ってみました。別クラスで定義したものにアクセス
する手段がないとか、module_evalの中で定義したメソッドでは外側の
名前になってしまうとか、かなり手抜きですが参考までに。


Index: parse.y
===================================================================
RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.136
diff -u -2 -p -r1.136 parse.y
--- parse.y	2001/12/11 03:48:08	1.136
+++ parse.y	2001/12/13 15:24:29
@@ -96,4 +96,5 @@ static stack_type cmdarg_stack = 0;
 #define CMDARG_P() (cmdarg_stack&1)
 
+static VALUE nest_scope;
 static int class_nest = 0;
 static int in_single = 0;
@@ -1413,4 +1414,5 @@ primary		: literal
 			    yyerror("class definition in method body");
 			class_nest++;
+			rb_ary_push(nest_scope, ID2SYM($2));
 			local_push();
 		        $<num>$ = ruby_sourceline;
@@ -1422,4 +1424,5 @@ primary		: literal
 		        nd_set_line($$, $<num>4);
 		        local_pop();
+			rb_ary_pop(nest_scope);
 			class_nest--;
 		    }
@@ -1451,4 +1454,5 @@ primary		: literal
 			    yyerror("module definition in method body");
 			class_nest++;
+			rb_ary_push(nest_scope, ID2SYM($2));
 			local_push();
 		        $<num>$ = ruby_sourceline;
@@ -1459,4 +1463,5 @@ primary		: literal
 		        $$ = NEW_MODULE($2, $4);
 		        nd_set_line($$, $<num>3);
+			rb_ary_pop(nest_scope);
 		        local_pop();
 			class_nest--;
@@ -2146,5 +2151,13 @@ yycompile(f, line)
     ruby_sourcefile = f;
     ruby_in_compile = 1;
+    if (!nest_scope) {
+	nest_scope = rb_ary_new();
+	rb_global_variable(&nest_scope);
+    }
+    else {
+	rb_ary_clear(nest_scope);
+    }
     n = yyparse();
+    rb_ary_clear(nest_scope);
     ruby_debug_lines = 0;
     compile_for_eval = 0;
@@ -3804,6 +3817,21 @@ yylex()
 	    if (tok()[1] == '@')
 		result = tCVAR;
-	    else
+	    else {
+		if (tok()[1] == '_' && tok()[2]) {
+		    VALUE scope = 0;
+		    if (in_def && RARRAY(nest_scope)->len) {
+			scope = rb_ary_join(nest_scope, rb_str_new2("::"));
+		    }
+		    else if (compile_for_eval && RNODE(scope = ruby_frame->cbase)->nd_next) {
+			scope = rb_class_path(RNODE(scope)->nd_clss);
+		    }
+		    if (scope) {
+			char *s = RSTRING(scope)->ptr;
+			tokadd('@');
+			while (*s) tokadd(*s++);
+		    }
+		}
 		result = tIVAR;
+	    }
 	    break;
 
@@ -5152,4 +5180,14 @@ rb_intern(name)
 	else {
 	    id |= ID_INSTANCE;
+	    if (name[1] == '_' && name[2]) {
+		while (*m && *m != '@') {
+		    if (!is_identchar(*m)) {
+			id = ID_JUNK;
+			break;
+		    }
+		    m++;
+		}
+		goto id_new;
+	    }
 	}
 	m++;
@@ -5195,4 +5233,5 @@ rb_intern(name)
     }
     if (*m) id = ID_JUNK;
+  id_new:
     id |= ++last_id << ID_SCOPE_SHIFT;
   id_regist:


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread

Prev Next