classes, stack and vm's

Alexander Cohen <alex@toomuchspace.com>
8 Sep 2004 00:06:17 -0400

          From comp.compilers

Related articles
classes, stack and vm's alex@toomuchspace.com (Alexander Cohen) (2004-09-08)
| List of all articles for this month |
From: Alexander Cohen <alex@toomuchspace.com>
Newsgroups: comp.compilers
Date: 8 Sep 2004 00:06:17 -0400
Organization: Compilers Central
Keywords: architecture
Posted-Date: 08 Sep 2004 00:06:17 EDT

Hi, im trying to learn a bit about virtual machines and how they
interact with the stack and the symbol list. Im a bit stuck on a
problem.


I have 1 stack and 1 symbol list. I have objects that can be created
and when created, they all have members and functions stored in the
object itself. The members are stored as an internal symbol list to
the object.


So lets say i want to call 1 of the functions of an object with a few
parameters like this:


obj2 = object.DoThis(par1)


And its defined like so:


obj2 object::DoThis(par1)
{
return new obj2
}


lets say <object> is already on the top of the stack, its also in the
symbol list since its a valid instance of an object. I need to pop it
off, then push <par1> onto the stack. Then i can jump to
<object::DoThis> and it will pop the stack to get the first parameter.
Where should this be stored? Should i add it <object>s symbol list so
it can be used thoughout the function? Should i put it in a temp symbol
list? Should i have a local and a global symbol list. I would go
through the locals, and if i dont find the symbol i need, go through
the global one.


Is there any tutorial on something like anywhere? I feel like there are
just a few things i need to grasp a bit better.


thanks
--
Alexander Cohen


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.