Browse Source

Fixing wrong handling of relational expression in a for statement

c.f. https://github.com/ariya/esprima/commit/db275592e1837353a3906fd71d668dea8dd535b3
Sebastien Ros 12 years ago
parent
commit
858bf60fe7
1 changed files with 8 additions and 8 deletions
  1. 8 8
      Jint/Parser/JavascriptParser.cs

+ 8 - 8
Jint/Parser/JavascriptParser.cs

@@ -2337,8 +2337,11 @@ namespace Jint.Parser
         private Expression ParseLeftHandSideExpressionAllowCall()
         private Expression ParseLeftHandSideExpressionAllowCall()
         {
         {
             LocationMarker marker = CreateLocationMarker();
             LocationMarker marker = CreateLocationMarker();
-
+            
+            var previousAllowIn = _state.AllowIn;
+            _state.AllowIn = true;
             Expression expr = MatchKeyword("new") ? ParseNewExpression() : ParsePrimaryExpression();
             Expression expr = MatchKeyword("new") ? ParseNewExpression() : ParsePrimaryExpression();
+            _state.AllowIn = previousAllowIn;
 
 
             while (Match(".") || Match("[") || Match("("))
             while (Match(".") || Match("[") || Match("("))
             {
             {
@@ -2371,7 +2374,9 @@ namespace Jint.Parser
         {
         {
             LocationMarker marker = CreateLocationMarker();
             LocationMarker marker = CreateLocationMarker();
 
 
+            var previousAllowIn = _state.AllowIn;
             Expression expr = MatchKeyword("new") ? ParseNewExpression() : ParsePrimaryExpression();
             Expression expr = MatchKeyword("new") ? ParseNewExpression() : ParsePrimaryExpression();
+            _state.AllowIn = previousAllowIn;
 
 
             while (Match(".") || Match("["))
             while (Match(".") || Match("["))
             {
             {
@@ -2562,14 +2567,11 @@ namespace Jint.Parser
         {
         {
             Expression expr;
             Expression expr;
 
 
-            bool previousAllowIn = _state.AllowIn;
-            _state.AllowIn = true;
-
             LocationMarker marker = CreateLocationMarker();
             LocationMarker marker = CreateLocationMarker();
             Expression left = ParseUnaryExpression();
             Expression left = ParseUnaryExpression();
 
 
             Token token = _lookahead;
             Token token = _lookahead;
-            int prec = binaryPrecedence(token, previousAllowIn);
+            int prec = binaryPrecedence(token, _state.AllowIn);
             if (prec == 0)
             if (prec == 0)
             {
             {
                 return left;
                 return left;
@@ -2582,7 +2584,7 @@ namespace Jint.Parser
 
 
             var stack = new List<object>( new object[] {left, token, right});
             var stack = new List<object>( new object[] {left, token, right});
 
 
-            while ((prec = binaryPrecedence(_lookahead, previousAllowIn)) > 0)
+            while ((prec = binaryPrecedence(_lookahead, _state.AllowIn)) > 0)
             {
             {
                 // Reduce: make a binary expression from the three topmost entries.
                 // Reduce: make a binary expression from the three topmost entries.
                 while ((stack.Count > 2) && (prec <= ((Token) stack[stack.Count - 2]).Precedence))
                 while ((stack.Count > 2) && (prec <= ((Token) stack[stack.Count - 2]).Precedence))
@@ -2611,8 +2613,6 @@ namespace Jint.Parser
                 stack.Push(expr);
                 stack.Push(expr);
             }
             }
 
 
-            _state.AllowIn = previousAllowIn;
-
             // Final reduce to clean-up the stack.
             // Final reduce to clean-up the stack.
             int i = stack.Count - 1;
             int i = stack.Count - 1;
             expr = (Expression) stack[i];
             expr = (Expression) stack[i];