Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some new nodes and stuffs to better handle required keyword argument …

…handling
  • Loading branch information...
commit 79f2a0d15f3bba67e918fb0e9df4477c58e5e2de 1 parent e1422ae
Thomas E Enebo enebo authored
2  core/src/main/java/org/jruby/ast/DAsgnNode.java
View
@@ -44,7 +44,7 @@
/**
* An assignment to a dynamic variable (e.g. block scope local variable).
*/
-public class DAsgnNode extends AssignableNode implements INameNode {
+public class DAsgnNode extends AssignableNode implements INameNode, IScopedNode {
// The name of the variable
private String name;
2  core/src/main/java/org/jruby/ast/DVarNode.java
View
@@ -47,7 +47,7 @@
/**
* Access a dynamic variable (e.g. block scope local variable).
*/
-public class DVarNode extends Node implements INameNode {
+public class DVarNode extends Node implements INameNode, IScopedNode {
// The name of the variable
private String name;
2  core/src/main/java/org/jruby/ast/LocalAsgnNode.java
View
@@ -46,7 +46,7 @@
/**
* An assignment to a local variable.
*/
-public class LocalAsgnNode extends AssignableNode implements INameNode {
+public class LocalAsgnNode extends AssignableNode implements INameNode, IScopedNode {
// The name of the variable
private String name;
2  core/src/main/java/org/jruby/ast/LocalVarNode.java
View
@@ -47,7 +47,7 @@
/**
* Access a local variable
*/
-public class LocalVarNode extends Node implements INameNode {
+public class LocalVarNode extends Node implements INameNode, IScopedNode {
// The name of the variable
private String name;
3  core/src/main/java/org/jruby/ast/NodeType.java
View
@@ -45,7 +45,8 @@
TRUENODE, UNDEFNODE, UNTILNODE, VALIASNODE, VCALLNODE, WHENNODE, WHILENODE, XSTRNODE, YIELDNODE,
ZARRAYNODE, ZEROARGNODE, ZSUPERNODE, COMMENTNODE, ROOTNODE, ATTRASSIGNNODE, ARGSPUSHNODE,
OPTARGNODE, ARGAUXILIARYNODE, LAMBDANODE, MULTIPLEASGN19NODE, RESTARG, ENCODINGNODE,
- LITERALNODE, BLOCKARG18NODE, KEYWORDARGNODE, KEYWORDRESTARGNODE, RATIONALNODE, COMPLEXNODE;
+ LITERALNODE, BLOCKARG18NODE, KEYWORDARGNODE, KEYWORDRESTARGNODE, RATIONALNODE, COMPLEXNODE,
+ REQUIRED_KEYWORD_ARGUMENT_VALUE;
/**
8 core/src/main/java/org/jruby/ast/visitor/AbstractNodeVisitor.java
View
@@ -26,8 +26,6 @@
***** END LICENSE BLOCK *****/
package org.jruby.ast.visitor;
-import java.util.HashSet;
-import java.util.Set;
import org.jruby.ast.AliasNode;
import org.jruby.ast.AndNode;
import org.jruby.ast.ArgsCatNode;
@@ -109,6 +107,7 @@
import org.jruby.ast.RationalNode;
import org.jruby.ast.RedoNode;
import org.jruby.ast.RegexpNode;
+import org.jruby.ast.RequiredKeywordArgumentValueNode;
import org.jruby.ast.RescueBodyNode;
import org.jruby.ast.RescueNode;
import org.jruby.ast.RestArgNode;
@@ -546,6 +545,11 @@ public Object visitRegexpNode(RegexpNode iVisited) {
}
@Override
+ public Object visitRequiredKeywordArgumentValueNode(RequiredKeywordArgumentValueNode iVisited) {
+ return defaultVisit(iVisited);
+ }
+
+ @Override
public Object visitRescueBodyNode(RescueBodyNode iVisited) {
return defaultVisit(iVisited);
}
5 core/src/main/java/org/jruby/ast/visitor/NodeVisitor.java
View
@@ -111,6 +111,7 @@
import org.jruby.ast.RationalNode;
import org.jruby.ast.RedoNode;
import org.jruby.ast.RegexpNode;
+import org.jruby.ast.RequiredKeywordArgumentValueNode;
import org.jruby.ast.RescueBodyNode;
import org.jruby.ast.RescueNode;
import org.jruby.ast.RestArgNode;
@@ -141,8 +142,7 @@
* Visitor interface to be implemented by visitors of the jRuby AST.
* each node will call the visit method appropriate to its type.
* @see org.jruby.ast.Node
- * @see org.jruby.ast.visitor.AbstractVisitor
- *
+ *
* @author Benoit Cerrina
**/
public interface NodeVisitor {
@@ -226,6 +226,7 @@
public Object visitRationalNode(RationalNode iVisited);
public Object visitRedoNode(RedoNode iVisited);
public Object visitRegexpNode(RegexpNode iVisited);
+ public Object visitRequiredKeywordArgumentValueNode(RequiredKeywordArgumentValueNode iVisited);
public Object visitRescueBodyNode(RescueBodyNode iVisited);
public Object visitRescueNode(RescueNode iVisited);
public Object visitRestArgNode(RestArgNode iVisited);
9 core/src/main/java/org/jruby/parser/RubyParser.java
View
@@ -85,6 +85,7 @@
import org.jruby.ast.RationalNode;
import org.jruby.ast.RedoNode;
import org.jruby.ast.RegexpNode;
+import org.jruby.ast.RequiredKeywordArgumentValueNode;
import org.jruby.ast.RescueBodyNode;
import org.jruby.ast.RescueNode;
import org.jruby.ast.RestArgNode;
@@ -137,7 +138,7 @@ public void setWarnings(IRubyWarnings warnings) {
support.setWarnings(warnings);
lexer.setWarnings(warnings);
}
- // line 141 "-"
+ // line 142 "-"
// %token constants
public static final int kCLASS = 257;
public static final int kMODULE = 258;
@@ -2448,7 +2449,7 @@ public Object yyparse (RubyLexer yyLex) throws java.io.IOException {
};
states[540] = new ParserState() {
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) {
- yyVal = support.keyword_arg(((Token)yyVals[0+yyTop]).getPosition(), support.assignable(((Token)yyVals[0+yyTop]), null));
+ yyVal = support.keyword_arg(((Token)yyVals[0+yyTop]).getPosition(), support.assignable(((Token)yyVals[0+yyTop]), new RequiredKeywordArgumentValueNode()));
return yyVal;
}
};
@@ -4667,7 +4668,7 @@ public Object yyparse (RubyLexer yyLex) throws java.io.IOException {
}
};
}
- // line 2238 "RubyParser.y"
+ // line 2239 "RubyParser.y"
/** The parse method use an lexer stream and parse it to an AST node
* structure
@@ -4686,4 +4687,4 @@ public RubyParserResult parse(ParserConfiguration configuration, LexerSource sou
return support.getResult();
}
}
- // line 8693 "-"
+ // line 8694 "-"
3  core/src/main/java/org/jruby/parser/RubyParser.y
View
@@ -82,6 +82,7 @@ import org.jruby.ast.PreExe19Node;
import org.jruby.ast.RationalNode;
import org.jruby.ast.RedoNode;
import org.jruby.ast.RegexpNode;
+import org.jruby.ast.RequiredKeywordArgumentValueNode;
import org.jruby.ast.RescueBodyNode;
import org.jruby.ast.RescueNode;
import org.jruby.ast.RestArgNode;
@@ -2058,7 +2059,7 @@ f_kw : f_label arg_value {
$$ = support.keyword_arg($1.getPosition(), support.assignable($1, $2));
}
| f_label {
- $$ = support.keyword_arg($1.getPosition(), support.assignable($1, null));
+ $$ = support.keyword_arg($1.getPosition(), support.assignable($1, new RequiredKeywordArgumentValueNode()));
}
f_block_kw : f_label primary_value {
5 core/src/main/java/org/jruby/truffle/translator/Translator.java
View
@@ -15,6 +15,7 @@
import com.oracle.truffle.api.impl.DefaultSourceSection;
import org.joni.Regex;
import org.jruby.ast.MultipleAsgn19Node;
+import org.jruby.ast.RequiredKeywordArgumentValueNode;
import org.jruby.common.IRubyWarnings;
import org.jruby.truffle.nodes.DefinedNode;
import org.jruby.truffle.nodes.ReadNode;
@@ -1991,6 +1992,10 @@ public Object visitKeywordArgNode(org.jruby.ast.KeywordArgNode node) {
return unimplemented(node);
}
+ public Object visitRequiredKeywordArgumentValueNode(RequiredKeywordArgumentValueNode node) {
+ return unimplemented(node);
+ }
+
public Object visitKeywordRestArgNode(org.jruby.ast.KeywordRestArgNode node) {
return unimplemented(node);
}
Please sign in to comment.
Something went wrong with that request. Please try again.