Skip to content
Browse files

Tag for 1.1.3

git-svn-id: http://svn.codehaus.org/jruby/tags/jruby-1_1_3@7225 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
2 parents 2a88947 + 99ec873 commit 3e92abe49e75c060f556f018be437296544d593b @enebo enebo committed
View
2 src/org/jruby/ast/AndNode.java
@@ -52,7 +52,7 @@ public AndNode(ISourcePosition position, Node firstNode, Node secondNode) {
super(position, NodeType.ANDNODE);
assert firstNode != null : "AndNode.first == null";
- assert secondNode != null : "AndNode.first == null";
+ assert secondNode != null : "AndNode.second == null";
this.firstNode = firstNode;
this.secondNode = secondNode;
View
2 src/org/jruby/ast/AssignableNode.java
@@ -69,7 +69,7 @@ public Node getValueNode() {
* @param valueNode The valueNode to set
*/
public void setValueNode(Node valueNode) {
- this.valueNode = valueNode;
+ this.valueNode = valueNode == null ? NilImplicitNode.NIL : valueNode;
}
/**
View
85 src/org/jruby/parser/DefaultRubyParser.java
@@ -1100,7 +1100,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
if (((MultipleAsgnNode)yyVals[-2+yyTop]).getHeadNode() != null) {
((MultipleAsgnNode)yyVals[-2+yyTop]).setValueNode(new ToAryNode(getPosition(((MultipleAsgnNode)yyVals[-2+yyTop])), ((Node)yyVals[0+yyTop])));
} else {
- ((MultipleAsgnNode)yyVals[-2+yyTop]).setValueNode(new ArrayNode(getPosition(((MultipleAsgnNode)yyVals[-2+yyTop])), ((Node)yyVals[0+yyTop])));
+ ((MultipleAsgnNode)yyVals[-2+yyTop]).setValueNode(support.newArrayNode(getPosition(((MultipleAsgnNode)yyVals[-2+yyTop])), ((Node)yyVals[0+yyTop])));
}
yyVal = ((MultipleAsgnNode)yyVals[-2+yyTop]);
}
@@ -1167,7 +1167,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
if (((MultipleAsgnNode)yyVals[-2+yyTop]).getHeadNode() != null) {
((MultipleAsgnNode)yyVals[-2+yyTop]).setValueNode(new ToAryNode(getPosition(((MultipleAsgnNode)yyVals[-2+yyTop])), ((Node)yyVals[0+yyTop])));
} else {
- ((MultipleAsgnNode)yyVals[-2+yyTop]).setValueNode(new ArrayNode(getPosition(((MultipleAsgnNode)yyVals[-2+yyTop])), ((Node)yyVals[0+yyTop])));
+ ((MultipleAsgnNode)yyVals[-2+yyTop]).setValueNode(support.newArrayNode(getPosition(((MultipleAsgnNode)yyVals[-2+yyTop])), ((Node)yyVals[0+yyTop])));
}
yyVal = ((MultipleAsgnNode)yyVals[-2+yyTop]);
}
@@ -1183,13 +1183,13 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 36:
// line 436 "DefaultRubyParser.y"
{
- yyVal = support.newAndNode(((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
+ yyVal = support.newAndNode(getPosition(((Token)yyVals[-1+yyTop])), ((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
}
break;
case 37:
// line 439 "DefaultRubyParser.y"
{
- yyVal = support.newOrNode(((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
+ yyVal = support.newOrNode(getPosition(((Token)yyVals[-1+yyTop])), ((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
}
break;
case 38:
@@ -1310,7 +1310,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 63:
// line 518 "DefaultRubyParser.y"
{
- yyVal = new MultipleAsgnNode(getPosition(((Token)yyVals[-2+yyTop])), new ArrayNode(getPosition(((Token)yyVals[-2+yyTop])), ((MultipleAsgnNode)yyVals[-1+yyTop])), null);
+ yyVal = new MultipleAsgnNode(getPosition(((Token)yyVals[-2+yyTop])), support.newArrayNode(getPosition(((Token)yyVals[-2+yyTop])), ((MultipleAsgnNode)yyVals[-1+yyTop])), null);
}
break;
case 64:
@@ -1360,7 +1360,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 72:
// line 550 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(((Node)yyVals[-1+yyTop]).getPosition(), ((Node)yyVals[-1+yyTop]));
+ yyVal = support.newArrayNode(((Node)yyVals[-1+yyTop]).getPosition(), ((Node)yyVals[-1+yyTop]));
}
break;
case 73:
@@ -1810,13 +1810,13 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 211:
// line 830 "DefaultRubyParser.y"
{
- yyVal = support.newAndNode(((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
+ yyVal = support.newAndNode(getPosition(((Token)yyVals[-1+yyTop])), ((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
}
break;
case 212:
// line 833 "DefaultRubyParser.y"
{
- yyVal = support.newOrNode(((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
+ yyVal = support.newOrNode(getPosition(((Token)yyVals[-1+yyTop])), ((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
}
break;
case 213:
@@ -1847,7 +1847,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 218:
// line 852 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((Node)yyVals[-1+yyTop])), ((Node)yyVals[-1+yyTop]));
+ yyVal = support.newArrayNode(getPosition(((Node)yyVals[-1+yyTop])), ((Node)yyVals[-1+yyTop]));
}
break;
case 219:
@@ -1866,14 +1866,14 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 221:
// line 862 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((ListNode)yyVals[-1+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
+ yyVal = support.newArrayNode(getPosition(((ListNode)yyVals[-1+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
}
break;
case 222:
// line 865 "DefaultRubyParser.y"
{
support.checkExpression(((Node)yyVals[-1+yyTop]));
- yyVal = new NewlineNode(getPosition(((Token)yyVals[-2+yyTop])), new SplatNode(getPosition(((Token)yyVals[-2+yyTop])), ((Node)yyVals[-1+yyTop])));
+ yyVal = new NewlineNode(getPosition(((Token)yyVals[-2+yyTop])), support.newSplatNode(getPosition(((Token)yyVals[-2+yyTop])), ((Node)yyVals[-1+yyTop])));
}
break;
case 223:
@@ -1892,7 +1892,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 225:
// line 877 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((Token)yyVals[-3+yyTop])), ((Node)yyVals[-2+yyTop]));
+ yyVal = support.newArrayNode(getPosition(((Token)yyVals[-3+yyTop])), ((Node)yyVals[-2+yyTop]));
}
break;
case 226:
@@ -1904,7 +1904,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 229:
// line 887 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((Node)yyVals[0+yyTop])), ((Node)yyVals[0+yyTop]));
+ yyVal = support.newArrayNode(getPosition(((Node)yyVals[0+yyTop])), ((Node)yyVals[0+yyTop]));
}
break;
case 230:
@@ -1923,14 +1923,14 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 232:
// line 897 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((ListNode)yyVals[-1+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
+ yyVal = support.newArrayNode(getPosition(((ListNode)yyVals[-1+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 233:
// line 901 "DefaultRubyParser.y"
{
- yyVal = support.arg_concat(getPosition(((ListNode)yyVals[-4+yyTop])), new ArrayNode(getPosition(((ListNode)yyVals[-4+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
+ yyVal = support.arg_concat(getPosition(((ListNode)yyVals[-4+yyTop])), support.newArrayNode(getPosition(((ListNode)yyVals[-4+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
@@ -1952,7 +1952,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 236:
// line 914 "DefaultRubyParser.y"
{
- yyVal = support.arg_blk_pass(new SplatNode(getPosition(((Token)yyVals[-2+yyTop])), ((Node)yyVals[-1+yyTop])), ((BlockPassNode)yyVals[0+yyTop]));
+ yyVal = support.arg_blk_pass(support.newSplatNode(getPosition(((Token)yyVals[-2+yyTop])), ((Node)yyVals[-1+yyTop])), ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 237:
@@ -1962,75 +1962,75 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 238:
// line 919 "DefaultRubyParser.y"
{
- yyVal = support.arg_blk_pass(new ArrayNode(getPosition(((Node)yyVals[-3+yyTop])), ((Node)yyVals[-3+yyTop])).addAll(((ListNode)yyVals[-1+yyTop])), ((BlockPassNode)yyVals[0+yyTop]));
+ yyVal = support.arg_blk_pass(support.newArrayNode(getPosition(((Node)yyVals[-3+yyTop])), ((Node)yyVals[-3+yyTop])).addAll(((ListNode)yyVals[-1+yyTop])), ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 239:
// line 922 "DefaultRubyParser.y"
{
- yyVal = support.arg_blk_pass(new ArrayNode(getPosition(((Node)yyVals[-2+yyTop])), ((Node)yyVals[-2+yyTop])), ((BlockPassNode)yyVals[0+yyTop]));
+ yyVal = support.arg_blk_pass(support.newArrayNode(getPosition(((Node)yyVals[-2+yyTop])), ((Node)yyVals[-2+yyTop])), ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 240:
// line 925 "DefaultRubyParser.y"
{
- yyVal = support.arg_concat(getPosition(((Node)yyVals[-4+yyTop])), new ArrayNode(getPosition(((Node)yyVals[-4+yyTop])), ((Node)yyVals[-4+yyTop])), ((Node)yyVals[-1+yyTop]));
+ yyVal = support.arg_concat(getPosition(((Node)yyVals[-4+yyTop])), support.newArrayNode(getPosition(((Node)yyVals[-4+yyTop])), ((Node)yyVals[-4+yyTop])), ((Node)yyVals[-1+yyTop]));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 241:
// line 929 "DefaultRubyParser.y"
{
- yyVal = support.arg_concat(getPosition(((Node)yyVals[-6+yyTop])), new ArrayNode(getPosition(((Node)yyVals[-6+yyTop])), ((Node)yyVals[-6+yyTop])).addAll(new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
+ yyVal = support.arg_concat(getPosition(((Node)yyVals[-6+yyTop])), support.newArrayNode(getPosition(((Node)yyVals[-6+yyTop])), ((Node)yyVals[-6+yyTop])).addAll(new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 242:
// line 933 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((ListNode)yyVals[-1+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
+ yyVal = support.newArrayNode(getPosition(((ListNode)yyVals[-1+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 243:
// line 937 "DefaultRubyParser.y"
{
- yyVal = support.arg_concat(getPosition(((ListNode)yyVals[-4+yyTop])), new ArrayNode(getPosition(((ListNode)yyVals[-4+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
+ yyVal = support.arg_concat(getPosition(((ListNode)yyVals[-4+yyTop])), support.newArrayNode(getPosition(((ListNode)yyVals[-4+yyTop])), new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 244:
// line 941 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((Node)yyVals[-3+yyTop])), ((Node)yyVals[-3+yyTop])).add(new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
+ yyVal = support.newArrayNode(getPosition(((Node)yyVals[-3+yyTop])), ((Node)yyVals[-3+yyTop])).add(new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 245:
// line 945 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((Node)yyVals[-5+yyTop])), ((Node)yyVals[-5+yyTop])).addAll(((ListNode)yyVals[-3+yyTop])).add(new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
+ yyVal = support.newArrayNode(getPosition(((Node)yyVals[-5+yyTop])), ((Node)yyVals[-5+yyTop])).addAll(((ListNode)yyVals[-3+yyTop])).add(new HashNode(getPosition(null), ((ListNode)yyVals[-1+yyTop])));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 246:
// line 949 "DefaultRubyParser.y"
{
- yyVal = support.arg_concat(getPosition(((Node)yyVals[-6+yyTop])), new ArrayNode(getPosition(((Node)yyVals[-6+yyTop])), ((Node)yyVals[-6+yyTop])).add(new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
+ yyVal = support.arg_concat(getPosition(((Node)yyVals[-6+yyTop])), support.newArrayNode(getPosition(((Node)yyVals[-6+yyTop])), ((Node)yyVals[-6+yyTop])).add(new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 247:
// line 953 "DefaultRubyParser.y"
{
- yyVal = support.arg_concat(getPosition(((Node)yyVals[-8+yyTop])), new ArrayNode(getPosition(((Node)yyVals[-8+yyTop])), ((Node)yyVals[-8+yyTop])).addAll(((ListNode)yyVals[-6+yyTop])).add(new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
+ yyVal = support.arg_concat(getPosition(((Node)yyVals[-8+yyTop])), support.newArrayNode(getPosition(((Node)yyVals[-8+yyTop])), ((Node)yyVals[-8+yyTop])).addAll(((ListNode)yyVals[-6+yyTop])).add(new HashNode(getPosition(null), ((ListNode)yyVals[-4+yyTop]))), ((Node)yyVals[-1+yyTop]));
yyVal = support.arg_blk_pass((Node)yyVal, ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 248:
// line 957 "DefaultRubyParser.y"
{
- yyVal = support.arg_blk_pass(new SplatNode(getPosition(((Token)yyVals[-2+yyTop])), ((Node)yyVals[-1+yyTop])), ((BlockPassNode)yyVals[0+yyTop]));
+ yyVal = support.arg_blk_pass(support.newSplatNode(getPosition(((Token)yyVals[-2+yyTop])), ((Node)yyVals[-1+yyTop])), ((BlockPassNode)yyVals[0+yyTop]));
}
break;
case 249:
@@ -2092,7 +2092,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 260:
// line 993 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition2(((Node)yyVals[0+yyTop])), ((Node)yyVals[0+yyTop]));
+ yyVal = support.newArrayNode(getPosition2(((Node)yyVals[0+yyTop])), ((Node)yyVals[0+yyTop]));
}
break;
case 261:
@@ -2116,7 +2116,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 264:
// line 1006 "DefaultRubyParser.y"
{
- yyVal = new SplatNode(getPosition(((Token)yyVals[-1+yyTop])), ((Node)yyVals[0+yyTop]));
+ yyVal = support.newSplatNode(getPosition(((Token)yyVals[-1+yyTop])), ((Node)yyVals[0+yyTop]));
}
break;
case 273:
@@ -2620,7 +2620,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 357:
// line 1314 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(getPosition(((Token)yyVals[-1+yyTop])), new WhenNode(getPosition(((Token)yyVals[-1+yyTop])), ((Node)yyVals[0+yyTop]), null, null));
+ yyVal = support.newArrayNode(getPosition(((Token)yyVals[-1+yyTop])), new WhenNode(getPosition(((Token)yyVals[-1+yyTop])), ((Node)yyVals[0+yyTop]), null, null));
}
break;
case 360:
@@ -2646,7 +2646,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 362:
// line 1336 "DefaultRubyParser.y"
{
- yyVal = new ArrayNode(((Node)yyVals[0+yyTop]).getPosition(), ((Node)yyVals[0+yyTop]));
+ yyVal = support.newArrayNode(((Node)yyVals[0+yyTop]).getPosition(), ((Node)yyVals[0+yyTop]));
}
break;
case 365:
@@ -3258,34 +3258,41 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
case 470:
// line 1790 "DefaultRubyParser.y"
{ /* [!null]*/
- yyVal = new ArrayNode(support.union(((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop])), ((Node)yyVals[-2+yyTop])).add(((Node)yyVals[0+yyTop]));
+ ISourcePosition position;
+ if (((Node)yyVals[-2+yyTop]) == null && ((Node)yyVals[0+yyTop]) == null) {
+ position = getPosition(((Token)yyVals[-1+yyTop]));
+ } else {
+ position = support.union(((Node)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop]));
+ }
+
+ yyVal = support.newArrayNode(position, ((Node)yyVals[-2+yyTop])).add(((Node)yyVals[0+yyTop]));
}
break;
case 490:
- // line 1802 "DefaultRubyParser.y"
+ // line 1809 "DefaultRubyParser.y"
{
yyerrok();
}
break;
case 493:
- // line 1808 "DefaultRubyParser.y"
+ // line 1815 "DefaultRubyParser.y"
{
yyerrok();
}
break;
case 494:
- // line 1812 "DefaultRubyParser.y"
+ // line 1819 "DefaultRubyParser.y"
{
yyVal = null;
}
break;
case 495:
- // line 1816 "DefaultRubyParser.y"
+ // line 1823 "DefaultRubyParser.y"
{
yyVal = null;
}
break;
- // line 7438 "-"
+ // line 7445 "-"
}
yyTop -= yyLen[yyN];
yyState = yyStates[yyTop];
@@ -3310,7 +3317,7 @@ public Object yyparse (RubyYaccLexer yyLex) throws java.io.IOException, yyExcept
}
}
- // line 1821 "DefaultRubyParser.y"
+ // line 1828 "DefaultRubyParser.y"
/** The parse method use an lexer stream and parse it to an AST node
* structure
@@ -3360,4 +3367,4 @@ private ISourcePosition getPosition(ISourcePositionHolder start, boolean inclusi
return lexer.getPosition(null, inclusive);
}
}
- // line 7518 "-"
+ // line 7525 "-"
View
71 src/org/jruby/parser/DefaultRubyParser.y
@@ -377,7 +377,7 @@ stmt : kALIAS fitem {
if ($1.getHeadNode() != null) {
$1.setValueNode(new ToAryNode(getPosition($1), $3));
} else {
- $1.setValueNode(new ArrayNode(getPosition($1), $3));
+ $1.setValueNode(support.newArrayNode(getPosition($1), $3));
}
$$ = $1;
}
@@ -420,7 +420,7 @@ stmt : kALIAS fitem {
if ($1.getHeadNode() != null) {
$1.setValueNode(new ToAryNode(getPosition($1), $3));
} else {
- $1.setValueNode(new ArrayNode(getPosition($1), $3));
+ $1.setValueNode(support.newArrayNode(getPosition($1), $3));
}
$$ = $1;
}
@@ -434,10 +434,10 @@ stmt : kALIAS fitem {
// Node:expr *CURRENT* all but arg so far
expr : command_call
| expr kAND expr {
- $$ = support.newAndNode($1, $3);
+ $$ = support.newAndNode(getPosition($2), $1, $3);
}
| expr kOR expr {
- $$ = support.newOrNode($1, $3);
+ $$ = support.newOrNode(getPosition($2), $1, $3);
}
| kNOT expr {
$$ = new NotNode(support.union($1, $2), support.getConditionNode($2));
@@ -516,7 +516,7 @@ mlhs : mlhs_basic
// MultipleAssignNode:mlhs_entry - mlhs w or w/o parens [!null]
mlhs_entry : mlhs_basic
| tLPAREN mlhs_entry tRPAREN {
- $$ = new MultipleAsgnNode(getPosition($1), new ArrayNode(getPosition($1), $2), null);
+ $$ = new MultipleAsgnNode(getPosition($1), support.newArrayNode(getPosition($1), $2), null);
}
// MultipleAssignNode:mlhs_basic - multiple left hand side (basic because used in multiple context) [!null]
@@ -548,7 +548,7 @@ mlhs_item : mlhs_node
// [!null]
mlhs_head : mlhs_item ',' {
- $$ = new ArrayNode($1.getPosition(), $1);
+ $$ = support.newArrayNode($1.getPosition(), $1);
}
| mlhs_head mlhs_item ',' {
$$ = $1.add($2);
@@ -828,10 +828,10 @@ arg : lhs '=' arg {
$$ = support.getOperatorCallNode($1, ">>", $3, getPosition(null));
}
| arg tANDOP arg {
- $$ = support.newAndNode($1, $3);
+ $$ = support.newAndNode(getPosition($2), $1, $3);
}
| arg tOROP arg {
- $$ = support.newOrNode($1, $3);
+ $$ = support.newOrNode(getPosition($2), $1, $3);
}
| kDEFINED opt_nl arg {
$$ = new DefinedNode(getPosition($1), $3);
@@ -850,7 +850,7 @@ arg_value : arg {
aref_args : none
| command opt_nl {
- $$ = new ArrayNode(getPosition($1), $1);
+ $$ = support.newArrayNode(getPosition($1), $1);
}
| args trailer {
$$ = $1;
@@ -860,11 +860,11 @@ aref_args : none
$$ = support.arg_concat(getPosition($1), $1, $4);
}
| assocs trailer {
- $$ = new ArrayNode(getPosition($1), new HashNode(getPosition(null), $1));
+ $$ = support.newArrayNode(getPosition($1), new HashNode(getPosition(null), $1));
}
| tSTAR arg opt_nl {
support.checkExpression($2);
- $$ = new NewlineNode(getPosition($1), new SplatNode(getPosition($1), $2));
+ $$ = new NewlineNode(getPosition($1), support.newSplatNode(getPosition($1), $2));
}
paren_args : tLPAREN2 none tRPAREN {
@@ -875,7 +875,7 @@ paren_args : tLPAREN2 none tRPAREN {
$<Node>$.setPosition(support.union($1, $4));
}
| tLPAREN2 block_call opt_nl tRPAREN {
- $$ = new ArrayNode(getPosition($1), $2);
+ $$ = support.newArrayNode(getPosition($1), $2);
}
| tLPAREN2 args ',' block_call opt_nl tRPAREN {
$$ = $2.add($4);
@@ -885,7 +885,7 @@ opt_paren_args: none | paren_args
// Node:call_args - Arguments for a function call
call_args : command {
- $$ = new ArrayNode(getPosition($1), $1);
+ $$ = support.newArrayNode(getPosition($1), $1);
}
| args opt_block_arg {
$$ = support.arg_blk_pass($1, $2);
@@ -895,11 +895,11 @@ call_args : command {
$$ = support.arg_blk_pass($<Node>$, $5);
}
| assocs opt_block_arg {
- $$ = new ArrayNode(getPosition($1), new HashNode(getPosition(null), $1));
+ $$ = support.newArrayNode(getPosition($1), new HashNode(getPosition(null), $1));
$$ = support.arg_blk_pass((Node)$$, $2);
}
| assocs ',' tSTAR arg_value opt_block_arg {
- $$ = support.arg_concat(getPosition($1), new ArrayNode(getPosition($1), new HashNode(getPosition(null), $1)), $4);
+ $$ = support.arg_concat(getPosition($1), support.newArrayNode(getPosition($1), new HashNode(getPosition(null), $1)), $4);
$$ = support.arg_blk_pass((Node)$$, $5);
}
| args ',' assocs opt_block_arg {
@@ -912,50 +912,50 @@ call_args : command {
$$ = support.arg_blk_pass((Node)$$, $7);
}
| tSTAR arg_value opt_block_arg {
- $$ = support.arg_blk_pass(new SplatNode(getPosition($1), $2), $3);
+ $$ = support.arg_blk_pass(support.newSplatNode(getPosition($1), $2), $3);
}
| block_arg {}
call_args2 : arg_value ',' args opt_block_arg {
- $$ = support.arg_blk_pass(new ArrayNode(getPosition($1), $1).addAll($3), $4);
+ $$ = support.arg_blk_pass(support.newArrayNode(getPosition($1), $1).addAll($3), $4);
}
| arg_value ',' block_arg {
- $$ = support.arg_blk_pass(new ArrayNode(getPosition($1), $1), $3);
+ $$ = support.arg_blk_pass(support.newArrayNode(getPosition($1), $1), $3);
}
| arg_value ',' tSTAR arg_value opt_block_arg {
- $$ = support.arg_concat(getPosition($1), new ArrayNode(getPosition($1), $1), $4);
+ $$ = support.arg_concat(getPosition($1), support.newArrayNode(getPosition($1), $1), $4);
$$ = support.arg_blk_pass((Node)$$, $5);
}
| arg_value ',' args ',' tSTAR arg_value opt_block_arg {
- $$ = support.arg_concat(getPosition($1), new ArrayNode(getPosition($1), $1).addAll(new HashNode(getPosition(null), $3)), $6);
+ $$ = support.arg_concat(getPosition($1), support.newArrayNode(getPosition($1), $1).addAll(new HashNode(getPosition(null), $3)), $6);
$$ = support.arg_blk_pass((Node)$$, $7);
}
| assocs opt_block_arg {
- $$ = new ArrayNode(getPosition($1), new HashNode(getPosition(null), $1));
+ $$ = support.newArrayNode(getPosition($1), new HashNode(getPosition(null), $1));
$$ = support.arg_blk_pass((Node)$$, $2);
}
| assocs ',' tSTAR arg_value opt_block_arg {
- $$ = support.arg_concat(getPosition($1), new ArrayNode(getPosition($1), new HashNode(getPosition(null), $1)), $4);
+ $$ = support.arg_concat(getPosition($1), support.newArrayNode(getPosition($1), new HashNode(getPosition(null), $1)), $4);
$$ = support.arg_blk_pass((Node)$$, $5);
}
| arg_value ',' assocs opt_block_arg {
- $$ = new ArrayNode(getPosition($1), $1).add(new HashNode(getPosition(null), $3));
+ $$ = support.newArrayNode(getPosition($1), $1).add(new HashNode(getPosition(null), $3));
$$ = support.arg_blk_pass((Node)$$, $4);
}
| arg_value ',' args ',' assocs opt_block_arg {
- $$ = new ArrayNode(getPosition($1), $1).addAll($3).add(new HashNode(getPosition(null), $5));
+ $$ = support.newArrayNode(getPosition($1), $1).addAll($3).add(new HashNode(getPosition(null), $5));
$$ = support.arg_blk_pass((Node)$$, $6);
}
| arg_value ',' assocs ',' tSTAR arg_value opt_block_arg {
- $$ = support.arg_concat(getPosition($1), new ArrayNode(getPosition($1), $1).add(new HashNode(getPosition(null), $3)), $6);
+ $$ = support.arg_concat(getPosition($1), support.newArrayNode(getPosition($1), $1).add(new HashNode(getPosition(null), $3)), $6);
$$ = support.arg_blk_pass((Node)$$, $7);
}
| arg_value ',' args ',' assocs ',' tSTAR arg_value opt_block_arg {
- $$ = support.arg_concat(getPosition($1), new ArrayNode(getPosition($1), $1).addAll($3).add(new HashNode(getPosition(null), $5)), $8);
+ $$ = support.arg_concat(getPosition($1), support.newArrayNode(getPosition($1), $1).addAll($3).add(new HashNode(getPosition(null), $5)), $8);
$$ = support.arg_blk_pass((Node)$$, $9);
}
| tSTAR arg_value opt_block_arg {
- $$ = support.arg_blk_pass(new SplatNode(getPosition($1), $2), $3);
+ $$ = support.arg_blk_pass(support.newSplatNode(getPosition($1), $2), $3);
}
| block_arg {}
@@ -991,7 +991,7 @@ opt_block_arg : ',' block_arg {
| none_block_pass
args : arg_value {
- $$ = new ArrayNode(getPosition2($1), $1);
+ $$ = support.newArrayNode(getPosition2($1), $1);
}
| args ',' arg_value {
$$ = $1.add($3);
@@ -1004,7 +1004,7 @@ mrhs : args ',' arg_value {
$$ = support.arg_concat(getPosition($1), $1, $4);
}
| tSTAR arg_value {
- $$ = new SplatNode(getPosition($1), $2);
+ $$ = support.newSplatNode(getPosition($1), $2);
}
primary : literal
@@ -1312,7 +1312,7 @@ when_args : args
$$ = $1.add(new WhenNode(getPosition($1), $4, null, null));
}
| tSTAR arg_value {
- $$ = new ArrayNode(getPosition($1), new WhenNode(getPosition($1), $2, null, null));
+ $$ = support.newArrayNode(getPosition($1), new WhenNode(getPosition($1), $2, null, null));
}
cases : opt_else | case_body
@@ -1334,7 +1334,7 @@ opt_rescue : kRESCUE exc_list exc_var then compstmt opt_rescue {
| {$$ = null;}
exc_list : arg_value {
- $$ = new ArrayNode($1.getPosition(), $1);
+ $$ = support.newArrayNode($1.getPosition(), $1);
}
| mrhs
| none
@@ -1788,7 +1788,14 @@ assocs : assoc // [!null]
// ListNode:assoc - A single hash value pair (e.g. a => b) [!null]
assoc : arg_value tASSOC arg_value { // [!null]
- $$ = new ArrayNode(support.union($1, $3), $1).add($3);
+ ISourcePosition position;
+ if ($1 == null && $3 == null) {
+ position = getPosition($2);
+ } else {
+ position = support.union($1, $3);
+ }
+
+ $$ = support.newArrayNode(position, $1).add($3);
}
operation : tIDENTIFIER | tCONSTANT | tFID
View
45 src/org/jruby/parser/ParserSupport.java
@@ -273,7 +273,7 @@ public AssignableNode assignable(Token lhs, Node value) {
case Tokens.k__LINE__:
throw new SyntaxException(PID.INVALID_ASSIGNMENT, lhs.getPosition(), "Can't assign to __LINE__", "__LINE__");
case Tokens.tIDENTIFIER:
- return currentScope.assign(value != NilImplicitNode.NIL ? union(lhs, value) : lhs.getPosition(), (String) lhs.getValue(), value);
+ return currentScope.assign(value != NilImplicitNode.NIL ? union(lhs, value) : lhs.getPosition(), (String) lhs.getValue(), makeNullNil(value));
case Tokens.tCONSTANT:
if (isInDef() || isInSingle()) {
throw new SyntaxException(PID.DYNAMIC_CONSTANT_ASSIGNMENT, lhs.getPosition(), "dynamic constant assignment");
@@ -315,7 +315,7 @@ public ISourcePosition union(ISourcePositionHolder first, ISourcePositionHolder
second = ((NewlineNode) second).getNextNode();
}
- if (second == null) return first.getPosition();
+ if (second == null) return first.getPosition();
if (first == null) return second.getPosition();
return first.getPosition().union(second.getPosition());
@@ -687,9 +687,16 @@ private boolean checkAssignmentInCondition(Node node) {
return false;
}
+
+ private Node makeNullNil(Node node) {
+ return node == null ? NilImplicitNode.NIL : node;
+ }
private Node cond0(Node node) {
checkAssignmentInCondition(node);
+
+ Node leftNode = null;
+ Node rightNode = null;
switch(node.nodeId) {
case DREGEXPNODE: {
@@ -698,11 +705,15 @@ private Node cond0(Node node) {
return new Match2Node(position, node, new GlobalVarNode(position, "$_"));
}
case ANDNODE:
- return new AndNode(node.getPosition(), cond0(((AndNode) node).getFirstNode()),
- cond0(((AndNode) node).getSecondNode()));
+ leftNode = cond0(((AndNode) node).getFirstNode());
+ rightNode = cond0(((AndNode) node).getSecondNode());
+
+ return new AndNode(node.getPosition(), makeNullNil(leftNode), makeNullNil(rightNode));
case ORNODE:
- return new OrNode(node.getPosition(), cond0(((OrNode) node).getFirstNode()),
- cond0(((OrNode) node).getSecondNode()));
+ leftNode = cond0(((OrNode) node).getFirstNode());
+ rightNode = cond0(((OrNode) node).getSecondNode());
+
+ return new OrNode(node.getPosition(), makeNullNil(leftNode), makeNullNil(rightNode));
case DOTNODE: {
DotNode dotNode = (DotNode) node;
if (dotNode.isLiteral()) return node;
@@ -726,7 +737,7 @@ private Node cond0(Node node) {
}
public Node getConditionNode(Node node) {
- if (node == null) return null;
+ if (node == null) return NilImplicitNode.NIL;
if (node instanceof NewlineNode) {
return new NewlineNode(node.getPosition(), cond0(((NewlineNode) node).getNextNode()));
@@ -750,17 +761,29 @@ private Node getFlipConditionNode(Node node) {
return node;
}
+
+ public SplatNode newSplatNode(ISourcePosition position, Node node) {
+ return new SplatNode(position, makeNullNil(node));
+ }
+
+ public ArrayNode newArrayNode(ISourcePosition position, Node firstNode) {
+ return new ArrayNode(position, makeNullNil(firstNode));
+ }
- public AndNode newAndNode(Node left, Node right) {
+ public AndNode newAndNode(ISourcePosition position, Node left, Node right) {
checkExpression(left);
- return new AndNode(union(left, right), left, right);
+ if (left == null && right == null) return new AndNode(position, makeNullNil(left), makeNullNil(right));
+
+ return new AndNode(union(left, right), makeNullNil(left), makeNullNil(right));
}
- public OrNode newOrNode(Node left, Node right) {
+ public OrNode newOrNode(ISourcePosition position, Node left, Node right) {
checkExpression(left);
+
+ if (left == null && right == null) return new OrNode(position, makeNullNil(left), makeNullNil(right));
- return new OrNode(union(left, right), left, right);
+ return new OrNode(union(left, right), makeNullNil(left), makeNullNil(right));
}
public Node getReturnArgsNode(Node node) {

0 comments on commit 3e92abe

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