Exemplo n.º 1
0
  @Override
  public Object execute(VirtualFrame frame) {
    // TODO(cs): can module ever not evaluate to a RubyModule?

    final RubyModule moduleObject = (RubyModule) module.execute(frame);

    final Object rhsValue = rhs.execute(frame);

    assert rhsValue != null;
    assert !(rhsValue instanceof String);

    moduleObject.setModuleConstant(name, rhsValue);

    return rhsValue;
  }
Exemplo n.º 2
0
  @Override
  public RubySymbol execute(VirtualFrame frame) {
    notDesignedForCompilation();

    final Object receiverObject = receiver.execute(frame);

    final RubyMethod methodObject = (RubyMethod) method.execute(frame);

    RubyModule module;

    if (receiverObject instanceof RubyModule) {
      module = (RubyModule) receiverObject;
    } else {
      module = ((RubyBasicObject) receiverObject).getSingletonClass(this);
    }

    final RubyMethod methodWithDeclaringModule = methodObject.withDeclaringModule(module);

    if (moduleFunctionFlag(frame)) {
      module.addMethod(this, methodWithDeclaringModule.withVisibility(Visibility.PRIVATE));
      module
          .getSingletonClass(this)
          .addMethod(this, methodWithDeclaringModule.withVisibility(Visibility.PUBLIC));
    } else {
      module.addMethod(this, methodWithDeclaringModule);
    }

    return getContext().newSymbol(method.getName());
  }
Exemplo n.º 3
0
 @Override
 public Object execute(VirtualFrame frame) {
   if (CompilerDirectives.injectBranchProbability(
       getBranchProbability(), condition.executeBoolean(frame))) {
     if (CompilerDirectives.inInterpreter()) {
       thenCount++;
     }
     thenProfile.enter();
     return thenBody.execute(frame);
   } else {
     if (CompilerDirectives.inInterpreter()) {
       elseCount++;
     }
     elseProfile.enter();
     return elseBody.execute(frame);
   }
 }
 @Override
 public Object execute(VirtualFrame frame) {
   if (RubyArguments.getUserArgumentsCount(frame.getArguments()) < minimum) {
     defaultValueProfile.enter();
     return defaultValue.execute(frame);
   } else {
     return RubyArguments.getUserArgument(frame.getArguments(), index);
   }
 }
Exemplo n.º 5
0
  @Override
  public RubyBasicObject executeRubyBasicObject(VirtualFrame frame) {
    final Object object = child.execute(frame);

    RubyBasicObject boxedObject;

    if (object instanceof RubyBasicObject) {
      boxedObject = (RubyBasicObject) object;
    } else {
      boxBranch.enter();
      boxedObject = getContext().getCoreLibrary().box(object);
    }

    return boxedObject;
  }
Exemplo n.º 6
0
  @Override
  public Object execute(VirtualFrame frame) {
    while (true) {
      try {
        final Object result = tryPart.execute(frame);
        elsePart.executeVoid(frame);
        return result;
      } catch (ControlFlowException exception) {
        controlFlowProfile.enter();

        throw exception;
      } catch (RuntimeException exception) {
        CompilerDirectives.transferToInterpreter();

        try {
          return handleException(frame, exception);
        } catch (RetryException e) {
          continue;
        }
      }
    }
  }