diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-19 14:15:12 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-26 10:03:43 +0000 |
commit | 89f585157af905d45012dbd9c079c48491e5211d (patch) | |
tree | bb0f3e34d9f030ce71634752ff9b0a9834adf5f3 /src/qml/jsruntime/qv4stringobject.cpp | |
parent | 1e7cd1acf64e13096231a25736ee227cb3b43b8b (diff) | |
download | qtdeclarative-89f585157af905d45012dbd9c079c48491e5211d.tar.gz |
Move special handling of getOwnProperty for StringObject where it belongs
Move the code into a virtual method of StringObject, bringing us closer
in line with the ES7 spec.
Change-Id: Iaf460f5a5517fe059a30be8c403d71625453b80a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4stringobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index b1ae5a1ce5..b9e04db28f 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -137,6 +137,26 @@ void StringObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, return Object::advanceIterator(m, it, name, index, p, attrs); } +PropertyAttributes StringObject::getOwnProperty(Managed *m, Identifier id, Property *p) +{ + PropertyAttributes attributes = Object::getOwnProperty(m, id, p); + if (attributes != Attr_Invalid) + return attributes; + + Object *o = static_cast<Object *>(m); + if (id.isArrayIndex()) { + uint index = id.asArrayIndex(); + if (o->isStringObject()) { + if (index >= static_cast<const StringObject *>(m)->length()) + return Attr_Invalid; + if (p) + p->value = static_cast<StringObject *>(o)->getIndex(index); + return Attr_NotConfigurable|Attr_NotWritable; + } + } + return Attr_Invalid; +} + DEFINE_OBJECT_VTABLE(StringCtor); void Heap::StringCtor::init(QV4::ExecutionContext *scope) |