Set property attributes more correctly
authorLars Knoll <lars.knoll@digia.com>
Mon, 29 Oct 2012 14:50:07 +0000 (15:50 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Wed, 31 Oct 2012 15:58:36 +0000 (16:58 +0100)
Also now check for enumerable in for/in statements.

Change-Id: I03a9968fc3d7f8f5e4eaf26591040acd9cc8ced1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qmljs_objects.cpp
qmljs_objects.h

index ecf97c4..5d71aa4 100644 (file)
@@ -153,9 +153,6 @@ void Object::__put__(Context *ctx, String *name, const Value &value, bool throwE
 
             // ### to simplify and speed up we should expand the relevant parts here (clauses 6,7,9,10,12,13)
             PropertyDescriptor desc = PropertyDescriptor::fromValue(value);
-            desc.configurable = PropertyDescriptor::Undefined;
-            desc.enumberable = PropertyDescriptor::Undefined;
-            desc.writable = PropertyDescriptor::Undefined;
             __defineOwnProperty__(ctx, name, &desc, throwException);
             return;
         }
@@ -185,6 +182,9 @@ void Object::__put__(Context *ctx, String *name, const Value &value, bool throwE
 
         PropertyDescriptor *p = members->insert(name);
         *p = PropertyDescriptor::fromValue(value);
+        p->configurable = PropertyDescriptor::Set;
+        p->enumberable = PropertyDescriptor::Set;
+        p->writable = PropertyDescriptor::Set;
     }
 
   reject:
@@ -312,7 +312,7 @@ String *ForEachIteratorObject::nextPropertyName()
         }
         p = current->members->_properties[tableIndex];
         // ### check that it's not a repeated attribute
-        if (p /*&& !(p->attributes & DontEnumAttribute)*/)
+        if (p && p->descriptor.isEnumerable())
             return p->name;
     }
 }
@@ -431,6 +431,7 @@ PropertyDescriptor *ActivationObject::__getPropertyDescriptor__(Context *ctx, St
             if (__qmljs_string_equal(var, name)) {
                 *to_fill = PropertyDescriptor::fromValue(context->locals[i]);
                 to_fill->writable = PropertyDescriptor::Set;
+                to_fill->enumberable = PropertyDescriptor::Set;
                 return to_fill;
             }
         }
@@ -439,6 +440,7 @@ PropertyDescriptor *ActivationObject::__getPropertyDescriptor__(Context *ctx, St
             if (__qmljs_string_equal(formal, name)) {
                 *to_fill = PropertyDescriptor::fromValue(context->arguments[i]);
                 to_fill->writable = PropertyDescriptor::Set;
+                to_fill->enumberable = PropertyDescriptor::Set;
                 return to_fill;
             }
         }
@@ -449,6 +451,8 @@ PropertyDescriptor *ActivationObject::__getPropertyDescriptor__(Context *ctx, St
             }
 
             *to_fill = PropertyDescriptor::fromValue(arguments);
+            to_fill->writable = PropertyDescriptor::Unset;
+            to_fill->enumberable = PropertyDescriptor::Unset;
             return to_fill;
         }
     }
@@ -469,6 +473,8 @@ PropertyDescriptor *ArgumentsObject::__getPropertyDescriptor__(Context *ctx, Str
         const quint32 i = Value::fromString(name).toUInt32(ctx);
         if (i < context->argumentCount) {
             *to_fill = PropertyDescriptor::fromValue(context->arguments[i]);
+            to_fill->writable = PropertyDescriptor::Unset;
+            to_fill->enumberable = PropertyDescriptor::Unset;
             return to_fill;
         }
     }
index 0760591..f7c3507 100644 (file)
@@ -138,9 +138,9 @@ struct PropertyDescriptor {
         PropertyDescriptor pd;
         pd.value = v;
         pd.type = Data;
-        pd.writable = Set;
-        pd.enumberable = Set;
-        pd.configurable = Set;
+        pd.writable = Undefined;
+        pd.enumberable = Undefined;
+        pd.configurable = Undefined;
         return pd;
     }
     static inline PropertyDescriptor fromAccessor(Object *getter, Object *setter) {
@@ -149,8 +149,8 @@ struct PropertyDescriptor {
         pd.set = setter;
         pd.type = Accessor;
         pd.writable = Undefined;
-        pd.enumberable = Set;
-        pd.configurable = Set;
+        pd.enumberable = Undefined;
+        pd.configurable = Undefined;
         return pd;
     }