@CompilerDirectives.TruffleBoundary public RubyConstant removeConstant(Node currentNode, String name) { checkFrozen(currentNode); RubyConstant oldConstant = constants.remove(name); newLexicalVersion(); return oldConstant; }
@CompilerDirectives.TruffleBoundary public void changeConstantVisibility(Node currentNode, String name, boolean isPrivate) { checkFrozen(currentNode); RubyConstant rubyConstant = constants.get(name); if (rubyConstant != null) { rubyConstant.setPrivate(isPrivate); newLexicalVersion(); } else { throw new RaiseException( context .getCoreLibrary() .nameErrorUninitializedConstant(rubyModuleObject, name, currentNode)); } }
public void setConstantInternal(Node currentNode, String name, Object value, boolean autoload) { checkFrozen(currentNode); RubyConstant previous = constants.get(name); if (previous == null) { constants.put(name, new RubyConstant(rubyModuleObject, value, false, autoload)); } else { // TODO(CS): warn when redefining a constant // TODO (nirvdrum 18-Feb-15): But don't warn when redefining an autoloaded constant. constants.put( name, new RubyConstant(rubyModuleObject, value, previous.isPrivate(), autoload)); } newLexicalVersion(); }