Reviewed by Oliver.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2007 10:26:02 +0000 (10:26 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2007 10:26:02 +0000 (10:26 +0000)
        - fix remaining problems with Window shadowing

        * kjs/nodes.cpp:
        (VarDeclNode::evaluate): Tweak the special case a little.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24534 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/nodes.cpp

index 03ba957..924b43b 100644 (file)
@@ -2,6 +2,15 @@
 
         Reviewed by Oliver.
         
+        - fix remaining problems with Window shadowing
+
+        * kjs/nodes.cpp:
+        (VarDeclNode::evaluate): Tweak the special case a little.
+
+2007-07-23  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Oliver.
+        
         - fix Window shadowing regressions caused by the previous commit.
 
         * kjs/nodes.cpp:
index 9ffea7b..622f4c3 100644 (file)
@@ -1623,7 +1623,17 @@ JSValue* VarDeclNode::evaluate(ExecState* exec)
 
     ASSERT(!chain.isEmpty());
 
-    if (init) {
+    bool inGlobalScope = ++chain.begin() == chain.end();
+
+    if (inGlobalScope && (init || !variableObject->getDirect(ident))) {
+        JSValue* val = init ? init->evaluate(exec) : jsUndefined();
+        int flags = Internal;
+        if (exec->context()->codeType() != EvalCode)
+            flags |= DontDelete;
+        if (varType == VarDeclNode::Constant)
+            flags |= ReadOnly;
+        variableObject->putDirect(ident, val, flags);
+    } else if (init) {
         JSValue* val = init->evaluate(exec);
         KJS_CHECKEXCEPTIONVALUE
             
@@ -1638,28 +1648,8 @@ JSValue* VarDeclNode::evaluate(ExecState* exec)
         if (varType == VarDeclNode::Constant)
             flags |= ReadOnly;
         
-        if (++chain.begin() == chain.end()) {
-            int flags = Internal;
-            if (exec->context()->codeType() != EvalCode)
-                flags |= DontDelete;
-            if (varType == VarDeclNode::Constant)
-                flags |= ReadOnly;
-            variableObject->putDirect(ident, val, flags);
-        } else {
-            ASSERT(variableObject->getDirect(ident) || ident == exec->propertyNames().arguments);
-            variableObject->put(exec, ident, val, flags);
-        }
-    } else {
-        if (++chain.begin() == chain.end()) {
-            int flags = Internal;
-            if (exec->context()->codeType() != EvalCode)
-                flags |= DontDelete;
-            if (varType == VarDeclNode::Constant)
-                flags |= ReadOnly;
-            variableObject->putDirect(ident, jsUndefined(), flags);
-        } else {
-
-        }
+        ASSERT(variableObject->getDirect(ident) || ident == exec->propertyNames().arguments);
+        variableObject->put(exec, ident, val, flags);
     }
 
     // no caller of this function actually uses the return value.