Esempio n. 1
0
 public Object executeLoop(
     RArray array, Selector selectorI, Selector selectorJ, boolean dropVal, int exactVal) {
   Selector selI = selectorI;
   Selector selJ = selectorJ;
   for (; ; ) {
     try {
       return execute(array, selI, selJ, dropVal, exactVal);
     } catch (UnexpectedResultException e) {
       Selector failedSelector = (Selector) e.getResult();
       if (failedSelector == selI) {
         RAny index = selI.getIndex();
         selectorIExpr.replace(
             Selector.createSelectorNode(
                 ast, subset, index, selectorIExpr.child, false, selectorI.getTransition()));
         selI = selectorIExpr.executeSelector(index);
       } else {
         // failedSelector == selectorJ
         RAny index = selJ.getIndex();
         selectorJExpr.replace(
             Selector.createSelectorNode(
                 ast, subset, index, selectorJExpr.child, false, selectorJ.getTransition()));
         selJ = selectorJExpr.executeSelector(index);
       }
     }
   }
 }
Esempio n. 2
0
 @Override
 public Object read(RubyBasicObject object, boolean condition) {
   try {
     return readFixnum(object, condition);
   } catch (UnexpectedResultException e) {
     return e.getResult();
   }
 }
Esempio n. 3
0
 @Override
 public Object execute(VirtualFrame frameValue) {
   int value;
   try {
     value = this.executeInt(frameValue);
   } catch (UnexpectedResultException ex) {
     return ex.getResult();
   }
   return value;
 }
Esempio n. 4
0
 @Override
 public boolean executeBoolean(VirtualFrame frameValue) throws UnexpectedResultException {
   int value;
   try {
     value = this.executeInt(frameValue);
   } catch (UnexpectedResultException ex) {
     return SIMPLETYPES.expectBoolean(ex.getResult());
   }
   return SIMPLETYPES.expectBoolean(value);
 }
 @Override
 public Object executeGeneric(VirtualFrame frameValue) {
   String value;
   try {
     value = this.executeString(frameValue);
   } catch (UnexpectedResultException ex) {
     return ex.getResult();
   }
   return value;
 }
Esempio n. 6
0
 @Override
 public int executeInt(VirtualFrame frameValue) throws UnexpectedResultException {
   int value0Value;
   try {
     value0Value = this.value0.executeInt(frameValue);
   } catch (UnexpectedResultException ex) {
     transferToInterpreter();
     Object value1Value = this.value1.execute(frameValue);
     return executeAndSpecialize0(
         InvocationGuardGenericNode.class,
         frameValue,
         ex.getResult(),
         value1Value,
         "Expected value0Value instanceof int");
   }
   int value1Value;
   try {
     value1Value = this.value1.executeInt(frameValue);
   } catch (UnexpectedResultException ex) {
     transferToInterpreter();
     return executeAndSpecialize0(
         InvocationGuardGenericNode.class,
         frameValue,
         value0Value,
         ex.getResult(),
         "Expected value1Value instanceof int");
   }
   if (super.guard(value0Value, value1Value)) {
     return super.doSpecialized(value0Value, value1Value);
   }
   transferToInterpreter();
   return executeAndSpecialize0(
       InvocationGuardGenericNode.class,
       frameValue,
       value0Value,
       value1Value,
       "One of guards [guard] failed");
 }
Esempio n. 7
0
 /**
  * Execute method which evaluates the lhs, selectors and optional expressions, checks that the
  * array selection can proceed and then proceeds optionally replacing the falling selectors.
  *
  * <p>The valued variant of execute is called for the production of the result, on failure the
  * responsible selector is replaced and the valued variant is called again.
  */
 protected final Object executeLoop(RArray array, boolean dropVal, int exactVal) {
   while (true) {
     try {
       return execute(array, dropVal, exactVal);
     } catch (UnexpectedResultException e) {
       Selector failedSelector = (Selector) e.getResult();
       for (int i = 0; i < selectorVals.length; ++i) {
         if (selectorVals[i] == failedSelector) {
           RAny index = failedSelector.getIndex();
           SelectorNode newSelector =
               Selector.createSelectorNode(
                   ast, subset, index, selectorExprs[i], false, failedSelector.getTransition());
           selectorExprs[i] = adoptChild(newSelector);
           selectorVals[i] = newSelector.executeSelector(index);
         }
       }
     }
   }
 }