Changeset 28899 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp
- Timestamp:
- Dec 20, 2007, 12:33:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.cpp
r28887 r28899 47 47 #define KJS_BREAKPOINT \ 48 48 if (Debugger::debuggersPresent > 0 && !hitStatement(exec)) \ 49 return 0;49 return Completion(Normal); 50 50 51 51 #define KJS_CHECKEXCEPTION \ … … 272 272 } 273 273 274 JSValue* Node::setErrorCompletion(ExecState* exec, ErrorType e, const char*msg)275 { 276 return exec->setThrowCompletion(Error::create(exec, e, msg, lineNo(), currentSourceId(exec), currentSourceURL(exec)));277 } 278 279 JSValue* Node::setErrorCompletion(ExecState* exec, ErrorType e, const char* msg, const Identifier&ident)274 Completion Node::createErrorCompletion(ExecState* exec, ErrorType e, const char *msg) 275 { 276 return Completion(Throw, Error::create(exec, e, msg, lineNo(), currentSourceId(exec), currentSourceURL(exec))); 277 } 278 279 Completion Node::createErrorCompletion(ExecState *exec, ErrorType e, const char *msg, const Identifier &ident) 280 280 { 281 281 UString message = msg; 282 282 substitute(message, ident.ustring()); 283 return exec->setThrowCompletion(Error::create(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec)));283 return Completion(Throw, Error::create(exec, e, message, lineNo(), currentSourceId(exec), currentSourceURL(exec))); 284 284 } 285 285 … … 365 365 } 366 366 367 JSValue*Node::rethrowException(ExecState* exec)367 Completion Node::rethrowException(ExecState* exec) 368 368 { 369 369 JSValue* exception = exec->exception(); 370 370 exec->clearException(); 371 371 handleException(exec, exception); 372 return exec->setThrowCompletion(exception);372 return Completion(Throw, exception); 373 373 } 374 374 … … 387 387 } 388 388 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"? 389 // return true if the debugger wants us to stop at this point 391 390 bool StatementNode::hitStatement(ExecState* exec) 392 391 { 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;392 Debugger *dbg = exec->dynamicGlobalObject()->debugger(); 393 if (dbg) 394 return dbg->atStatement(exec, currentSourceId(exec), firstLine(), lastLine()); 395 else 396 return true; // continue 398 397 } 399 398 … … 3550 3549 3551 3550 // ECMA 12.2 3552 JSValue* VarStatementNode::execute(ExecState*exec)3553 { 3554 KJS_BREAKPOINT 3551 Completion VarStatementNode::execute(ExecState *exec) 3552 { 3553 KJS_BREAKPOINT; 3555 3554 3556 3555 next->evaluate(exec); 3557 3556 KJS_CHECKEXCEPTION 3558 3557 3559 return exec->setNormalCompletion();3558 return Completion(Normal); 3560 3559 } 3561 3560 … … 3589 3588 } 3590 3589 3591 static inline JSValue* statementListExecute(SourceElements& statements, ExecState* exec) 3592 { 3593 JSValue* value = 0; 3594 size_t size = statements.size(); 3595 for (size_t i = 0; i != size; ++i) { 3596 JSValue* statementValue = statements[i]->execute(exec); 3597 if (exec->completionType() != Normal) 3598 return statementValue; 3599 if (statementValue) 3600 value = statementValue; 3601 } 3602 return exec->setNormalCompletion(value); 3603 } 3604 3590 static inline Completion statementListExecute(SourceElements& statements, ExecState* exec) 3591 { 3592 JSValue* v = 0; 3593 Completion c(Normal); 3594 const SourceElements::iterator end = statements.end(); 3595 for (SourceElements::iterator ptr = statements.begin(); ptr != end; ++ptr) { 3596 c = (*ptr)->execute(exec); 3597 3598 if (JSValue* v2 = c.value()) 3599 v = v2; 3600 c.setValue(v); 3601 3602 if (c.complType() != Normal) 3603 return c; 3604 } 3605 return c; 3606 } 3607 3605 3608 // ------------------------------ BlockNode ------------------------------------ 3606 3609 … … 3617 3620 3618 3621 // ECMA 12.1 3619 JSValue* BlockNode::execute(ExecState*exec)3622 Completion BlockNode::execute(ExecState *exec) 3620 3623 { 3621 3624 return statementListExecute(*m_children, exec); … … 3625 3628 3626 3629 // ECMA 12.3 3627 JSValue* EmptyStatementNode::execute(ExecState* exec)3628 { 3629 return exec->setNormalCompletion();3630 Completion EmptyStatementNode::execute(ExecState *) 3631 { 3632 return Completion(Normal); 3630 3633 } 3631 3634 … … 3639 3642 3640 3643 // ECMA 12.4 3641 JSValue* ExprStatementNode::execute(ExecState*exec)3642 { 3643 KJS_BREAKPOINT3644 3645 JSValue* value= expr->evaluate(exec);3646 3647 3648 return exec->setNormalCompletion(value);3644 Completion ExprStatementNode::execute(ExecState *exec) 3645 { 3646 KJS_BREAKPOINT; 3647 3648 JSValue *v = expr->evaluate(exec); 3649 KJS_CHECKEXCEPTION 3650 3651 return Completion(Normal, v); 3649 3652 } 3650 3653 … … 3662 3665 3663 3666 // ECMA 12.5 3664 JSValue*IfNode::execute(ExecState* exec)3665 { 3666 KJS_BREAKPOINT 3667 Completion IfNode::execute(ExecState* exec) 3668 { 3669 KJS_BREAKPOINT; 3667 3670 3668 3671 bool b = expr->evaluateToBoolean(exec); … … 3675 3678 // no else 3676 3679 if (!statement2) 3677 return exec->setNormalCompletion();3680 return Completion(Normal); 3678 3681 3679 3682 // else … … 3690 3693 3691 3694 // ECMA 12.6.1 3692 JSValue* DoWhileNode::execute(ExecState*exec)3693 { 3694 KJS_BREAKPOINT 3695 Completion DoWhileNode::execute(ExecState *exec) 3696 { 3697 KJS_BREAKPOINT; 3695 3698 3696 3699 JSValue* value = 0; … … 3698 3701 while (1) { 3699 3702 exec->pushIteration(); 3700 JSValue* statementValue= statement->execute(exec);3703 Completion c = statement->execute(exec); 3701 3704 exec->popIteration(); 3702 3705 3703 3706 if (exec->dynamicGlobalObject()->timedOut()) 3704 exec->setInterruptedCompletion(); 3705 3706 if (statementValue) 3707 value = statementValue; 3708 3709 if (exec->completionType() != Normal) { 3710 if (exec->completionType() == Continue && ls.contains(exec->breakOrContinueTarget())) 3711 goto continueDoWhileLoop; 3712 if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget())) 3713 break; 3714 return statementValue; 3707 return Completion(Interrupted); 3708 3709 if (c.isValueCompletion()) 3710 value = c.value(); 3711 3712 if (!((c.complType() == Continue) && ls.contains(c.target()))) { 3713 if ((c.complType() == Break) && ls.contains(c.target())) 3714 return Completion(Normal, value); 3715 if (c.complType() != Normal) 3716 return c; 3715 3717 } 3716 3718 3717 continueDoWhileLoop:3718 3719 bool b = expr->evaluateToBoolean(exec); 3719 3720 KJS_CHECKEXCEPTION 3720 3721 if (!b) 3721 break;3722 } 3723 3724 return exec->setNormalCompletion(value);3722 return Completion(Normal, value); 3723 } 3724 3725 return Completion(); // work around gcc 4.0 bug 3725 3726 } 3726 3727 … … 3734 3735 3735 3736 // ECMA 12.6.2 3736 JSValue* WhileNode::execute(ExecState*exec)3737 { 3738 KJS_BREAKPOINT 3737 Completion WhileNode::execute(ExecState *exec) 3738 { 3739 KJS_BREAKPOINT; 3739 3740 3740 3741 JSValue* value = 0; … … 3744 3745 KJS_CHECKEXCEPTION 3745 3746 if (!b) 3746 break;3747 return Completion(Normal, value); 3747 3748 3748 3749 exec->pushIteration(); 3749 JSValue* statementValue= statement->execute(exec);3750 Completion c = statement->execute(exec); 3750 3751 exec->popIteration(); 3751 3752 3752 3753 if (exec->dynamicGlobalObject()->timedOut()) 3753 return exec->setInterruptedCompletion(); 3754 3755 if (statementValue) 3756 value = statementValue; 3757 3758 if (exec->completionType() != Normal) { 3759 if (exec->completionType() == Continue && ls.contains(exec->breakOrContinueTarget())) 3760 continue; 3761 if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget())) 3762 break; 3763 return statementValue; 3764 } 3765 } 3766 3767 return exec->setNormalCompletion(value); 3754 return Completion(Interrupted); 3755 3756 if (c.isValueCompletion()) 3757 value = c.value(); 3758 3759 if ((c.complType() == Continue) && ls.contains(c.target())) 3760 continue; 3761 if ((c.complType() == Break) && ls.contains(c.target())) 3762 return Completion(Normal, value); 3763 if (c.complType() != Normal) 3764 return c; 3765 } 3766 3767 return Completion(); // work around gcc 4.0 bug 3768 3768 } 3769 3769 … … 3782 3782 3783 3783 // ECMA 12.6.3 3784 JSValue*ForNode::execute(ExecState *exec)3785 { 3786 JSValue* value= 0;3784 Completion ForNode::execute(ExecState *exec) 3785 { 3786 JSValue* cval = 0; 3787 3787 3788 3788 if (expr1) { … … 3796 3796 KJS_CHECKEXCEPTION 3797 3797 if (!b) 3798 break;3798 return Completion(Normal, cval); 3799 3799 } 3800 3800 3801 3801 exec->pushIteration(); 3802 JSValue* statementValue= statement->execute(exec);3802 Completion c = statement->execute(exec); 3803 3803 exec->popIteration(); 3804 if (statementValue) 3805 value = statementValue; 3804 if (c.isValueCompletion()) 3805 cval = c.value(); 3806 if (!((c.complType() == Continue) && ls.contains(c.target()))) { 3807 if ((c.complType() == Break) && ls.contains(c.target())) 3808 return Completion(Normal, cval); 3809 if (c.complType() != Normal) 3810 return c; 3811 } 3806 3812 3807 3813 if (exec->dynamicGlobalObject()->timedOut()) 3808 return exec->setInterruptedCompletion(); 3809 3810 if (exec->completionType() != Normal) { 3811 if (exec->completionType() == Continue && ls.contains(exec->breakOrContinueTarget())) 3812 goto continueForLoop; 3813 if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget())) 3814 break; 3815 return statementValue; 3816 } 3817 3818 continueForLoop: 3814 return Completion(Interrupted); 3815 3819 3816 if (expr3) { 3820 3817 expr3->evaluate(exec); … … 3823 3820 } 3824 3821 3825 return exec->setNormalCompletion(value);3822 return Completion(); // work around gcc 4.0 bug 3826 3823 } 3827 3824 … … 3851 3848 3852 3849 // ECMA 12.6.4 3853 JSValue* ForInNode::execute(ExecState* exec) 3854 { 3855 JSValue* value = 0; 3850 Completion ForInNode::execute(ExecState *exec) 3851 { 3852 JSValue *e; 3853 JSValue *retval = 0; 3854 JSObject *v; 3855 Completion c; 3856 PropertyNameArray propertyNames; 3856 3857 3857 3858 if (varDecl) { … … 3860 3861 } 3861 3862 3862 JSValue* e = expr->evaluate(exec); 3863 3864 // For Null and Undefined, we want to make sure not to go through 3865 // the loop at all, because toObject will throw an exception. 3863 e = expr->evaluate(exec); 3864 3865 // for Null and Undefined, we want to make sure not to go through 3866 // the loop at all, because their object wrappers will have a 3867 // property list but will throw an exception if you attempt to 3868 // access any property. 3866 3869 if (e->isUndefinedOrNull()) 3867 return exec->setNormalCompletion();3870 return Completion(Normal); 3868 3871 3869 3872 KJS_CHECKEXCEPTION 3870 JSObject* v = e->toObject(exec); 3871 PropertyNameArray propertyNames; 3873 v = e->toObject(exec); 3872 3874 v->getPropertyNames(exec, propertyNames); 3873 3875 3874 3876 PropertyNameArray::const_iterator end = propertyNames.end(); 3875 3877 for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != end; ++it) { 3876 const Identifier &name = *it;3878 const Identifier &name = *it; 3877 3879 if (!v->hasProperty(exec, name)) 3878 3880 continue; … … 3927 3929 3928 3930 exec->pushIteration(); 3929 JSValue* statementValue= statement->execute(exec);3931 c = statement->execute(exec); 3930 3932 exec->popIteration(); 3931 if ( statementValue)3932 value = statementValue;3933 3934 if ( exec->completionType() != Normal) {3935 if (exec->completionType() == Continue && ls.contains(exec->breakOrContinueTarget()))3936 continue;3937 if (exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget()))3938 break;3939 return statementValue;3933 if (c.isValueCompletion()) 3934 retval = c.value(); 3935 3936 if (!((c.complType() == Continue) && ls.contains(c.target()))) { 3937 if ((c.complType() == Break) && ls.contains(c.target())) 3938 break; 3939 if (c.complType() != Normal) { 3940 return c; 3941 } 3940 3942 } 3941 3943 } 3942 3944 3943 return exec->setNormalCompletion(value);3945 return Completion(Normal, retval); 3944 3946 } 3945 3947 … … 3947 3949 3948 3950 // ECMA 12.7 3949 JSValue* ContinueNode::execute(ExecState*exec)3950 { 3951 KJS_BREAKPOINT 3951 Completion ContinueNode::execute(ExecState *exec) 3952 { 3953 KJS_BREAKPOINT; 3952 3954 3953 3955 if (ident.isEmpty() && !exec->inIteration()) 3954 return setErrorCompletion(exec, SyntaxError, "Invalid continue statement.");3956 return createErrorCompletion(exec, SyntaxError, "Invalid continue statement."); 3955 3957 if (!ident.isEmpty() && !exec->seenLabels()->contains(ident)) 3956 return setErrorCompletion(exec, SyntaxError, "Label %s not found.", ident);3957 return exec->setContinueCompletion(&ident);3958 return createErrorCompletion(exec, SyntaxError, "Label %s not found.", ident); 3959 return Completion(Continue, &ident); 3958 3960 } 3959 3961 … … 3961 3963 3962 3964 // ECMA 12.8 3963 JSValue* BreakNode::execute(ExecState *exec) 3964 { 3965 KJS_BREAKPOINT 3966 3967 if (ident.isEmpty() && !exec->inIteration() && !exec->inSwitch()) 3968 return setErrorCompletion(exec, SyntaxError, "Invalid break statement."); 3965 Completion BreakNode::execute(ExecState *exec) 3966 { 3967 KJS_BREAKPOINT; 3968 3969 if (ident.isEmpty() && !exec->inIteration() && 3970 !exec->inSwitch()) 3971 return createErrorCompletion(exec, SyntaxError, "Invalid break statement."); 3969 3972 if (!ident.isEmpty() && !exec->seenLabels()->contains(ident)) 3970 return setErrorCompletion(exec, SyntaxError, "Label %s not found.");3971 return exec->setBreakCompletion(&ident);3973 return createErrorCompletion(exec, SyntaxError, "Label %s not found."); 3974 return Completion(Break, &ident); 3972 3975 } 3973 3976 … … 3981 3984 3982 3985 // ECMA 12.9 3983 JSValue* ReturnNode::execute(ExecState*exec)3984 { 3985 KJS_BREAKPOINT 3986 Completion ReturnNode::execute(ExecState *exec) 3987 { 3988 KJS_BREAKPOINT; 3986 3989 3987 3990 CodeType codeType = exec->codeType(); 3988 3991 if (codeType != FunctionCode) 3989 return setErrorCompletion(exec, SyntaxError, "Invalid return statement.");3992 return createErrorCompletion(exec, SyntaxError, "Invalid return statement."); 3990 3993 3991 3994 if (!value) 3992 return exec->setReturnValueCompletion(jsUndefined());3993 3994 JSValue *v = value->evaluate(exec);3995 return Completion(ReturnValue, jsUndefined()); 3996 3997 JSValue *v = value->evaluate(exec); 3995 3998 KJS_CHECKEXCEPTION 3996 3999 3997 return exec->setReturnValueCompletion(v);4000 return Completion(ReturnValue, v); 3998 4001 } 3999 4002 … … 4007 4010 4008 4011 // ECMA 12.10 4009 JSValue*WithNode::execute(ExecState *exec)4010 { 4011 KJS_BREAKPOINT 4012 Completion WithNode::execute(ExecState *exec) 4013 { 4014 KJS_BREAKPOINT; 4012 4015 4013 4016 JSValue *v = expr->evaluate(exec); … … 4016 4019 KJS_CHECKEXCEPTION 4017 4020 exec->pushScope(o); 4018 JSValue* value= statement->execute(exec);4021 Completion res = statement->execute(exec); 4019 4022 exec->popScope(); 4020 4023 4021 return value;4024 return res; 4022 4025 } 4023 4026 … … 4042 4045 4043 4046 // ECMA 12.11 4044 JSValue* CaseClauseNode::executeStatements(ExecState*exec)4047 Completion CaseClauseNode::evalStatements(ExecState *exec) 4045 4048 { 4046 4049 if (m_children) 4047 4050 return statementListExecute(*m_children, exec); 4048 return exec->setNormalCompletion(); 4051 else 4052 return Completion(Normal, jsUndefined()); 4049 4053 } 4050 4054 … … 4078 4082 4079 4083 // ECMA 12.11 4080 JSValue* CaseBlockNode::executeBlock(ExecState* exec, JSValue* input) 4081 { 4082 ClauseListNode* a = list1.get(); 4084 Completion CaseBlockNode::evalBlock(ExecState *exec, JSValue *input) 4085 { 4086 JSValue *v; 4087 Completion res; 4088 ClauseListNode *a = list1.get(); 4089 ClauseListNode *b = list2.get(); 4090 CaseClauseNode *clause; 4091 4083 4092 while (a) { 4084 CaseClauseNode*clause = a->getClause();4093 clause = a->getClause(); 4085 4094 a = a->getNext(); 4086 JSValue*v = clause->evaluate(exec);4095 v = clause->evaluate(exec); 4087 4096 KJS_CHECKEXCEPTION 4088 4097 if (strictEqual(exec, input, v)) { 4089 JSValue* res = clause->executeStatements(exec);4090 if ( exec->completionType() != Normal)4098 res = clause->evalStatements(exec); 4099 if (res.complType() != Normal) 4091 4100 return res; 4092 for (; a; a = a->getNext()) {4093 JSValue* res = a->getClause()->executeStatements(exec);4094 if ( exec->completionType() != Normal)4101 while (a) { 4102 res = a->getClause()->evalStatements(exec); 4103 if (res.complType() != Normal) 4095 4104 return res; 4105 a = a->getNext(); 4096 4106 } 4097 4107 break; … … 4099 4109 } 4100 4110 4101 ClauseListNode* b = list2.get();4102 4111 while (b) { 4103 CaseClauseNode*clause = b->getClause();4112 clause = b->getClause(); 4104 4113 b = b->getNext(); 4105 JSValue*v = clause->evaluate(exec);4114 v = clause->evaluate(exec); 4106 4115 KJS_CHECKEXCEPTION 4107 4116 if (strictEqual(exec, input, v)) { 4108 JSValue* res = clause->executeStatements(exec);4109 if ( exec->completionType() != Normal)4117 res = clause->evalStatements(exec); 4118 if (res.complType() != Normal) 4110 4119 return res; 4111 4120 goto step18; … … 4115 4124 // default clause 4116 4125 if (def) { 4117 JSValue* res = def->executeStatements(exec);4118 if ( exec->completionType() != Normal)4126 res = def->evalStatements(exec); 4127 if (res.complType() != Normal) 4119 4128 return res; 4120 4129 } … … 4122 4131 step18: 4123 4132 while (b) { 4124 CaseClauseNode*clause = b->getClause();4125 JSValue* res = clause->executeStatements(exec);4126 if ( exec->completionType() != Normal)4133 clause = b->getClause(); 4134 res = clause->evalStatements(exec); 4135 if (res.complType() != Normal) 4127 4136 return res; 4128 4137 b = b->getNext(); … … 4132 4141 KJS_CHECKEXCEPTION 4133 4142 4134 return exec->setNormalCompletion();4143 return Completion(Normal); 4135 4144 } 4136 4145 … … 4144 4153 4145 4154 // ECMA 12.11 4146 JSValue* SwitchNode::execute(ExecState*exec)4147 { 4148 KJS_BREAKPOINT 4155 Completion SwitchNode::execute(ExecState *exec) 4156 { 4157 KJS_BREAKPOINT; 4149 4158 4150 4159 JSValue *v = expr->evaluate(exec); … … 4152 4161 4153 4162 exec->pushSwitch(); 4154 JSValue* result = block->executeBlock(exec,v);4163 Completion res = block->evalBlock(exec,v); 4155 4164 exec->popSwitch(); 4156 4165 4157 if ( exec->completionType() == Break && ls.contains(exec->breakOrContinueTarget()))4158 exec->setCompletionType(Normal);4159 return res ult;4166 if ((res.complType() == Break) && ls.contains(res.target())) 4167 return Completion(Normal, res.value()); 4168 return res; 4160 4169 } 4161 4170 … … 4168 4177 4169 4178 // ECMA 12.12 4170 JSValue*LabelNode::execute(ExecState *exec)4179 Completion LabelNode::execute(ExecState *exec) 4171 4180 { 4172 4181 if (!exec->seenLabels()->push(label)) 4173 return setErrorCompletion(exec, SyntaxError, "Duplicated label %s found.", label);4174 JSValue* result= statement->execute(exec);4182 return createErrorCompletion(exec, SyntaxError, "Duplicated label %s found.", label); 4183 Completion e = statement->execute(exec); 4175 4184 exec->seenLabels()->pop(); 4176 4185 4177 if ( exec->completionType() == Break && exec->breakOrContinueTarget() == label)4178 exec->setCompletionType(Normal);4179 return result;4186 if ((e.complType() == Break) && (e.target() == label)) 4187 return Completion(Normal, e.value()); 4188 return e; 4180 4189 } 4181 4190 … … 4188 4197 4189 4198 // ECMA 12.13 4190 JSValue* ThrowNode::execute(ExecState*exec)4191 { 4192 KJS_BREAKPOINT 4199 Completion ThrowNode::execute(ExecState *exec) 4200 { 4201 KJS_BREAKPOINT; 4193 4202 4194 4203 JSValue *v = expr->evaluate(exec); … … 4196 4205 4197 4206 handleException(exec, v); 4198 return exec->setThrowCompletion(v);4207 return Completion(Throw, v); 4199 4208 } 4200 4209 … … 4210 4219 4211 4220 // ECMA 12.14 4212 JSValue*TryNode::execute(ExecState *exec)4213 { 4214 KJS_BREAKPOINT 4215 4216 JSValue* result= tryBlock->execute(exec);4221 Completion TryNode::execute(ExecState *exec) 4222 { 4223 KJS_BREAKPOINT; 4224 4225 Completion c = tryBlock->execute(exec); 4217 4226 4218 4227 if (Collector::isOutOfMemory()) 4219 return result; // don't try to catch an out of memory exception thrown by the collector4228 return c; // don't try to catch an out of memory exception thrown by the collector 4220 4229 4221 if (catchBlock && exec->completionType() == Throw) {4222 JSObject *obj = new JSObject;4223 obj->put(exec, exceptionIdent, result, DontDelete);4230 if (catchBlock && c.complType() == Throw) { 4231 JSObject *obj = new JSObject; 4232 obj->put(exec, exceptionIdent, c.value(), DontDelete); 4224 4233 exec->pushScope(obj); 4225 result= catchBlock->execute(exec);4234 c = catchBlock->execute(exec); 4226 4235 exec->popScope(); 4227 4236 } 4228 4237 4229 4238 if (finallyBlock) { 4230 ComplType savedCompletionType = exec->completionType(); 4231 JSValue* finallyResult = finallyBlock->execute(exec); 4232 if (exec->completionType() != Normal) 4233 result = finallyResult; 4234 else 4235 exec->setCompletionType(savedCompletionType); 4239 Completion c2 = finallyBlock->execute(exec); 4240 if (c2.complType() != Normal) 4241 c = c2; 4236 4242 } 4237 4243 4238 return result;4244 return c; 4239 4245 } 4240 4246 … … 4491 4497 } 4492 4498 4493 JSValue*ProgramNode::execute(ExecState* exec)4499 Completion ProgramNode::execute(ExecState* exec) 4494 4500 { 4495 4501 processDeclarations(exec); … … 4497 4503 } 4498 4504 4499 JSValue*EvalNode::execute(ExecState* exec)4505 Completion EvalNode::execute(ExecState* exec) 4500 4506 { 4501 4507 processDeclarations(exec); … … 4503 4509 } 4504 4510 4505 JSValue*FunctionBodyNode::execute(ExecState* exec)4511 Completion FunctionBodyNode::execute(ExecState* exec) 4506 4512 { 4507 4513 processDeclarations(exec); … … 4510 4516 if (!dbg->callEvent(exec, sourceId(), lineNo(), exec->function(), *exec->arguments())) { 4511 4517 dbg->imp()->abort(); 4512 return exec->setInterruptedCompletion();4518 return Completion(Interrupted, jsUndefined()); 4513 4519 } 4514 4520 } 4515 4521 4516 JSValue* result= ScopeNode::execute(exec);4522 Completion completion = ScopeNode::execute(exec); 4517 4523 4518 4524 if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) { 4519 if (exec->completionType() == Throw) 4520 exec->setException(result); 4525 if (completion.complType() == Throw) 4526 exec->setException(completion.value()); 4527 4521 4528 if (!dbg->returnEvent(exec, sourceId(), lineNo(), exec->function())) { 4522 4529 dbg->imp()->abort(); 4523 return exec->setInterruptedCompletion();4530 return Completion(Interrupted, jsUndefined()); 4524 4531 } 4525 4532 } 4526 4533 4527 4534 4528 return result;4535 return completion; 4529 4536 } 4530 4537 … … 4549 4556 } 4550 4557 4551 JSValue* FuncDeclNode::execute(ExecState* exec)4552 { 4553 return exec->setNormalCompletion();4558 Completion FuncDeclNode::execute(ExecState *) 4559 { 4560 return Completion(Normal); 4554 4561 } 4555 4562
Note:
See TracChangeset
for help on using the changeset viewer.