Changeset 24533 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Jul 23, 2007, 1:48:04 AM (18 years ago)
Author:
mjs
Message:

Reviewed by Oliver.


  • fix Window shadowing regressions caused by the previous commit.
  • kjs/nodes.cpp: (VarDeclNode::evaluate): Handle the case of global scope specially.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r24532 r24533  
    16191619JSValue* VarDeclNode::evaluate(ExecState* exec)
    16201620{
    1621     JSValue* val;
     1621    const ScopeChain& chain = exec->context()->scopeChain();
     1622    JSObject* variableObject = exec->context()->variableObject();
     1623
     1624    ASSERT(!chain.isEmpty());
     1625
    16221626    if (init) {
    1623         val = init->evaluate(exec);
     1627        JSValue* val = init->evaluate(exec);
    16241628        KJS_CHECKEXCEPTIONVALUE
    16251629           
    1626         const ScopeChain& chain = exec->context()->scopeChain();
    1627         JSObject* variableObject = exec->context()->variableObject();
    1628 
    1629         ASSERT(!chain.isEmpty());
    1630         ASSERT(variableObject->getDirect(ident) || ident == exec->propertyNames().arguments);
    1631 
    16321630        // if the variable object is the top of the scope chain, then that must
    16331631        // be where this variable is declared, processVarDecls would have put
     
    16411639            flags |= ReadOnly;
    16421640       
    1643         variableObject->put(exec, ident, val, flags);
    1644     }
     1641        if (++chain.begin() == chain.end()) {
     1642            int flags = Internal;
     1643            if (exec->context()->codeType() != EvalCode)
     1644                flags |= DontDelete;
     1645            if (varType == VarDeclNode::Constant)
     1646                flags |= ReadOnly;
     1647            variableObject->putDirect(ident, val, flags);
     1648        } else {
     1649            ASSERT(variableObject->getDirect(ident) || ident == exec->propertyNames().arguments);
     1650            variableObject->put(exec, ident, val, flags);
     1651        }
     1652    } else {
     1653        if (++chain.begin() == chain.end()) {
     1654            int flags = Internal;
     1655            if (exec->context()->codeType() != EvalCode)
     1656                flags |= DontDelete;
     1657            if (varType == VarDeclNode::Constant)
     1658                flags |= ReadOnly;
     1659            variableObject->putDirect(ident, jsUndefined(), flags);
     1660        } else {
     1661
     1662        }
     1663    }
    16451664
    16461665    // no caller of this function actually uses the return value.
Note: See TracChangeset for help on using the changeset viewer.