Fix remaining issues with the delete operator
authorSimon Hausmann <simon.hausmann@digia.com>
Fri, 25 Jan 2013 14:52:42 +0000 (15:52 +0100)
committerLars Knoll <lars.knoll@digia.com>
Fri, 25 Jan 2013 14:56:19 +0000 (15:56 +0100)
Delete on known temps should return true and false on known local variables.

Change-Id: I71be8361306eb825b975a3aee294665eb8561366
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
qmljs_environment.cpp
qv4codegen.cpp
tests/TestExpectations

index a4db06a..8b2be30 100644 (file)
@@ -251,14 +251,26 @@ void ExecutionContext::destroy()
 
 bool ExecutionContext::deleteProperty(String *name)
 {
+    bool hasWith = false;
     for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
         if (ctx->withObject) {
+            hasWith = true;
             if (ctx->withObject->__hasProperty__(this, name))
                 return ctx->withObject->__delete__(this, name);
         } else {
             if (ctx->activation && ctx->activation->__hasProperty__(this, name))
                 return ctx->activation->__delete__(this, name);
         }
+        if (FunctionObject *f = ctx->function) {
+            if (f->needsActivation || hasWith) {
+                for (unsigned int i = 0; i < f->varCount; ++i)
+                    if (f->varList[i]->isEqualTo(name))
+                        return false;
+                for (int i = (int)f->formalParameterCount - 1; i >= 0; --i)
+                    if (f->formalParameterList[i]->isEqualTo(name))
+                        return false;
+            }
+        }
     }
     if (strictMode)
         throwSyntaxError(0);
index 9575bc1..e5d9994 100644 (file)
@@ -1322,6 +1322,10 @@ bool Codegen::visit(DeleteExpression *ast)
         _expr.code = _block->CONST(IR::BoolType, 1);
         return false;
     }
+    if (expr->asTemp() && expr->asTemp()->index >=  _env->members.size()) {
+        _expr.code = _block->CONST(IR::BoolType, 1);
+        return false;
+    }
 
     IR::ExprList *args = _function->New<IR::ExprList>();
     args->init(reference(expr));
index b04ad1d..8fffc99 100644 (file)
@@ -32,9 +32,6 @@ S11.3.2_A4_T1 failing
 S11.3.2_A4_T2 failing
 S11.3.2_A4_T3 failing
 S11.3.2_A4_T4 failing
-11.4.1-2-5 failing
-11.4.1-4.a-5 failing
-S11.4.1_A2.1 failing
 S11.5.3_A4_T2 failing
 S11.8.6_A3 failing
 S11.8.6_A5_T2 failing
@@ -95,4 +92,6 @@ Sbp_A3_T1 failing
 Sbp_A4_T1 failing
 Sbp_A4_T2 failing
 S12.4_A1 failing
-S15.2.4.4_A14 failing
\ No newline at end of file
+S15.2.4.4_A14 failing
+# Try/catch scoping issue
+S12.14_A4 failing
\ No newline at end of file