Exemplo n.º 1
0
  @Override
  public Object interpret(
      ThreadContext context,
      StaticScope currScope,
      DynamicScope currDynScope,
      IRubyObject self,
      Object[] temp) {
    ConstantCache cache = this.cache; // Store to temp so it does null out on us mid-stream
    if (!ConstantCache.isCached(cache)) return cache(context, currScope, currDynScope, self, temp);

    return cache.value;
  }
 protected static void processOtherOp(
     ThreadContext context,
     Instr instr,
     Operation operation,
     DynamicScope currDynScope,
     StaticScope currScope,
     Object[] temp,
     IRubyObject self,
     Block.Type blockType) {
   switch (operation) {
     case RECV_SELF:
       break;
     case COPY:
       {
         CopyInstr c = (CopyInstr) instr;
         setResult(
             temp,
             currDynScope,
             c.getResult(),
             retrieveOp(c.getSource(), context, self, currDynScope, currScope, temp));
         break;
       }
     case GET_FIELD:
       {
         GetFieldInstr gfi = (GetFieldInstr) instr;
         IRubyObject object =
             (IRubyObject) gfi.getSource().retrieve(context, self, currScope, currDynScope, temp);
         VariableAccessor a = gfi.getAccessor(object);
         Object result = a == null ? null : (IRubyObject) a.get(object);
         if (result == null) {
           if (context.runtime.isVerbose()) {
             context
                 .runtime
                 .getWarnings()
                 .warning(
                     IRubyWarnings.ID.IVAR_NOT_INITIALIZED,
                     "instance variable " + gfi.getRef() + " not initialized");
           }
           result = context.nil;
         }
         setResult(temp, currDynScope, gfi.getResult(), result);
         break;
       }
     case SEARCH_CONST:
       {
         SearchConstInstr sci = (SearchConstInstr) instr;
         ConstantCache cache = sci.getConstantCache();
         Object result =
             !ConstantCache.isCached(cache)
                 ? sci.cache(context, currScope, currDynScope, self, temp)
                 : cache.value;
         setResult(temp, currDynScope, sci.getResult(), result);
         break;
       }
     case RUNTIME_HELPER:
       {
         RuntimeHelperCall rhc = (RuntimeHelperCall) instr;
         setResult(
             temp,
             currDynScope,
             rhc.getResult(),
             rhc.callHelper(context, currScope, currDynScope, self, temp, blockType));
         break;
       }
     case CHECK_FOR_LJE:
       ((CheckForLJEInstr) instr).check(context, currDynScope, blockType);
       break;
     case LOAD_FRAME_CLOSURE:
       setResult(temp, currDynScope, instr, context.getFrameBlock());
       return;
       // ---------- All the rest ---------
     default:
       setResult(
           temp,
           currDynScope,
           instr,
           instr.interpret(context, currScope, currDynScope, self, temp));
       break;
   }
 }