(linenum→info "unix/slp.c:2238")

ruby/1.9.0/insns.def

    1: /** ##skip -*- mode:c; style:ruby -*-
    2:   insns.def - YARV instruction definitions
    3: 
    4:   $Author: $
    5:   $Date: $
    6:   created at: 04/01/01 01:17:55 JST
    7: 
    8:   Copyright (C) 2004-2007 Koichi Sasada
    9: */
   10: 
   11: /** ##skip
   12:   instruction comment
   13:   @c: category
   14:   @e: english description
   15:   @j: japanese description
   16: 
   17:   instruction form:
   18:     DEFINE_INSN
   19:     instrunction_name
   20:     (instruction_operands, ..)
   21:     (pop_values, ..)
   22:     (return value)
   23:     {
   24:        .. // insn body
   25:     }
   26: 
   27:  */
   28: 
   29: 
   30: /**
   31:   @c nop
   32:   @e nop
   33:   @j nop
   34:  */
   35: DEFINE_INSN
   36: nop
   37: ()
   38: ()
   39: ()
   40: {
   41:     /* none */
   42: }
   43: 
   44: /**********************************************************/
   45: /* deal with variables                                    */
   46: /**********************************************************/
   47: 
   48: /**
   49:   @c variable
   50:   @e get local variable value (which is pointed by idx).
   51:   @j idx ?Ŏw?肳?ꂽ???[?J???ϐ???^?b?N?ɒu???B
   52:  */
   53: DEFINE_INSN
   54: getlocal
   55: (lindex_t idx)
   56: ()
   57: (VALUE val)
   58: {
   59:     val = *(GET_LFP() - idx);
   60: }
   61: 
   62: /**
   63:   @c variable
   64:   @e set local variable value (which is pointed by idx) as val.
   65:   @j idx ?Ŏw?肳?ꂽ???[?J???ϐ???l ?ɐݒ肷??
   66:  */
   67: DEFINE_INSN
   68: setlocal
   69: (lindex_t idx)
   70: (VALUE val)
   71: ()
   72: {
   73:     (*(GET_LFP() - idx)) = val;
   74: }
   75: 
   76: /**
   77:   @c variable
   78:   @e get special local variable ($~, $_, ..) value.
   79:   @j ??????[?J???ϐ??i$~, $_, ...?j?̒l?𓾂?
   80:  */
   81: DEFINE_INSN
   82: getspecial
   83: (VALUE key, rb_num_t type)
   84: ()
   85: (VALUE val)
   86: {
   87:     val = vm_getspecial(th, GET_LFP(), key, type);
   88: }
   89: 
   90: /**
   91:   @c variable
   92:   @e set special local variable ($~, $_, ...) value as obj.
   93:   @j ??ʂȃ??[?J???ϐ??i$~, $_, ...?j?̒l??ݒ肷??
   94:  */
   95: DEFINE_INSN
   96: setspecial
   97: (VALUE key)
   98: (VALUE obj)
   99: ()
  100: {
  101:     lfp_svar_set(th, GET_LFP(), key, obj);
  102: }
  103: 
  104: /**
  105:   @c variable
  106:   @e get block local variable(which is pointed by idx and level).
  107:      level means nest level of block, and specify how above this variable.
  108:   @j level, idx ?Ŏw?肳?ꂽ?u???b?N???[?J???ϐ??̒l??^?b?N?ɒu???B
  109:      level ?̓u???b?N?̃l?X?g???x???ŁA???i?ォ????B
  110:  */
  111: DEFINE_INSN
  112: getdynamic
  113: (dindex_t idx, rb_num_t level)
  114: ()
  115: (VALUE val)
  116: {
  117:     int i;
  118:     VALUE *dfp2 = GET_DFP();
  119:     for (i = 0; i < level; i++) {
  120:         dfp2 = GET_PREV_DFP(dfp2);
  121:     }
  122:     val = *(dfp2 - idx);
  123: }
  124: 
  125: /**
  126:   @c variable
  127:   @e set block local variable(which is pointed by 'idx') as val.
  128:      level means nest level of block, and specify how above this variable.
  129:   @j level, idx ?Ŏw?肳?ꂽ?u???b?N???[?J???ϐ??̒l??l ?ɂ???
  130:      level ?̓u???b?N?̃l?X?g???x???ŁA???i?ォ????B
  131:  */
  132: DEFINE_INSN
  133: setdynamic
  134: (dindex_t idx, rb_num_t level)
  135: (VALUE val)
  136: ()
  137: {
  138:     int i;
  139:     VALUE *dfp2 = GET_DFP();
  140:     for (i = 0; i < level; i++) {
  141:         dfp2 = GET_PREV_DFP(dfp2);
  142:     }
  143:     *(dfp2 - idx) = val;
  144: }
  145: 
  146: /**
  147:   @c variable
  148:   @e get instance variable id of obj.
  149:      if is_local is not 0, search as class local variable.
  150:   @j self ?̃C???X?^???X?ϐ? id ?̒l?𓾂?
  151:  */
  152: DEFINE_INSN
  153: getinstancevariable
  154: (ID id)
  155: ()
  156: (VALUE val)
  157: {
  158:     val = rb_ivar_get(GET_SELF(), id);
  159: }
  160: 
  161: /**
  162:   @c variable
  163:   @e set instance variable id of obj as val.
  164:      if is_local is not 0, search as class local variable.
  165:   @j self ?̃C???X?^???X?ϐ? id ??l ?ɂ???
  166:  */
  167: DEFINE_INSN
  168: setinstancevariable
  169: (ID id)
  170: (VALUE val)
  171: ()
  172: {
  173:     rb_ivar_set(GET_SELF(), id, val);
  174: }
  175: 
  176: /**
  177:   @c variable
  178:   @e get class variable id of klass as val.
  179:   @j ???݂̃X?R?[?v?̃N???X?ϐ? id ?̒l?𓾂?
  180:  */
  181: DEFINE_INSN
  182: getclassvariable
  183: (ID id)
  184: ()
  185: (VALUE val)
  186: {
  187:     val = rb_cvar_get(vm_get_cvar_base(th, GET_ISEQ()), id);
  188: }
  189: 
  190: /**
  191:   @c variable
  192:   @e set class variable id of klass as val.
  193:   @j klass ?̃N???X?ϐ? id ??l ?ɂ???
  194:  */
  195: DEFINE_INSN
  196: setclassvariable
  197: (ID id)
  198: (VALUE val)
  199: ()
  200: {
  201:     rb_cvar_set(vm_get_cvar_base(th, GET_ISEQ()), id, val);
  202: }
  203: 
  204: /**
  205:   @c variable
  206:   @e
  207:    get constant variable id. if klass is Qnil, constant
  208:    are searched in current scope. if klass is Qfalse, constant as
  209:    top level constant. otherwise, get constant under klass
  210:    class or module.
  211:   @j ?萔 id ?̒l?𓾂?
  212:    klass ?? Qnil ?Ȃ????̃X?R?[?v?œ????????̒l?𓾂?
  213:    Qfalse ?Ȃ??g?b?v???x???X?R?[?v?𓾂?
  214:    ?????O?Ȃ?klass ?N???X?̉??̒萔?𓾂?
  215:  */
  216: DEFINE_INSN
  217: getconstant
  218: (ID id)
  219: (VALUE klass)
  220: (VALUE val)
  221: {
  222:     val = vm_get_ev_const(th, GET_ISEQ(), klass, id, 0);
  223: }
  224: 
  225: /**
  226:   @c variable
  227:   @e
  228:    set constant variable id. if klass is Qfalse, constant
  229:    is able to access in this scope. if klass is Qnil, set
  230:    top level constant. otherwise, set constant under klass
  231:    class or module.
  232: 
  233:   @j ?萔 id ?̒l??l ?ɂ???
  234:    klass ?? Qfalse ?Ȃ????̃X?R?[?v?œ??????? id ?̒l??肷??
  235:    Qnil ?Ȃ??g?b?v???x???X?R?[?v?̒l??肷??
  236:    ?????O?Ȃ?klass ?N???X?̉??̒萔??肷??
  237:  */
  238: DEFINE_INSN
  239: setconstant
  240: (ID id)
  241: (VALUE val, VALUE klass)
  242: ()
  243: {
  244:     if (klass == Qnil) {
  245:         klass = vm_get_cbase(th);
  246:     }
  247:     if (NIL_P(klass)) {
  248:         rb_raise(rb_eTypeError, "no class/module to define constant");
  249:     }
  250: 
  251:     switch (TYPE(klass)) {
  252:       case T_CLASS:
  253:       case T_MODULE:
  254:         break;
  255:       default: {
  256:         volatile VALUE tmp = rb_obj_as_string(klass);
  257:         rb_raise(rb_eTypeError, "%s is not a class/module",
  258:                  RSTRING_PTR(tmp));
  259:       }
  260:     }
  261: 
  262:     rb_const_set(klass, id, val);
  263:     INC_VM_STATE_VERSION();
  264: }
  265: 
  266: /**
  267:   @c variable
  268:   @e get global variable id.
  269:   @j ?O???[?o???ϐ? id ?̒l?𓾂?
  270:  */
  271: DEFINE_INSN
  272: getglobal
  273: (GENTRY entry)
  274: ()
  275: (VALUE val)
  276: {
  277:     val = GET_GLOBAL(entry);
  278: }
  279: 
  280: /**
  281:   @c variable
  282:   @e set global variable id as val.
  283:   @j ?O???[?o???ϐ? id ?̒l??肷??
  284:  */
  285: DEFINE_INSN
  286: setglobal
  287: (GENTRY entry)
  288: (VALUE val)
  289: ()
  290: {
  291:     SET_GLOBAL(entry, val);
  292: }
  293: 
  294: 
  295: /**********************************************************/
  296: /* deal with values                                       */
  297: /**********************************************************/
  298: 
  299: /**
  300:   @c put
  301:   @e put nil to stack.
  302:   @j ?X?^?b?N??nil ??b?V??????
  303:  */
  304: DEFINE_INSN
  305: putnil
  306: ()
  307: ()
  308: (VALUE val)
  309: {
  310:     val = Qnil;
  311: }
  312: 
  313: /**
  314:   @c put
  315:   @e put self.
  316:   @j ?X?^?b?N??self ??b?V??????
  317:  */
  318: DEFINE_INSN
  319: putself
  320: ()
  321: ()
  322: (VALUE val)
  323: {
  324:     val = GET_SELF();
  325: }
  326: 
  327: /**
  328:   @c put
  329:   @e put some object.
  330:      i.e. Fixnum, true, false, nil, and so on.
  331:   @j ?I?u?W?F?N?g val ??^?b?N?Ƀv?b?V??????
  332:      i.e. Fixnum, true, false, nil, and so on.
  333:  */
  334: DEFINE_INSN
  335: putobject
  336: (VALUE val)
  337: ()
  338: (VALUE val)
  339: {
  340:     /* */
  341: }
  342: 
  343: /**
  344:   @c put
  345:   @e put string val. string will be copied.
  346:   @j ???????s?[???ăX?^?b?N?Ƀv?b?V??????
  347:  */
  348: DEFINE_INSN
  349: putstring
  350: (VALUE str)
  351: ()
  352: (VALUE val)
  353: {
  354:     val = rb_str_new3(str);
  355: }
  356: 
  357: /**
  358:   @c put
  359:   @e put concatenate strings
  360:   @j ?X?^?b?N?g?b?v?̕?????n ?˜A?????C???ʂ?^?b?N?Ƀv?b?V??????
  361:  */
  362: DEFINE_INSN
  363: concatstrings
  364: (rb_num_t num)
  365: (...)
  366: (VALUE val) // inc += 1 - num;
  367: {
  368:     int i;
  369:     VALUE v;
  370: 
  371:     val = rb_str_new(0, 0);
  372:     for (i = num - 1; i >= 0; i--) {
  373:         v = TOPN(i);
  374:         rb_str_append(val, v);
  375:     }
  376:     POPN(num);
  377: }
  378: 
  379: /**
  380:   @c put
  381:   @e to_str
  382:   @j to_str ?̌??ʂ?^?b?N?Ƀv?b?V??????
  383:  */
  384: DEFINE_INSN
  385: tostring
  386: ()
  387: (VALUE val)
  388: (VALUE val)
  389: {
  390:     val = rb_obj_as_string(val);
  391: }
  392: 
  393: /**
  394:   @c put
  395:   @e to Regexp
  396:   @j ??????r ?𐳋K?\???ɃR???p?C?????ăX?^?b?N?Ƀv?b?V??????
  397:      ?R???p?C?????Copt ?𐳋K?\???̃I?v?V?????Ƃ???
  398:  */
  399: DEFINE_INSN
  400: toregexp
  401: (rb_num_t opt)
  402: (VALUE str)
  403: (VALUE val)
  404: {
  405:     volatile VALUE tmp = str; /* for GC */
  406:     val = rb_reg_new(str, opt);
  407: }
  408: 
  409: /**
  410:   @c put
  411:   @e put new array.
  412:   @j ?V?????z??X?^?b?N?? num ?‚̒l?ŏ???Đ??????v?b?V??????
  413:  */
  414: DEFINE_INSN
  415: newarray
  416: (rb_num_t num)
  417: (...)
  418: (VALUE val) // inc += 1 - num;
  419: {
  420:     val = rb_ary_new4((long)num, STACK_ADDR_FROM_TOP(num));
  421:     POPN(num);
  422: }
  423: 
  424: /**
  425:   @c put
  426:   @e dup array
  427:   @j ?z??y ??p ???ăX?^?b?N?Ƀv?b?V??????
  428:  */
  429: DEFINE_INSN
  430: duparray
  431: (VALUE ary)
  432: ()
  433: (VALUE val)
  434: {
  435:     val = rb_ary_dup(ary);
  436: }
  437: 
  438: /**
  439:   @c put
  440:   @e expand array to num objects.
  441:   @j ?X?^?b?N?g?b?v?̃I?u?W?F?N?g???z??????A?????W?J????
  442:      ?z??u?W?F?N?g?̗v?f???? num?ȉ??Ȃ??A???? nil ??ށBnum?ȏ???
  443:      num?ȏ??v?f?͐؂??Ă?
  444:      ?z??u?W?F?N?g?łȂ????Anum - 1 ?‚?nil ??ށB
  445:      ?? flag ???^?Ȃ??c???f?̔z??ς?     flag: 0x01 - ?Ō??z??     flag: 0x02 - postarg ?p
  446:      flag: 0x04 - reverse?
  447:  */
  448: DEFINE_INSN
  449: expandarray
  450: (rb_num_t num, rb_num_t flag)
  451: (..., VALUE ary)
  452: (...) // inc += flag == 0x02 ? num : ((num > 0) ? num - 1 + (flag ? 1 : 0) : num + 1 - (flag ? 1 : 0));
  453: {
  454:     vm_expandarray(GET_CFP(), ary, num, flag);
  455: }
  456: 
  457: /**
  458:   @c put
  459:   @e concat two arrays
  460:   @j ??̔z??y1, ary2 ??????X?^?b?N?փv?b?V??????
  461:  */
  462: DEFINE_INSN
  463: concatarray
  464: ()
  465: (VALUE ary1, VALUE ary2st)
  466: (VALUE ary)
  467: {
  468:     VALUE ary2 = ary2st;
  469:     VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_a");
  470:     VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_a");
  471: 
  472:     if (NIL_P(tmp1)) {
  473:         tmp1 = rb_ary_new3(1, ary1);
  474:     }
  475: 
  476:     if (NIL_P(tmp2)) {
  477:         tmp2 = rb_ary_new3(1, ary2);
  478:     }
  479: 
  480:     if (tmp1 == ary1) {
  481:         tmp1 = rb_ary_dup(ary1);
  482:     }
  483:     ary = rb_ary_concat(tmp1, tmp2);
  484: }
  485: 
  486: /**
  487:   @c put
  488:   @e splat array
  489:   @j ?z??y ?ɑ΂???to_a ??яo???B
  490:  */
  491: DEFINE_INSN
  492: splatarray
  493: (VALUE flag)
  494: (VALUE ary)
  495: (VALUE obj)
  496: {
  497:     VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "to_a");
  498:     if (NIL_P(tmp)) {
  499:         tmp = rb_ary_new3(1, ary);
  500:     }
  501:     obj = tmp;
  502: }
  503: 
  504: /**
  505:   @c put
  506:   @e check value is included in ary
  507:   @j ?z??y ?ɗv?f obj ??????邩?ǂ????`?F?b?N?Bcase/when ?ŗ??p????
  508:  */
  509: DEFINE_INSN
  510: checkincludearray
  511: (VALUE flag)
  512: (VALUE obj, VALUE ary)
  513: (VALUE obj, VALUE result)
  514: {
  515:     int i;
  516:     result = Qfalse;
  517: 
  518:     if (TYPE(ary) != T_ARRAY) {
  519:         ary = rb_Array(ary);
  520:     }
  521: 
  522:     if (flag == Qtrue) {
  523:         /* NODE_CASE */
  524:         for (i = 0; i < RARRAY_LEN(ary); i++) {
  525:             /* TODO: fix me (use another method dispatch) */
  526:             if (RTEST(rb_funcall2(RARRAY_PTR(ary)[i], idEqq, 1, &obj))) {
  527:                 result = Qtrue;
  528:                 break;
  529:             }
  530:         }
  531:     }
  532:     else {
  533:         obj = Qfalse;
  534:         /* NODE_WHEN */
  535:         for (i = 0; i < RARRAY_LEN(ary); i++) {
  536:             if (RTEST(RARRAY_PTR(ary)[i])) {
  537:                 obj = result = Qtrue;
  538:                 break;
  539:             }
  540:         }
  541:     }
  542: }
  543: 
  544: /**
  545:   @c put
  546:   @e put new Hash.
  547:   @j ?V?????n?b?V????^?b?N?g?b?v??n ?‚?????Đ???????
  548:      n ?̓L?[?ƒl?̃y?A?Ȃ̂?2 ?̔{???łȂ????Ȃ????B
  549:  */
  550: DEFINE_INSN
  551: newhash
  552: (rb_num_t num)
  553: (...)
  554: (VALUE val) // inc += 1 - num;
  555: {
  556:     int i;
  557:     VALUE k, v;
  558:     val = rb_hash_new();
  559: 
  560:     for (i = num; i > 0; i -= 2) {
  561:         v = TOPN(i - 2);
  562:         k = TOPN(i - 1);
  563:         rb_hash_aset(val, k, v);
  564:     }
  565:     POPN(num);
  566: }
  567: 
  568: /**
  569:   @c put
  570:   @e put new Range object.(Range.new(low, high, flag))
  571:   @j Range.new(low, high, flag) ?̂悤?ȃI?u?W?F?N?g?𐶐????X?^?b?N?Ƀv?b?V??????
  572:  */
  573: DEFINE_INSN
  574: newrange
  575: (rb_num_t flag)
  576: (VALUE low, VALUE high)
  577: (VALUE val)
  578: {
  579:     val = rb_range_new(low, high, flag);
  580: }
  581: 
  582: /**********************************************************/
  583: /* deal with stack operation                              */
  584: /**********************************************************/
  585: 
  586: /**
  587:   @c stack
  588:   @e pop from stack.
  589:   @j ?X?^?b?N?????ƒ|?b?v????
  590:  */
  591: DEFINE_INSN
  592: pop
  593: ()
  594: (VALUE val)
  595: ()
  596: {
  597:     val = val;
  598:     /* none */
  599: }
  600: 
  601: /**
  602:   @c stack
  603:   @e duplicate stack top.
  604:   @j ?X?^?b?N?g?b?v??s?[???ăX?^?b?N?Ƀv?b?V??????
  605:  */
  606: DEFINE_INSN
  607: dup
  608: ()
  609: (VALUE val)
  610: (VALUE val1, VALUE val2)
  611: {
  612:     val1 = val2 = val;
  613: }
  614: 
  615: /**
  616:   @c stack
  617:   @e duplicate stack top n elements
  618:   @j ?X?^?b?N?g?b?v??n ?‚?s?[???ăX?^?b?N?Ƀv?b?V??????
  619:  */
  620: DEFINE_INSN
  621: dupn
  622: (rb_num_t n)
  623: (...)
  624: (...) // inc += n;
  625: {
  626:     int i;
  627:     VALUE *sp = STACK_ADDR_FROM_TOP(n);
  628:     for (i = 0; i < n; i++) {
  629:         GET_SP()[i] = sp[i];
  630:     }
  631:     INC_SP(n);
  632: }
  633: 
  634: 
  635: /**
  636:   @c stack
  637:   @e swap top 2 vals
  638:   @j ?X?^?b?N?g?b?v??2 ?‚̒l???????
  639:  */
  640: DEFINE_INSN
  641: swap
  642: ()
  643: (VALUE val, VALUE obj)
  644: (VALUE obj, VALUE val)
  645: {
  646:     /* none */
  647: }
  648: 
  649: /**
  650:   @c stack
  651:   @e for stack caching.
  652:   @j ?X?^?b?N?L???b?V???O?̏?𒲐????邽?߂ɕK?v?Ȗ??߁B
  653:  */
  654: DEFINE_INSN
  655: reput
  656: ()
  657: (..., VALUE val)
  658: (VALUE val) // inc += 0;
  659: {
  660:     /* none */
  661: }
  662: 
  663: /**
  664:   @c stack
  665:   @e get nth stack value from stack top
  666:   @j ?X?^?b?N?g?b?v???? ?–ڂ?^?b?N?Ƀv?b?V??????
  667:  */
  668: DEFINE_INSN
  669: topn
  670: (rb_num_t n)
  671: (...)
  672: (VALUE val) // inc += 1;
  673: {
  674:     val = TOPN(n);
  675: }
  676: 
  677: /**
  678:   @c stack
  679:   @e set Nth stack entry to stack top
  680:   @j ?X?^?b?N?g?b?v?̒l???–ڂ̃X?^?b?N?ɃR?s?[
  681:  */
  682: DEFINE_INSN
  683: setn
  684: (rb_num_t n)
  685: (..., VALUE val)
  686: (VALUE val) // inc += 0
  687: {
  688:     TOPN(n-1) = val;
  689: }
  690: 
  691: /**
  692:   @c stack
  693:   @e empt current stack
  694:   @j current stack ??ɂ???
  695:  */
  696: DEFINE_INSN
  697: emptstack
  698: ()
  699: (...)
  700: (...) // inc = 0; depth = 0;
  701: {
  702:     SET_SP(GET_CFP()->bp);
  703: }
  704: 
  705: 
  706: /**********************************************************/
  707: /* deal with setting                                      */
  708: /**********************************************************/
  709: 
  710: /**
  711:   @c setting
  712:   @e define (singleton) method id as body
  713:   @j ?i??فj???\?b?h id ??dy ?Ƃ??Ē?????
  714:  */
  715: DEFINE_INSN
  716: definemethod
  717: (ID id, ISEQ body, rb_num_t is_singleton)
  718: (VALUE obj)
  719: ()
  720: {
  721:     vm_define_method(th, obj, id, body, is_singleton,
  722:                      get_cref(GET_ISEQ(), GET_LFP()));
  723: }
  724: 
  725: /**
  726:   @c setting
  727:   @e make alias (if v_p is Qtrue, make valias)
  728:   @j alias ????? v_p ?? Qtrue ?Ȃ?valias (global variable) ???
  729:  */
  730: DEFINE_INSN
  731: alias
  732: (VALUE v_p)
  733: (VALUE sym1, VALUE sym2)
  734: ()
  735: {
  736:     VALUE klass;
  737: 
  738:     if (v_p == Qtrue) {
  739:         rb_alias_variable(SYM2ID(sym1), SYM2ID(sym2));
  740:     }
  741:     else {
  742:         klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
  743:         rb_alias(klass, SYM2ID(sym1), SYM2ID(sym2));
  744:     }
  745: }
  746: 
  747: /**
  748:   @c setting
  749:   @e undef
  750:   @j undef ????B
  751:  */
  752: DEFINE_INSN
  753: undef
  754: ()
  755: (VALUE sym)
  756: ()
  757: {
  758:     VALUE klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
  759:     rb_undef(klass, SYM2ID(sym));
  760:     INC_VM_STATE_VERSION();
  761: }
  762: 
  763: /**
  764:   @c setting
  765:   @e defined?
  766:   @j defined? ????B
  767:  */
  768: DEFINE_INSN
  769: defined
  770: (rb_num_t type, VALUE obj, VALUE needstr)
  771: (VALUE v)
  772: (VALUE val)
  773: {
  774:     VALUE klass;
  775:     char *expr_type = 0;
  776:     val = Qnil;
  777: 
  778:     switch (type) {
  779:       case DEFINED_IVAR:
  780:         if (rb_ivar_defined(GET_SELF(), SYM2ID(obj))) {
  781:             expr_type = "instance-variable";
  782:         }
  783:         break;
  784:       case DEFINED_IVAR2:
  785:         klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
  786:         break;
  787:       case DEFINED_GVAR:
  788:         if (rb_gvar_defined((struct global_entry *)(obj & ~1))) {
  789:             expr_type = "global-variable";
  790:         }
  791:         break;
  792:       case DEFINED_CVAR:
  793:         klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
  794:         if (rb_cvar_defined(klass, SYM2ID(obj))) {
  795:             expr_type = "class variable";
  796:         }
  797:         break;
  798:       case DEFINED_CONST:
  799:         klass = v;
  800:         if (vm_get_ev_const(th, GET_ISEQ(), klass, SYM2ID(obj), 1)) {
  801:             expr_type = "constant";
  802:         }
  803:         break;
  804:       case DEFINED_FUNC:
  805:         klass = CLASS_OF(v);
  806:         if (rb_method_boundp(klass, SYM2ID(obj), 0)) {
  807:             expr_type = "method";
  808:         }
  809:         break;
  810:       case DEFINED_METHOD:{
  811:           VALUE klass = CLASS_OF(v);
  812:           NODE *method = (NODE *) rb_method_node(klass, SYM2ID(obj));
  813: 
  814:           if (method) {
  815:               if (!(method->nd_noex & NOEX_PRIVATE)) {
  816:                   if (!((method->nd_noex & NOEX_PROTECTED) &&
  817:                         !rb_obj_is_kind_of(GET_SELF(),
  818:                                            rb_class_real(klass)))) {
  819:                       expr_type = "method";
  820:                   }
  821:               }
  822:           }
  823:           break;
  824:       }
  825:       case DEFINED_YIELD:
  826:         if (GET_BLOCK_PTR()) {
  827:             expr_type = "yield";
  828:         }
  829:         break;
  830:       case DEFINED_ZSUPER:{
  831:           rb_iseq_t *ip = GET_ISEQ();
  832:           while (ip) {
  833:               if (ip->defined_method_id) {
  834:                   break;
  835:               }
  836:               ip = ip->parent_iseq;
  837:           }
  838:           if (ip) {
  839:               VALUE klass = vm_search_normal_superclass(ip->klass, GET_SELF());
  840:               if (rb_method_boundp(klass, ip->defined_method_id, 0)) {
  841:                   expr_type = "super";
  842:               }
  843:           }
  844:           break;
  845:       }
  846:       case DEFINED_REF:{
  847:           val = vm_getspecial(th, GET_LFP(), Qfalse, FIX2INT(obj));
  848:           if (val != Qnil) {
  849:               expr_type = "global-variable";
  850:           }
  851:           break;
  852:       }
  853:       default:
  854:         rb_bug("unimplemented defined? type (VM)");
  855:         break;
  856:     }
  857:     if (expr_type != 0) {
  858:         if (needstr != Qfalse) {
  859:             val = rb_str_new2(expr_type);
  860:         }
  861:         else {
  862:             val = Qtrue;
  863:         }
  864:     }
  865: }
  866: 
  867: /**
  868:   @c setting
  869:   @e END{}
  870:   @j END{} ?ɑΉ????邽?߂Ƀu???b?N??^????
  871:  */
  872: DEFINE_INSN
  873: postexe
  874: (ISEQ blockiseq)
  875: ()
  876: ()
  877: {
  878:     rb_block_t *blockptr;
  879:     VALUE proc;
  880:     extern void rb_call_end_proc(VALUE data);
  881: 
  882:     blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(GET_CFP());
  883:     blockptr->iseq = blockiseq;
  884:     blockptr->proc = 0;
  885: 
  886:     proc = vm_make_proc(th, GET_CFP(), blockptr);
  887:     rb_set_end_proc(rb_call_end_proc, proc);
  888: }
  889: 
  890: /**
  891:   @c setting
  892:   @e trace
  893:   @j trace ?p?̖??߁B
  894:  */
  895: DEFINE_INSN
  896: trace
  897: (rb_num_t nf)
  898: ()
  899: ()
  900: {
  901:     rb_event_flag_t flag = nf;
  902:     EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */);
  903: }
  904: 
  905: /**********************************************************/
  906: /* deal with control flow 1: class/module                 */
  907: /**********************************************************/