Changeset 27799 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp
- Timestamp:
- Nov 14, 2007, 2:59:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.cpp
r27749 r27799 3597 3597 static inline void statementListPushFIFO(SourceElements& statements, DeclarationStacks::NodeStack& stack) 3598 3598 { 3599 for (SourceElements::iterator ptr = statements.end() - 1; ptr >= statements.begin(); --ptr) 3600 stack.append((*ptr).get()); 3599 SourceElements::iterator it = statements.end(); 3600 SourceElements::iterator begin = statements.begin(); 3601 while (it != begin) { 3602 --it; 3603 stack.append((*it).get()); 3604 } 3601 3605 } 3602 3606 3603 3607 static inline void statementListGetDeclarations(SourceElements& statements, DeclarationStacks& stacks) 3604 3608 { 3605 for (SourceElements::iterator ptr = statements.end() - 1; ptr >= statements.begin(); --ptr) 3606 if ((*ptr)->mayHaveDeclarations()) 3607 stacks.nodeStack.append((*ptr).get()); 3608 } 3609 3610 static inline Node* statementListInitializeDeclarationStacks(SourceElements& statements, DeclarationStacks::NodeStack& stack) 3611 { 3612 for (SourceElements::iterator ptr = statements.end() - 1; ptr >= statements.begin(); --ptr) 3613 if ((*ptr)->mayHaveDeclarations()) 3614 stack.append((*ptr).get()); 3609 SourceElements::iterator it = statements.end(); 3610 SourceElements::iterator begin = statements.begin(); 3611 while (it != begin) { 3612 --it; 3613 if ((*it)->mayHaveDeclarations()) 3614 stacks.nodeStack.append((*it).get()); 3615 } 3616 } 3617 3618 static inline Node* statementListInitializeDeclarationStack(SourceElements& statements, DeclarationStacks::NodeStack& stack) 3619 { 3620 ASSERT(!stack.size()); // Otherwise, the removeLast() call might remove someone else's node. 3621 3622 SourceElements::iterator it = statements.end(); 3623 SourceElements::iterator begin = statements.begin(); 3624 3625 while (it != begin) { 3626 --it; 3627 if ((*it)->mayHaveDeclarations()) 3628 stack.append((*it).get()); 3629 } 3630 3615 3631 if (!stack.size()) 3616 3632 return 0; 3633 3617 3634 Node* n = stack.last(); 3618 3635 stack.removeLast(); … … 3622 3639 static inline Node* statementListInitializeVariableAccessStack(SourceElements& statements, DeclarationStacks::NodeStack& stack) 3623 3640 { 3624 for (SourceElements::iterator ptr = statements.end() - 1; ptr != statements.begin(); --ptr) 3625 stack.append((*ptr).get()); 3626 return statements[0].get(); 3641 if (!statements.size()) 3642 return 0; 3643 3644 SourceElements::iterator it = statements.end(); 3645 SourceElements::iterator begin = statements.begin(); 3646 SourceElements::iterator beginPlusOne = begin + 1; 3647 3648 while (it != beginPlusOne) { 3649 --it; 3650 stack.append((*it).get()); 3651 } 3652 3653 return (*begin).get(); 3627 3654 } 3628 3655 … … 3647 3674 // ------------------------------ BlockNode ------------------------------------ 3648 3675 3649 void BlockNode::optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack& nodeStack)3650 {3651 if (m_children)3652 statementListPushFIFO(*m_children, nodeStack);3653 }3654 3655 3676 BlockNode::BlockNode(SourceElements* children) 3656 3677 { 3657 if (children) {3678 ASSERT(children); 3658 3679 m_mayHaveDeclarations = true; 3659 3680 m_children.set(children); 3660 setLoc(children->at(0)->firstLine(), children->at(children->size() - 1)->lastLine()); 3661 } 3681 } 3682 3683 void BlockNode::optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack& nodeStack) 3684 { 3685 statementListPushFIFO(*m_children, nodeStack); 3662 3686 } 3663 3687 3664 3688 void BlockNode::getDeclarations(DeclarationStacks& stacks) 3665 3689 { 3666 ASSERT(m_children);3667 3690 statementListGetDeclarations(*m_children, stacks); 3668 3691 } … … 3671 3694 Completion BlockNode::execute(ExecState *exec) 3672 3695 { 3673 if (!m_children) 3674 return Completion(Normal); 3675 3676 return statementListExecute(*m_children, exec); 3696 return statementListExecute(*m_children, exec); 3677 3697 } 3678 3698 … … 4404 4424 void FunctionBodyNode::initializeDeclarationStacks(ExecState* exec) 4405 4425 { 4406 if (!m_children)4407 return;4408 4409 4426 DeclarationStacks::NodeStack nodeStack; 4410 4427 DeclarationStacks stacks(exec, nodeStack, m_varStack, m_functionStack); 4411 Node* node = statementListInitializeDeclarationStack s(*m_children, nodeStack);4428 Node* node = statementListInitializeDeclarationStack(*m_children, nodeStack); 4412 4429 if (!node) 4413 4430 return; … … 4448 4465 void FunctionBodyNode::optimizeVariableAccess() 4449 4466 { 4450 if (!m_children)4451 return;4452 4453 4467 DeclarationStacks::NodeStack nodeStack; 4454 4468 Node* node = statementListInitializeVariableAccessStack(*m_children, nodeStack);
Note:
See TracChangeset
for help on using the changeset viewer.