aboutsummaryrefslogtreecommitdiffstats
path: root/insns.def
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-02 19:15:29 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-02 19:15:29 +0000
commit15164bf33cf27f38cd5657e2b58acfd9a312f2ed (patch)
treef939e6fdde282f61ea440b773a3d2dc841611767 /insns.def
parent86bafab212c2d73f02386a5e8440f9a72a86ae31 (diff)
downloadruby-15164bf33cf27f38cd5657e2b58acfd9a312f2ed.tar.gz
* insns.def (defined), vm_insnhelper.c (vm_defined):
move instruction body to the vm_defined() function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r--insns.def101
1 files changed, 1 insertions, 100 deletions
diff --git a/insns.def b/insns.def
index 74762e7644..8eaa466107 100644
--- a/insns.def
+++ b/insns.def
@@ -715,106 +715,7 @@ defined
(VALUE v)
(VALUE val)
{
- VALUE klass;
- enum defined_type expr_type = 0;
- enum defined_type type = (enum defined_type)op_type;
-
- val = Qnil;
-
- switch (type) {
- case DEFINED_IVAR:
- if (rb_ivar_defined(GET_SELF(), SYM2ID(obj))) {
- expr_type = DEFINED_IVAR;
- }
- break;
- case DEFINED_IVAR2:
- klass = vm_get_cbase(GET_EP());
- break;
- case DEFINED_GVAR:
- if (rb_gvar_defined(rb_global_entry(SYM2ID(obj)))) {
- expr_type = DEFINED_GVAR;
- }
- break;
- case DEFINED_CVAR: {
- const rb_cref_t *cref = rb_vm_get_cref(GET_EP());
- klass = vm_get_cvar_base(cref, GET_CFP());
- if (rb_cvar_defined(klass, SYM2ID(obj))) {
- expr_type = DEFINED_CVAR;
- }
- break;
- }
- case DEFINED_CONST:
- klass = v;
- if (vm_get_ev_const(th, klass, SYM2ID(obj), 1)) {
- expr_type = DEFINED_CONST;
- }
- break;
- case DEFINED_FUNC:
- klass = CLASS_OF(v);
- if (rb_method_boundp(klass, SYM2ID(obj), 0)) {
- expr_type = DEFINED_METHOD;
- }
- break;
- case DEFINED_METHOD:{
- VALUE klass = CLASS_OF(v);
- const rb_method_entry_t *me = rb_method_entry(klass, SYM2ID(obj), 0);
-
- if (me) {
- const rb_method_definition_t *def = me->def;
- if (!(def->flag & NOEX_PRIVATE)) {
- if (!((def->flag & NOEX_PROTECTED) &&
- !rb_obj_is_kind_of(GET_SELF(),
- rb_class_real(klass)))) {
- expr_type = DEFINED_METHOD;
- }
- }
- }
- {
- VALUE args[2];
- VALUE r;
-
- args[0] = obj; args[1] = Qfalse;
- r = rb_check_funcall(v, idRespond_to_missing, 2, args);
- if (r != Qundef && RTEST(r))
- expr_type = DEFINED_METHOD;
- }
- break;
- }
- case DEFINED_YIELD:
- if (GET_BLOCK_PTR()) {
- expr_type = DEFINED_YIELD;
- }
- break;
- case DEFINED_ZSUPER:{
- rb_call_info_t cit;
- if (vm_search_superclass(GET_CFP(), GET_ISEQ(), Qnil, &cit) == 0) {
- VALUE klass = cit.klass;
- ID id = cit.mid;
- if (rb_method_boundp(klass, id, 0)) {
- expr_type = DEFINED_ZSUPER;
- }
- }
- break;
- }
- case DEFINED_REF:{
- val = vm_getspecial(th, GET_LEP(), Qfalse, FIX2INT(obj));
- if (val != Qnil) {
- expr_type = DEFINED_GVAR;
- }
- break;
- }
- default:
- rb_bug("unimplemented defined? type (VM)");
- break;
- }
- if (expr_type != 0) {
- if (needstr != Qfalse) {
- val = rb_iseq_defined_string(expr_type);
- }
- else {
- val = Qtrue;
- }
- }
+ val = vm_defined(th, GET_CFP(), op_type, obj, needstr, v);
}
/**