diff options
author | Christian Kamm <[email protected]> | 2011-11-21 14:51:03 +0100 |
---|---|---|
committer | Christian Kamm <[email protected]> | 2011-11-25 10:36:42 +0100 |
commit | 097850c842ce872d31716ddb528ebfad346475da (patch) | |
tree | fcbf558b7c37f1f4bb2bb3ea0bcf398d5a7f2b32 /src/libs/qmljs/qmljsvalueowner.h | |
parent | e2b0835b58aefdab91edda097c1180dae08058f6 (diff) |
QmlJS: Speed up ValueOwner construction.
* Don't build all default values (including the global object)
separately for each ValueOwner instance.
* Instead, keep all global, immutable values in a single, shared
instance.
While refactoring, some cases where we *modified* the global object had
to be removed:
* C++ context properties no longer get injected into the global object,
instead they now have their own scope just above the global one.
* The Qt object's prototype no longer gets modified in Link. Instead,
it's now a reference to the "Qt" object provided in a qmltypes file.
* The whole concept of a function 'Activation' that could potentially
affect the global object was removed.
Change-Id: Id382faf965efa747fcc7a9b0bc2c90429d84d61b
Reviewed-by: Leandro Melo <[email protected]>
Diffstat (limited to 'src/libs/qmljs/qmljsvalueowner.h')
-rw-r--r-- | src/libs/qmljs/qmljsvalueowner.h | 73 |
1 files changed, 15 insertions, 58 deletions
diff --git a/src/libs/qmljs/qmljsvalueowner.h b/src/libs/qmljs/qmljsvalueowner.h index d1edfe02485..0add1f1d0b9 100644 --- a/src/libs/qmljs/qmljsvalueowner.h +++ b/src/libs/qmljs/qmljsvalueowner.h @@ -62,13 +62,14 @@ class Imports; class TypeScope; class JSImportScope; class Function; +class SharedValueOwner; class QMLJS_EXPORT ValueOwner { Q_DISABLE_COPY(ValueOwner) public: - ValueOwner(); + ValueOwner(const SharedValueOwner *shared = 0); ~ValueOwner(); const NullValue *nullValue() const; @@ -83,10 +84,8 @@ public: const ColorValue *colorValue() const; const AnchorLineValue *anchorLineValue() const; - ObjectValue *newObject(const ObjectValue *prototype); + ObjectValue *newObject(const Value *prototype); ObjectValue *newObject(); - Function *newFunction(); - const Value *newArray(); // ### remove me // QML objects const ObjectValue *qmlKeysObject(); @@ -100,19 +99,19 @@ public: const Value *defaultValueForBuiltinType(const QString &typeName) const; // global object - ObjectValue *globalObject() const; + const ObjectValue *globalObject() const; const ObjectValue *mathObject() const; const ObjectValue *qtObject() const; // prototypes - ObjectValue *objectPrototype() const; - ObjectValue *functionPrototype() const; - ObjectValue *numberPrototype() const; - ObjectValue *booleanPrototype() const; - ObjectValue *stringPrototype() const; - ObjectValue *arrayPrototype() const; - ObjectValue *datePrototype() const; - ObjectValue *regexpPrototype() const; + const ObjectValue *objectPrototype() const; + const ObjectValue *functionPrototype() const; + const ObjectValue *numberPrototype() const; + const ObjectValue *booleanPrototype() const; + const ObjectValue *stringPrototype() const; + const ObjectValue *arrayPrototype() const; + const ObjectValue *datePrototype() const; + const ObjectValue *regexpPrototype() const; // ctors const FunctionValue *objectCtor() const; @@ -139,64 +138,22 @@ public: void registerValue(Value *value); // internal -private: - void initializePrototypes(); - +protected: Function *addFunction(ObjectValue *object, const QString &name, const Value *result, int argumentCount = 0, int optionalCount = 0, bool variadic = false); Function *addFunction(ObjectValue *object, const QString &name, int argumentCount = 0, int optionalCount = 0, bool variadic = false); -private: - ObjectValue *_objectPrototype; - ObjectValue *_functionPrototype; - ObjectValue *_numberPrototype; - ObjectValue *_booleanPrototype; - ObjectValue *_stringPrototype; - ObjectValue *_arrayPrototype; - ObjectValue *_datePrototype; - ObjectValue *_regexpPrototype; - - Function *_objectCtor; - Function *_functionCtor; - Function *_arrayCtor; - Function *_stringCtor; - Function *_booleanCtor; - Function *_numberCtor; - Function *_dateCtor; - Function *_regexpCtor; - - ObjectValue *_globalObject; - ObjectValue *_mathObject; - ObjectValue *_qtObject; - ObjectValue *_qmlKeysObject; - ObjectValue *_qmlFontObject; - ObjectValue *_qmlPointObject; - ObjectValue *_qmlSizeObject; - ObjectValue *_qmlRectObject; - ObjectValue *_qmlVector3DObject; - - NullValue _nullValue; - UndefinedValue _undefinedValue; - UnknownValue _unknownValue; - NumberValue _numberValue; - RealValue _realValue; - IntValue _intValue; - BooleanValue _booleanValue; - StringValue _stringValue; - UrlValue _urlValue; - ColorValue _colorValue; - AnchorLineValue _anchorLineValue; QList<Value *> _registeredValues; + QMutex _mutex; ConvertToNumber _convertToNumber; ConvertToString _convertToString; ConvertToObject _convertToObject; TypeId _typeId; - CppQmlTypes _cppQmlTypes; - QMutex _mutex; + const SharedValueOwner *_shared; }; } // namespace QmlJS |