keriwarr / orangejoos

JOOS1W Compiler, written in Crystal
0 stars 1 forks source link

add array init, access, assignment, and length #88

Closed lgo closed 6 years ago

lgo commented 6 years ago

ignore the first commit as it's currently on another PR.


Arrays are stored with the length as the first double-word. The data follows that in the layout. The array pointer itself is shifted so the data begins at the pointer's address.

Going forward, if we wish to continue storing the array ptr with the data at the start of the ptr address after vtables are also stored, we can consistently store the vtable at the [instance_ptr - 4]. That means that classes too would follow this semantic. This will not impact the instructions needed for virtual dispatching, as the lookup can have the -4 offset embedded.