Changeset 68288 in webkit for trunk/JavaScriptCore/parser/JSParser.cpp
- Timestamp:
- Sep 24, 2010, 1:54:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/JSParser.cpp
r67769 r68288 205 205 : m_usesEval(false) 206 206 , m_needsFullActivation(false) 207 , m_allowsNewDecls(true) 207 208 { 208 209 } … … 213 214 } 214 215 216 void preventNewDecls() { m_allowsNewDecls = false; } 217 bool allowsNewDecls() const { return m_allowsNewDecls; } 218 215 219 void useVariable(const Identifier* ident, bool isEval) 216 220 { … … 250 254 bool m_usesEval; 251 255 bool m_needsFullActivation; 256 bool m_allowsNewDecls; 252 257 IdentifierSet m_declaredVariables; 253 258 IdentifierSet m_usedVariables; … … 287 292 m_scopeStack[m_scopeStack.size() - 2].collectFreeVariables(&m_scopeStack.last(), shouldTrackClosedVariables); 288 293 m_scopeStack.removeLast(); 294 } 295 296 void declareVariable(const Identifier* ident) 297 { 298 unsigned i = m_scopeStack.size() - 1; 299 ASSERT(i < m_scopeStack.size()); 300 while (!m_scopeStack[i].allowsNewDecls()) { 301 i--; 302 ASSERT(i < m_scopeStack.size()); 303 } 304 m_scopeStack[i].declareVariable(ident); 289 305 } 290 306 … … 426 442 next(); 427 443 bool hasInitializer = match(EQUAL); 428 currentScope()->declareVariable(name);444 declareVariable(name); 429 445 context.addVar(name, (hasInitializer || (!m_allowsIn && match(INTOKEN))) ? DeclarationStacks::HasInitializer : 0); 430 446 if (hasInitializer) { … … 458 474 next(); 459 475 bool hasInitializer = match(EQUAL); 460 currentScope()->declareVariable(name);476 declareVariable(name); 461 477 context.addVar(name, DeclarationStacks::IsConstant | (hasInitializer ? DeclarationStacks::HasInitializer : 0)); 462 478 TreeExpression initializer = 0; … … 760 776 ScopeRef catchScope = pushScope(); 761 777 catchScope->declareVariable(ident); 778 catchScope->preventNewDecls(); 762 779 consumeOrFail(CLOSEPAREN); 763 780 matchOrFail(OPENBRACE); … … 863 880 matchOrFail(IDENT); 864 881 usesArguments = m_globalData->propertyNames->arguments == *m_token.m_data.ident; 865 currentScope()->declareVariable(m_token.m_data.ident);882 declareVariable(m_token.m_data.ident); 866 883 TreeFormalParameterList list = context.createFormalParameterList(*m_token.m_data.ident); 867 884 TreeFormalParameterList tail = list; … … 871 888 matchOrFail(IDENT); 872 889 const Identifier* ident = m_token.m_data.ident; 873 currentScope()->declareVariable(ident);890 declareVariable(ident); 874 891 next(); 875 892 usesArguments = usesArguments || m_globalData->propertyNames->arguments == *ident; … … 934 951 failIfFalse((parseFunctionInfo<FunctionNeedsName, true>(context, name, parameters, body, openBracePos, closeBracePos, bodyStartLine))); 935 952 failIfFalse(name); 936 currentScope()->declareVariable(name);953 declareVariable(name); 937 954 return context.createFuncDeclStatement(name, body, parameters, openBracePos, closeBracePos, bodyStartLine, m_lastLine); 938 955 }
Note:
See TracChangeset
for help on using the changeset viewer.