Guest User

Untitled

a guest
Feb 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.76 KB | None | 0 0
  1. diff --git a/Source/JavaScriptCore/parser/JSParser.cpp b/Source/JavaScriptCore/parser/JSParser.cpp
  2. index f445259..349921b 100644
  3. --- a/Source/JavaScriptCore/parser/JSParser.cpp
  4. +++ b/Source/JavaScriptCore/parser/JSParser.cpp
  5. @@ -652,11 +652,14 @@ private:
  6.          bool isFunction() { return m_isFunction; }
  7.          bool isFunctionBoundary() { return m_isFunctionBoundary; }
  8.          
  9. -        bool declareVariable(const Identifier* ident)
  10. +        bool declareVariable(const Identifier* ident, bool isLetInduced)
  11.          {
  12.              bool isValidStrictMode = m_globalData->propertyNames->eval != *ident && m_globalData->propertyNames->arguments != *ident;
  13.              m_isValidStrictMode = m_isValidStrictMode && isValidStrictMode;
  14. -            m_declaredVariables.add(ident->ustring().impl());
  15. +            if (isLetInduced)
  16. +                m_letInducedVariables.add(ident->ustring().impl());
  17. +            else
  18. +                m_declaredVariables.add(ident->ustring().impl());
  19.              return isValidStrictMode;
  20.          }
  21.          
  22. @@ -791,6 +794,7 @@ private:
  23.          IdentifierSet m_usedVariables;
  24.          IdentifierSet m_closedVariables;
  25.          IdentifierSet m_writtenVariables;
  26. +        IdentifierSet m_letInducedVariables;
  27.      };
  28.  
  29.      typedef Vector<Scope, 10> ScopeStack;
  30. @@ -879,7 +883,7 @@ private:
  31.          return popScopeInternal(scope, shouldTrackClosedVariables);
  32.      }
  33.  
  34. -    bool declareVariable(const Identifier* ident)
  35. +    bool declareVariable(const Identifier* ident, bool isLetInduced)
  36.      {
  37.          unsigned i = m_scopeStack.size() - 1;
  38.          ASSERT(i < m_scopeStack.size());
  39. @@ -887,7 +891,7 @@ private:
  40.              i--;
  41.              ASSERT(i < m_scopeStack.size());
  42.          }
  43. -        return m_scopeStack[i].declareVariable(ident);
  44. +        return m_scopeStack[i].declareVariable(ident, isLetInduced);
  45.      }
  46.      
  47.      void declareWrite(const Identifier* ident)
  48. @@ -1091,7 +1095,7 @@ template <class TreeBuilder> TreeExpression JSParser::parseVarDeclarationList(Tr
  49.          lastIdent = name;
  50.          next();
  51.          bool hasInitializer = match(EQUAL);
  52. -        failIfFalseIfStrictWithNameAndMessage(declareVariable(name), "Cannot declare a variable named", name->impl(), "in strict mode.");
  53. +        failIfFalseIfStrictWithNameAndMessage(declareVariable(name, false), "Cannot declare a variable named", name->impl(), "in strict mode.");
  54.          context.addVar(name, (hasInitializer || (!m_allowsIn && match(INTOKEN))) ? DeclarationStacks::HasInitializer : 0);
  55.          if (hasInitializer) {
  56.              int varDivot = tokenStart() + 1;
  57. @@ -1124,7 +1128,7 @@ template <class TreeBuilder> TreeConstDeclList JSParser::parseConstDeclarationLi
  58.          const Identifier* name = m_token.m_data.ident;
  59.          next();
  60.          bool hasInitializer = match(EQUAL);
  61. -        declareVariable(name);
  62. +        declareVariable(name, false);
  63.          context.addVar(name, DeclarationStacks::IsConstant | (hasInitializer ? DeclarationStacks::HasInitializer : 0));
  64.          TreeExpression initializer = 0;
  65.          if (hasInitializer) {
  66. @@ -1448,7 +1452,7 @@ template <class TreeBuilder> TreeStatement JSParser::parseTryStatement(TreeBuild
  67.          ident = m_token.m_data.ident;
  68.          next();
  69.          AutoPopScopeRef catchScope(this, pushScope());
  70. -        failIfFalseIfStrictWithNameAndMessage(catchScope->declareVariable(ident), "Cannot declare a variable named", ident->impl(), "in strict mode");
  71. +        failIfFalseIfStrictWithNameAndMessage(catchScope->declareVariable(ident, false), "Cannot declare a variable named", ident->impl(), "in strict mode");
  72.          catchScope->preventNewDecls();
  73.          consumeOrFail(CLOSEPAREN);
  74.          matchOrFail(OPENBRACE);
  75. @@ -1598,7 +1602,7 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc
  76.          failIfTrueWithMessage(*name == m_globalData->propertyNames->underscoreProto, "Cannot name a function __proto__");
  77.          next();
  78.          if (!nameIsInContainingScope)
  79. -            failIfFalseIfStrict(functionScope->declareVariable(name));
  80. +            failIfFalseIfStrict(functionScope->declareVariable(name, false));
  81.      } else if (requirements == FunctionNeedsName)
  82.          return false;
  83.      consumeOrFail(OPENPAREN);
  84. @@ -1674,7 +1678,7 @@ template <class TreeBuilder> TreeStatement JSParser::parseFunctionDeclaration(Tr
  85.      int bodyStartLine = 0;
  86.      failIfFalse((parseFunctionInfo<FunctionNeedsName, true>(context, name, parameters, body, openBracePos, closeBracePos, bodyStartLine)));
  87.      failIfFalse(name);
  88. -    failIfFalseIfStrict(declareVariable(name));
  89. +    failIfFalseIfStrict(declareVariable(name, false));
  90.      return context.createFuncDeclStatement(name, body, parameters, openBracePos, closeBracePos, bodyStartLine, m_lastLine);
  91.  }
Add Comment
Please, Sign In to add comment