Changeset 28855 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp
- Timestamp:
- Dec 18, 2007, 11:42:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.cpp
r28854 r28855 210 210 211 211 Node::Node() 212 : m_mayHaveDeclarations(false) 213 , m_expectedReturnType(ObjectType) 212 : m_expectedReturnType(ObjectType) 214 213 { 215 214 m_line = lexer().lineNo(); … … 217 216 218 217 Node::Node(JSType expectedReturn) 219 : m_mayHaveDeclarations(false) 220 , m_expectedReturnType(expectedReturn) 218 : m_expectedReturnType(expectedReturn) 221 219 { 222 220 m_line = lexer().lineNo(); … … 3451 3449 , init(in) 3452 3450 { 3453 m_mayHaveDeclarations = true;3454 3451 } 3455 3452 … … 3460 3457 if (init) 3461 3458 nodeStack.append(init.get()); 3462 }3463 3464 void VarDeclNode::getDeclarations(DeclarationStacks& stacks)3465 {3466 if (next) {3467 ASSERT(next->mayHaveDeclarations());3468 stacks.nodeStack.append(next.get());3469 }3470 3471 // The normal check to avoid overwriting pre-existing values with variable3472 // declarations doesn't work for the "arguments" property because we3473 // instantiate it lazily. So we need to check here instead.3474 if (ident == stacks.exec->propertyNames().arguments)3475 return;3476 3477 stacks.varStack.append(this);3478 3459 } 3479 3460 … … 3576 3557 } 3577 3558 3578 void VarStatementNode::getDeclarations(DeclarationStacks& stacks)3579 {3580 ASSERT(next->mayHaveDeclarations());3581 stacks.nodeStack.append(next.get());3582 }3583 3584 3559 // ------------------------------ Helper functions for handling Vectors of StatementNode ------------------------------- 3585 3560 … … 3592 3567 stack.append((*it).get()); 3593 3568 } 3594 }3595 3596 static inline void statementListGetDeclarations(SourceElements& statements, DeclarationStacks& stacks)3597 {3598 SourceElements::iterator it = statements.end();3599 SourceElements::iterator begin = statements.begin();3600 while (it != begin) {3601 --it;3602 if ((*it)->mayHaveDeclarations())3603 stacks.nodeStack.append((*it).get());3604 }3605 }3606 3607 static inline Node* statementListInitializeDeclarationStack(SourceElements& statements, DeclarationStacks::NodeStack& stack)3608 {3609 ASSERT(!stack.size()); // Otherwise, the removeLast() call might remove someone else's node.3610 3611 SourceElements::iterator it = statements.end();3612 SourceElements::iterator begin = statements.begin();3613 3614 while (it != begin) {3615 --it;3616 if ((*it)->mayHaveDeclarations())3617 stack.append((*it).get());3618 }3619 3620 if (!stack.size())3621 return 0;3622 3623 Node* n = stack.last();3624 stack.removeLast();3625 return n;3626 3569 } 3627 3570 … … 3667 3610 { 3668 3611 ASSERT(m_children); 3669 m_mayHaveDeclarations = true;3670 3612 } 3671 3613 … … 3673 3615 { 3674 3616 statementListPushFIFO(*m_children, nodeStack); 3675 }3676 3677 void BlockNode::getDeclarations(DeclarationStacks& stacks)3678 {3679 statementListGetDeclarations(*m_children, stacks);3680 3617 } 3681 3618 … … 3745 3682 } 3746 3683 3747 void IfNode::getDeclarations(DeclarationStacks& stacks)3748 {3749 if (statement2 && statement2->mayHaveDeclarations())3750 stacks.nodeStack.append(statement2.get());3751 if (statement1->mayHaveDeclarations())3752 stacks.nodeStack.append(statement1.get());3753 }3754 3755 3684 // ------------------------------ DoWhileNode ---------------------------------- 3756 3685 … … 3793 3722 3794 3723 return Completion(); // work around gcc 4.0 bug 3795 }3796 3797 void DoWhileNode::getDeclarations(DeclarationStacks& stacks)3798 {3799 if (statement->mayHaveDeclarations())3800 stacks.nodeStack.append(statement.get());3801 3724 } 3802 3725 … … 3841 3764 3842 3765 return Completion(); // work around gcc 4.0 bug 3843 }3844 3845 void WhileNode::getDeclarations(DeclarationStacks& stacks)3846 {3847 if (statement->mayHaveDeclarations())3848 stacks.nodeStack.append(statement.get());3849 3766 } 3850 3767 … … 3904 3821 } 3905 3822 3906 void ForNode::getDeclarations(DeclarationStacks& stacks)3907 {3908 if (statement->mayHaveDeclarations())3909 stacks.nodeStack.append(statement.get());3910 if (expr1 && expr1->mayHaveDeclarations())3911 stacks.nodeStack.append(expr1.get());3912 }3913 3914 3823 // ------------------------------ ForInNode ------------------------------------ 3915 3824 … … 3917 3826 : init(0L), lexpr(l), expr(e), varDecl(0L), statement(s) 3918 3827 { 3919 m_mayHaveDeclarations = true;3920 3828 } 3921 3829 … … 3923 3831 : ident(i), init(in), expr(e), statement(s) 3924 3832 { 3925 m_mayHaveDeclarations = true;3926 3927 3833 // for( var foo = bar in baz ) 3928 3834 varDecl = new VarDeclNode(ident, init.get(), VarDeclNode::Variable); … … 3937 3843 if (varDecl) 3938 3844 nodeStack.append(varDecl.get()); 3939 }3940 3941 void ForInNode::getDeclarations(DeclarationStacks& stacks)3942 {3943 if (statement->mayHaveDeclarations())3944 stacks.nodeStack.append(statement.get());3945 if (varDecl && varDecl->mayHaveDeclarations())3946 stacks.nodeStack.append(varDecl.get());3947 3845 } 3948 3846 … … 4103 4001 // ------------------------------ WithNode ------------------------------------- 4104 4002 4105 void WithNode::getDeclarations(DeclarationStacks& stacks)4106 {4107 if (statement->mayHaveDeclarations())4108 stacks.nodeStack.append(statement.get());4109 }4110 4111 4003 void WithNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack) 4112 4004 { … … 4141 4033 } 4142 4034 4143 void CaseClauseNode::getDeclarations(DeclarationStacks& stacks)4144 {4145 if (m_children)4146 statementListGetDeclarations(*m_children, stacks);4147 }4148 4149 4035 // ECMA 12.11 4150 4036 JSValue *CaseClauseNode::evaluate(ExecState *exec) … … 4174 4060 } 4175 4061 4176 void ClauseListNode::getDeclarations(DeclarationStacks& stacks)4177 {4178 if (next && next->mayHaveDeclarations())4179 stacks.nodeStack.append(next.get());4180 if (clause->mayHaveDeclarations())4181 stacks.nodeStack.append(clause.get());4182 }4183 4184 4062 // ------------------------------ CaseBlockNode -------------------------------- 4185 4063 … … 4189 4067 , list2(l2) 4190 4068 { 4191 m_mayHaveDeclarations = true;4192 4069 } 4193 4070 … … 4200 4077 if (list1) 4201 4078 nodeStack.append(list1.get()); 4202 }4203 4204 void CaseBlockNode::getDeclarations(DeclarationStacks& stacks)4205 {4206 if (list2 && list2->mayHaveDeclarations())4207 stacks.nodeStack.append(list2.get());4208 if (def && def->mayHaveDeclarations())4209 stacks.nodeStack.append(def.get());4210 if (list1 && list1->mayHaveDeclarations())4211 stacks.nodeStack.append(list1.get());4212 4079 } 4213 4080 … … 4283 4150 } 4284 4151 4285 void SwitchNode::getDeclarations(DeclarationStacks& stacks)4286 {4287 if (block->mayHaveDeclarations())4288 stacks.nodeStack.append(block.get());4289 }4290 4291 4152 // ECMA 12.11 4292 4153 Completion SwitchNode::execute(ExecState *exec) … … 4311 4172 { 4312 4173 nodeStack.append(statement.get()); 4313 }4314 4315 void LabelNode::getDeclarations(DeclarationStacks& stacks)4316 {4317 if (statement->mayHaveDeclarations())4318 stacks.nodeStack.append(statement.get());4319 4174 } 4320 4175 … … 4359 4214 nodeStack.append(finallyBlock.get()); 4360 4215 nodeStack.append(tryBlock.get()); 4361 }4362 4363 void TryNode::getDeclarations(DeclarationStacks& stacks)4364 {4365 if (finallyBlock && finallyBlock->mayHaveDeclarations())4366 stacks.nodeStack.append(finallyBlock.get());4367 if (catchBlock && catchBlock->mayHaveDeclarations())4368 stacks.nodeStack.append(catchBlock.get());4369 if (tryBlock->mayHaveDeclarations())4370 stacks.nodeStack.append(tryBlock.get());4371 4216 } 4372 4217 … … 4612 4457 } 4613 4458 4614 void FuncDeclNode::getDeclarations(DeclarationStacks& stacks)4615 {4616 stacks.functionStack.append(this);4617 }4618 4619 4459 FunctionImp* FuncDeclNode::makeFunction(ExecState* exec) 4620 4460 {
Note:
See TracChangeset
for help on using the changeset viewer.