Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
135 additions
and 24 deletions.
- +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java
- +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
- +7 −5 core/src/main/java/org/jruby/truffle/nodes/methods/arguments/CheckArityNode.java
- +70 −0 core/src/main/java/org/jruby/truffle/nodes/methods/arguments/ReadKeywordArgumentNode.java
- +7 −1 core/src/main/java/org/jruby/truffle/runtime/methods/Arity.java
- +44 −0 core/src/main/java/org/jruby/truffle/translator/LoadArgumentsTranslator.java
- +2 −2 core/src/main/java/org/jruby/truffle/translator/MethodTranslator.java
- +0 −4 spec/truffle/tags/language/lambda_tags.txt
- +0 −7 spec/truffle/tags/language/method_tags.txt
- +2 −2 spec/truffle/tags/language/versions/def_2.0_tags.txt
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.nodes.methods.arguments; | ||
|
||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
import com.oracle.truffle.api.utilities.BranchProfile; | ||
import org.jruby.truffle.nodes.RubyNode; | ||
import org.jruby.truffle.nodes.RubyValueProfile; | ||
import org.jruby.truffle.runtime.RubyArguments; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.UndefinedPlaceholder; | ||
import org.jruby.truffle.runtime.core.RubyHash; | ||
import org.jruby.truffle.runtime.core.RubyString; | ||
|
||
import java.util.Map; | ||
|
||
public class ReadKeywordArgumentNode extends RubyNode { | ||
|
||
private final String name; | ||
@Child protected RubyNode defaultValue; | ||
|
||
public ReadKeywordArgumentNode(RubyContext context, SourceSection sourceSection, String name, RubyNode defaultValue) { | ||
super(context, sourceSection); | ||
this.name = name; | ||
this.defaultValue = defaultValue; | ||
} | ||
|
||
@Override | ||
public Object execute(VirtualFrame frame) { | ||
notDesignedForCompilation(); | ||
|
||
final int last = RubyArguments.getUserArgumentsCount(frame.getArguments()) - 1; | ||
|
||
if (last == -1) { | ||
return defaultValue.execute(frame); | ||
} | ||
|
||
final Object hashValue = RubyArguments.getUserArgument(frame.getArguments(), last); | ||
|
||
if (!(hashValue instanceof RubyHash)) { | ||
return defaultValue.execute(frame); | ||
} | ||
|
||
final RubyHash hash = (RubyHash) hashValue; | ||
|
||
Object value = null; | ||
|
||
for (Map.Entry<Object, Object> entry : hash.slowToMap().entrySet()) { | ||
if (entry.getKey().toString().equals(name)) { | ||
value = entry.getValue(); | ||
break; | ||
} | ||
} | ||
|
||
if (value == null) { | ||
return defaultValue.execute(frame); | ||
} | ||
|
||
return value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters