What are the 'this' and 'that' memory segments for?

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

What are the 'this' and 'that' memory segments for?

A_Random_Person
   Hello! Just wondering. What are the the 'this' and 'that' memory segments for?
Reply | Threaded
Open this post in threaded view
|

Re: What are the 'this' and 'that' memory segments for?

ivant
"this" and "that" are just memory segments (actually pointers to, or addresses of, the start of the said segments). They are used by the Jack compiler in chapter 11.

For now, you can think of these as just two segments, which can be set to different regions in memory, and which then can be used by the VM program to access said regions. The semantics of these regions depend on the language that is being implemented.
Reply | Threaded
Open this post in threaded view
|

Re: What are the 'this' and 'that' memory segments for?

A_Random_Person
Okay
Reply | Threaded
Open this post in threaded view
|

Re: What are the 'this' and 'that' memory segments for?

WBahn
Administrator
As ivant said, they just give you the ability to work with two different blocks of memory (from the heap) at the same time. You actually have the ability to use them however you want, but it might help you to at least have a glimpse of how the N2T project expects them to be used by the compiler.

Why two? Because it turns out that is what is needed by the envisioned compiler implementation down the road.

As a foretaste, the 'this' segment is used for a object. The 'this' pointer will be set equal to the memory address where that object's field variables so that the VM code can access them in the 'this' memory segment. The 'that' segment is used to work with arrays in a similar way.