Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Source/JavaScriptCore/parser/JSParser.cpp b/Source/JavaScriptCore/parser/JSParser.cpp
- index f445259..349921b 100644
- --- a/Source/JavaScriptCore/parser/JSParser.cpp
- +++ b/Source/JavaScriptCore/parser/JSParser.cpp
- @@ -652,11 +652,14 @@ private:
- bool isFunction() { return m_isFunction; }
- bool isFunctionBoundary() { return m_isFunctionBoundary; }
- - bool declareVariable(const Identifier* ident)
- + bool declareVariable(const Identifier* ident, bool isLetInduced)
- {
- bool isValidStrictMode = m_globalData->propertyNames->eval != *ident && m_globalData->propertyNames->arguments != *ident;
- m_isValidStrictMode = m_isValidStrictMode && isValidStrictMode;
- - m_declaredVariables.add(ident->ustring().impl());
- + if (isLetInduced)
- + m_letInducedVariables.add(ident->ustring().impl());
- + else
- + m_declaredVariables.add(ident->ustring().impl());
- return isValidStrictMode;
- }
- @@ -791,6 +794,7 @@ private:
- IdentifierSet m_usedVariables;
- IdentifierSet m_closedVariables;
- IdentifierSet m_writtenVariables;
- + IdentifierSet m_letInducedVariables;
- };
- typedef Vector<Scope, 10> ScopeStack;
- @@ -879,7 +883,7 @@ private:
- return popScopeInternal(scope, shouldTrackClosedVariables);
- }
- - bool declareVariable(const Identifier* ident)
- + bool declareVariable(const Identifier* ident, bool isLetInduced)
- {
- unsigned i = m_scopeStack.size() - 1;
- ASSERT(i < m_scopeStack.size());
- @@ -887,7 +891,7 @@ private:
- i--;
- ASSERT(i < m_scopeStack.size());
- }
- - return m_scopeStack[i].declareVariable(ident);
- + return m_scopeStack[i].declareVariable(ident, isLetInduced);
- }
- void declareWrite(const Identifier* ident)
- @@ -1091,7 +1095,7 @@ template <class TreeBuilder> TreeExpression JSParser::parseVarDeclarationList(Tr
- lastIdent = name;
- next();
- bool hasInitializer = match(EQUAL);
- - failIfFalseIfStrictWithNameAndMessage(declareVariable(name), "Cannot declare a variable named", name->impl(), "in strict mode.");
- + failIfFalseIfStrictWithNameAndMessage(declareVariable(name, false), "Cannot declare a variable named", name->impl(), "in strict mode.");
- context.addVar(name, (hasInitializer || (!m_allowsIn && match(INTOKEN))) ? DeclarationStacks::HasInitializer : 0);
- if (hasInitializer) {
- int varDivot = tokenStart() + 1;
- @@ -1124,7 +1128,7 @@ template <class TreeBuilder> TreeConstDeclList JSParser::parseConstDeclarationLi
- const Identifier* name = m_token.m_data.ident;
- next();
- bool hasInitializer = match(EQUAL);
- - declareVariable(name);
- + declareVariable(name, false);
- context.addVar(name, DeclarationStacks::IsConstant | (hasInitializer ? DeclarationStacks::HasInitializer : 0));
- TreeExpression initializer = 0;
- if (hasInitializer) {
- @@ -1448,7 +1452,7 @@ template <class TreeBuilder> TreeStatement JSParser::parseTryStatement(TreeBuild
- ident = m_token.m_data.ident;
- next();
- AutoPopScopeRef catchScope(this, pushScope());
- - failIfFalseIfStrictWithNameAndMessage(catchScope->declareVariable(ident), "Cannot declare a variable named", ident->impl(), "in strict mode");
- + failIfFalseIfStrictWithNameAndMessage(catchScope->declareVariable(ident, false), "Cannot declare a variable named", ident->impl(), "in strict mode");
- catchScope->preventNewDecls();
- consumeOrFail(CLOSEPAREN);
- matchOrFail(OPENBRACE);
- @@ -1598,7 +1602,7 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc
- failIfTrueWithMessage(*name == m_globalData->propertyNames->underscoreProto, "Cannot name a function __proto__");
- next();
- if (!nameIsInContainingScope)
- - failIfFalseIfStrict(functionScope->declareVariable(name));
- + failIfFalseIfStrict(functionScope->declareVariable(name, false));
- } else if (requirements == FunctionNeedsName)
- return false;
- consumeOrFail(OPENPAREN);
- @@ -1674,7 +1678,7 @@ template <class TreeBuilder> TreeStatement JSParser::parseFunctionDeclaration(Tr
- int bodyStartLine = 0;
- failIfFalse((parseFunctionInfo<FunctionNeedsName, true>(context, name, parameters, body, openBracePos, closeBracePos, bodyStartLine)));
- failIfFalse(name);
- - failIfFalseIfStrict(declareVariable(name));
- + failIfFalseIfStrict(declareVariable(name, false));
- return context.createFuncDeclStatement(name, body, parameters, openBracePos, closeBracePos, bodyStartLine, m_lastLine);
- }
Add Comment
Please, Sign In to add comment