Ellie designed to have class constructors with either body or no body.
class Test {
pri v test;
co(test); //Automaticly assigned to test variable
}
class Test {
pri v test;
co(test) {
self.test = test; //Assigned manually
}
}
For implementing vector we needed a construct time call since needed allocations should've been called.
pub class Vec<Type> {
co() {
// Create heap pointer with 0 size
allocate_heap_pointer(self.pointer, 0);
// Create array on stack pointer reference it to heap pointer.
write_pointer(self.pointer, new TypeId(0, 9), self.pointer.to_le_bytes());
}
pri v size = 0;
pri v pointer = get_pointer_here();
@description= "Push element to vector";
@example= "
v vec = new Vec<int>();
vec.push(13);
print(vec); //[13]
";
pub fn push(element: Type) : void {
v p_size = platform_size();
self.size += p_size;
// Resize heap pointer
resize_heap_pointer(self.pointer, self.size * p_size);
// Insert data to resized region
insert_data_to_heap_data_range(
self.pointer,
self.size * p_size, (self.size * p_size) + p_size,
get_pointer(element)
);
}
}
But since there is no support for constructor body at this time I couldn't make vector work.
Ellie designed to have class constructors with either body or no body.
For implementing vector we needed a construct time call since needed allocations should've been called.
But since there is no support for constructor body at this time I couldn't make vector work.