Exemplo n.º 1
0
  /** Set the value of a constant, possibly redefining it. */
  @CompilerDirectives.TruffleBoundary
  public void setConstant(Node currentNode, String name, Object value) {
    if (getContext().getCoreLibrary().isLoadingRubyCore()) {
      final RubyConstant currentConstant = constants.get(name);

      if (currentConstant != null) {
        return;
      }
    }

    if (RubyGuards.isRubyModule(value)) {
      Layouts.MODULE
          .getFields(((DynamicObject) value))
          .getAdoptedByLexicalParent(rubyModuleObject, name, currentNode);
    } else {
      setConstantInternal(currentNode, name, value, false);
    }
  }
Exemplo n.º 2
0
 @CompilerDirectives.TruffleBoundary
 public void setAutoloadConstant(Node currentNode, String name, DynamicObject filename) {
   assert RubyGuards.isRubyString(filename);
   setConstantInternal(currentNode, name, filename, true);
 }