diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-08 16:43:10 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:18:45 +0000 |
commit | 37b85ca10eef7236dbea0decd265c40fa8d0caf1 (patch) | |
tree | ed3343cd350dff8aa3be1d471c745775ae523855 /src/qml/jsruntime/qv4engine.cpp | |
parent | 360a48aa3f5346aa7aaff741e4ef8f5dc8701f51 (diff) |
Add SymbolObject, well known symbols and fix most remaining issues
Added SymbolObject, the equivalent to StringObject which was
still missing so far. Added the predefined standard symbols,
and fixed most test failures related to symbols.
Change-Id: I1e28b439e7c4f5141b4a09bd8fb666c60691f192
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 87ae0e09d7..22dc984b4a 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -194,6 +194,7 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) typedArrayPrototype = static_cast<Object *>(jsAlloca(NTypedArrayTypes)); typedArrayCtors = static_cast<FunctionObject *>(jsAlloca(NTypedArrayTypes)); jsStrings = jsAlloca(NJSStrings); + jsSymbols = jsAlloca(NJSSymbols); // set up stack limits jsStackLimit = jsStackBase + JSStackLimit/sizeof(Value); @@ -264,6 +265,18 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) jsStrings[String_buffer] = newIdentifier(QStringLiteral("buffer")); jsStrings[String_lastIndex] = newIdentifier(QStringLiteral("lastIndex")); + jsSymbols[Symbol_hasInstance] = Symbol::create(this, QStringLiteral("@Symbol.hasInstance")); + jsSymbols[Symbol_isConcatSpreadable] = Symbol::create(this, QStringLiteral("@Symbol.isConcatSpreadable")); + jsSymbols[Symbol_iterator] = Symbol::create(this, QStringLiteral("@Symbol.iterator")); + jsSymbols[Symbol_match] = Symbol::create(this, QStringLiteral("@Symbol.match")); + jsSymbols[Symbol_replace] = Symbol::create(this, QStringLiteral("@Symbol.replace")); + jsSymbols[Symbol_search] = Symbol::create(this, QStringLiteral("@Symbol.search")); + jsSymbols[Symbol_species] = Symbol::create(this, QStringLiteral("@Symbol.species")); + jsSymbols[Symbol_split] = Symbol::create(this, QStringLiteral("@Symbol.split")); + jsSymbols[Symbol_toPrimitive] = Symbol::create(this, QStringLiteral("@Symbol.toPrimitive")); + jsSymbols[Symbol_toStringTag] = Symbol::create(this, QStringLiteral("@Symbol.toStringTag")); + jsSymbols[Symbol_unscopables] = Symbol::create(this, QStringLiteral("@Symbol.unscopables")); + ic = newInternalClass(ArrayPrototype::staticVTable(), objectPrototype()); Q_ASSERT(ic->d()->prototype); ic = ic->addMember(id_length()->identifier(), Attr_NotConfigurable|Attr_NotEnumerable); @@ -289,6 +302,8 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) classes[Class_StringObject] = ic->changePrototype(stringPrototype()->d()); Q_ASSERT(classes[Class_StringObject]->find(id_length()->identifier()) == Heap::StringObject::LengthPropertyIndex); + classes[Class_SymbolObject] = newInternalClass(QV4::SymbolObject::staticVTable(), symbolPrototype()); + jsObjects[NumberProto] = memoryManager->allocate<NumberPrototype>(); jsObjects[BooleanProto] = memoryManager->allocate<BooleanPrototype>(); jsObjects[DateProto] = memoryManager->allocate<DatePrototype>(); @@ -593,6 +608,11 @@ Heap::Object *ExecutionEngine::newStringObject(const String *string) return memoryManager->allocate<StringObject>(string); } +Heap::Object *ExecutionEngine::newSymbolObject(const Symbol *symbol) +{ + return memoryManager->allocObject<SymbolObject>(classes[Class_SymbolObject], symbol); +} + Heap::Object *ExecutionEngine::newNumberObject(double value) { return memoryManager->allocate<NumberObject>(value); |