WOOO compiles all in one file! Dependencies resolved! Next up, C name mangeling for scoping

This commit is contained in:
Nathan Braswell
2015-03-11 01:58:10 -04:00
parent 9e9b4371da
commit 6a311fb237
14 changed files with 230 additions and 133 deletions

View File

@@ -1,6 +1,6 @@
import mem:*;
import util:*;
import io:*;
//import io:*;
typedef template<T> vector (Destructable) {
|T*| data;
@@ -25,6 +25,8 @@ typedef template<T> vector (Destructable) {
for (|int| i = 0; i < lesser<int>(size, newSize); i++;)
newData[i] = data[i];
delete<T>(data, 0);
data = newData;
available = newSize;
return true;
}
@@ -34,21 +36,22 @@ typedef template<T> vector (Destructable) {
|T| get(|int| index) {
if (index < 0 || index >= size) {
println("Vector access out of bounds! Retuning 0th element as sanest option");
// println("Vector access out of bounds! Retuning 0th element as sanest option");
return data[0];
}
return data[index];
}
|T*| getBackingMemory() { return data; }
|void| set(|int| index, |T| dataIn) {
if (index < 0 || index >= size)
return;
data[index] = dataIn;
}
|void| addEnd(|T| dataIn) {
if (size < available)
size++;
else
size++;
if (size >= available)
resize(size*2);
data[size-1] = dataIn;
}