Esempio n. 1
0
 public final void setResult(RTValue res) {
   res = res.getValue();
   if (res != this) {
     result = res;
     if (parent == null) {
       if (res instanceof RTResultFunction) {
         ((RTResultFunction) res).setParent(this);
       }
     } else {
       parent.setResult(res);
     }
   }
 }
Esempio n. 2
0
  // WARNING: the implementation of this method must be kept compatible with unsynchronizedEvaluate
  private final synchronized RTValue synchronizedEvaluate(RTExecutionContext ec)
      throws CALExecutorException {
    if (!LECCMachineConfiguration.nonInterruptibleRuntime() && ec.isQuitRequested()) {
      throw RTValue.INTERRUPT_EXCEPTION;
    }

    RTValue newResult = result == null ? this : result;
    RTValue lastResult;

    // do not repeatedly poll the SourceGenerationConfiguration settings in the most performance
    // important common case
    // where we are not generating any runtime statistics

    if (RTResultFunction.HAS_RUNTIME_STATS) {

      // Attempt to reduce this result
      do {
        if (LECCMachineConfiguration.generateStatistics()) {
          ec.incrementNReductions();
        }

        lastResult = newResult;
        newResult = newResult.synchronizedReduce(ec);

      } while (lastResult != newResult);

    } else {

      // Attempt to reduce this result
      do {
        lastResult = newResult;
        newResult = newResult.synchronizedReduce(ec);
      } while (lastResult != newResult);
    }

    if (newResult != this) {
      setResult(newResult);
    }

    return newResult;
  }