Changeset 38747 in webkit
- Timestamp:
- Nov 24, 2008 11:23:44 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r38745 r38747 1 2008-11-24 Cameron Zwarich <zwarich@apple.com> 2 3 Reviewed by Geoff Garen. 4 5 Bug 13790: Function declarations are not treated as statements (used to affect starcraft2.com) 6 <https://bugs.webkit.org/show_bug.cgi?id=13790> 7 8 Modify the parser to treat function declarations as statements, 9 simplifying the grammar in the process. Technically, according to the 10 grammar in the ECMA spec, function declarations are not statements and 11 can not be used everywhere that statements can, but it is not worth the 12 possibility compatibility issues just to stick to the spec in this case. 13 14 * parser/Grammar.y: 15 * parser/Nodes.cpp: 16 (JSC::FuncDeclNode::emitBytecode): Avoid returning ignoredResult() 17 as a result, because it causes a crash in DoWhileNode::emitBytecode(). 18 1 19 2008-11-24 Geoffrey Garen <ggaren@apple.com> 2 20 -
trunk/JavaScriptCore/parser/Grammar.y
r38649 r38747 261 261 %type <statementNode> ThrowStatement TryStatement 262 262 %type <statementNode> DebuggerStatement 263 %type <statementNode> SourceElement264 263 265 264 %type <expressionNode> Initializer InitializerNoIn 266 %type < funcDeclNode>FunctionDeclaration265 %type <statementNode> FunctionDeclaration 267 266 %type <funcExprNode> FunctionExpr 268 267 %type <functionBodyNode> FunctionBody … … 797 796 | VariableStatement 798 797 | ConstStatement 798 | FunctionDeclaration 799 799 | EmptyStatement 800 800 | ExprStatement … … 1169 1169 1170 1170 FunctionDeclaration: 1171 FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNode Info(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); }1171 FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeDeclarationInfo<StatementNode*>(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); $$.m_funcDeclarations->data.append(static_cast<FuncDeclNode*>($$.m_node)); } 1172 1172 | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE 1173 1173 { 1174 $$ = createNode Info(new FuncDeclNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features | ClosureFeature, 0);1174 $$ = createNodeDeclarationInfo<StatementNode*>(new FuncDeclNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features | ClosureFeature, 0); 1175 1175 if ($4.m_features & ArgumentsFeature) 1176 1176 $7->setUsesArguments(); 1177 DBG($7, @6, @8); 1177 DBG($7, @6, @8); 1178 $$.m_funcDeclarations->data.append(static_cast<FuncDeclNode*>($$.m_node)); 1178 1179 } 1179 1180 ; … … 1219 1220 1220 1221 SourceElements: 1221 S ourceElement{ $$.m_node = new SourceElements(GLOBAL_DATA);1222 Statement { $$.m_node = new SourceElements(GLOBAL_DATA); 1222 1223 $$.m_node->append($1.m_node); 1223 1224 $$.m_varDeclarations = $1.m_varDeclarations; … … 1226 1227 $$.m_numConstants = $1.m_numConstants; 1227 1228 } 1228 | SourceElements S ourceElement{ $$.m_node->append($2.m_node);1229 | SourceElements Statement { $$.m_node->append($2.m_node); 1229 1230 $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations); 1230 1231 $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations); … … 1232 1233 $$.m_numConstants = $1.m_numConstants + $2.m_numConstants; 1233 1234 } 1234 ;1235 1236 SourceElement:1237 FunctionDeclaration { $$ = createNodeDeclarationInfo<StatementNode*>($1.m_node, 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), $1.m_features, 0); $$.m_funcDeclarations->data.append($1.m_node); }1238 | Statement { $$ = $1; }1239 1235 ; 1240 1236 … … 1627 1623 | VariableStatement_NoNode 1628 1624 | ConstStatement_NoNode 1625 | FunctionDeclaration_NoNode 1629 1626 | EmptyStatement_NoNode 1630 1627 | ExprStatement_NoNode … … 1821 1818 1822 1819 SourceElements_NoNode: 1823 SourceElement_NoNode 1824 | SourceElements_NoNode SourceElement_NoNode 1825 ; 1826 1827 SourceElement_NoNode: 1828 FunctionDeclaration_NoNode 1829 | Statement_NoNode 1820 Statement_NoNode 1821 | SourceElements_NoNode Statement_NoNode 1830 1822 ; 1831 1823 -
trunk/JavaScriptCore/parser/Nodes.cpp
r38635 r38747 2633 2633 RegisterID* FuncDeclNode::emitBytecode(BytecodeGenerator&, RegisterID* dst) 2634 2634 { 2635 if (dst == ignoredResult()) 2636 dst = 0; 2635 2637 return dst; 2636 2638 } -
trunk/LayoutTests/ChangeLog
r38736 r38747 1 2008-11-24 Cameron Zwarich <zwarich@apple.com> 2 3 Reviewed by Geoff Garen. 4 5 Add tests for bug 13790: Function declarations are not treated as statements (used to affect starcraft2.com) 6 <https://bugs.webkit.org/show_bug.cgi?id=13790> 7 8 * fast/js/function-declaration-statement-expected.txt: Added. 9 * fast/js/function-declaration-statement.html: Added. 10 * fast/js/resources/function-declaration-statement.js: Added. 11 1 12 2008-11-24 Nikolas Zimmermann <nikolas.zimmermann@torchmobile.com> 2 13
Note: See TracChangeset
for help on using the changeset viewer.