Permalink
Browse files

JRUBY-2824: Regression: Lots of Interpreter crashes on empty expressions

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@7223 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent cba0800 commit 99ec87344f56535932bdc1f609dfd9371e64fd92 @enebo enebo committed Jul 19, 2008
@@ -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;
@@ -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;
}
/**
@@ -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 "-"
Oops, something went wrong.

0 comments on commit 99ec873

Please sign in to comment.