void SyncManagerImpl::AddCreateOpForElementRecurs(RemoteSyncPeer& peer, const ElementPtr& element) { // Construct a CreateOperation for this element XGuid parentGuid = kInvalidXGuid; ElementPtr parent = element->GetParent(); if (parent) { parentGuid = parent->GetGUID(); } { CreateOperationPtr createOp = new CreateOperation( element->GetElementType(), element->GetName(), element->GetGUID(), parentGuid, element->GetXValue(), m_syncContext->GetAuthorityLevel(), m_syncContext); // Add to the list of outgoing ops peer.SendOp(createOp); } // If this is an object element... ObjectElementPtr objElement = ObjectElement::Cast(element); if (objElement) { // Recurs to the children of this element for (int32 i = 0; i < objElement->GetElementCount(); ++i) { AddCreateOpForElementRecurs(peer, objElement->GetElementAt(i)); } } else { // If the element is an array, add Insert operations for all its entries ArrayElement* arrayElement = reflection_cast<ArrayElement>(element); if (arrayElement != nullptr) { int32 numEntries = arrayElement->GetCount(); for (int32 i = 0; i < numEntries; ++i) { InsertOperationPtr insertOp = new InsertOperation( element->GetGUID(), i, arrayElement->GetXValue(i), m_syncContext->GetAuthorityLevel(), m_syncContext); // Add to the list of outgoing ops peer.SendOp(insertOp); } } } }
void add(int cur,Chare *e,int group) { // Just grab the name and nothing else: ArrayElement *elt = (ArrayElement*)e; PUP::er &p=*pp; beginItem(p,cur); p.comment("name"); char *n=elt->ckDebugChareName(); p(n,strlen(n)); free(n); }
void add(int cur, Chare *e, int group) { // Pup the element data ArrayElement *elt = (ArrayElement*)e; PUP::er &p=*pp; beginItem(p,cur); //elt->ckDebugPup(p); // Now ignore any pupper, just copy all the memory as raw data p.comment("name"); char *n=elt->ckDebugChareName(); p(n,strlen(n)); free(n); int type = elt->ckGetChareType(); p.comment("type"); const char *t = _chareTable[type]->name; p((char*)t,strlen(t)); p.comment("value"); int size = _chareTable[type]->size; p((char*)elt,size); }
MapVariant::MapVariant(const std::vector<ArrayElement *> &elems, bool replace /* = true */) { unsigned int size = elems.size(); m_elems.reserve(size); for (unsigned int i = 0; i < size; i++) { ArrayElement *elem = elems[i]; if (elem->hasName()) { uint idx = insertKey(elem->getName(), elem->getHash()); if (idx < m_elems.size()) { if (replace) { Variant *&v = m_elems[idx]; if (v) { ArrayFuncs::release(v); } v = ArrayFuncs::element(elem->getVariant()); } continue; } } else { appendKey(); } m_elems.push_back(ArrayFuncs::element(elem->getVariant())); } }
/** * Adds a new element at the specified index. If index is greater than * the list size the element is appended. * The element is dinamically duplicated so that the caller can release * the element at any time. This method returns the position (0 based) at which * the element has been inserted. It can be different by index if index is out * of the array bounds, in that case element is appended as last element. * It returns -1 in case of errors. * * @param index the insertion position * @param element the element to insert - NULL is not allowed! */ int ArrayList::add(int index, ArrayElement& element) { if (index < 0) { return -1; } int s = size(); if (index > s) { index = s; } Element* newElement = new Element(); newElement->e = element.clone(); newElement->n = NULL; Element* e; if (index == s) { // Inserting the new element at the end e = lastElement; } else { // Inserting the new element at the index-th position e = head; for (int i=0; i<index-1; ++i) { e = e->n; } } if (e == NULL || index == 0) { // // Insertion at the beginning of the array // newElement->n = head; head = newElement; if (e == NULL) { lastElement = newElement; } count++; return index; } if (e->n) { // // Insertion in the middle of the array // newElement->n = e->n; e->n = newElement; } else { // // Insertion at the end of the array // e->n = newElement; lastElement = newElement; } count++; return index; }
/** * Adds a new element at the specified index. If index is greater than * the list size the element is appended. * The element is dinamically duplicated so that the caller can release * the element at any time. This method returns the position (0 based) at which * the element has been inserted. It can be different by index if index is out * of the array bounds, in that case element is appended as last element. * It returns -1 in case of errors. * * @param index the insertion position * @param element the element to insert - NULL is not allowed! */ int ArrayList::add(int index, ArrayElement& element) { if (index < 0) { return -1; } int s = size(); if (index > s) { index = s; } Element* newElement = new Element(); newElement->e = element.clone(); newElement->n = NULL; Element* e; if (index == s) { // Inserting the new element at the end e = lastElement; } else { // Inserting the new element at the index-th position e = head; for (int i=0; i<index-1; ++i) { e = e->n; } } // Check if we are replacing the ghost or one of its neighbors if (iterator == &ghost) { if (e && ghost.n == e->n) { iterator = newElement; } else if (e == NULL && ghost.n == head) { iterator = newElement; } } if (e == NULL || index == 0) { // // Insertion at the beginning of the array // newElement->n = head; head = newElement; if (e == NULL) { lastElement = newElement; } count++; return index; } if (e->n) { // // Insertion in the middle of the array // newElement->n = e->n; e->n = newElement; } else { // // Insertion at the end of the array // e->n = newElement; lastElement = newElement; } count++; return index; }
bool ArrayTest::testSimpleArray() { const std::string code = simpleArrayTestKernel; Analyse analyse(code); KernelFunction function = analyse.getKernelInfo()->getFunctions().front(); std::list<DeclInfo*> varDecls = function.getVarDecls(); std::list<ArrayInfo*> arrayDecls = function.getArrayDecls(); CHECK(isOccupied(varDecls), 0, ON_PRECONDITION); CHECK(varDecls.size() == 1, 0, ON_PRECONDITION); CHECK(isOccupied(arrayDecls), 0, ON_PRECONDITION); CHECK(arrayDecls.size() == 1, 0, ON_PRECONDITION); uint line = 2; ArrayElement* checkElement; ArrayInfoIterator it = arrayDecls.begin(); DeclInfoIterator jt = varDecls.begin(); Array* checkArray = (*it)->array; int array[] = { 1, -2, 3 }; uint idx = 0; while (idx < checkArray->getSize()->getValue()) { checkElement = checkArray->getArrayElement(idx); CHECK(checkElement->getIndex()->getValue() == idx, line, code); CHECK(checkElement->getParameter()->getValue() == array[idx++], line, code); } array[0] = -10; checkElement = checkArray->getArrayElement(idx); CHECK(checkElement->getIndex()->getValue() == 0, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[0], line, code); array[1] = 12 / 2 * -1; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 1, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[1], line, code); array[2] = 10 + 3; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); array[0] = 0; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 0, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[0], line, code); int value = 23; CHECK((*jt)->Parameter->getValue() == value, line, code); array[2] = value; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); CHECK(++it == arrayDecls.end(), 0, ON_POSTCONDITION); CHECK(++jt == varDecls.end(), 0, ON_POSTCONDITION); return true; }
bool ArrayTest::testInitArray() { const std::string code = initArrayTestKernel; Analyse analyse(code); KernelFunction function = analyse.getKernelInfo()->getFunctions().front(); std::list<DeclInfo*> varDecls = function.getVarDecls(); std::list<ArrayInfo*> arrayDecls = function.getArrayDecls(); CHECK(isOccupied(varDecls), 0, ON_PRECONDITION); CHECK(varDecls.size() == 1, 0, ON_PRECONDITION); CHECK(isOccupied(arrayDecls), 0, ON_PRECONDITION); CHECK(arrayDecls.size() == 18, 0, ON_PRECONDITION); //TODO: Implement int array[] = {array2[1], ...} // CHECK(arrayDecls.size() == 20, 0, ON_PRECONDITION); uint line = 1; Array* checkArray; ArrayElement* checkElement; ArrayInfoIterator it = arrayDecls.begin(); DeclInfoIterator jt = varDecls.begin(); // int array1[1] checkArray = (*it)->array; CHECK(checkArray->getSize()->getValue() == 1, ++line, code); checkElement = checkArray->getArrayElement(0); CHECK(checkElement->getIndex()->getValue() == 0, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); // int array2[2] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 2, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array3[3] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 3, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array4[4] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 4, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array5[5] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 5, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array6[6] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 6, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array7[7] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 7, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array8[8] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 8, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array16[16] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 16, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array32[32] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 32, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array64[64] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 64, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int array1024[1024] checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 1024, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == 0, line, code); } // int a[] = {1}; checkArray = (*++it)->array; checkElement = checkArray->getArrayElement(0); CHECK(checkElement->getIndex()->getValue() == 0, ++line, code); CHECK(checkElement->getParameter()->getValue() == 1, line, code); int b[] = { 34, -127495 }; ++line; checkArray = (*++it)->array; for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == b[i], line, code); } int c[] = { 1, -2, 3, -4 }; ++line; checkArray = (*++it)->array; for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == c[i], line, code); } int d[] = { 1025, 5, 18, 23 }; ++line; checkArray = (*++it)->array; for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == d[i], line, code); } int e[] = { 3, 7, 23, 789, 1, -4, 34, -56765, 1, 5656, 123123, -67768, 345, 123, 980, 345, 21, -123, -234, 234, -7678, 23, 5667, 3214, -56, 345 }; ++line; checkArray = (*++it)->array; for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == e[i], line, code); } line += 5; int k = 42; CHECK((*jt)->Parameter->getValue() == k, ++line, code); int f[] = { k, k }; checkArray = (*++it)->array; CHECK(checkArray->getSize()->getValue() == 2, ++line, code); for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { checkElement = checkArray->getArrayElement(i); CHECK(checkElement->getIndex()->getValue() == i, line, code); CHECK(checkElement->getParameter()->getValue() == f[i], line, code); } //TODO: Implement int array[] = {array2[1], ...} // int g[] = {f[0], k}; // checkArray = (*++it)->array; // CHECK(checkArray->getSize()->getValue() == 2, ++line, code); // for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { // checkElement = checkArray->getArrayElement(i); // CHECK(checkElement->getIndex()->getValue() == i, line, code); // CHECK(checkElement->getParameter()->getValue() == g[i], line, code); // } // // int h[] = {k, g[0], k}; // checkArray = (*++it)->array; // CHECK(checkArray->getSize()->getValue() == 3, ++line, code); // for (uint i = 0; i < checkArray->getSize()->getValue(); ++i) { // checkElement = checkArray->getArrayElement(i); // CHECK(checkElement->getIndex()->getValue() == i, line, code); // CHECK(checkElement->getParameter()->getValue() == h[i], line, code); // } CHECK(++it == arrayDecls.end(), 0, ON_POSTCONDITION); CHECK(++jt == varDecls.end(), 0, ON_POSTCONDITION); return true; }
bool ArrayTest::testCalcIndex() { const std::string code = calcIndexTestKernel; Analyse analyse(code); KernelFunction function = analyse.getKernelInfo()->getFunctions().front(); std::list<DeclInfo*> varDecls = function.getVarDecls(); std::list<ArrayInfo*> arrayDecls = function.getArrayDecls(); CHECK(isOccupied(varDecls), 0, ON_PRECONDITION); CHECK(varDecls.size() == 18, 0, ON_PRECONDITION); CHECK(isOccupied(arrayDecls), 0, ON_PRECONDITION); CHECK(arrayDecls.size() == 1, 0, ON_PRECONDITION); uint line = 2; ArrayElement* checkElement; ArrayInfoIterator it = arrayDecls.begin(); DeclInfoIterator jt = varDecls.begin(); Array* checkArray = (*it)->array; int array[] = { 1, 2, 3, 4 }; uint idx = 0; while (idx < checkArray->getSize()->getValue()) { checkElement = checkArray->getArrayElement(idx); CHECK(checkElement->getIndex()->getValue() == idx, line, code); CHECK(checkElement->getParameter()->getValue() == array[idx++], line, code); } array[1 + 1] = 52; checkElement = checkArray->getArrayElement(idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); array[0 - 1 + 2] = 34; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 1, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[1], line, code); array[4 / 2] = -323; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); int i = 0; CHECK((*jt)->Parameter->getValue() == i, ++line, code); array[i] = 123; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == i, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[i], line, code); array[i++] = 23; checkElement = checkArray->getArrayElement(++idx); CHECK((*++jt)->Parameter->getValue() == i, ++line, code); CHECK(checkElement->getIndex()->getValue() == i - 1, line, code); CHECK(checkElement->getParameter()->getValue() == array[i - 1], line, code); array[++i] = 17; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == i, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[i], line, code); CHECK((*++jt)->Parameter->getValue() == i, line, code); array[--i] = 56; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == i, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[i], line, code); CHECK((*++jt)->Parameter->getValue() == i, line, code); array[i--] = -9; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == i + 1, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[i + 1], line, code); CHECK((*++jt)->Parameter->getValue() == i, line, code); array[i + 1] = 5665; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == i + 1, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[i + 1], line, code); int k = array[1 + 3 - 2]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); k = array[i]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); k = array[++i]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); CHECK((*++jt)->Parameter->getValue() == i, line, code); k = array[i++]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); CHECK((*++jt)->Parameter->getValue() == i, line, code); k = array[--i]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); CHECK((*++jt)->Parameter->getValue() == i, line, code); k = array[i--]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); CHECK((*++jt)->Parameter->getValue() == i, line, code); k = array[i + i + 2]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); k = array[++i / 2 + 1]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); CHECK((*++jt)->Parameter->getValue() == i, line, code); CHECK(++it == arrayDecls.end(), 0, ON_POSTCONDITION); CHECK(++jt == varDecls.end(), 0, ON_POSTCONDITION); return true; }
bool ArrayTest::testCalc() { const std::string code = calcTestKernel; Analyse analyse(code); KernelFunction function = analyse.getKernelInfo()->getFunctions().front(); std::list<DeclInfo*> varDecls = function.getVarDecls(); std::list<ArrayInfo*> arrayDecls = function.getArrayDecls(); CHECK(isOccupied(varDecls), 0, ON_PRECONDITION); CHECK(varDecls.size() == 11, 0, ON_PRECONDITION); // CHECK(varDecls.size() == 13, 0, ON_PRECONDITION); CHECK(isOccupied(arrayDecls), 0, ON_PRECONDITION); CHECK(arrayDecls.size() == 1, 0, ON_PRECONDITION); uint line = 2; ArrayElement* checkElement; ArrayInfoIterator it = arrayDecls.begin(); DeclInfoIterator jt = varDecls.begin(); Array* checkArray = (*it)->array; int array[] = { 1, 2, 3, 4 }; uint idx = 0; while (idx < checkArray->getSize()->getValue()) { checkElement = checkArray->getArrayElement(idx); CHECK(checkElement->getIndex()->getValue() == idx, line, code); CHECK(checkElement->getParameter()->getValue() == array[idx++], line, code); } array[1] += 52; checkElement = checkArray->getArrayElement(idx); CHECK(checkElement->getIndex()->getValue() == 1, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[1], line, code); array[2] -= 52; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); array[3] %= 10 - 2; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 3, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[3], line, code); array[3] *= array[1] + 1; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 3, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[3], line, code); int k = array[0]++; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 0, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[0], line, code); CHECK((*jt)->Parameter->getValue() == k, line, code); k = ++array[1]; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 1, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[1], line, code); CHECK((*++jt)->Parameter->getValue() == k, line, code); k = array[2]--; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); CHECK((*++jt)->Parameter->getValue() == k, line, code); k = --array[2]; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); CHECK((*++jt)->Parameter->getValue() == k, line, code); array[3] = --array[2]; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 3, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[3], line, code); checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); array[1] += array[2]--; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 1, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[1], line, code); checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); array[0] *= ++array[1]; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 0, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[0], line, code); checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 1, line, code); CHECK(checkElement->getParameter()->getValue() == array[1], line, code); array[0] = 0; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 0, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[0], line, code); array[1] = array[0]; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 1, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[1], line, code); array[2] = array[1]; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); array[3] = array[2]; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 3, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[3], line, code); // array[array[0] + 1] = 2; // checkElement = checkArray->getArrayElement(++idx); // CHECK(checkElement->getIndex()->getValue() == array[0] + 1, ++line, code); // CHECK(checkElement->getParameter()->getValue() == array[1], line, code); // // array[array[++array[0]] + 1] = 42; // checkElement = checkArray->getArrayElement(++idx); // CHECK(checkElement->getIndex()->getValue() == array[3], ++line, code); // CHECK(checkElement->getParameter()->getValue() == 42, line, code); // checkElement = checkArray->getArrayElement(++idx); // CHECK(checkElement->getIndex()->getValue() == 0, line, code); // CHECK(checkElement->getParameter()->getValue() == array[0], line, code); k = array[0]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); k = array[1]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); k = array[2]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); k = array[3]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); array[2] = 3; checkElement = checkArray->getArrayElement(++idx); CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); CHECK(checkElement->getParameter()->getValue() == array[2], line, code); // k = array[array[array[array[0]]]]; // CHECK((*++jt)->Parameter->getValue() == k, ++line, code); k = 0; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); // k = array[array[array[array[k]]]]; // CHECK((*++jt)->Parameter->getValue() == k, ++line, code); k = 0; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); // ++array[++k]; // CHECK((*++jt)->Parameter->getValue() == k, ++line, code); // checkElement = checkArray->getArrayElement(++idx); // CHECK(checkElement->getIndex()->getValue() == k, line, code); // CHECK(checkElement->getParameter()->getValue() == array[k], line, code); k = array[1]; CHECK((*++jt)->Parameter->getValue() == k, ++line, code); // array[2] = array[2]++; // checkElement = checkArray->getArrayElement(++idx); // CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); // CHECK(checkElement->getParameter()->getValue() == array[2] + 1, line, code); // checkElement = checkArray->getArrayElement(++idx); // CHECK(checkElement->getIndex()->getValue() == 2, line, code); // CHECK(checkElement->getParameter()->getValue() == array[2], line, code); // array[2] = ++array[2]; // checkElement = checkArray->getArrayElement(++idx); // CHECK(checkElement->getIndex()->getValue() == 2, ++line, code); // CHECK(checkElement->getParameter()->getValue() == array[2], line, code); // checkElement = checkArray->getArrayElement(++idx); // CHECK(checkElement->getIndex()->getValue() == 2, line, code); // CHECK(checkElement->getParameter()->getValue() == array[2], line, code); CHECK(++it == arrayDecls.end(), 0, ON_POSTCONDITION); CHECK(++jt == varDecls.end(), 0, ON_POSTCONDITION); return true; }