From: <bi...@us...> - 2014-08-26 19:11:12
|
Revision: 10413 http://sourceforge.net/p/oorexx/code-0/10413 Author: bigrixx Date: 2014-08-26 19:11:07 +0000 (Tue, 26 Aug 2014) Log Message: ----------- Good place for a checkin Modified Paths: -------------- sandbox/rick/newsource/interpreter/RexxClasses/CoreClasses.orx sandbox/rick/newsource/interpreter/classes/ArrayClass.cpp sandbox/rick/newsource/interpreter/classes/ArrayClass.hpp sandbox/rick/newsource/interpreter/classes/NumberStringClass.cpp sandbox/rick/newsource/interpreter/classes/QueueClass.hpp Modified: sandbox/rick/newsource/interpreter/RexxClasses/CoreClasses.orx =================================================================== --- sandbox/rick/newsource/interpreter/RexxClasses/CoreClasses.orx 2014-08-26 00:02:51 UTC (rev 10412) +++ sandbox/rick/newsource/interpreter/RexxClasses/CoreClasses.orx 2014-08-26 19:11:07 UTC (rev 10413) @@ -131,8 +131,8 @@ ::METHOD string_cls_null return "00"x -// Start of classes that exist only to add collections of methods to -// primitive classes +-- Start of classes that exist only to add collections of methods to +-- primitive classes /*============================================================================*/ /* Additional S U P P L I E R methods */ @@ -958,7 +958,7 @@ .local~objectname = "The Local Directory" -- give the local environment a nicer descriptive name. - // set up the system objects in the local environment + -- set up the system objects in the local environment .local~setentry('STDIN', input) .local~setentry('INPUT',.monitor~new(.stdin)) .input~objectname = "The INPUT monitor" Modified: sandbox/rick/newsource/interpreter/classes/ArrayClass.cpp =================================================================== --- sandbox/rick/newsource/interpreter/classes/ArrayClass.cpp 2014-08-26 00:02:51 UTC (rev 10412) +++ sandbox/rick/newsource/interpreter/classes/ArrayClass.cpp 2014-08-26 19:11:07 UTC (rev 10413) @@ -810,24 +810,24 @@ */ void ArrayClass::openGap(size_t index, size_t elements) { - // is this larger than our current size? If so, we have nothing to move + // is this larger than our current last element? If so, we have nothing to move // but do need to expand the array size to accommodate the additional members - if (index > size()) + if (index > lastItem) { ensureSpace(index + elements - 1); } else { - // the last element to move. NOTE: we check this BEFORE - // expanding the size, otherwise we move too many elements. - char *_end = (char *)slotAddress(this->size() + 1); - // make sure we have space for the additional elements ensureSpace(size() + elements); - /* get the address of first element */ + + // the last element to move. + char *_end = (char *)slotAddress(lastItem + 1); + + // get the start and end of the gap char *_start = (char *)slotAddress(index); char *_target = (char *)slotAddress(index + elements); - /* shift the array over */ + // shift the array section over to create a gap memmove(_target, _start, _end - _start); // now null out all of the slots in the gap, using an @@ -850,9 +850,15 @@ */ void ArrayClass::closeGap(size_t index, size_t elements) { - // if we're beyond the current size, nothing to do - if (index > size()) + // if we're beyond the current last item, nothing to do here + if (index > lastItem) { + // if the index is within the size bounds of the + // array, we need to adjust the size + if (index <= size()) + { + shrink(elements); + } return; } @@ -867,6 +873,21 @@ { clearArrayItem(i); } + + // we could have cleared out the last item when + // we cleared the gap, thus removing the need to + // shift anything + if (lastItem < index) + { + // if the index is within the size bounds of the + // array, we need to adjust the size + if (index <= size()) + { + shrink(elements); + } + return; + } + // get the address of first element and the first item to move. char *_target = (char *)slotAddress(index); char *_start = (char *)slotAddress(index + elements); @@ -876,8 +897,6 @@ memmove(_target, _start, _end - _start); // adjust the last element position lastItem -= elements; - // adjust the size downward - shrink(elements); } @@ -1965,10 +1984,10 @@ // we don't need to reallocate anything here, just adjust the size values if (toSize <= maximumSize) { - // keep both the extension array and our information in sync - // (Both of these could be updating the same information) + // during marking, the main array and the expanson array both mark. If we've + // extended, we need to keep the size at zero in the original. If we've not + // extended, then updating the expansion array size also updates the original. expansionArray->arraySize = toSize; - arraySize = toSize; return; } @@ -1983,7 +2002,7 @@ size_t newSize = size() + extendSize; // now allocate the extension array of the required size + some extra. - ArrayClass *newArray = (ArrayClass *)new_array(newSize); + ArrayClass *newArray = new (toSize, newSize) ArrayClass; // The extension array, by definition, will not be in old space, so // we can just copy everything in one shot. memcpy(newArray->data(), data(), dataSize()); @@ -1999,8 +2018,6 @@ setField(expansionArray, newArray); // keep max Size value in synch maximumSize = newArray->maximumSize; - // make sure size is correct. - newArray->arraySize = newSize; } Modified: sandbox/rick/newsource/interpreter/classes/ArrayClass.hpp =================================================================== --- sandbox/rick/newsource/interpreter/classes/ArrayClass.hpp 2014-08-26 00:02:51 UTC (rev 10412) +++ sandbox/rick/newsource/interpreter/classes/ArrayClass.hpp 2014-08-26 19:11:07 UTC (rev 10413) @@ -213,7 +213,7 @@ void resize(); inline void ensureSpace(size_t newSize) { - // out of bounds? */ + // out of bounds? if (newSize > size()) { // expand to at least the given size Modified: sandbox/rick/newsource/interpreter/classes/NumberStringClass.cpp =================================================================== --- sandbox/rick/newsource/interpreter/classes/NumberStringClass.cpp 2014-08-26 00:02:51 UTC (rev 10412) +++ sandbox/rick/newsource/interpreter/classes/NumberStringClass.cpp 2014-08-26 19:11:07 UTC (rev 10413) @@ -2596,7 +2596,7 @@ state = NUMBER_E; } // other non-digit? We're no longer scanning a number. - else if (inch >= RexxString::ch_ZERO && inch <= RexxString::ch_NINE) + else if (inch < RexxString::ch_ZERO || inch > RexxString::ch_NINE) { return false; } @@ -2614,7 +2614,7 @@ { // not a digit immediately after the period, we don't have a // number any more - if (inch >= RexxString::ch_ZERO && inch <= RexxString::ch_NINE) + if (inch < RexxString::ch_ZERO || inch > RexxString::ch_NINE) { return false; } @@ -2639,7 +2639,7 @@ state = NUMBER_E; } // non-digit other than an 'E'?, no longer a valid numeric. - else if (inch >= RexxString::ch_ZERO && inch <= RexxString::ch_NINE) + else if (inch < RexxString::ch_ZERO || inch > RexxString::ch_NINE) { return false; } Modified: sandbox/rick/newsource/interpreter/classes/QueueClass.hpp =================================================================== --- sandbox/rick/newsource/interpreter/classes/QueueClass.hpp 2014-08-26 00:02:51 UTC (rev 10412) +++ sandbox/rick/newsource/interpreter/classes/QueueClass.hpp 2014-08-26 19:11:07 UTC (rev 10413) @@ -63,10 +63,10 @@ RexxObject *putRexx(RexxInternalObject *value, RexxObject *index); RexxObject *initRexx(RexxObject *initialSize); - inline RexxInternalObject *pop() { return removeFirst();}; - inline RexxInternalObject *pull() { return removeFirst();}; - inline void push(RexxInternalObject *obj) { addFirst(obj);}; - inline void queue(RexxInternalObject *obj) { addLast(obj);}; + inline RexxInternalObject *pop() { return deleteItem(1);} + inline RexxInternalObject *pull() { return deleteItem(1);} + inline void push(RexxInternalObject *obj) { addFirst(obj); } + inline void queue(RexxInternalObject *obj) { addLast(obj); } virtual RexxInternalObject *remove(size_t index); RexxObject *newRexx(RexxObject **init_args, size_t argCount); QueueClass *ofRexx(RexxObject **args, size_t argCount); |