Rename variables and functions
authorLars Knoll <lars.knoll@digia.com>
Sun, 3 Feb 2013 09:25:55 +0000 (10:25 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 4 Feb 2013 14:06:41 +0000 (15:06 +0100)
Prepare for merging the Array class with ArrayObject

Change-Id: I03a2b10f290e18f8933efc11f83c76716e3721f4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/v4/qmljs_runtime.cpp
src/v4/qv4argumentsobject.cpp
src/v4/qv4array.cpp
src/v4/qv4array.h
src/v4/qv4arrayobject.cpp
src/v4/qv4jsonobject.cpp
src/v4/qv4object.cpp
src/v4/qv4object.h
src/v4/qv4objectiterator.cpp
src/v4/qv4stringobject.cpp

index 2161d89..6330435 100644 (file)
@@ -596,7 +596,7 @@ Value __qmljs_get_element(ExecutionContext *ctx, Value object, Value index)
     Object *o = object.objectValue();
 
     if (idx < UINT_MAX) {
-        const PropertyDescriptor *p = o->array.nonSparseAt(idx);
+        const PropertyDescriptor *p = o->array.nonSparseArrayAt(idx);
         if (p && p->type == PropertyDescriptor::Data)
             return p->value;
 
@@ -616,7 +616,7 @@ void __qmljs_set_element(ExecutionContext *ctx, Value object, Value index, Value
 
     uint idx = index.asArrayIndex();
     if (idx < UINT_MAX) {
-        PropertyDescriptor *p = o->array.nonSparseAtRef(idx);
+        PropertyDescriptor *p = o->array.nonSparseArrayAtRef(idx);
         if (p && p->type == PropertyDescriptor::Data && p->isWritable()) {
             p->value = value;
             return;
index f732750..cb88028 100644 (file)
@@ -82,7 +82,7 @@ ArgumentsObject::ArgumentsObject(ExecutionContext *context, int formalParameterC
 
 bool ArgumentsObject::defineOwnProperty(ExecutionContext *ctx, uint index, const PropertyDescriptor *desc)
 {
-    PropertyDescriptor *pd = array.at(index);
+    PropertyDescriptor *pd = array.arrayAt(index);
     PropertyDescriptor map;
     bool isMapped = false;
     if (pd && index < (uint)mappedArguments.size())
index decef65..ffefd1b 100644 (file)
@@ -463,23 +463,23 @@ SparseArrayNode *SparseArray::insert(uint akey)
 }
 
 Array::Array(const Array &other)
-    : len(other.len)
+    : arrayLen(other.arrayLen)
     , arrayObject(0)
-    , values(other.values)
-    , sparse(0)
+    , arrayData(other.arrayData)
+    , sparseArray(0)
 {
-    freeList = other.freeList;
-    if (other.sparse)
-        sparse = new SparseArray(*other.sparse);
+    arrayFreeList = other.arrayFreeList;
+    if (other.sparseArray)
+        sparseArray = new SparseArray(*other.sparseArray);
 }
 
 
-Value Array::indexOf(Value v, uint fromIndex, uint endIndex, ExecutionContext *ctx, Object *o)
+Value Array::arrayIndexOf(Value v, uint fromIndex, uint endIndex, ExecutionContext *ctx, Object *o)
 {
     bool protoHasArray = false;
     Object *p = o;
     while ((p = p->prototype))
-        if (p->array.length())
+        if (p->array.arrayLength())
             protoHasArray = true;
 
     if (protoHasArray) {
@@ -490,100 +490,100 @@ Value Array::indexOf(Value v, uint fromIndex, uint endIndex, ExecutionContext *c
             if (exists && __qmljs_strict_equal(value, v))
                 return Value::fromDouble(i);
         }
-    } else if (sparse) {
-        for (SparseArrayNode *n = sparse->lowerBound(fromIndex); n && n->key() < endIndex; n = n->nextNode()) {
+    } else if (sparseArray) {
+        for (SparseArrayNode *n = sparseArray->lowerBound(fromIndex); n && n->key() < endIndex; n = n->nextNode()) {
             bool exists;
-            Value value = o->getValueChecked(ctx, descriptor(n->value), &exists);
+            Value value = o->getValueChecked(ctx, arrayDecriptor(n->value), &exists);
             if (exists && __qmljs_strict_equal(value, v))
                 return Value::fromDouble(n->key());
         }
     } else {
-        if ((int) endIndex > values.size())
-            endIndex = values.size();
-        PropertyDescriptor *pd = values.data() + offset;
+        if ((int) endIndex > arrayData.size())
+            endIndex = arrayData.size();
+        PropertyDescriptor *pd = arrayData.data() + arrayOffset;
         PropertyDescriptor *end = pd + endIndex;
         pd += fromIndex;
         while (pd < end) {
             bool exists;
             Value value = o->getValueChecked(ctx, pd, &exists);
             if (exists && __qmljs_strict_equal(value, v))
-                return Value::fromDouble(pd - offset - values.constData());
+                return Value::fromDouble(pd - arrayOffset - arrayData.constData());
             ++pd;
         }
     }
     return Value::fromInt32(-1);
 }
 
-void Array::concat(const Array &other)
+void Array::arrayConcat(const Array &other)
 {
     initSparse();
-    int newLen = len + other.length();
-    if (other.sparse)
+    int newLen = arrayLen + other.arrayLength();
+    if (other.sparseArray)
         initSparse();
-    if (sparse) {
-        if (other.sparse) {
-            for (const SparseArrayNode *it = other.sparse->begin(); it != other.sparse->end(); it = it->nextNode())
-                set(len + it->key(), other.descriptor(it->value));
+    if (sparseArray) {
+        if (other.sparseArray) {
+            for (const SparseArrayNode *it = other.sparseArray->begin(); it != other.sparseArray->end(); it = it->nextNode())
+                arraySet(arrayLen + it->key(), other.arrayDecriptor(it->value));
         } else {
-            int oldSize = values.size();
-            values.resize(oldSize + other.length());
-            memcpy(values.data() + oldSize, other.values.constData() + other.offset, other.length()*sizeof(PropertyDescriptor));
-            for (uint i = 0; i < other.length(); ++i) {
-                SparseArrayNode *n = sparse->insert(len + i);
+            int oldSize = arrayData.size();
+            arrayData.resize(oldSize + other.arrayLength());
+            memcpy(arrayData.data() + oldSize, other.arrayData.constData() + other.arrayOffset, other.arrayLength()*sizeof(PropertyDescriptor));
+            for (uint i = 0; i < other.arrayLength(); ++i) {
+                SparseArrayNode *n = sparseArray->insert(arrayLen + i);
                 n->value = oldSize + i;
             }
         }
     } else {
-        int oldSize = values.size();
-        values.resize(oldSize + other.length());
-        memcpy(values.data() + oldSize, other.values.constData() + other.offset, other.length()*sizeof(PropertyDescriptor));
+        int oldSize = arrayData.size();
+        arrayData.resize(oldSize + other.arrayLength());
+        memcpy(arrayData.data() + oldSize, other.arrayData.constData() + other.arrayOffset, other.arrayLength()*sizeof(PropertyDescriptor));
     }
-    setLengthUnchecked(newLen);
+    setArrayLengthUnchecked(newLen);
 }
 
-void Array::sort(ExecutionContext *context, Object *thisObject, const Value &comparefn, uint len)
+void Array::arraySort(ExecutionContext *context, Object *thisObject, const Value &comparefn, uint len)
 {
-    if (sparse) {
+    if (sparseArray) {
         context->throwUnimplemented("Array::sort unimplemented for sparse arrays");
         return;
-        delete sparse;
+        delete sparseArray;
     }
 
     ArrayElementLessThan lessThan(context, thisObject, comparefn);
-    if (len > values.size() - offset)
-        len = values.size() - offset;
-    PropertyDescriptor *begin = values.begin() + offset;
+    if (len > arrayData.size() - arrayOffset)
+        len = arrayData.size() - arrayOffset;
+    PropertyDescriptor *begin = arrayData.begin() + arrayOffset;
     std::sort(begin, begin + len, lessThan);
 }
 
 
 void Array::initSparse()
 {
-    if (!sparse) {
-        sparse = new SparseArray;
-        for (int i = offset; i < values.size(); ++i) {
-            SparseArrayNode *n = sparse->insert(i - offset);
+    if (!sparseArray) {
+        sparseArray = new SparseArray;
+        for (int i = arrayOffset; i < arrayData.size(); ++i) {
+            SparseArrayNode *n = sparseArray->insert(i - arrayOffset);
             n->value = i;
         }
 
-        if (offset) {
-            int o = offset;
+        if (arrayOffset) {
+            int o = arrayOffset;
             for (int i = 0; i < o - 1; ++i) {
-                values[i].type = PropertyDescriptor::Generic;
-                values[i].value = Value::fromInt32(i + 1);
+                arrayData[i].type = PropertyDescriptor::Generic;
+                arrayData[i].value = Value::fromInt32(i + 1);
             }
-            values[o - 1].type = PropertyDescriptor::Generic;
-            values[o - 1].value = Value::fromInt32(values.size());
-            freeList = 0;
+            arrayData[o - 1].type = PropertyDescriptor::Generic;
+            arrayData[o - 1].value = Value::fromInt32(arrayData.size());
+            arrayFreeList = 0;
         } else {
-            freeList = values.size();
+            arrayFreeList = arrayData.size();
         }
     }
 }
 
-void Array::setLengthUnchecked(uint l)
+void Array::setArrayLengthUnchecked(uint l)
 {
-    len = l;
+    arrayLen = l;
     if (arrayObject) {
         // length is always the first property of an array
         PropertyDescriptor &lengthProperty = arrayObject->memberData[ArrayObject::LengthPropertyIndex];
@@ -591,18 +591,18 @@ void Array::setLengthUnchecked(uint l)
     }
 }
 
-bool Array::setLength(uint newLen) {
+bool Array::setArrayLength(uint newLen) {
     const PropertyDescriptor *lengthProperty = arrayObject->memberData.constData() + ArrayObject::LengthPropertyIndex;
     if (lengthProperty && !lengthProperty->isWritable())
         return false;
-    uint oldLen = length();
+    uint oldLen = arrayLength();
     bool ok = true;
     if (newLen < oldLen) {
-        if (sparse) {
-            SparseArrayNode *begin = sparse->lowerBound(newLen);
-            SparseArrayNode *it = sparse->end()->previousNode();
+        if (sparseArray) {
+            SparseArrayNode *begin = sparseArray->lowerBound(newLen);
+            SparseArrayNode *it = sparseArray->end()->previousNode();
             while (1) {
-                PropertyDescriptor &pd = values[it->value];
+                PropertyDescriptor &pd = arrayData[it->value];
                 if (pd.type != PropertyDescriptor::Generic && !pd.isConfigurable()) {
                     ok = false;
                     newLen = it->key() + 1;
@@ -610,40 +610,40 @@ bool Array::setLength(uint newLen) {
                 }
                 pd.type = PropertyDescriptor::Generic;
                 pd.value.tag = Value::_Undefined_Type;
-                pd.value.int_32 = freeList;
-                freeList = it->value;
+                pd.value.int_32 = arrayFreeList;
+                arrayFreeList = it->value;
                 bool brk = (it == begin);
                 SparseArrayNode *prev = it->previousNode();
-                sparse->erase(it);
+                sparseArray->erase(it);
                 if (brk)
                     break;
                 it = prev;
             }
         } else {
-            PropertyDescriptor *it = values.data() + values.size();
-            const PropertyDescriptor *begin = values.constData() + offset + newLen;
+            PropertyDescriptor *it = arrayData.data() + arrayData.size();
+            const PropertyDescriptor *begin = arrayData.constData() + arrayOffset + newLen;
             while (--it >= begin) {
                 if (it->type != PropertyDescriptor::Generic && !it->isConfigurable()) {
                     ok = false;
-                    newLen = it - values.data() + offset + 1;
+                    newLen = it - arrayData.data() + arrayOffset + 1;
                     break;
                 }
             }
-            values.resize(newLen + offset);
+            arrayData.resize(newLen + arrayOffset);
         }
     } else {
         if (newLen >= 0x100000)
             initSparse();
     }
-    setLengthUnchecked(newLen);
+    setArrayLengthUnchecked(newLen);
     return ok;
 }
 
-void Array::markObjects() const
+void Array::markArrayObjects() const
 {
-    uint i = sparse ? 0 : offset;
-    for (; i < (uint)values.size(); ++i) {
-        const PropertyDescriptor &pd = values.at(i);
+    uint i = sparseArray ? 0 : arrayOffset;
+    for (; i < (uint)arrayData.size(); ++i) {
+        const PropertyDescriptor &pd = arrayData.at(i);
         if (pd.isData()) {
             if (Managed *m = pd.value.asManaged())
                 m->mark();
index b165ed2..d0057e4 100644 (file)
@@ -366,14 +366,14 @@ class Array
 {
     friend struct ArrayPrototype;
 
-    uint len;
+    uint arrayLen;
     ArrayObject *arrayObject;
     union {
-        uint freeList;
-        uint offset;
+        uint arrayFreeList;
+        uint arrayOffset;
     };
-    QVector<PropertyDescriptor> values;
-    SparseArray *sparse;
+    QVector<PropertyDescriptor> arrayData;
+    SparseArray *sparseArray;
 
     void fillDescriptor(PropertyDescriptor *pd, Value v)
     {
@@ -384,105 +384,105 @@ class Array
         pd->value = v;
     }
 
-    uint allocValue() {
-        uint idx = freeList;
-        if (values.size() <= (int)freeList)
-            values.resize(++freeList);
+    uint allocArrayValue() {
+        uint idx = arrayFreeList;
+        if (arrayData.size() <= (int)arrayFreeList)
+            arrayData.resize(++arrayFreeList);
         else
-            freeList = values.at(freeList).value.integerValue();
+            arrayFreeList = arrayData.at(arrayFreeList).value.integerValue();
         return idx;
     }
 
-    uint allocValue(Value v) {
-        uint idx = allocValue();
-        PropertyDescriptor *pd = &values[idx];
+    uint allocArrayValue(Value v) {
+        uint idx = allocArrayValue();
+        PropertyDescriptor *pd = &arrayData[idx];
         fillDescriptor(pd, v);
         return idx;
     }
-    void freeValue(int idx) {
-        PropertyDescriptor &pd = values[idx];
+    void freeArrayValue(int idx) {
+        PropertyDescriptor &pd = arrayData[idx];
         pd.type = PropertyDescriptor::Generic;
         pd.value.tag = Value::_Undefined_Type;
-        pd.value.int_32 = freeList;
-        freeList = idx;
+        pd.value.int_32 = arrayFreeList;
+        arrayFreeList = idx;
     }
 
-    PropertyDescriptor *descriptor(uint index) {
-        PropertyDescriptor *pd = values.data() + index;
-        if (!sparse)
-            pd += offset;
+    PropertyDescriptor *arrayDecriptor(uint index) {
+        PropertyDescriptor *pd = arrayData.data() + index;
+        if (!sparseArray)
+            pd += arrayOffset;
         return pd;
     }
-    const PropertyDescriptor *descriptor(uint index) const {
-        const PropertyDescriptor *pd = values.data() + index;
-        if (!sparse)
-            pd += offset;
+    const PropertyDescriptor *arrayDecriptor(uint index) const {
+        const PropertyDescriptor *pd = arrayData.data() + index;
+        if (!sparseArray)
+            pd += arrayOffset;
         return pd;
     }
 
-    void getHeadRoom() {
-        assert(!sparse && !offset);
-        offset = qMax(values.size() >> 2, 16);
-        QVector<PropertyDescriptor> newValues(values.size() + offset);
-        memcpy(newValues.data() + offset, values.constData(), values.size()*sizeof(PropertyDescriptor));
-        values = newValues;
+    void getArrayHeadRoom() {
+        assert(!sparseArray && !arrayOffset);
+        arrayOffset = qMax(arrayData.size() >> 2, 16);
+        QVector<PropertyDescriptor> newValues(arrayData.size() + arrayOffset);
+        memcpy(newValues.data() + arrayOffset, arrayData.constData(), arrayData.size()*sizeof(PropertyDescriptor));
+        arrayData = newValues;
     }
 
 public:
-    Array() : len(0), arrayObject(0), offset(0), sparse(0) {}
+    Array() : arrayLen(0), arrayObject(0), arrayOffset(0), sparseArray(0) {}
     Array(const Array &other);
-    ~Array() { delete sparse; }
+    ~Array() { delete sparseArray; }
     void initSparse();
 
-    uint length() const { return len; }
-    bool setLength(uint newLen);
+    uint arrayLength() const { return arrayLen; }
+    bool setArrayLength(uint newLen);
 
     void setArrayObject(ArrayObject *a) { arrayObject = a; }
 
-    void setLengthUnchecked(uint l);
+    void setArrayLengthUnchecked(uint l);
 
-    PropertyDescriptor *insert(uint index) {
+    PropertyDescriptor *arrayInsert(uint index) {
         PropertyDescriptor *pd;
-        if (!sparse && (index < 0x1000 || index < len + (len >> 2))) {
-            if (index + offset >= (uint)values.size()) {
-                values.resize(offset + index + 1);
-                for (uint i = len + 1; i < index; ++i) {
-                    values[i].type = PropertyDescriptor::Generic;
-                    values[i].value.tag = Value::_Undefined_Type;
+        if (!sparseArray && (index < 0x1000 || index < arrayLen + (arrayLen >> 2))) {
+            if (index + arrayOffset >= (uint)arrayData.size()) {
+                arrayData.resize(arrayOffset + index + 1);
+                for (uint i = arrayLen + 1; i < index; ++i) {
+                    arrayData[i].type = PropertyDescriptor::Generic;
+                    arrayData[i].value.tag = Value::_Undefined_Type;
                 }
             }
-            pd = descriptor(index);
+            pd = arrayDecriptor(index);
         } else {
             initSparse();
-            SparseArrayNode *n = sparse->insert(index);
+            SparseArrayNode *n = sparseArray->insert(index);
             if (n->value == UINT_MAX)
-                n->value = allocValue();
-            pd = descriptor(n->value);
+                n->value = allocArrayValue();
+            pd = arrayDecriptor(n->value);
         }
-        if (index >= len)
-            setLengthUnchecked(index + 1);
+        if (index >= arrayLen)
+            setArrayLengthUnchecked(index + 1);
         return pd;
     }
 
-    void set(uint index, const PropertyDescriptor *pd) {
-        *insert(index) = *pd;
+    void arraySet(uint index, const PropertyDescriptor *pd) {
+        *arrayInsert(index) = *pd;
     }
 
-    void set(uint index, Value value) {
-        PropertyDescriptor *pd = insert(index);
+    void arraySet(uint index, Value value) {
+        PropertyDescriptor *pd = arrayInsert(index);
         fillDescriptor(pd, value);
     }
 
-    bool deleteIndex(uint index) {
-        if (index >= len)
+    bool deleteArrayIndex(uint index) {
+        if (index >= arrayLen)
             return true;
         PropertyDescriptor *pd = 0;
-        if (!sparse) {
-            pd = at(index);
+        if (!sparseArray) {
+            pd = arrayAt(index);
         } else {
-            SparseArrayNode *n = sparse->findNode(index);
+            SparseArrayNode *n = sparseArray->findNode(index);
             if (n)
-                pd = descriptor(n->value);
+                pd = arrayDecriptor(n->value);
         }
         if (!pd || pd->type == PropertyDescriptor::Generic)
             return true;
@@ -490,144 +490,143 @@ public:
             return false;
         pd->type = PropertyDescriptor::Generic;
         pd->value.tag = Value::_Undefined_Type;
-        if (sparse) {
-            pd->value.int_32 = freeList;
-            freeList = pd - values.constData();
+        if (sparseArray) {
+            pd->value.int_32 = arrayFreeList;
+            arrayFreeList = pd - arrayData.constData();
         }
         return true;
     }
 
-    PropertyDescriptor *at(uint index) {
-        if (!sparse) {
-            if (index >= values.size() - offset)
+    PropertyDescriptor *arrayAt(uint index) {
+        if (!sparseArray) {
+            if (index >= arrayData.size() - arrayOffset)
                 return 0;
-            return values.data() + index + offset;
+            return arrayData.data() + index + arrayOffset;
         } else {
-            SparseArrayNode *n = sparse->findNode(index);
+            SparseArrayNode *n = sparseArray->findNode(index);
             if (!n)
                 return 0;
-            return values.data() + n->value;
+            return arrayData.data() + n->value;
         }
     }
 
-    const PropertyDescriptor *nonSparseAt(uint index) const {
-        if (sparse)
+    const PropertyDescriptor *nonSparseArrayAt(uint index) const {
+        if (sparseArray)
             return 0;
-        index += offset;
-        if (index >= (uint)values.size())
+        index += arrayOffset;
+        if (index >= (uint)arrayData.size())
             return 0;
-        return values.constData() + index;
+        return arrayData.constData() + index;
     }
 
-    PropertyDescriptor *nonSparseAtRef(uint index) {
-        if (sparse)
+    PropertyDescriptor *nonSparseArrayAtRef(uint index) {
+        if (sparseArray)
             return 0;
-        index += offset;
-        if (index >= (uint)values.size())
+        index += arrayOffset;
+        if (index >= (uint)arrayData.size())
             return 0;
-        return values.data() + index;
+        return arrayData.data() + index;
     }
 
-    const PropertyDescriptor *at(uint index) const {
-        if (!sparse) {
-            if (index >= values.size() - offset)
+    const PropertyDescriptor *arrayAt(uint index) const {
+        if (!sparseArray) {
+            if (index >= arrayData.size() - arrayOffset)
                 return 0;
-            return values.constData() + index + offset;
+            return arrayData.constData() + index + arrayOffset;
         } else {
-            SparseArrayNode *n = sparse->findNode(index);
+            SparseArrayNode *n = sparseArray->findNode(index);
             if (!n)
                 return 0;
-            return values.constData() + n->value;
+            return arrayData.constData() + n->value;
         }
     }
 
-    void markObjects() const;
+    void markArrayObjects() const;
 
     void push_front(Value v) {
-        if (!sparse) {
-            if (!offset)
-                getHeadRoom();
+        if (!sparseArray) {
+            if (!arrayOffset)
+                getArrayHeadRoom();
 
-            --offset;
+            --arrayOffset;
             PropertyDescriptor &pd = values[offset];
             fillDescriptor(&pd, v);
         } else {
-            uint idx = allocValue(v);
-            sparse->push_front(idx);
+            uint idx = allocArrayValue(v);
+            sparseArray->push_front(idx);
         }
-        setLengthUnchecked(len + 1);
+        setArrayLengthUnchecked(arrayLen + 1);
     }
     PropertyDescriptor *front() {
         PropertyDescriptor *pd = 0;
-        if (!sparse) {
-            if (len)
-                pd = values.data() + offset;
+        if (!sparseArray) {
+            if (arrayLen)
+                pd = arrayData.data() + arrayOffset;
         } else {
-            SparseArrayNode *n = sparse->findNode(0);
+            SparseArrayNode *n = sparseArray->findNode(0);
             if (n)
-                pd = descriptor(n->value);
+                pd = arrayDecriptor(n->value);
         }
         if (pd && pd->type == PropertyDescriptor::Generic)
             return 0;
         return pd;
     }
     void pop_front() {
-        if (!len)
+        if (!arrayLen)
             return;
-        if (!sparse) {
-            ++offset;
+        if (!sparseArray) {
+            ++arrayOffset;
         } else {
-            uint idx = sparse->pop_front();
-            freeValue(idx);
+            uint idx = sparseArray->pop_front();
+            freeArrayValue(idx);
         }
-        setLengthUnchecked(len - 1);
+        setArrayLengthUnchecked(arrayLen - 1);
     }
     void push_back(Value v) {
-        if (!sparse) {
-            if (len + offset >= (uint)values.size())
-                values.resize(values.size() + 1);
-            PropertyDescriptor &pd = values[len + offset];
+        if (!sparseArray) {
+            PropertyDescriptor pd;
             fillDescriptor(&pd, v);
+            arrayData.append(pd);
         } else {
-            uint idx = allocValue(v);
-            sparse->push_back(idx, len);
+            uint idx = allocArrayValue(v);
+            sparseArray->push_back(idx, arrayLen);
         }
-        setLengthUnchecked(len + 1);
+        setArrayLengthUnchecked(arrayLen + 1);
     }
     PropertyDescriptor *back() {
         PropertyDescriptor *pd = 0;
-        if (!sparse) {
-            if (len)
-                pd = values.data() + offset + len;
+        if (!sparseArray) {
+            if (arrayLen)
+                pd = arrayData.data() + arrayOffset + arrayLen;
         } else {
-            SparseArrayNode *n = sparse->findNode(len - 1);
+            SparseArrayNode *n = sparseArray->findNode(arrayLen - 1);
             if (n)
-                pd = descriptor(n->value);
+                pd = arrayDecriptor(n->value);
         }
         if (pd && pd->type == PropertyDescriptor::Generic)
             return 0;
         return pd;
     }
     void pop_back() {
-        if (!len)
+        if (!arrayLen)
             return;
-        if (!sparse) {
-            values.resize(values.size() - 1);
+        if (!sparseArray) {
+            arrayData.resize(arrayData.size() - 1);
         } else {
-            uint idx = sparse->pop_back(len);
+            uint idx = sparseArray->pop_back(arrayLen);
             if (idx != UINT_MAX)
-                freeValue(idx);
+                freeArrayValue(idx);
         }
-        setLengthUnchecked(len - 1);
+        setArrayLengthUnchecked(arrayLen - 1);
     }
 
-    SparseArrayNode *sparseLowerBound(uint idx) { return sparse ? sparse->lowerBound(idx) : 0; }
-    SparseArrayNode *sparseBegin() { return sparse ? sparse->begin() : 0; }
-    SparseArrayNode *sparseEnd() { return sparse ? sparse->end() : 0; }
+    SparseArrayNode *sparseArrayLowerBound(uint idx) { return sparseArray ? sparseArray->lowerBound(idx) : 0; }
+    SparseArrayNode *sparseArrayBegin() { return sparseArray ? sparseArray->begin() : 0; }
+    SparseArrayNode *sparseArrayEnd() { return sparseArray ? sparseArray->end() : 0; }
 
-    void concat(const Array &other);
-    void sort(ExecutionContext *context, Object *thisObject, const Value &comparefn, uint len);
-    Value indexOf(Value v, uint fromIndex, uint len, ExecutionContext *ctx, Object *o);
+    void arrayConcat(const Array &other);
+    void arraySort(ExecutionContext *context, Object *thisObject, const Value &comparefn, uint arrayLen);
+    Value arrayIndexOf(Value v, uint fromIndex, uint arrayLen, ExecutionContext *ctx, Object *o);
 };
 
 }
index 680a373..b24ca32 100644 (file)
@@ -62,10 +62,10 @@ Value ArrayCtor::call(ExecutionContext *ctx)
             return Value::undefinedValue();
         }
 
-        value.setLengthUnchecked(len);
+        value.setArrayLengthUnchecked(len);
     } else {
         for (unsigned int i = 0; i < ctx->argumentCount; ++i) {
-            value.set(i, ctx->argument(i));
+            value.arraySet(i, ctx->argument(i));
         }
     }
 
@@ -104,7 +104,7 @@ void ArrayPrototype::init(ExecutionContext *ctx, const Value &ctor)
 uint ArrayPrototype::getLength(ExecutionContext *ctx, Object *o)
 {
     if (o->isArrayObject())
-        return o->array.length();
+        return o->array.arrayLength();
     return o->__get__(ctx, ctx->engine->id_length).toUInt32(ctx);
 }
 
@@ -133,18 +133,18 @@ Value ArrayPrototype::method_concat(ExecutionContext *ctx)
         result = instance->array;
     else {
         QString v = ctx->thisObject.toString(ctx)->toQString();
-        result.set(0, Value::fromString(ctx, v));
+        result.arraySet(0, Value::fromString(ctx, v));
     }
 
     for (uint i = 0; i < ctx->argumentCount; ++i) {
-        quint32 k = result.length();
+        quint32 k = result.arrayLength();
         Value arg = ctx->argument(i);
 
         if (ArrayObject *elt = arg.asArrayObject())
-            result.concat(elt->array);
+            result.arrayConcat(elt->array);
 
         else
-            result.set(k, arg);
+            result.arraySet(k, arg);
     }
 
     return Value::fromObject(ctx->engine->newArrayObject(ctx, result));
@@ -176,7 +176,7 @@ Value ArrayPrototype::method_join(ExecutionContext *ctx)
 
     // ### FIXME
     if (ArrayObject *a = self.asArrayObject()) {
-        for (uint i = 0; i < a->array.length(); ++i) {
+        for (uint i = 0; i < a->array.arrayLength(); ++i) {
             if (i)
                 R += r4;
 
@@ -222,7 +222,7 @@ Value ArrayPrototype::method_pop(ExecutionContext *ctx)
 
     instance->__delete__(ctx, len - 1);
     if (instance->isArrayObject())
-        instance->array.setLengthUnchecked(len - 1);
+        instance->array.setArrayLengthUnchecked(len - 1);
     else
         instance->__put__(ctx, ctx->engine->id_length, Value::fromDouble(len - 1));
     return result;
@@ -251,10 +251,10 @@ Value ArrayPrototype::method_push(ExecutionContext *ctx)
     bool protoHasArray = false;
     Object *p = instance;
     while ((p = p->prototype))
-        if (p->array.length())
+        if (p->array.arrayLength())
             protoHasArray = true;
 
-    if (!protoHasArray && len == instance->array.length()) {
+    if (!protoHasArray && len == instance->array.arrayLength()) {
         for (uint i = 0; i < ctx->argumentCount; ++i) {
             Value v = ctx->argument(i);
             instance->array.push_back(v);
@@ -312,10 +312,10 @@ Value ArrayPrototype::method_shift(ExecutionContext *ctx)
     bool protoHasArray = false;
     Object *p = instance;
     while ((p = p->prototype))
-        if (p->array.length())
+        if (p->array.arrayLength())
             protoHasArray = true;
 
-    if (!protoHasArray && len >= instance->array.length()) {
+    if (!protoHasArray && len >= instance->array.arrayLength()) {
         instance->array.pop_front();
     } else {
         // do it the slow way
@@ -365,7 +365,7 @@ Value ArrayPrototype::method_slice(ExecutionContext *ctx)
         bool exists;
         Value v = o->__get__(ctx, i, &exists);
         if (exists)
-            result.set(n, v);
+            result.arraySet(n, v);
         ++n;
     }
     return Value::fromObject(ctx->engine->newArrayObject(ctx, result));
@@ -378,7 +378,7 @@ Value ArrayPrototype::method_sort(ExecutionContext *ctx)
     uint len = getLength(ctx, instance);
 
     Value comparefn = ctx->argument(0);
-    instance->array.sort(ctx, instance, comparefn, len);
+    instance->array.arraySort(ctx, instance, comparefn, len);
     return ctx->thisObject;
 }
 
@@ -398,8 +398,8 @@ Value ArrayPrototype::method_splice(ExecutionContext *ctx)
 
     uint deleteCount = (uint)qMin(qMax(ctx->argument(1).toInteger(ctx), 0.), (double)(len - start));
 
-    newArray->array.values.resize(deleteCount);
-    PropertyDescriptor *pd = newArray->array.values.data();
+    newArray->array.arrayData.resize(deleteCount);
+    PropertyDescriptor *pd = newArray->array.arrayData.data();
     for (uint i = 0; i < deleteCount; ++i) {
         pd->type = PropertyDescriptor::Data;
         pd->writable = PropertyDescriptor::Enabled;
@@ -408,7 +408,7 @@ Value ArrayPrototype::method_splice(ExecutionContext *ctx)
         pd->value = instance->__get__(ctx, start + i);
         ++pd;
     }
-    newArray->array.setLengthUnchecked(deleteCount);
+    newArray->array.setArrayLengthUnchecked(deleteCount);
 
     uint itemCount = ctx->argumentCount < 2 ? 0 : ctx->argumentCount - 2;
 
@@ -417,7 +417,7 @@ Value ArrayPrototype::method_splice(ExecutionContext *ctx)
             bool exists;
             Value v = instance->__get__(ctx, k + deleteCount, &exists);
             if (exists)
-                instance->array.set(k + itemCount, v);
+                instance->array.arraySet(k + itemCount, v);
             else
                 instance->__delete__(ctx, k + itemCount);
         }
@@ -429,7 +429,7 @@ Value ArrayPrototype::method_splice(ExecutionContext *ctx)
             bool exists;
             Value v = instance->__get__(ctx, k + deleteCount - 1, &exists);
             if (exists)
-                instance->array.set(k + itemCount - 1, v);
+                instance->array.arraySet(k + itemCount - 1, v);
             else
                 instance->__delete__(ctx, k + itemCount - 1);
             --k;
@@ -437,7 +437,7 @@ Value ArrayPrototype::method_splice(ExecutionContext *ctx)
     }
 
     for (uint i = 0; i < itemCount; ++i)
-        instance->array.set(start + i, ctx->argument(i + 2));
+        instance->array.arraySet(start + i, ctx->argument(i + 2));
 
     ctx->strictMode = true;
     instance->__put__(ctx, ctx->engine->id_length, Value::fromDouble(len - deleteCount + itemCount));
@@ -453,10 +453,10 @@ Value ArrayPrototype::method_unshift(ExecutionContext *ctx)
     bool protoHasArray = false;
     Object *p = instance;
     while ((p = p->prototype))
-        if (p->array.length())
+        if (p->array.arrayLength())
             protoHasArray = true;
 
-    if (!protoHasArray && len >= instance->array.length()) {
+    if (!protoHasArray && len >= instance->array.arrayLength()) {
         for (int i = ctx->argumentCount - 1; i >= 0; --i) {
             Value v = ctx->argument(i);
             instance->array.push_front(v);
@@ -516,7 +516,7 @@ Value ArrayPrototype::method_indexOf(ExecutionContext *ctx)
         return Value::fromInt32(-1);
     }
 
-    return instance->array.indexOf(searchValue, fromIndex, len, ctx, instance);
+    return instance->array.arrayIndexOf(searchValue, fromIndex, len, ctx, instance);
 }
 
 Value ArrayPrototype::method_lastIndexOf(ExecutionContext *ctx)
@@ -654,7 +654,7 @@ Value ArrayPrototype::method_map(ExecutionContext *ctx)
     Value thisArg = ctx->argument(1);
 
     ArrayObject *a = ctx->engine->newArrayObject(ctx);
-    a->array.setLengthUnchecked(len);
+    a->array.setArrayLengthUnchecked(len);
 
     for (uint k = 0; k < len; ++k) {
         bool exists;
@@ -667,7 +667,7 @@ Value ArrayPrototype::method_map(ExecutionContext *ctx)
         args[1] = Value::fromDouble(k);
         args[2] = ctx->thisObject;
         Value mapped = callback->call(ctx, thisArg, args, 3);
-        a->array.set(k, mapped);
+        a->array.arraySet(k, mapped);
     }
     return Value::fromObject(a);
 }
@@ -699,7 +699,7 @@ Value ArrayPrototype::method_filter(ExecutionContext *ctx)
         args[2] = ctx->thisObject;
         Value selected = callback->call(ctx, thisArg, args, 3);
         if (__qmljs_to_boolean(selected, ctx)) {
-            a->array.set(to, v);
+            a->array.arraySet(to, v);
             ++to;
         }
     }
index 5c0027f..c5df590 100644 (file)
@@ -314,7 +314,7 @@ Value Parser::parseArray()
             Value val;
             if (!parseValue(&val))
                 return Value::undefinedValue();
-            array.set(index, val);
+            array.arraySet(index, val);
             QChar token = nextToken();
             if (token == EndArray)
                 break;
@@ -329,7 +329,7 @@ Value Parser::parseArray()
         }
     }
 
-    DEBUG << "size =" << array.length();
+    DEBUG << "size =" << array.arrayLength();
     END;
 
     --nestingLevel;
@@ -832,7 +832,7 @@ QString Stringify::JA(ArrayObject *a)
     indent += gap;
 
     QStringList partial;
-    uint len = a->array.length();
+    uint len = a->array.arrayLength();
     for (uint i = 0; i < len; ++i) {
         bool exists;
         Value v = a->__get__(ctx, i, &exists);
@@ -897,7 +897,7 @@ Value JsonObject::method_stringify(ExecutionContext *ctx)
     if (o) {
         stringify.replacerFunction = o->asFunctionObject();
         if (o->isArrayObject()) {
-            for (uint i = 0; i < o->array.length(); ++i) {
+            for (uint i = 0; i < o->array.arrayLength(); ++i) {
                 Value v = o->__get__(ctx, i);
                 if (v.asNumberObject() || v.asStringObject() || v.isNumber())
                     v = __qmljs_to_string(v, ctx);
index 5903df4..e2e49eb 100644 (file)
@@ -201,7 +201,7 @@ void Object::markObjects()
             }
         }
     }
-    array.markObjects();
+    array.markArrayObjects();
 }
 
 PropertyDescriptor *Object::insertMember(String *s)
@@ -234,7 +234,7 @@ PropertyDescriptor *Object::__getOwnProperty__(ExecutionContext *ctx, String *na
 
 PropertyDescriptor *Object::__getOwnProperty__(ExecutionContext *ctx, uint index)
 {
-    PropertyDescriptor *p = array.at(index);
+    PropertyDescriptor *p = array.arrayAt(index);
     if(p && p->type != PropertyDescriptor::Generic)
         return p;
     if (isStringObject())
@@ -267,7 +267,7 @@ PropertyDescriptor *Object::__getPropertyDescriptor__(ExecutionContext *ctx, uin
 {
     Object *o = this;
     while (o) {
-        PropertyDescriptor *p = o->array.at(index);
+        PropertyDescriptor *p = o->array.arrayAt(index);
         if(p && p->type != PropertyDescriptor::Generic)
             return p;
         if (o->isStringObject()) {
@@ -318,7 +318,7 @@ Value Object::__get__(ExecutionContext *ctx, uint index, bool *hasProperty)
     PropertyDescriptor *pd = 0;
     Object *o = this;
     while (o) {
-        PropertyDescriptor *p = o->array.at(index);
+        PropertyDescriptor *p = o->array.arrayAt(index);
         if (p && p->type != PropertyDescriptor::Generic) {
             pd = p;
             break;
@@ -368,7 +368,7 @@ void Object::__put__(ExecutionContext *ctx, String *name, Value value)
             uint l = value.asArrayLength(ctx, &ok);
             if (!ok)
                 ctx->throwRangeError(value);
-            ok = array.setLength(l);
+            ok = array.setArrayLength(l);
             if (!ok)
                 goto reject;
         } else {
@@ -480,7 +480,7 @@ void Object::__put__(ExecutionContext *ctx, uint index, Value value)
         return;
     }
 
-    array.set(index, value);
+    array.arraySet(index, value);
     return;
 
   reject:
@@ -505,7 +505,7 @@ bool Object::__hasProperty__(const ExecutionContext *ctx, String *name) const
 
 bool Object::__hasProperty__(const ExecutionContext *ctx, uint index) const
 {
-    const PropertyDescriptor *p = array.at(index);
+    const PropertyDescriptor *p = array.arrayAt(index);
     if (p && p->type != PropertyDescriptor::Generic)
         return true;
 
@@ -541,7 +541,7 @@ bool Object::__delete__(ExecutionContext *ctx, String *name)
 
 bool Object::__delete__(ExecutionContext *ctx, uint index)
 {
-    if (array.deleteIndex(index))
+    if (array.deleteArrayIndex(index))
         return true;
     if (ctx->strictMode)
         __qmljs_throw_type_error(ctx);
@@ -572,7 +572,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, String *name, const Pr
             uint l = desc->value.asArrayLength(ctx, &ok);
             if (!ok)
                 ctx->throwRangeError(desc->value);
-            succeeded = array.setLength(l);
+            succeeded = array.setArrayLength(l);
         }
         if (desc->writable == PropertyDescriptor::Disabled)
             lp->writable = PropertyDescriptor::Disabled;
@@ -609,7 +609,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Prop
     PropertyDescriptor *current;
 
     // 15.4.5.1, 4b
-    if (isArrayObject() && index >= array.length() && !memberData.at(ArrayObject::LengthPropertyIndex).isWritable())
+    if (isArrayObject() && index >= array.arrayLength() && !memberData.at(ArrayObject::LengthPropertyIndex).isWritable())
         goto reject;
 
     if (isNonStrictArgumentsObject)
@@ -622,7 +622,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Prop
         if (!extensible)
             goto reject;
         // clause 4
-        PropertyDescriptor *pd = array.insert(index);
+        PropertyDescriptor *pd = array.arrayInsert(index);
         *pd = *desc;
         pd->fullyPopulated();
         return true;
index dd67bee..d8c0e56 100644 (file)
@@ -189,7 +189,7 @@ struct ArrayObject: Object {
     };
 
     ArrayObject(ExecutionContext *ctx) { init(ctx); }
-    ArrayObject(ExecutionContext *ctx, const Array &value): Object(value) { init(ctx); array.setLengthUnchecked(array.length()); }
+    ArrayObject(ExecutionContext *ctx, const Array &value): Object(value) { init(ctx); array.setArrayLengthUnchecked(array.arrayLength()); }
     void init(ExecutionContext *context);
 };
 
index 62f3c30..ecbeaec 100644 (file)
@@ -76,20 +76,20 @@ PropertyDescriptor *ObjectIterator::next(String **name, uint *index)
                 return s->__getOwnProperty__(context, *index);
             }
             flags &= ~CurrentIsString;
-            arrayNode = current->array.sparseBegin();
+            arrayNode = current->array.sparseArrayBegin();
             // iterate until we're past the end of the string
             while (arrayNode && arrayNode->key() < slen)
                 arrayNode = arrayNode->nextNode();
         }
 
         if (!arrayIndex)
-            arrayNode = current->array.sparseBegin();
+            arrayNode = current->array.sparseArrayBegin();
 
         // sparse arrays
         if (arrayNode) {
-            while (arrayNode != current->array.sparseEnd()) {
+            while (arrayNode != current->array.sparseArrayEnd()) {
                 int k = arrayNode->key();
-                p = current->array.at(k);
+                p = current->array.arrayAt(k);
                 arrayNode = arrayNode->nextNode();
                 if (p && (!(flags & EnumberableOnly) || p->isEnumerable())) {
                     arrayIndex = k + 1;
@@ -101,8 +101,8 @@ PropertyDescriptor *ObjectIterator::next(String **name, uint *index)
             arrayIndex = UINT_MAX;
         }
         // dense arrays
-        while (arrayIndex < current->array.length()) {
-            p = current->array.at(arrayIndex);
+        while (arrayIndex < current->array.arrayLength()) {
+            p = current->array.arrayAt(arrayIndex);
             ++arrayIndex;
             if (p && p->type != PropertyDescriptor::Generic && (!(flags & EnumberableOnly) || p->isEnumerable())) {
                 *index = arrayIndex - 1;
index 788d6cd..a026e46 100644 (file)
@@ -337,7 +337,7 @@ Value StringPrototype::method_match(ExecutionContext *parentCtx, Value thisObjec
             previousLastIndex = thisIndex;
         }
         Value matchStr = result.objectValue()->__get__(parentCtx, (uint)0, (bool *)0);
-        a->array.set(n, matchStr);
+        a->array.arraySet(n, matchStr);
         ++n;
     }
     if (!n)
@@ -572,18 +572,18 @@ Value StringPrototype::method_split(ExecutionContext *ctx)
             array->array.push_back(Value::fromString(ctx, text.mid(offset, matchOffsets[0] - offset)));
             offset = qMax(offset + 1, matchOffsets[1]);
 
-            if (array->array.length() >= limit)
+            if (array->array.arrayLength() >= limit)
                 break;
 
             for (int i = 1; i < re->value->captureCount(); ++i) {
                 uint start = matchOffsets[i * 2];
                 uint end = matchOffsets[i * 2 + 1];
                 array->array.push_back(Value::fromString(ctx, text.mid(start, end - start)));
-                if (array->array.length() >= limit)
+                if (array->array.arrayLength() >= limit)
                     break;
             }
         }
-        if (array->array.length() < limit)
+        if (array->array.arrayLength() < limit)
             array->array.push_back(Value::fromString(ctx, text.mid(offset)));
     } else {
         QString separator = separatorValue.toString(ctx)->toQString();
@@ -598,10 +598,10 @@ Value StringPrototype::method_split(ExecutionContext *ctx)
         while ((end = text.indexOf(separator, start)) != -1) {
             array->array.push_back(Value::fromString(ctx, text.mid(start, end - start)));
             start = end + separator.size();
-            if (array->array.length() >= limit)
+            if (array->array.arrayLength() >= limit)
                 break;
         }
-        if (array->array.length() < limit && start != -1)
+        if (array->array.arrayLength() < limit && start != -1)
             array->array.push_back(Value::fromString(ctx, text.mid(start)));
     }
     return result;