Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

This patch adds Resizable*Array pmcs as the counterparts to Fixed*Array

pmcs.  It does so by inheriting from them, so the Fixed ones are changed
too.

Courtesy of Matt Fowles <fowles@sccs.swarthmore.edu>


git-svn-id: https://svn.parrot.org/parrot/trunk@6220 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 6a546727950e8f8775a973f6bc42a0ee5ca04c45 1 parent c455897
Dan Sugalski authored
View
10 MANIFEST
@@ -82,6 +82,11 @@ classes/pmc.num []
classes/pointer.pmc []
classes/random.pmc []
classes/ref.pmc []
+classes/resizablebooleanarray.pmc []
+classes/resizablefloatarray.pmc []
+classes/resizableintegerarray.pmc []
+classes/resizablepmcarray.pmc []
+classes/resizablestringarray.pmc []
classes/retcontinuation.pmc []
classes/sarray.pmc []
classes/scalar.pmc []
@@ -2734,6 +2739,11 @@ t/pmc/perlstring.t []
t/pmc/pmc.t []
t/pmc/prop.t []
t/pmc/ref.t []
+t/pmc/resizablebooleanarray.t []
+t/pmc/resizablefloatarray.t []
+t/pmc/resizableintegerarray.t []
+t/pmc/resizablepmcarray.t []
+t/pmc/resizablestringarray.t []
t/pmc/sarray.t []
t/pmc/scratchpad.t []
t/pmc/signal.t []
View
32 classes/fixedbooleanarray.pmc
@@ -112,7 +112,7 @@ fixed sized array).
*/
INTVAL get_bool () {
- INTVAL size = DYNSELF.elements();
+ INTVAL size = DYNDYNSELF.elements();
return (INTVAL)(size != 0);
}
@@ -139,7 +139,7 @@ Returns the number of elements in the array.
*/
INTVAL get_integer () {
- return DYNSELF.elements();
+ return DYNDYNSELF.elements();
}
@@ -176,7 +176,7 @@ Returns the integer value of the element at index C<*key>.
INTVAL get_integer_keyed (PMC* key) {
/* simple int keys only */
INTVAL k = key_integer(INTERP, key);
- return SELF.get_integer_keyed_int(k);
+ return DYNSELF.get_integer_keyed_int(k);
}
@@ -191,7 +191,7 @@ Returns the floating-point value of the element at index C<key>.
*/
FLOATVAL get_number_keyed_int (INTVAL key) {
- return (FLOATVAL)SELF.get_integer_keyed_int(key);
+ return (FLOATVAL)DYNSELF.get_integer_keyed_int(key);
}
/*
@@ -206,7 +206,7 @@ Returns the floating-point value of the element at index C<*key>.
FLOATVAL get_number_keyed (PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_number_keyed_int(k);
+ return DYNSELF.get_number_keyed_int(k);
}
/*
@@ -221,7 +221,7 @@ Returns the Parrot string value of the element at index C<key>.
STRING* get_string_keyed_int (INTVAL key) {
PMC *temp;
- temp = SELF.get_pmc_keyed_int(key);
+ temp = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_string(INTERP, temp);
}
@@ -237,7 +237,7 @@ Returns the Parrot string value of the element at index C<*key>.
STRING* get_string_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_string_keyed_int(k);
+ return DYNSELF.get_string_keyed_int(k);
}
@@ -256,7 +256,7 @@ Returns the PMC value of the element at index C<key>.
INTVAL val;
ret = pmc_new(INTERP, enum_class_Boolean);
- val = SELF.get_integer_keyed_int(key);
+ val = DYNSELF.get_integer_keyed_int(key);
VTABLE_set_integer_native(INTERP, ret, val);
return ret;
}
@@ -273,7 +273,7 @@ Returns the PMC value of the element at index C<*key>.
PMC* get_pmc_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_pmc_keyed_int(k);
+ return DYNSELF.get_pmc_keyed_int(k);
}
/*
@@ -327,7 +327,7 @@ Sets the integer value of the element at index C<key> to C<value>.
void set_integer_keyed (PMC *key, INTVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_integer_keyed_int(k, value);
+ DYNSELF.set_integer_keyed_int(k, value);
}
/*
@@ -342,7 +342,7 @@ C<value>.
*/
void set_number_keyed_int (INTVAL key, FLOATVAL value) {
- SELF.set_integer_keyed_int(key, (INTVAL)(value != 0.0));
+ DYNSELF.set_integer_keyed_int(key, (INTVAL)(value != 0.0));
}
/*
@@ -359,7 +359,7 @@ C<value>.
void set_number_keyed(PMC *key, FLOATVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_number_keyed_int(k, value);
+ DYNSELF.set_number_keyed_int(k, value);
}
/*
@@ -379,7 +379,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
tempPMC = pmc_new(INTERP, enum_class_Boolean);
VTABLE_set_string_native(INTERP, tempPMC, value);
tempInt = VTABLE_get_integer(INTERP, tempPMC);
- SELF.set_integer_keyed_int(key, tempInt);
+ DYNSELF.set_integer_keyed_int(key, tempInt);
}
/*
@@ -396,7 +396,7 @@ C<value>.
void set_string_keyed(PMC *key, STRING* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_string_keyed_int(k, value);
+ DYNSELF.set_string_keyed_int(k, value);
}
/*
@@ -413,7 +413,7 @@ Sets the PMC value of the element at index C<key> to C<*src>.
INTVAL tempInt;
tempInt = VTABLE_get_integer(INTERP, src);
- SELF.set_integer_keyed_int(key, tempInt);
+ DYNSELF.set_integer_keyed_int(key, tempInt);
}
/*
@@ -430,7 +430,7 @@ C<value>.
void set_pmc_keyed(PMC *key, PMC* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_pmc_keyed_int(k, value);
+ DYNSELF.set_pmc_keyed_int(k, value);
}
}
View
32 classes/fixedfloatarray.pmc
@@ -112,7 +112,7 @@ fixed sized array).
*/
INTVAL get_bool () {
- INTVAL size = DYNSELF.elements();
+ INTVAL size = DYNDYNSELF.elements();
return (INTVAL)(size != 0);
}
@@ -139,7 +139,7 @@ Returns the number of elements in the array.
*/
INTVAL get_integer () {
- return DYNSELF.elements();
+ return DYNDYNSELF.elements();
}
@@ -154,7 +154,7 @@ Returns the integer value of the element at index C<key>.
*/
INTVAL get_integer_keyed_int (INTVAL key) {
- return (INTVAL)SELF.get_number_keyed_int(key);
+ return (INTVAL)DYNSELF.get_number_keyed_int(key);
}
/*
@@ -170,7 +170,7 @@ Returns the integer value of the element at index C<*key>.
INTVAL get_integer_keyed (PMC* key) {
/* simple int keys only */
INTVAL k = key_integer(INTERP, key);
- return SELF.get_integer_keyed_int(k);
+ return DYNSELF.get_integer_keyed_int(k);
}
@@ -206,7 +206,7 @@ Returns the floating-point value of the element at index C<*key>.
FLOATVAL get_number_keyed (PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_number_keyed_int(k);
+ return DYNSELF.get_number_keyed_int(k);
}
/*
@@ -221,7 +221,7 @@ Returns the Parrot string value of the element at index C<key>.
STRING* get_string_keyed_int (INTVAL key) {
PMC *temp;
- temp = SELF.get_pmc_keyed_int(key);
+ temp = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_string(INTERP, temp);
}
@@ -237,7 +237,7 @@ Returns the Parrot string value of the element at index C<*key>.
STRING* get_string_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_string_keyed_int(k);
+ return DYNSELF.get_string_keyed_int(k);
}
@@ -256,7 +256,7 @@ Returns the PMC value of the element at index C<key>.
FLOATVAL val;
ret = pmc_new(INTERP, enum_class_Float);
- val = SELF.get_number_keyed_int(key);
+ val = DYNSELF.get_number_keyed_int(key);
VTABLE_set_number_native(INTERP, ret, val);
return ret;
}
@@ -273,7 +273,7 @@ Returns the PMC value of the element at index C<*key>.
PMC* get_pmc_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_pmc_keyed_int(k);
+ return DYNSELF.get_pmc_keyed_int(k);
}
/*
@@ -305,7 +305,7 @@ Sets the integer value of the element at index C<key> to C<value>.
*/
void set_integer_keyed_int (INTVAL key, INTVAL value) {
- SELF.set_number_keyed_int(key, (FLOATVAL)value);
+ DYNSELF.set_number_keyed_int(key, (FLOATVAL)value);
}
/*
@@ -321,7 +321,7 @@ Sets the integer value of the element at index C<key> to C<value>.
void set_integer_keyed (PMC *key, INTVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_integer_keyed_int(k, value);
+ DYNSELF.set_integer_keyed_int(k, value);
}
/*
@@ -359,7 +359,7 @@ C<value>.
void set_number_keyed(PMC *key, FLOATVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_number_keyed_int(k, value);
+ DYNSELF.set_number_keyed_int(k, value);
}
/*
@@ -379,7 +379,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
tempPMC = pmc_new(INTERP, enum_class_Float);
VTABLE_set_string_native(INTERP, tempPMC, value);
tempNum = VTABLE_get_number(INTERP, tempPMC);
- SELF.set_number_keyed_int(key, tempNum);
+ DYNSELF.set_number_keyed_int(key, tempNum);
}
/*
@@ -396,7 +396,7 @@ C<value>.
void set_string_keyed(PMC *key, STRING* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_string_keyed_int(k, value);
+ DYNSELF.set_string_keyed_int(k, value);
}
/*
@@ -412,7 +412,7 @@ Sets the PMC value of the element at index C<key> to C<*src>.
void set_pmc_keyed_int (INTVAL key, PMC* src) {
FLOATVAL tempNum;
tempNum = VTABLE_get_number(INTERP, src);
- SELF.set_number_keyed_int(key, tempNum);
+ DYNSELF.set_number_keyed_int(key, tempNum);
}
/*
@@ -429,7 +429,7 @@ C<value>.
void set_pmc_keyed(PMC *key, PMC* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_pmc_keyed_int(k, value);
+ DYNSELF.set_pmc_keyed_int(k, value);
}
}
View
32 classes/fixedintegerarray.pmc
@@ -112,7 +112,7 @@ fixed sized array).
*/
INTVAL get_bool () {
- INTVAL size = DYNSELF.elements();
+ INTVAL size = DYNDYNSELF.elements();
return (INTVAL)(size != 0);
}
@@ -139,7 +139,7 @@ Returns the number of elements in the array.
*/
INTVAL get_integer () {
- return DYNSELF.elements();
+ return DYNDYNSELF.elements();
}
@@ -176,7 +176,7 @@ Returns the integer value of the element at index C<*key>.
INTVAL get_integer_keyed (PMC* key) {
/* simple int keys only */
INTVAL k = key_integer(INTERP, key);
- return SELF.get_integer_keyed_int(k);
+ return DYNSELF.get_integer_keyed_int(k);
}
@@ -191,7 +191,7 @@ Returns the floating-point value of the element at index C<key>.
*/
FLOATVAL get_number_keyed_int (INTVAL key) {
- return (FLOATVAL)SELF.get_integer_keyed_int(key);
+ return (FLOATVAL)DYNSELF.get_integer_keyed_int(key);
}
/*
@@ -206,7 +206,7 @@ Returns the floating-point value of the element at index C<*key>.
FLOATVAL get_number_keyed (PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_number_keyed_int(k);
+ return DYNSELF.get_number_keyed_int(k);
}
/*
@@ -221,7 +221,7 @@ Returns the Parrot string value of the element at index C<key>.
STRING* get_string_keyed_int (INTVAL key) {
PMC *temp;
- temp = SELF.get_pmc_keyed_int(key);
+ temp = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_string(INTERP, temp);
}
@@ -237,7 +237,7 @@ Returns the Parrot string value of the element at index C<*key>.
STRING* get_string_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_string_keyed_int(k);
+ return DYNSELF.get_string_keyed_int(k);
}
@@ -256,7 +256,7 @@ Returns the PMC value of the element at index C<key>.
INTVAL val;
ret = pmc_new(INTERP, enum_class_Integer);
- val = SELF.get_integer_keyed_int(key);
+ val = DYNSELF.get_integer_keyed_int(key);
VTABLE_set_integer_native(INTERP, ret, val);
return ret;
}
@@ -273,7 +273,7 @@ Returns the PMC value of the element at index C<*key>.
PMC* get_pmc_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_pmc_keyed_int(k);
+ return DYNSELF.get_pmc_keyed_int(k);
}
/*
@@ -327,7 +327,7 @@ Sets the integer value of the element at index C<key> to C<value>.
void set_integer_keyed (PMC *key, INTVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_integer_keyed_int(k, value);
+ DYNSELF.set_integer_keyed_int(k, value);
}
/*
@@ -342,7 +342,7 @@ C<value>.
*/
void set_number_keyed_int (INTVAL key, FLOATVAL value) {
- SELF.set_integer_keyed_int(key, (INTVAL)value);
+ DYNSELF.set_integer_keyed_int(key, (INTVAL)value);
}
/*
@@ -359,7 +359,7 @@ C<value>.
void set_number_keyed(PMC *key, FLOATVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_number_keyed_int(k, value);
+ DYNSELF.set_number_keyed_int(k, value);
}
/*
@@ -379,7 +379,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
tempPMC = pmc_new(INTERP, enum_class_Integer);
VTABLE_set_string_native(INTERP, tempPMC, value);
tempInt = VTABLE_get_integer(INTERP, tempPMC);
- SELF.set_integer_keyed_int(key, tempInt);
+ DYNSELF.set_integer_keyed_int(key, tempInt);
}
/*
@@ -396,7 +396,7 @@ C<value>.
void set_string_keyed(PMC *key, STRING* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_string_keyed_int(k, value);
+ DYNSELF.set_string_keyed_int(k, value);
}
/*
@@ -413,7 +413,7 @@ Sets the PMC value of the element at index C<key> to C<*src>.
INTVAL tempInt;
tempInt = VTABLE_get_integer(INTERP, src);
- SELF.set_integer_keyed_int(key, tempInt);
+ DYNSELF.set_integer_keyed_int(key, tempInt);
}
/*
@@ -430,7 +430,7 @@ C<value>.
void set_pmc_keyed(PMC *key, PMC* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_pmc_keyed_int(k, value);
+ DYNSELF.set_pmc_keyed_int(k, value);
}
}
View
32 classes/fixedpmcarray.pmc
@@ -137,7 +137,7 @@ fixed sized array).
*/
INTVAL get_bool () {
- INTVAL size = DYNSELF.elements();
+ INTVAL size = DYNDYNSELF.elements();
return (INTVAL)(size != 0);
}
@@ -164,7 +164,7 @@ Returns the number of elements in the array.
*/
INTVAL get_integer () {
- return DYNSELF.elements();
+ return DYNDYNSELF.elements();
}
@@ -179,7 +179,7 @@ Returns the integer value of the element at index C<key>.
*/
INTVAL get_integer_keyed_int (INTVAL key) {
- PMC *tempPMC = SELF.get_pmc_keyed_int(key);
+ PMC *tempPMC = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_integer(INTERP, tempPMC);
}
@@ -196,7 +196,7 @@ Returns the integer value of the element at index C<*key>.
INTVAL get_integer_keyed (PMC* key) {
/* simple int keys only */
INTVAL k = key_integer(INTERP, key);
- return SELF.get_integer_keyed_int(k);
+ return DYNSELF.get_integer_keyed_int(k);
}
@@ -211,7 +211,7 @@ Returns the floating-point value of the element at index C<key>.
*/
FLOATVAL get_number_keyed_int (INTVAL key) {
- PMC *tempPMC = SELF.get_pmc_keyed_int(key);
+ PMC *tempPMC = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_number(INTERP, tempPMC);
}
@@ -227,7 +227,7 @@ Returns the floating-point value of the element at index C<*key>.
FLOATVAL get_number_keyed (PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_number_keyed_int(k);
+ return DYNSELF.get_number_keyed_int(k);
}
/*
@@ -241,7 +241,7 @@ Returns the Parrot string value of the element at index C<key>.
*/
STRING* get_string_keyed_int (INTVAL key) {
- PMC *tempPMC = SELF.get_pmc_keyed_int(key);
+ PMC *tempPMC = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_string(INTERP, tempPMC);
}
@@ -257,7 +257,7 @@ Returns the Parrot string value of the element at index C<*key>.
STRING* get_string_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_string_keyed_int(k);
+ return DYNSELF.get_string_keyed_int(k);
}
@@ -293,7 +293,7 @@ Returns the PMC value of the element at index C<*key>.
PMC* get_pmc_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_pmc_keyed_int(k);
+ return DYNSELF.get_pmc_keyed_int(k);
}
/*
@@ -335,7 +335,7 @@ Sets the integer value of the element at index C<key> to C<value>.
val = pmc_new(INTERP, enum_class_Integer);
VTABLE_set_integer_native(INTERP, val, value);
- SELF.set_pmc_keyed_int(key, val);
+ DYNSELF.set_pmc_keyed_int(key, val);
}
/*
@@ -351,7 +351,7 @@ Sets the integer value of the element at index C<key> to C<value>.
void set_integer_keyed (PMC *key, INTVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_integer_keyed_int(k, value);
+ DYNSELF.set_integer_keyed_int(k, value);
}
/*
@@ -370,7 +370,7 @@ C<value>.
val = pmc_new(INTERP, enum_class_Float);
VTABLE_set_number_native(INTERP, val, value);
- SELF.set_pmc_keyed_int(key, val);
+ DYNSELF.set_pmc_keyed_int(key, val);
}
/*
@@ -387,7 +387,7 @@ C<value>.
void set_number_keyed(PMC *key, FLOATVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_number_keyed_int(k, value);
+ DYNSELF.set_number_keyed_int(k, value);
}
/*
@@ -405,7 +405,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
val = pmc_new(INTERP, enum_class_PerlString);
VTABLE_set_string_native(INTERP, val, value);
- SELF.set_pmc_keyed_int(key, val);
+ DYNSELF.set_pmc_keyed_int(key, val);
}
/*
@@ -422,7 +422,7 @@ C<value>.
void set_string_keyed(PMC *key, STRING* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_string_keyed_int(k, value);
+ DYNSELF.set_string_keyed_int(k, value);
}
/*
@@ -459,7 +459,7 @@ C<value>.
void set_pmc_keyed(PMC *key, PMC* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_pmc_keyed_int(k, value);
+ DYNSELF.set_pmc_keyed_int(k, value);
}
}
View
32 classes/fixedstringarray.pmc
@@ -136,7 +136,7 @@ fixed sized array).
*/
INTVAL get_bool () {
- INTVAL size = DYNSELF.elements();
+ INTVAL size = DYNDYNSELF.elements();
return (INTVAL)(size != 0);
}
@@ -163,7 +163,7 @@ Returns the number of elements in the array.
*/
INTVAL get_integer () {
- return DYNSELF.elements();
+ return DYNDYNSELF.elements();
}
@@ -178,7 +178,7 @@ Returns the integer value of the element at index C<key>.
*/
INTVAL get_integer_keyed_int (INTVAL key) {
- PMC *tempPMC = SELF.get_pmc_keyed_int(key);
+ PMC *tempPMC = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_integer(INTERP, tempPMC);
}
@@ -195,7 +195,7 @@ Returns the integer value of the element at index C<*key>.
INTVAL get_integer_keyed (PMC* key) {
/* simple int keys only */
INTVAL k = key_integer(INTERP, key);
- return SELF.get_integer_keyed_int(k);
+ return DYNSELF.get_integer_keyed_int(k);
}
@@ -210,7 +210,7 @@ Returns the floating-point value of the element at index C<key>.
*/
FLOATVAL get_number_keyed_int (INTVAL key) {
- PMC *tempPMC = SELF.get_pmc_keyed_int(key);
+ PMC *tempPMC = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_number(INTERP, tempPMC);
}
@@ -226,7 +226,7 @@ Returns the floating-point value of the element at index C<*key>.
FLOATVAL get_number_keyed (PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_number_keyed_int(k);
+ return DYNSELF.get_number_keyed_int(k);
}
/*
@@ -261,7 +261,7 @@ Returns the Parrot string value of the element at index C<*key>.
STRING* get_string_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_string_keyed_int(k);
+ return DYNSELF.get_string_keyed_int(k);
}
@@ -280,7 +280,7 @@ Returns the PMC value of the element at index C<key>.
STRING *val;
ret = pmc_new(INTERP, enum_class_PerlString);
- val = SELF.get_string_keyed_int(key);
+ val = DYNSELF.get_string_keyed_int(key);
VTABLE_set_string_native(INTERP, ret, val);
return ret;
}
@@ -297,7 +297,7 @@ Returns the PMC value of the element at index C<*key>.
PMC* get_pmc_keyed(PMC* key) {
INTVAL k = key_integer(INTERP, key);
- return SELF.get_pmc_keyed_int(k);
+ return DYNSELF.get_pmc_keyed_int(k);
}
/*
@@ -335,7 +335,7 @@ Sets the integer value of the element at index C<key> to C<value>.
ret = pmc_new(INTERP, enum_class_PerlString);
VTABLE_set_integer_native(INTERP, ret, value);
val = VTABLE_get_string(INTERP, ret);
- SELF.set_string_keyed_int(key, val);
+ DYNSELF.set_string_keyed_int(key, val);
}
/*
@@ -351,7 +351,7 @@ Sets the integer value of the element at index C<key> to C<value>.
void set_integer_keyed (PMC *key, INTVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_integer_keyed_int(k, value);
+ DYNSELF.set_integer_keyed_int(k, value);
}
/*
@@ -372,7 +372,7 @@ C<value>.
ret = pmc_new(INTERP, enum_class_PerlString);
VTABLE_set_number_native(INTERP, ret, value);
val = VTABLE_get_string(INTERP, ret);
- SELF.set_string_keyed_int(key, val);
+ DYNSELF.set_string_keyed_int(key, val);
}
/*
@@ -389,7 +389,7 @@ C<value>.
void set_number_keyed(PMC *key, FLOATVAL value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_number_keyed_int(k, value);
+ DYNSELF.set_number_keyed_int(k, value);
}
/*
@@ -426,7 +426,7 @@ C<value>.
void set_string_keyed(PMC *key, STRING* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_string_keyed_int(k, value);
+ DYNSELF.set_string_keyed_int(k, value);
}
/*
@@ -443,7 +443,7 @@ Sets the PMC value of the element at index C<key> to C<*src>.
STRING *temp;
temp = VTABLE_get_string(INTERP, src);
- SELF.set_string_keyed_int(key, temp);
+ DYNSELF.set_string_keyed_int(key, temp);
}
/*
@@ -460,7 +460,7 @@ C<value>.
void set_pmc_keyed(PMC *key, PMC* value) {
INTVAL k;
k = key_integer(INTERP, key);
- SELF.set_pmc_keyed_int(k, value);
+ DYNSELF.set_pmc_keyed_int(k, value);
}
}
View
118 classes/resizablebooleanarray.pmc
@@ -0,0 +1,118 @@
+/*
+Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+$Id$
+
+=head1 NAME
+
+classes/resizablebooleanarray.pmc - resizable size array for booleans only
+
+=head1 DESCRIPTION
+
+This class, ResizableBooleanArray, implements an array of resizable size, which stores booleans,
+it uses Boolean PMCs for all of the conversions
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
+#include "parrot/parrot.h"
+
+pmclass ResizableBooleanArray extends FixedBooleanArray need_ext does array {
+
+/*
+
+=item C<INTVAL get_integer_keyed_int(INTVAL key)>
+
+Returns the integer value of the element at index C<key>.
+
+=cut
+
+*/
+
+ INTVAL get_integer_keyed_int (INTVAL key) {
+ INTVAL *data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableBooleanArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (INTVAL *)PMC_data(SELF);
+ return data[key];
+ }
+
+
+/*
+
+=item C<void set_integer_native(INTVAL size)>
+
+Resizes the array to C<size> elements.
+
+=cut
+
+*/
+
+ void set_integer_native (INTVAL size) {
+
+ if (size < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableBooleanArray: Can't resize!\n");
+
+ PMC_int_val(SELF) = size;
+ PMC_data(SELF) = mem_sys_realloc(PMC_data(SELF), size*sizeof(INTVAL));
+ PObj_active_destroy_SET(SELF);
+ }
+
+/*
+
+=item C<void set_integer_keyed_int(INTVAL key, INTVAL value)>
+
+Sets the integer value of the element at index C<key> to C<value>.
+
+=cut
+
+*/
+
+ void set_integer_keyed_int (INTVAL key, INTVAL value) {
+ INTVAL *data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableBooleanArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (INTVAL*)PMC_data(SELF);
+ data[key] = (value != 0);
+ }
+
+}
+
+/*
+
+=back
+
+=head1 SEE ALSO
+
+F<docs/pdds/pdd03_calling_conventions.pod>.
+
+=head1 HISTORY
+
+Initial version 2004.06.11 by Matt Fowles
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+*/
View
117 classes/resizablefloatarray.pmc
@@ -0,0 +1,117 @@
+/*
+Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+$Id$
+
+=head1 NAME
+
+classes/resizablefloatarray.pmc - resizable size array for floating point numbers only
+
+=head1 DESCRIPTION
+
+This class, ResizableFloatArray, implements an array of resizable size, which stored FLOATVALs,
+it uses Float PMCs to do all necessary conversions
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
+#include "parrot/parrot.h"
+
+pmclass ResizableFloatArray extends FixedFloatArray need_ext does array {
+
+
+/*
+
+=item C<FLOATVAL get_number_keyed_int(INTVAL key)>
+
+Returns the floating-point value of the element at index C<key>.
+
+=cut
+
+*/
+
+ FLOATVAL get_number_keyed_int (INTVAL key) {
+ FLOATVAL *data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableFloatArray: index out of bounds!\n");
+ if (key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (FLOATVAL *)PMC_data(SELF);
+ return data[key];
+ }
+
+
+/*
+
+=item C<void set_integer_native(INTVAL size)>
+
+Resizes the array to C<size> elements.
+
+=cut
+
+*/
+
+ void set_integer_native (INTVAL size) {
+ if (size < 0)
+ internal_exception(OUT_OF_BOUNDS, "ResizableFloatArray: Can't resize!\n");
+ PMC_int_val(SELF) = size;
+ PMC_data(SELF) = mem_sys_realloc(PMC_data(SELF), size*sizeof(FLOATVAL));
+ PObj_active_destroy_SET(SELF);
+ }
+
+/*
+
+=item C<void set_number_keyed_int(INTVAL key, FLOATVAL value)>
+
+Sets the floating-point value of the element at index C<key> to
+C<value>.
+
+=cut
+
+*/
+
+ void set_number_keyed_int (INTVAL key, FLOATVAL value) {
+ FLOATVAL *data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableFloatArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (FLOATVAL*)PMC_data(SELF);
+ data[key] = value;
+ }
+
+}
+
+/*
+
+=back
+
+=head1 SEE ALSO
+
+F<docs/pdds/pdd03_calling_conventions.pod>.
+
+=head1 HISTORY
+
+Initial version 2004.06.11 by Matt Fowles
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+*/
View
114 classes/resizableintegerarray.pmc
@@ -0,0 +1,114 @@
+/*
+Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+$Id$
+
+=head1 NAME
+
+classes/resizableintegerarray.pmc - resizable size array for integers only
+
+=head1 DESCRIPTION
+
+This class, ResizableIntegerArray, implements an array of resizable size, which stored INTVALs,
+it uses Integer PMCs for all of the conversions
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
+#include "parrot/parrot.h"
+
+pmclass ResizableIntegerArray extends FixedIntegerArray need_ext does array {
+
+/*
+
+=item C<INTVAL get_integer_keyed_int(INTVAL key)>
+
+Returns the integer value of the element at index C<key>.
+
+=cut
+
+*/
+
+ INTVAL get_integer_keyed_int (INTVAL key) {
+ INTVAL *data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableIntegerArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (INTVAL *)PMC_data(SELF);
+ return data[key];
+ }
+
+/*
+
+=item C<void set_integer_native(INTVAL size)>
+
+Resizes the array to C<size> elements.
+
+=cut
+
+*/
+
+ void set_integer_native (INTVAL size) {
+ if (size < 0)
+ internal_exception(OUT_OF_BOUNDS, "ResizableIntegerArray: Can't resize!\n");
+ PMC_int_val(SELF) = size;
+ PMC_data(SELF) = mem_sys_realloc(PMC_data(SELF), size*sizeof(INTVAL));
+ PObj_active_destroy_SET(SELF);
+ }
+
+/*
+
+=item C<void set_integer_keyed_int(INTVAL key, INTVAL value)>
+
+Sets the integer value of the element at index C<key> to C<value>.
+
+=cut
+
+*/
+
+ void set_integer_keyed_int (INTVAL key, INTVAL value) {
+ INTVAL *data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableIntegerArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (INTVAL*)PMC_data(SELF);
+ data[key] = value;
+ }
+
+}
+
+/*
+
+=back
+
+=head1 SEE ALSO
+
+F<docs/pdds/pdd03_calling_conventions.pod>.
+
+=head1 HISTORY
+
+Initial version 2004.06.11 by Matt Fowles
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+*/
View
129 classes/resizablepmcarray.pmc
@@ -0,0 +1,129 @@
+/*
+Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+$Id$
+
+=head1 NAME
+
+classes/resizablepmcarray.pmc - resizable size array for PMCs only
+
+=head1 DESCRIPTION
+
+This class, ResizablePMCArray, implements an array of resizable size, which stores PMCs,
+it puts things into Integer, Float, or String PMCs as appropriate
+TODO currently this uses PerlString instead of String PMCs.
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
+#include "parrot/parrot.h"
+
+pmclass ResizablePMCArray extends FixedPMCArray need_ext does array {
+
+
+/*
+
+=item C<PMC *get_pmc_keyed_int(INTVAL key)>
+
+Returns the PMC value of the element at index C<key>.
+
+=cut
+
+*/
+
+ PMC* get_pmc_keyed_int (INTVAL key) {
+ PMC **data;
+ PMC *res;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizablePMCArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (PMC **)PMC_data(SELF);
+ if(data[key] == PMCNULL)
+ data[key] = pmc_new(INTERP, enum_class_Undef);
+ return data[key];
+ }
+
+
+/*
+
+=item C<void set_integer_native(INTVAL size)>
+
+Resizes the array to C<size> elements.
+
+=cut
+
+*/
+
+ void set_integer_native (INTVAL size) {
+ int i;
+ PMC **data;
+
+ if (size < 0)
+ internal_exception(OUT_OF_BOUNDS, "ResizablePMCArray: Can't resize!\n");
+
+ data = (PMC**)mem_sys_realloc(PMC_data(SELF), size*sizeof(PMC*));
+ for(i = PMC_int_val(SELF); i < size; i++)
+ data[i] = PMCNULL;
+
+ PMC_int_val(SELF) = size;
+ PMC_data(SELF) = data;
+ PObj_custom_mark_destroy_SETALL(SELF);
+ }
+
+
+/*
+
+=item C<void set_pmc_keyed_int(INTVAL key, PMC *src)>
+
+Sets the PMC value of the element at index C<key> to C<*src>.
+
+=cut
+
+*/
+
+ void set_pmc_keyed_int (INTVAL key, PMC* src) {
+ PMC **data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizablePMCArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (PMC**)PMC_data(SELF);
+ data[key] = src;
+ }
+
+}
+
+/*
+
+=back
+
+=head1 SEE ALSO
+
+F<docs/pdds/pdd03_calling_conventions.pod>.
+
+=head1 HISTORY
+
+Initial version 2004.06.11 by Matt Fowles
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+*/
View
123 classes/resizablestringarray.pmc
@@ -0,0 +1,123 @@
+/*
+Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+$Id$
+
+=head1 NAME
+
+classes/resizablestringarray.pmc - resizable size array for strings only
+
+=head1 DESCRIPTION
+
+This class, ResizableStringArray, implements an array of resizable size, which stored STRING*
+TODO: it uses PerlString's internally to perform conversion, but it should use String PMCs
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
+#include "parrot/parrot.h"
+
+pmclass ResizableStringArray extends FixedStringArray need_ext does array {
+
+/*
+
+=item C<STRING *get_string_keyed_int(INTVAL key)>
+
+Returns the Parrot string value of the element at index C<key>.
+
+=cut
+
+*/
+
+ STRING* get_string_keyed_int (INTVAL key) {
+ STRING **data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableStringArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (STRING **)PMC_data(SELF);
+ return data[key];
+ }
+
+/*
+
+=item C<void set_integer_native(INTVAL size)>
+
+Resizes the array to C<size> elements.
+
+=cut
+
+*/
+
+ void set_integer_native (INTVAL size) {
+ int i;
+ STRING **data;
+ if (size < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableStringArray: Can't resize!\n");
+
+ data = mem_sys_realloc(PMC_data(SELF), size*sizeof(STRING*));
+ for(i = PMC_int_val(SELF); i < size; i++)
+ data[i] = NULL;
+
+ PMC_int_val(SELF) = size;
+ PMC_data(SELF) = data;
+ PObj_custom_mark_destroy_SETALL(SELF);
+ }
+
+
+/*
+
+=item C<void set_string_keyed_int(INTVAL key, STRING *value)>
+
+Sets the Parrot string value of the element at index C<key> to C<value>.
+
+=cut
+
+*/
+
+ void set_string_keyed_int (INTVAL key, STRING* value) {
+ STRING **data;
+ if (key < 0)
+ internal_exception(OUT_OF_BOUNDS,
+ "ResizableStringArray: index out of bounds!\n");
+ if(key >= PMC_int_val(SELF))
+ DYNSELF.set_integer_native(key+1);
+
+ data = (STRING**)PMC_data(SELF);
+ data[key] = value;
+ }
+
+}
+
+/*
+
+=back
+
+=head1 SEE ALSO
+
+F<docs/pdds/pdd03_calling_conventions.pod>.
+
+=head1 HISTORY
+
+Initial version 2004.06.11 by Matt Fowles
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+*/
View
287 t/pmc/resizablebooleanarray.t
@@ -0,0 +1,287 @@
+#! perl -w
+# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# $Id$
+
+=head1 NAME
+
+t/pmc/resizablebooleanarray.t - ResizableBooleanArray PMC
+
+=head1 SYNOPSIS
+
+ % perl t/pmc/ResizableBooleanArray.t
+
+=head1 DESCRIPTION
+
+Tests C<ResizableBooleanArray> PMC. Checks size, sets various elements, including
+out-of-bounds test. Checks INT and PMC keys.
+
+=cut
+
+use Parrot::Test tests => 7;
+use Test::More;
+
+my $fp_equality_macro = <<'ENDOFMACRO';
+.macro fp_eq ( J, K, L )
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ gt N2, 0.000001, .$FPEQNOK
+
+ restore N2
+ restore N1
+ restore N0
+ branch .L
+.local $FPEQNOK:
+ restore N2
+ restore N1
+ restore N0
+.endm
+.macro fp_ne( J,K,L)
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ lt N2, 0.000001, .$FPNENOK
+
+ restore N2
+ restore N1
+ restore N0
+ branch .L
+.local $FPNENOK:
+ restore N2
+ restore N1
+ restore N0
+.endm
+ENDOFMACRO
+
+output_is(<<'CODE', <<'OUTPUT', "Setting array size");
+ new P0, .ResizableBooleanArray
+
+ set I0,P0
+ eq I0,0,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0,1
+ set I0,P0
+ eq I0,1,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0,5
+ set I0,P0
+ eq I0,5,OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ set P0,50
+ set I0,P0
+ eq I0,50,OK_4
+ print "not "
+OK_4: print "ok 4\n"
+
+ set P0,7
+ set I0,P0
+ eq I0,7,OK_5
+ print "not "
+OK_5: print "ok 5\n"
+ end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Setting first element");
+ new P0, .ResizableBooleanArray
+ set P0, 1
+
+ set P0[0],-7
+ set I0,P0[0]
+ eq I0,1,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[0],3.7
+ set N0,P0[0]
+ eq N0,1.0,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[0],"17"
+ set S0,P0[0]
+ eq S0,"1",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Setting second element");
+ new P0, .ResizableBooleanArray
+ set P0, 2
+
+ set P0[1], -7
+ set I0, P0[1]
+ eq I0,1,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[1], 3.7
+ set N0, P0[1]
+ eq N0,1.0,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[1],"17"
+ set S0, P0[1]
+ eq S0,"1",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+# TODO: Rewrite these properly when we have exceptions
+
+output_is(<<'CODE', <<'OUTPUT', "Setting out-of-bounds elements");
+ new P0, .ResizableBooleanArray
+
+ set P0[1], -7
+ set I0, P0[1]
+ eq I0,1,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[0], 3.7
+ set N0, P0[0]
+ eq N0,1.0,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[5],"17"
+ set S0, P0[5]
+ eq S0,"1",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Getting out-of-bounds elements");
+ new P0, .ResizableBooleanArray
+ set P0, 1
+
+ set I0, P0[1]
+ print "ok 1\n"
+ end
+CODE
+ok 1
+OUTPUT
+
+
+output_is(<<"CODE", <<'OUTPUT', "Set via PMC keys, access via INTs");
+@{[ $fp_equality_macro ]}
+ new P0, .ResizableBooleanArray
+ new P1, .Key
+
+ set P1, 0
+ set P0[P1], 25
+
+ set P1, 1
+ set P0[P1], 2.5
+
+ set P1, 2
+ set P0[P1], "17"
+
+ set I0, P0[0]
+ eq I0, 1, OK1
+ print "not "
+OK1: print "ok 1\\n"
+
+ set N0, P0[1]
+ .fp_eq(N0, 1.0, OK2)
+ print "not "
+OK2: print "ok 2\\n"
+
+ set S0, P0[2]
+ eq S0, "1", OK3
+ print "not "
+OK3: print "ok 3\\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<"CODE", <<'OUTPUT', "Set via INTs, access via PMC Keys");
+@{[ $fp_equality_macro ]}
+ new P0, .ResizableBooleanArray
+
+ set P0[25], 125
+ set P0[128], 10.2
+ set P0[513], "17"
+ new P1, .PerlInt
+ set P1, 123456
+ set P0[1023], P1
+
+ new P2, .Key
+ set P2, 25
+ set I0, P0[P2]
+ eq I0, 1, OK1
+ print "not "
+OK1: print "ok 1\\n"
+
+ set P2, 128
+ set N0, P0[P2]
+ .fp_eq(N0, 1.0, OK2)
+ print "not "
+OK2: print "ok 2\\n"
+
+ set P2, 513
+ set S0, P0[P2]
+ eq S0, "1", OK3
+ print "not "
+OK3: print "ok 3\\n"
+
+ set P2, 1023
+ set P3, P0[P2]
+ set I1, P3
+ eq I1, 1, OK4
+ print "not "
+OK4: print "ok 4\\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+OUTPUT
+
+1;
View
271 t/pmc/resizablefloatarray.t
@@ -0,0 +1,271 @@
+#! perl -w
+# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# $Id$
+
+=head1 NAME
+
+t/pmc/resizablefloatarray.t - ResizableFloatArray PMC
+
+=head1 SYNOPSIS
+
+ % perl t/pmc/resizablefloatarray.t
+
+=head1 DESCRIPTION
+
+Tests C<ResizableFloatArray> PMC. Checks size, sets various elements, including
+out-of-bounds test. Checks INT and PMC keys.
+
+=cut
+
+use Parrot::Test tests => 7;
+use Test::More;
+
+my $fp_equality_macro = <<'ENDOFMACRO';
+.macro fp_eq ( J, K, L )
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ gt N2, 0.000001, .$FPEQNOK
+
+ restore N2
+ restore N1
+ restore N0
+ branch .L
+.local $FPEQNOK:
+ restore N2
+ restore N1
+ restore N0
+.endm
+.macro fp_ne( J,K,L)
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ lt N2, 0.000001, .$FPNENOK
+
+ restore N2
+ restore N1
+ restore N0
+ branch .L
+.local $FPNENOK:
+ restore N2
+ restore N1
+ restore N0
+.endm
+ENDOFMACRO
+
+output_is(<<'CODE', <<'OUTPUT', "Setting array size");
+ new P0,.ResizableFloatArray
+
+ set I0,P0
+ eq I0,0,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0,1
+ set I0,P0
+ eq I0,1,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0,5
+ set I0,P0
+ eq I0,5,OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ set P0,9
+ set I0,P0
+ eq I0,9,OK_4
+ print "not "
+OK_4: print "ok 4\n"
+
+ set P0,7
+ set I0,P0
+ eq I0,7,OK_5
+ print "not "
+OK_5: print "ok 5\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Setting first element");
+ new P0, .ResizableFloatArray
+ set P0, 1
+
+ set P0[0],-7
+ set I0,P0[0]
+ eq I0,-7,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[0],3.7
+ set N0,P0[0]
+ eq N0,3.7,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[0],"17.2"
+ set S0,P0[0]
+ eq S0,"17.2",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Setting second element");
+ new P0, .ResizableFloatArray
+
+ set P0[1], -7
+ set I0, P0[1]
+ eq I0,-7,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[1], 3.7
+ set N0, P0[1]
+ eq N0,3.7,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[1],"17.1"
+ set S0, P0[1]
+ eq S0,"17.1",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+# TODO: Rewrite these properly when we have exceptions
+
+output_is(<<'CODE', <<'OUTPUT', "Setting out-of-bounds elements");
+ new P0, .ResizableFloatArray
+ set P0, 1
+
+ set P0[1], -7
+ print "ok 1\n"
+
+ end
+CODE
+ok 1
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Getting out-of-bounds elements");
+ new P0, .ResizableFloatArray
+ set P0, 1
+
+ set I0, P0[1]
+ print "ok 1\n"
+ end
+CODE
+ok 1
+OUTPUT
+
+
+output_is(<<"CODE", <<'OUTPUT', "Set via PMC keys, access via INTs");
+@{[ $fp_equality_macro ]}
+ new P0, .ResizableFloatArray
+ new P1, .Key
+
+ set P1, 0
+ set P0[P1], 25
+
+ set P1, 1
+ set P0[P1], 2.5
+
+ set P1, 2
+ set P0[P1], "17.32"
+
+ set I0, P0[0]
+ eq I0, 25, OK1
+ print "not "
+OK1: print "ok 1\\n"
+
+ set N0, P0[1]
+ .fp_eq(N0, 2.5, OK2)
+ print "not "
+OK2: print "ok 2\\n"
+
+ set S0, P0[2]
+ eq S0, "17.32", OK3
+ print "not "
+OK3: print "ok 3\\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<"CODE", <<'OUTPUT', "Set via INTs, access via PMC Keys");
+@{[ $fp_equality_macro ]}
+ new P0, .ResizableFloatArray
+
+ set P0[25], 125
+ set P0[128], 10.2
+ set P0[513], "17.3"
+ new P1, .PerlInt
+ set P1, 123456
+ set P0[1023], P1
+
+ new P2, .Key
+ set P2, 25
+ set I0, P0[P2]
+ eq I0, 125, OK1
+ print "not "
+OK1: print "ok 1\\n"
+
+ set P2, 128
+ set N0, P0[P2]
+ .fp_eq(N0, 10.2, OK2)
+ print "not "
+OK2: print "ok 2\\n"
+
+ set P2, 513
+ set S0, P0[P2]
+ eq S0, "17.3", OK3
+ print "not "
+OK3: print "ok 3\\n"
+
+ set P2, 1023
+ set P3, P0[P2]
+ set I1, P3
+ eq I1, 123456, OK4
+ print "not "
+OK4: print "ok 4\\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+OUTPUT
+
+1;
View
271 t/pmc/resizableintegerarray.t
@@ -0,0 +1,271 @@
+#! perl -w
+# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# $Id$
+
+=head1 NAME
+
+t/pmc/resizableintegerarray.t - ResizableIntegerArray PMC
+
+=head1 SYNOPSIS
+
+ % perl t/pmc/ResizableIntegerArray.t
+
+=head1 DESCRIPTION
+
+Tests C<ResizableIntegerArray> PMC. Checks size, sets various elements, including
+out-of-bounds test. Checks INT and PMC keys.
+
+=cut
+
+use Parrot::Test tests => 7;
+use Test::More;
+
+my $fp_equality_macro = <<'ENDOFMACRO';
+.macro fp_eq ( J, K, L )
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ gt N2, 0.000001, .$FPEQNOK
+
+ restore N2
+ restore N1
+ restore N0
+ branch .L
+.local $FPEQNOK:
+ restore N2
+ restore N1
+ restore N0
+.endm
+.macro fp_ne( J,K,L)
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ lt N2, 0.000001, .$FPNENOK
+
+ restore N2
+ restore N1
+ restore N0
+ branch .L
+.local $FPNENOK:
+ restore N2
+ restore N1
+ restore N0
+.endm
+ENDOFMACRO
+
+output_is(<<'CODE', <<'OUTPUT', "Setting array size");
+ new P0,.ResizableIntegerArray
+
+ set I0,P0
+ eq I0,0,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0,1
+ set I0,P0
+ eq I0,1,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0,5
+ set I0,P0
+ eq I0,5,OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ set P0,9
+ set I0,P0
+ eq I0,9,OK_4
+ print "not "
+OK_4: print "ok 4\n"
+
+ set P0,7
+ set I0,P0
+ eq I0,7,OK_5
+ print "not "
+OK_5: print "ok 5\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Setting first element");
+ new P0, .ResizableIntegerArray
+ set P0, 1
+
+ set P0[0],-7
+ set I0,P0[0]
+ eq I0,-7,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[0],3.7
+ set N0,P0[0]
+ eq N0,3.0,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[0],"17"
+ set S0,P0[0]
+ eq S0,"17",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Setting second element");
+ new P0, .ResizableIntegerArray
+
+ set P0[1], -7
+ set I0, P0[1]
+ eq I0,-7,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[1], 3.7
+ set N0, P0[1]
+ eq N0,3.0,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[1],"17"
+ set S0, P0[1]
+ eq S0,"17",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+# TODO: Rewrite these properly when we have exceptions
+
+output_is(<<'CODE', <<'OUTPUT', "Setting out-of-bounds elements");
+ new P0, .ResizableIntegerArray
+ set P0, 1
+
+ set P0[1], -7
+ print "ok 1\n"
+
+ end
+CODE
+ok 1
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Getting out-of-bounds elements");
+ new P0, .ResizableIntegerArray
+ set P0, 1
+
+ set I0, P0[1]
+ print "ok 1\n"
+ end
+CODE
+ok 1
+OUTPUT
+
+
+output_is(<<"CODE", <<'OUTPUT', "Set via PMC keys, access via INTs");
+@{[ $fp_equality_macro ]}
+ new P0, .ResizableIntegerArray
+ new P1, .Key
+
+ set P1, 0
+ set P0[P1], 25
+
+ set P1, 1
+ set P0[P1], 2.5
+
+ set P1, 2
+ set P0[P1], "17"
+
+ set I0, P0[0]
+ eq I0, 25, OK1
+ print "not "
+OK1: print "ok 1\\n"
+
+ set N0, P0[1]
+ .fp_eq(N0, 2.0, OK2)
+ print "not "
+OK2: print "ok 2\\n"
+
+ set S0, P0[2]
+ eq S0, "17", OK3
+ print "not "
+OK3: print "ok 3\\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<"CODE", <<'OUTPUT', "Set via INTs, access via PMC Keys");
+@{[ $fp_equality_macro ]}
+ new P0, .ResizableIntegerArray
+
+ set P0[25], 125
+ set P0[128], 10.2
+ set P0[513], "17"
+ new P1, .PerlInt
+ set P1, 123456
+ set P0[1023], P1
+
+ new P2, .Key
+ set P2, 25
+ set I0, P0[P2]
+ eq I0, 125, OK1
+ print "not "
+OK1: print "ok 1\\n"
+
+ set P2, 128
+ set N0, P0[P2]
+ .fp_eq(N0, 10.0, OK2)
+ print "not "
+OK2: print "ok 2\\n"
+
+ set P2, 513
+ set S0, P0[P2]
+ eq S0, "17", OK3
+ print "not "
+OK3: print "ok 3\\n"
+
+ set P2, 1023
+ set P3, P0[P2]
+ set I1, P3
+ eq I1, 123456, OK4
+ print "not "
+OK4: print "ok 4\\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+OUTPUT
+
+1;
View
270 t/pmc/resizablepmcarray.t
@@ -0,0 +1,270 @@
+#! perl -w
+# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# $Id$
+
+=head1 NAME
+
+t/pmc/resizablepmcarray.t - ResizablePMCArray PMC
+
+=head1 SYNOPSIS
+
+ % perl t/pmc/ResizablePMCArray.t
+
+=head1 DESCRIPTION
+
+Tests C<ResizablePMCArray> PMC. Checks size, sets various elements, including
+out-of-bounds test. Checks INT and PMC keys.
+
+=cut
+
+use Parrot::Test tests => 7;
+use Test::More;
+
+my $fp_equality_macro = <<'ENDOFMACRO';
+.macro fp_eq ( J, K, L )
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ gt N2, 0.000001, .$FPEQNOK
+
+ restore N2
+ restore N1
+ restore N0
+ branch .L
+.local $FPEQNOK:
+ restore N2
+ restore N1
+ restore N0
+.endm
+.macro fp_ne( J,K,L)
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ lt N2, 0.000001, .$FPNENOK
+
+ restore N2
+ restore N1
+ restore N0
+ branch .L
+.local $FPNENOK:
+ restore N2
+ restore N1
+ restore N0
+.endm
+ENDOFMACRO
+
+output_is(<<'CODE', <<'OUTPUT', "Setting array size");
+ new P0,.ResizablePMCArray
+
+ set I0,P0
+ eq I0,0,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0,1
+ set I0,P0
+ eq I0,1,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0,5
+ set I0,P0
+ eq I0,5,OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ set P0,9
+ set I0,P0
+ eq I0,9,OK_4
+ print "not "
+OK_4: print "ok 4\n"
+
+ set P0,7
+ set I0,P0
+ eq I0,7,OK_5
+ print "not "
+OK_5: print "ok 5\n"
+ end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Setting first element");
+ new P0, .ResizablePMCArray
+ set P0, 1
+
+ set P0[0],-7
+ set I0,P0[0]
+ eq I0,-7,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[0],3.7
+ set N0,P0[0]
+ eq N0,3.7,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[0],"muwhahaha"
+ set S0,P0[0]
+ eq S0,"muwhahaha",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Setting second element");
+ new P0, .ResizablePMCArray
+
+ set P0[1], -7
+ set I0, P0[1]
+ eq I0,-7,OK_1
+ print "not "
+OK_1: print "ok 1\n"
+
+ set P0[1], 3.7
+ set N0, P0[1]
+ eq N0,3.7,OK_2
+ print "not "
+OK_2: print "ok 2\n"
+
+ set P0[1],"purple"
+ set S0, P0[1]
+ eq S0,"purple",OK_3
+ print "not "
+OK_3: print "ok 3\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+# TODO: Rewrite these properly when we have exceptions
+
+output_is(<<'CODE', <<'OUTPUT', "Setting out-of-bounds elements");
+ new P0, .ResizablePMCArray
+ set P0, 1
+
+ set P0[1], -7
+ print "ok 1\n"
+
+ end
+CODE
+ok 1
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Getting out-of-bounds elements");
+ new P0, .ResizablePMCArray
+ set P0, 1
+
+ set I0, P0[1]
+ print "ok 1\n"
+ end
+CODE
+ok 1
+OUTPUT
+
+
+output_is(<<"CODE", <<'OUTPUT', "Set via PMC keys, access via INTs");
+@{[ $fp_equality_macro ]}
+ new P0, .ResizablePMCArray
+ new P1, .Key
+
+ set P1, 0
+ set P0[P1], 25
+
+ set P1, 1
+ set P0[P1], 2.5
+
+ set P1, 2
+ set P0[P1], "bleep"
+
+ set I0, P0[0]
+ eq I0, 25, OK1
+ print "not "
+OK1: print "ok 1\\n"
+
+ set N0, P0[1]
+ .fp_eq(N0, 2.5, OK2)
+ print "not "
+OK2: print "ok 2\\n"
+
+ set S0, P0[2]
+ eq S0, "bleep", OK3
+ print "not "
+OK3: print "ok 3\\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+OUTPUT
+
+output_is(<<"CODE", <<'OUTPUT', "Set via INTs, access via PMC Keys");
+@{[ $fp_equality_macro ]}
+ new P0, .ResizablePMCArray
+
+ set P0[25], 125
+ set P0[128], 10.2
+ set P0[513], "cow"
+ new P1, .PerlInt
+ set P1, 123456
+ set P0[1023], P1
+
+ new P2, .Key
+ set P2, 25
+ set I0, P0[P2]
+ eq I0, 125, OK1
+ print "not "
+OK1: print "ok 1\\n"
+
+ set P2, 128
+ set N0, P0[P2]
+ .fp_eq(N0, 10.2, OK2)
+ print "not "
+OK2: print "ok 2\\n"
+
+ set P2, 513
+ set S0, P0[P2]
+ eq S0, "cow", OK3
+ print "not "
+OK3: print "ok 3\\n"
+
+ set P2, 1023
+ set P3, P0[P2]
+ set I1, P3
+ eq I1, 123456, OK4
+ print "not "
+OK4: print "ok 4\\n"
+
+ end
+CODE
+ok 1
+ok 2
+ok 3
+ok 4
+OUTPUT
+
+1;
View
272 t/pmc/resizablestringarray.t
@@ -0,0 +1,272 @@
+#! perl -w
+# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# $Id$
+
+=head1 NAME
+
+t/pmc/resizablestringarray.t - ResizableStringArray PMC
+
+=head1 SYNOPSIS
+
+ % perl t/pmc/ResizableStringArray.t
+
+=head1 DESCRIPTION
+
+Tests C<ResizableStringArray> PMC. Checks size, sets various elements, including
+out-of-bounds test. Checks INT and PMC keys.
+
+=cut
+
+use Parrot::Test tests => 7;
+use Test::More;
+
+my $fp_equality_macro = <<'ENDOFMACRO';
+.macro fp_eq ( J, K, L )
+ save N0
+ save N1
+ save N2
+
+ set N0, .J
+ set N1, .K
+ sub N2, N1,N0
+ abs N2, N2
+ gt N2, 0.000001, .$FPEQNOK
+
+ restore N2
+ restore N1