getting the address of a object

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

getting the address of a object

ngogo
In order to deAlloc memory of an object the book offers to store the lenght of a given segment in the register preceding the object.
Though, in order to actually reach the address preceding the block one would need to use the array object as an integer whos'e value is the objects address.
For example:
Array previous = o-1;
where o is the given object.

Is this legal in jack? If not - how can one reach the lenght of the segment?
Reply | Threaded
Open this post in threaded view
|

Re: getting the address of a object

cadet1620
Administrator
ngogo wrote
... in order to actually reach the address preceding the block one would need to use the array object as an integer whos'e value is the objects address.
For example:
Array previous = o-1;
where o is the given object.

Is this legal in jack? If not - how can one reach the lenght of the segment?
Since Jack is untyped, this is legal. I have more than just the length in my memory headers so I have
    var Array header;
    let header = block-2;
in my code. (block is the parameter passed to deAlloc.)

--Mark