Skip to content

Commit

Permalink
Showing 5 changed files with 30 additions and 18 deletions.
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/module/remove_class_variable_tags.txt

This file was deleted.

5 changes: 5 additions & 0 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -159,6 +159,11 @@ def mspec(command, *args)
env_vars = command
command, *args = args
end

if ENV["JRUBY_ECLIPSE"] == "true"

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Jul 10, 2015

Contributor

Did you mean to commit this?

This comment has been minimized.

Copy link
@eregon

eregon Jul 11, 2015

Author Member

In a separate commit ideally but yeah it's fine as it is a fix for the previous commit.

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Jul 11, 2015

Contributor

No worries. It didn't fit in with the rest so I wasn't sure if it was accidental.

This comment has been minimized.

Copy link
@eregon

eregon Jul 11, 2015

Author Member

I was showing off my fast feedback loop with Eclipse to @pitr-ch and then I accidentally committed this extra bit 😄

args.unshift "-ttool/jruby_eclipse"
end

sh env_vars, 'ruby', 'spec/mspec/bin/mspec', command, '--config', 'spec/truffle/truffle.mspec', *args
end
end
24 changes: 13 additions & 11 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
Original file line number Diff line number Diff line change
@@ -1740,24 +1740,26 @@ public RubyModule doProtected(VirtualFrame frame, RubyModule module, Object[] na
}

@CoreMethod(names = "remove_class_variable", required = 1)
public abstract static class RemoveClassVariableNode extends CoreMethodArrayArgumentsNode {
@NodeChildren({
@NodeChild(type = RubyNode.class, value = "module"),
@NodeChild(type = RubyNode.class, value = "name")
})
public abstract static class RemoveClassVariableNode extends CoreMethodNode {

public RemoveClassVariableNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization(guards = "isRubyString(name)")
public RubyModule removeClassVariableString(RubyModule module, RubyBasicObject name) {
module.removeClassVariable(this, name.toString());
return module;
@CreateCast("name")
public RubyNode coerceToString(RubyNode name) {
return NameToJavaStringNodeGen.create(getContext(), getSourceSection(), name);
}

@TruffleBoundary
@Specialization(guards = "isRubySymbol(name)")
public RubyModule removeClassVariableSymbol(RubyModule module, RubyBasicObject name) {
module.removeClassVariable(this, SymbolNodes.getString(name));
return module;
@Specialization
public Object removeClassVariableString(RubyModule module, String name) {
RubyContext.checkClassVariableName(getContext(), name, this);
return module.removeClassVariable(this, name);
}

}
Original file line number Diff line number Diff line change
@@ -983,6 +983,11 @@ public RubyException nameErrorLocalVariableNotDefined(String name, RubyBasicObje
return nameError(String.format("local variable `%s' not defined for %s", name, binding.toString()), name, currentNode);
}

public RubyException nameErrorClassVariableNotDefined(String name, RubyModule module, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return nameError(String.format("class variable `%s' not defined for %s", name, module.getName()), name, currentNode);
}

public RubyException noMethodError(String message, String name, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
RubyException noMethodError = new RubyException(context.getCoreLibrary().getNoMethodErrorClass(), StringNodes.createString(context.getCoreLibrary().getStringClass(), message), RubyCallStack.getBacktrace(currentNode));
Original file line number Diff line number Diff line change
@@ -356,10 +356,15 @@ public void setClassVariable(Node currentNode, String variableName, Object value
}

@TruffleBoundary
public void removeClassVariable(Node currentNode, String variableName) {
public Object removeClassVariable(Node currentNode, String name) {
checkFrozen(currentNode);

classVariables.remove(variableName);
final Object found = classVariables.remove(name);
if (found == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(context.getCoreLibrary().nameErrorClassVariableNotDefined(name, this, currentNode));
}
return found;
}

@TruffleBoundary

0 comments on commit 084efdb

Please sign in to comment.