summaryrefslogtreecommitdiff
path: root/insns.def
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-04 19:17:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-04 19:17:33 +0000
commit72f2d2a00d8ae3861a15ca92bf9322951a22b6cf (patch)
tree3f74f159fcc7abf2e87ff7295e6400651a26a8c4 /insns.def
parent71364da03fcae2e0fb7b2641b6ac1e507ee03da6 (diff)
* parse.y (rb_compose_ivar2): function to create a new ivar2
symbol from a symbol and a class. back-ported from matzruby. * parse.y (rb_decompose_ivar2): reverse function of rb_compose_ivar2(). * marshal.c (w_symbol): support class local instance variables. * marshal.c (r_object0): ditto. * compile.c (defined_expr): ditto. * compile.c (iseq_compile_each): ditto. * insns.def: add two new instructions: getinstancevariable2 and setinstancevariable2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r--insns.def38
1 files changed, 38 insertions, 0 deletions
diff --git a/insns.def b/insns.def
index 99401cc395..b84d07f290 100644
--- a/insns.def
+++ b/insns.def
@@ -188,6 +188,22 @@ getinstancevariable
/**
@c variable
+ @e get class local instance variable id of obj.
+ @j obj のクラスローカルインスタンス変数 id を得る。
+ */
+DEFINE_INSN
+getinstancevariable2
+(ID id)
+()
+(VALUE val)
+{
+ /* need to cache composed id */
+ id = rb_compose_ivar2(id, eval_get_cvar_base(th, GET_ISEQ()));
+ val = rb_ivar_get(GET_SELF(), id);
+}
+
+/**
+ @c variable
@e set instance variable id of obj as val.
@j obj のインスタンス変数を val にする。
*/
@@ -202,6 +218,22 @@ setinstancevariable
/**
@c variable
+ @e set class local instance variable id of obj as val.
+ @j obj のクラスローカルインスタンス変数を val にする。
+ */
+DEFINE_INSN
+setinstancevariable2
+(ID id)
+(VALUE val)
+()
+{
+ /* need to cache composed id */
+ id = rb_compose_ivar2(id, eval_get_cvar_base(th, GET_ISEQ()));
+ rb_ivar_set(GET_SELF(), id, val);
+}
+
+/**
+ @c variable
@e get class variable id of klass as val.
@j klass のクラス変数 id を得る。
*/
@@ -901,6 +933,12 @@ defined
expr_type = "instance-variable";
}
break;
+ case DEFINED_IVAR2:
+ klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
+ if (rb_ivar_defined(GET_SELF(), rb_compose_ivar2(SYM2ID(obj), klass))) {
+ expr_type = "class local instance-variable";
+ }
+ break;
case DEFINED_GVAR:
if (rb_gvar_defined((struct global_entry *)(obj & ~1))) {
expr_type = "global-variable";