From 5e4edb43a2a3183931b3d891b1c4bd6031b73560 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 14 May 2008 02:31:28 +0000 Subject: * insns.def: add a "putcbase" instruction. * compile.c, insns.def: fix to use putcbase instruction for class search. Qundef should not be used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- insns.def | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'insns.def') diff --git a/insns.def b/insns.def index 0850fab32f..7723874c6c 100644 --- a/insns.def +++ b/insns.def @@ -237,18 +237,11 @@ getconstant DEFINE_INSN setconstant (ID id) -(VALUE val, VALUE klass) +(VALUE val, VALUE cbase) () { - if (klass == Qundef) { - klass = vm_get_cbase(th); - if (NIL_P(klass)) { - rb_raise(rb_eTypeError, "no class/module to define constant"); - } - } - - vm_check_if_namespace(klass); - rb_const_set(klass, id, val); + vm_check_if_namespace(cbase); + rb_const_set(cbase, id, val); INC_VM_STATE_VERSION(); } @@ -313,6 +306,20 @@ putself val = GET_SELF(); } +/** + @c put + @e put cbase. + @j スタックに cbase をプッシュする。 + */ +DEFINE_INSN +putcbase +() +() +(VALUE val) +{ + val = vm_get_cbase(th); +} + /** @c put @e put some object. @@ -929,13 +936,6 @@ defineclass super = rb_cObject; } - if (cbase == Qundef) { - cbase = vm_get_cbase(th); - if (NIL_P(cbase)) { - rb_raise(rb_eTypeError, "no class/module to define constant"); - } - } - vm_check_if_namespace(cbase); /* find klass */ @@ -972,12 +972,6 @@ defineclass case 2: /* val is dummy. classdef returns class scope value */ /* super is dummy */ - if (cbase == Qundef) { - cbase = vm_get_cbase(th); - if (NIL_P(cbase)) { - rb_raise(rb_eTypeError, "no class/module to define constant"); - } - } vm_check_if_namespace(cbase); -- cgit v1.2.3