Skip to content

Commit

Permalink
[Truffle] Allow the extra parameter of Module#constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Oct 10, 2014
1 parent d3aabe2 commit 8ec4a4a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
Expand Up @@ -432,7 +432,7 @@ public boolean isClassVariableDefined(RubyModule module, RubySymbol name) {

}

@CoreMethod(names = "constants", maxArgs = 0)
@CoreMethod(names = "constants", minArgs = 0, maxArgs = 1)
public abstract static class ConstantsNode extends CoreMethodNode {

public ConstantsNode(RubyContext context, SourceSection sourceSection) {
Expand All @@ -444,11 +444,17 @@ public ConstantsNode(ConstantsNode prev) {
}

@Specialization
public RubyArray constants(@SuppressWarnings("unused") RubyModule module) {
public RubyArray constants(RubyModule module, UndefinedPlaceholder unused) {
return constants(module, true);
}

@Specialization
public RubyArray constants(RubyModule module, boolean inherit) {
notDesignedForCompilation();

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());

// TODO(cs): handle inherit
for (String constant : module.getConstants().keySet()) {
array.slowPush(getContext().newSymbol(constant));
}
Expand Down

0 comments on commit 8ec4a4a

Please sign in to comment.