Changeset 28973 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp
- Timestamp:
- Dec 24, 2007, 2:13:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.cpp
r28937 r28973 381 381 void SourceElements::append(PassRefPtr<StatementNode> statement) 382 382 { 383 if (statement->isEmptyStatement()) 384 return; 385 383 386 if (Debugger::debuggersPresent) 384 387 m_statements.append(new BreakpointCheckStatement(statement)); … … 3420 3423 } 3421 3424 3422 // ------------------------------ AssignExprNode ------------------------------- 3423 3424 void AssignExprNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack) 3425 { 3426 nodeStack.append(expr.get()); 3427 } 3428 3429 // ECMA 12.2 3430 JSValue* AssignExprNode::evaluate(ExecState* exec) 3431 { 3432 return expr->evaluate(exec); 3433 } 3434 3435 bool AssignExprNode::evaluateToBoolean(ExecState* exec) 3436 { 3437 return expr->evaluateToBoolean(exec); 3438 } 3439 3440 double AssignExprNode::evaluateToNumber(ExecState* exec) 3441 { 3442 return expr->evaluateToNumber(exec); 3443 } 3444 3445 int32_t AssignExprNode::evaluateToInt32(ExecState* exec) 3446 { 3447 return expr->evaluateToInt32(exec); 3448 } 3449 3450 uint32_t AssignExprNode::evaluateToUInt32(ExecState* exec) 3451 { 3452 return expr->evaluateToInt32(exec); 3453 } 3454 3455 // ------------------------------ VarDeclNode ---------------------------------- 3456 3457 VarDeclNode::VarDeclNode(const Identifier &id, AssignExprNode *in, Type t) 3458 : varType(t) 3459 , ident(id) 3425 // ------------------------------ ConstDeclNode ---------------------------------- 3426 3427 ConstDeclNode::ConstDeclNode(const Identifier& id, ExpressionNode* in) 3428 : ident(id) 3460 3429 , init(in) 3461 3430 { 3462 3431 } 3463 3432 3464 void VarDeclNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack)3433 void ConstDeclNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack) 3465 3434 { 3466 3435 if (next) … … 3470 3439 } 3471 3440 3472 void VarDeclNode::handleSlowCase(ExecState* exec, const ScopeChain& chain, JSValue* val)3441 void ConstDeclNode::handleSlowCase(ExecState* exec, const ScopeChain& chain, JSValue* val) 3473 3442 { 3474 3443 ScopeChainIterator iter = chain.begin(); … … 3491 3460 unsigned flags = 0; 3492 3461 base->getPropertyAttributes(ident, flags); 3493 if (varType == VarDeclNode::Constant) 3494 flags |= ReadOnly; 3462 flags |= ReadOnly; 3495 3463 3496 3464 base->put(exec, ident, val, flags); … … 3498 3466 3499 3467 // ECMA 12.2 3500 inline void VarDeclNode::evaluateSingle(ExecState* exec)3468 inline void ConstDeclNode::evaluateSingle(ExecState* exec) 3501 3469 { 3502 3470 ASSERT(exec->variableObject()->hasOwnProperty(exec, ident) || exec->codeType() == EvalCode); // Guaranteed by processDeclarations. … … 3514 3482 if (exec->codeType() != EvalCode) 3515 3483 flags |= DontDelete; 3516 if (varType == VarDeclNode::Constant) 3517 flags |= ReadOnly; 3484 flags |= ReadOnly; 3518 3485 variableObject->put(exec, ident, val, flags); 3519 3486 } else { … … 3529 3496 unsigned flags = 0; 3530 3497 variableObject->getPropertyAttributes(ident, flags); 3531 if (varType == VarDeclNode::Constant) 3532 flags |= ReadOnly; 3498 flags |= ReadOnly; 3533 3499 3534 3500 variableObject->put(exec, ident, val, flags); … … 3537 3503 } 3538 3504 3539 JSValue* VarDeclNode::evaluate(ExecState* exec)3505 JSValue* ConstDeclNode::evaluate(ExecState* exec) 3540 3506 { 3541 3507 evaluateSingle(exec); 3542 3508 3543 if ( VarDeclNode* n = next.get()) {3509 if (ConstDeclNode* n = next.get()) { 3544 3510 do { 3545 3511 n->evaluateSingle(exec); … … 3551 3517 } 3552 3518 3553 // ------------------------------ VarStatementNode -----------------------------3554 3555 void VarStatementNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack)3519 // ------------------------------ ConstStatementNode ----------------------------- 3520 3521 void ConstStatementNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack) 3556 3522 { 3557 3523 ASSERT(next); … … 3560 3526 3561 3527 // ECMA 12.2 3562 JSValue* VarStatementNode::execute(ExecState* exec)3528 JSValue* ConstStatementNode::execute(ExecState* exec) 3563 3529 { 3564 3530 next->evaluate(exec); … … 3655 3621 } 3656 3622 3623 // ------------------------------ VarStatementNode ---------------------------- 3624 3625 void VarStatementNode::optimizeVariableAccess(SymbolTable&, DeclarationStacks::NodeStack& nodeStack) 3626 { 3627 ASSERT(expr); 3628 nodeStack.append(expr.get()); 3629 } 3630 3631 JSValue* VarStatementNode::execute(ExecState* exec) 3632 { 3633 expr->evaluate(exec); 3634 KJS_CHECKEXCEPTION 3635 3636 return exec->setNormalCompletion(); 3637 } 3638 3657 3639 // ------------------------------ IfNode --------------------------------------- 3658 3640 … … 3827 3809 3828 3810 ForInNode::ForInNode(ExpressionNode* l, ExpressionNode* e, StatementNode* s) 3829 : init(0L), lexpr(l), expr(e), varDecl(0L), statement(s) 3830 { 3831 } 3832 3833 ForInNode::ForInNode(const Identifier& i, AssignExprNode* in, ExpressionNode* e, StatementNode* s) 3834 : ident(i), init(in), expr(e), statement(s) 3835 { 3811 : init(0L), lexpr(l), expr(e), statement(s), identIsVarDecl(false) 3812 { 3813 } 3814 3815 ForInNode::ForInNode(const Identifier& i, ExpressionNode* in, ExpressionNode* e, StatementNode* s) 3816 : ident(i), lexpr(new ResolveNode(i)), expr(e), statement(s), identIsVarDecl(true) 3817 { 3818 if (in) 3819 init = new AssignResolveNode(i, in); 3836 3820 // for( var foo = bar in baz ) 3837 varDecl = new VarDeclNode(ident, init.get(), VarDeclNode::Variable);3838 lexpr = new ResolveNode(ident);3839 3821 } 3840 3822 … … 3844 3826 nodeStack.append(expr.get()); 3845 3827 nodeStack.append(lexpr.get()); 3846 if ( varDecl)3847 nodeStack.append( varDecl.get());3828 if (init) 3829 nodeStack.append(init.get()); 3848 3830 } 3849 3831 … … 3853 3835 JSValue* value = 0; 3854 3836 3855 if ( varDecl) {3856 varDecl->evaluate(exec);3837 if (init) { 3838 init->evaluate(exec); 3857 3839 KJS_CHECKEXCEPTION 3858 3840 } … … 4268 4250 4269 4251 for (size_t i = 0, size = m_varStack.size(); i < size; ++i, ++localStorageIndex) { 4270 Identifier& ident = m_varStack[i] ->ident;4252 Identifier& ident = m_varStack[i].first; 4271 4253 if (ident == exec->propertyNames().arguments) 4272 4254 continue; … … 4302 4284 m_varIndexes.resize(size); 4303 4285 for (size_t i = 0; i < size; ++i) { 4304 const Identifier& ident = m_varStack[i] ->ident;4286 const Identifier& ident = m_varStack[i].first; 4305 4287 if (variableObject->getDirect(ident)) { 4306 4288 m_varIndexes[i] = missingSymbolMarker(); // Signal not to initialize this declaration. … … 4369 4351 4370 4352 for (size_t i = 0, size = m_varStack.size(); i < size; ++i) { 4371 VarDeclNode* node = m_varStack[i];4353 bool isConstant = m_varStack[i].second & DeclarationStacks::IsConstant; 4372 4354 int attributes = minAttributes; 4373 if ( node->varType == VarDeclNode::Constant)4355 if (isConstant) 4374 4356 attributes |= ReadOnly; 4375 4357 localStorage.uncheckedAppend(LocalStorageEntry(jsUndefined(), attributes)); … … 4421 4403 continue; 4422 4404 4423 VarDeclNode* node = m_varStack[i];4405 bool isConstant = m_varStack[i].second & DeclarationStacks::IsConstant; 4424 4406 int attributes = minAttributes; 4425 if ( node->varType == VarDeclNode::Constant)4407 if (isConstant) 4426 4408 attributes |= ReadOnly; 4427 4409 LocalStorageEntry entry = LocalStorageEntry(jsUndefined(), attributes); … … 4444 4426 4445 4427 for (i = 0, size = m_varStack.size(); i < size; ++i) { 4446 VarDeclNode* node = m_varStack[i]; 4447 if (variableObject->hasOwnProperty(exec, node->ident)) 4428 Identifier& ident = m_varStack[i].first; 4429 bool isConstant = m_varStack[i].second & DeclarationStacks::IsConstant; 4430 if (variableObject->hasOwnProperty(exec, ident)) 4448 4431 continue; 4449 4432 int attributes = minAttributes; 4450 if ( node->varType == VarDeclNode::Constant)4433 if (isConstant) 4451 4434 attributes |= ReadOnly; 4452 variableObject->put(exec, node->ident, jsUndefined(), attributes);4435 variableObject->put(exec, ident, jsUndefined(), attributes); 4453 4436 } 4454 4437
Note:
See TracChangeset
for help on using the changeset viewer.