Skip to content
Browse files

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

…handling
  • Loading branch information...
1 parent 460db29 commit e1422ae433390e3238a2cffbb00d56afadf63a03 @enebo enebo committed Feb 27, 2014
View
16 core/src/main/java/org/jruby/ast/IScopedNode.java
@@ -0,0 +1,16 @@
+package org.jruby.ast;
+
+/**
+ * A marker interface for scoped variables (which have an offset and depth).
+ */
+public interface IScopedNode {
+ /**
+ * How many scopes down we should look for this variable
+ */
+ public int getDepth();
+
+ /**
+ * Which index (or slot) this variable is located at in the scope it is stored in.
+ */
+ public int getIndex();
+}
View
34 core/src/main/java/org/jruby/ast/RequiredKeywordArgumentValueNode.java
@@ -0,0 +1,34 @@
+package org.jruby.ast;
+
+import java.util.List;
+import org.jruby.ast.visitor.NodeVisitor;
+import org.jruby.lexer.yacc.ISourcePosition;
+
+/**
+ * Marker to indicate that rather than assigning nil (where in multiple
+ * places we have nulls getting implicitly converted to nils) we should
+ * raise an error.
+ *
+ * MRI passes a -1 as a special value so we are doing something similar
+ * but more explicit.
+ */
+public class RequiredKeywordArgumentValueNode extends Node implements InvisibleNode {
+ public RequiredKeywordArgumentValueNode() {
+ super(ISourcePosition.INVALID_POSITION);
+ }
+
+ @Override
+ public Object accept(NodeVisitor visitor) {
+ return visitor.visitRequiredKeywordArgumentValueNode(this);
+ }
+
+ @Override
+ public List<Node> childNodes() {
+ return EMPTY_LIST;
+ }
+
+ @Override
+ public NodeType getNodeType() {
+ return NodeType.REQUIRED_KEYWORD_ARGUMENT_VALUE;
+ }
+}

0 comments on commit e1422ae

Please sign in to comment.
Something went wrong with that request. Please try again.