Get rid of virtual __get__ in RegExpObject
authorSimon Hausmann <simon.hausmann@digia.com>
Fri, 18 Jan 2013 13:38:29 +0000 (14:38 +0100)
committerLars Knoll <lars.knoll@digia.com>
Fri, 18 Jan 2013 15:29:18 +0000 (16:29 +0100)
Instead implement the properties as run-time initialized properties.  Fixes
also a bunch of tests that verifies that they are own properties.

Change-Id: I3c4ba52edcec2b59020a2966436b33b2ca5d7f46
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
qmljs_objects.cpp
qmljs_objects.h
qv4regexp.h
tests/TestExpectations

index 5351c3f..0236d3c 100644 (file)
@@ -1111,32 +1111,18 @@ RegExpObject::RegExpObject(ExecutionEngine *engine, PassRefPtr<RegExp> value, bo
 {
     if (!members)
         members.reset(new PropertyTable());
-    lastIndexProperty = members->insert(engine->identifier("lastIndex"));
+    lastIndexProperty = members->insert(engine->identifier(QStringLiteral("lastIndex")));
     lastIndexProperty->type = PropertyDescriptor::Data;
     lastIndexProperty->writable = PropertyDescriptor::Enabled;
     lastIndexProperty->enumberable = PropertyDescriptor::Disabled;
     lastIndexProperty->configurable = PropertyDescriptor::Disabled;
     lastIndexProperty->value = Value::fromInt32(0);
-}
-
-Value RegExpObject::__get__(ExecutionContext *ctx, String *name, bool *hasProperty)
-{
-    QString n = name->toQString();
-    Value v = Value::undefinedValue();
-    if (n == QLatin1String("source"))
-        v = Value::fromString(ctx, value->pattern());
-    else if (n == QLatin1String("global"))
-        v = Value::fromBoolean(global);
-    else if (n == QLatin1String("ignoreCase"))
-        v = Value::fromBoolean(value->ignoreCase());
-    else if (n == QLatin1String("multiline"))
-        v = Value::fromBoolean(value->multiLine());
-    if (v.type() != Value::Undefined_Type) {
-        if (hasProperty)
-            *hasProperty = true;
-        return v;
-    }
-    return Object::__get__(ctx, name, hasProperty);
+    if (!this->value.get())
+        return;
+    defineDefaultProperty(engine->identifier(QStringLiteral("source")), Value::fromString(engine->newString(this->value->pattern())));
+    defineDefaultProperty(engine->identifier(QStringLiteral("global")), Value::fromBoolean(global));
+    defineDefaultProperty(engine->identifier(QStringLiteral("ignoreCase")), Value::fromBoolean(this->value->ignoreCase()));
+    defineDefaultProperty(engine->identifier(QStringLiteral("multiline")), Value::fromBoolean(this->value->multiLine()));
 }
 
 ErrorObject::ErrorObject(ExecutionEngine* engine, const Value &message)
index 54b826c..f1cbf4b 100644 (file)
@@ -362,11 +362,10 @@ struct IsFiniteFunction: FunctionObject
 struct RegExpObject: Object {
     RefPtr<RegExp> value;
     PropertyDescriptor *lastIndexProperty;
-    bool global;
+    const bool global;
     RegExpObject(ExecutionEngine *engine, PassRefPtr<RegExp> value, bool global);
     virtual QString className() { return QStringLiteral("RegExp"); }
     virtual RegExpObject *asRegExpObject() { return this; }
-    virtual Value __get__(ExecutionContext *ctx, String *name, bool *hasProperty);
 };
 
 struct ErrorObject: Object {
index 3b7a980..7fd8225 100644 (file)
@@ -79,11 +79,11 @@ private:
     Q_DISABLE_COPY(RegExp);
     RegExp(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline);
 
-    QString m_pattern;
+    const QString m_pattern;
     OwnPtr<JSC::Yarr::BytecodePattern> m_byteCode;
     int m_subPatternCount;
-    bool m_ignoreCase;
-    bool m_multiLine;
+    const bool m_ignoreCase;
+    const bool m_multiLine;
 };
 
 } // end of namespace VM
index 1b6d87d..90a2883 100644 (file)
@@ -315,19 +315,15 @@ S15.10.6.2_A1_T2 failing
 S15.10.7_A2_T1 failing
 15.10.7.1-2 failing
 S15.10.7.1_A10 failing
-S15.10.7.1_A8 failing
 S15.10.7.1_A9 failing
 15.10.7.2-2 failing
 S15.10.7.2_A10 failing
-S15.10.7.2_A8 failing
 S15.10.7.2_A9 failing
 15.10.7.3-2 failing
 S15.10.7.3_A10 failing
-S15.10.7.3_A8 failing
 S15.10.7.3_A9 failing
 15.10.7.4-2 failing
 S15.10.7.4_A10 failing
-S15.10.7.4_A8 failing
 S15.10.7.4_A9 failing
 S15.11.4.2_A1 failing
 S15.11.4.2_A2 failing
@@ -1298,4 +1294,4 @@ S15.4.4.13_A1_T2 failing
 15.4.4.17-7-c-i-6 failing
 
 # Regressions introduced with https://codereview.qt-project.org/#change,45044
-15.4.4.21-8-b-iii-1-6 failing
+15.4.4.21-8-b-iii-1-6 failing
\ No newline at end of file