Changeset 28937 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp
- Timestamp:
- Dec 21, 2007, 1:54:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.cpp
r28935 r28937 45 45 namespace KJS { 46 46 47 #define KJS_BREAKPOINT \48 if (Debugger::debuggersPresent > 0 && !hitStatement(exec)) \49 return 0;50 51 47 #define KJS_CHECKEXCEPTION \ 52 48 if (exec->hadException()) \ … … 69 65 handleException(exec); \ 70 66 return false; \ 71 }72 73 #define KJS_CHECKEXCEPTIONLIST \74 if (exec->hadException()) { \75 handleException(exec); \76 return; \77 67 } 78 68 … … 212 202 : m_expectedReturnType(ObjectType) 213 203 { 214 m_line = lexer().lineNo();204 m_line = lexer().lineNo(); 215 205 } 216 206 … … 365 355 } 366 356 367 JSValue* Node::rethrowException(ExecState* exec)357 NEVER_INLINE JSValue* Node::rethrowException(ExecState* exec) 368 358 { 369 359 JSValue* exception = exec->exception(); … … 387 377 } 388 378 389 // Set normal completion and return false if the debugger wants us to stop at this point. 390 // FIXME: This seems like poor naming and strange design. Why false to stop? Why "hit statement"? 391 bool StatementNode::hitStatement(ExecState* exec) 392 { 393 Debugger* debugger = exec->dynamicGlobalObject()->debugger(); 394 if (!debugger || debugger->atStatement(exec, currentSourceId(exec), firstLine(), lastLine())) 395 return true; 396 exec->setCompletionType(Normal); 397 return false; 379 // ------------------------------ SourceElements -------------------------------- 380 381 void SourceElements::append(PassRefPtr<StatementNode> statement) 382 { 383 if (Debugger::debuggersPresent) 384 m_statements.append(new BreakpointCheckStatement(statement)); 385 else 386 m_statements.append(statement); 387 } 388 389 // ------------------------------ BreakpointCheckStatement -------------------------------- 390 391 BreakpointCheckStatement::BreakpointCheckStatement(PassRefPtr<StatementNode> statement) 392 : m_statement(statement) 393 { 394 ASSERT(m_statement); 395 } 396 397 JSValue* BreakpointCheckStatement::execute(ExecState* exec) 398 { 399 if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) 400 if (!debugger->atStatement(exec, currentSourceId(exec), m_statement->firstLine(), m_statement->lastLine())) 401 return exec->setNormalCompletion(); 402 return m_statement->execute(exec); 403 } 404 405 void BreakpointCheckStatement::streamTo(SourceStream& stream) const 406 { 407 m_statement->streamTo(stream); 398 408 } 399 409 … … 839 849 for (ArgumentListNode *n = this; n; n = n->next.get()) { 840 850 JSValue *v = n->expr->evaluate(exec); 841 KJS_CHECKEXCEPTION LIST851 KJS_CHECKEXCEPTIONVOID 842 852 list.append(v); 843 853 } … … 3552 3562 JSValue* VarStatementNode::execute(ExecState* exec) 3553 3563 { 3554 KJS_BREAKPOINT3555 3556 3564 next->evaluate(exec); 3557 3565 KJS_CHECKEXCEPTION … … 3562 3570 // ------------------------------ Helper functions for handling Vectors of StatementNode ------------------------------- 3563 3571 3564 static inline void statementListPushFIFO(S ourceElements& statements, DeclarationStacks::NodeStack& stack)3565 { 3566 S ourceElements::iterator it = statements.end();3567 S ourceElements::iterator begin = statements.begin();3572 static inline void statementListPushFIFO(StatementVector& statements, DeclarationStacks::NodeStack& stack) 3573 { 3574 StatementVector::iterator it = statements.end(); 3575 StatementVector::iterator begin = statements.begin(); 3568 3576 while (it != begin) { 3569 3577 --it; … … 3572 3580 } 3573 3581 3574 static inline Node* statementListInitializeVariableAccessStack(S ourceElements& statements, DeclarationStacks::NodeStack& stack)3582 static inline Node* statementListInitializeVariableAccessStack(StatementVector& statements, DeclarationStacks::NodeStack& stack) 3575 3583 { 3576 3584 if (!statements.size()) 3577 3585 return 0; 3578 3586 3579 S ourceElements::iterator it = statements.end();3580 S ourceElements::iterator begin = statements.begin();3581 S ourceElements::iterator beginPlusOne = begin + 1;3587 StatementVector::iterator it = statements.end(); 3588 StatementVector::iterator begin = statements.begin(); 3589 StatementVector::iterator beginPlusOne = begin + 1; 3582 3590 3583 3591 while (it != beginPlusOne) { … … 3589 3597 } 3590 3598 3591 static inline JSValue* statementListExecute(S ourceElements& statements, ExecState* exec)3599 static inline JSValue* statementListExecute(StatementVector& statements, ExecState* exec) 3592 3600 { 3593 3601 JSValue* value = 0; … … 3606 3614 3607 3615 BlockNode::BlockNode(SourceElements* children) 3608 : m_children(children ? children : new SourceElements) 3609 { 3610 ASSERT(m_children);3616 { 3617 if (children) 3618 children->releaseContentsIntoVector(m_children); 3611 3619 } 3612 3620 3613 3621 void BlockNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack) 3614 3622 { 3615 statementListPushFIFO( *m_children, nodeStack);3623 statementListPushFIFO(m_children, nodeStack); 3616 3624 } 3617 3625 … … 3619 3627 JSValue* BlockNode::execute(ExecState* exec) 3620 3628 { 3621 return statementListExecute( *m_children, exec);3629 return statementListExecute(m_children, exec); 3622 3630 } 3623 3631 … … 3641 3649 JSValue* ExprStatementNode::execute(ExecState* exec) 3642 3650 { 3643 KJS_BREAKPOINT3644 3645 3651 JSValue* value = expr->evaluate(exec); 3646 3652 KJS_CHECKEXCEPTION … … 3660 3666 JSValue* IfNode::execute(ExecState* exec) 3661 3667 { 3662 KJS_BREAKPOINT3663 3664 3668 bool b = m_condition->evaluateToBoolean(exec); 3665 3669 KJS_CHECKEXCEPTION … … 3679 3683 JSValue* IfElseNode::execute(ExecState* exec) 3680 3684 { 3681 KJS_BREAKPOINT;3682 3683 3685 bool b = m_condition->evaluateToBoolean(exec); 3684 3686 KJS_CHECKEXCEPTION … … 3701 3703 JSValue* DoWhileNode::execute(ExecState* exec) 3702 3704 { 3703 KJS_BREAKPOINT3704 3705 3705 JSValue* value = 0; 3706 3706 … … 3745 3745 JSValue* WhileNode::execute(ExecState* exec) 3746 3746 { 3747 KJS_BREAKPOINT3748 3749 3747 JSValue* value = 0; 3750 3748 … … 3949 3947 JSValue* ContinueNode::execute(ExecState* exec) 3950 3948 { 3951 KJS_BREAKPOINT3952 3953 3949 if (ident.isEmpty() && !exec->inIteration()) 3954 3950 return setErrorCompletion(exec, SyntaxError, "Invalid continue statement."); … … 3963 3959 JSValue* BreakNode::execute(ExecState *exec) 3964 3960 { 3965 KJS_BREAKPOINT3966 3967 3961 if (ident.isEmpty() && !exec->inIteration() && !exec->inSwitch()) 3968 3962 return setErrorCompletion(exec, SyntaxError, "Invalid break statement."); … … 3983 3977 JSValue* ReturnNode::execute(ExecState* exec) 3984 3978 { 3985 KJS_BREAKPOINT3986 3987 3979 CodeType codeType = exec->codeType(); 3988 3980 if (codeType != FunctionCode) … … 4009 4001 JSValue* WithNode::execute(ExecState *exec) 4010 4002 { 4011 KJS_BREAKPOINT4012 4013 4003 JSValue *v = expr->evaluate(exec); 4014 4004 KJS_CHECKEXCEPTION … … 4028 4018 if (expr) 4029 4019 nodeStack.append(expr.get()); 4030 if (m_children) 4031 statementListPushFIFO(*m_children, nodeStack); 4020 statementListPushFIFO(m_children, nodeStack); 4032 4021 } 4033 4022 … … 4044 4033 JSValue* CaseClauseNode::executeStatements(ExecState* exec) 4045 4034 { 4046 if (m_children) 4047 return statementListExecute(*m_children, exec); 4048 return exec->setNormalCompletion(); 4035 return statementListExecute(m_children, exec); 4049 4036 } 4050 4037 … … 4146 4133 JSValue* SwitchNode::execute(ExecState* exec) 4147 4134 { 4148 KJS_BREAKPOINT4149 4150 4135 JSValue *v = expr->evaluate(exec); 4151 4136 KJS_CHECKEXCEPTION … … 4190 4175 JSValue* ThrowNode::execute(ExecState* exec) 4191 4176 { 4192 KJS_BREAKPOINT4193 4194 4177 JSValue *v = expr->evaluate(exec); 4195 4178 KJS_CHECKEXCEPTION … … 4212 4195 JSValue* TryNode::execute(ExecState *exec) 4213 4196 { 4214 KJS_BREAKPOINT4215 4216 4197 JSValue* result = tryBlock->execute(exec); 4217 4198 … … 4341 4322 { 4342 4323 DeclarationStacks::NodeStack nodeStack; 4343 Node* node = statementListInitializeVariableAccessStack( *m_children, nodeStack);4324 Node* node = statementListInitializeVariableAccessStack(m_children, nodeStack); 4344 4325 if (!node) 4345 4326 return;
Note:
See TracChangeset
for help on using the changeset viewer.