Re: Interpreter advice required

lars@bearnip.com (Lars Duening)
3 May 2002 15:55:38 -0400

          From comp.compilers

Related articles
Interpreter advice required jwillans@cs.york.ac.uk (2002-04-29)
Re: Interpreter advice required lars@bearnip.com (2002-05-03)
Re: Interpreter advice required per@bothner.com (Per Bothner) (2002-05-08)
| List of all articles for this month |

From: lars@bearnip.com (Lars Duening)
Newsgroups: comp.compilers
Date: 3 May 2002 15:55:38 -0400
Organization: Compilers Central
References: 02-04-160
Keywords: Java, design, interpreter, OOP
Posted-Date: 03 May 2002 15:55:38 EDT

On 29 Apr 2002 01:52:51 -0400, James Willans <jwillans@cs.york.ac.uk> wrote:


> My problem is that I have little understanding about the runtime
> organisation of object oriented programs. I have been using Watt's
> "Programming language processors in Java" which has helped a lot, but
> doesn't deal indepth with how to make decisions about the form the
> virtual machine will take given the language that is going to be
> interpreted (clearly it is not necessary to simulate a real machine).
> In fact, most books I have looked at don't deal with object oriented
> programming language interpretation.
>
> Any pointers to useful material is greatly appreciated.


Well, here is how the interpreter for LPC (a mildly object-oriented
dialect of C used in LPMuds) is organised:


Objects are datastructures which hold the data members and a pointer
to the program structure. The program ('class') structure holds the
compiled bytecode in a single block of memory, and a list of function
descriptors (name, starting offset, arguments, etc). Also in the
structure is a list of datamember descriptors, and the list of
directly inherited programs.


Inheritance is implemented such that every program structure holds the
descriptors for all functions and datamembers, both own and inherited
(including indirectly inherited ones). The descriptors for the
non-inherited functions simply give a starting offset in the bytecode
block; inherited functions are specified by a reference to the
inherited program, and the index of the function within the inherited
program. For functions inherited over several level this creates a
chain of references until the real function descriptor is found.


When executing a program, the interpreter context includes a pointer
to the current object and a pointer to the program actually executed.
Apart from that, there is not much difference to an interpreter for a
'normal' language.


Hope this helped a bit.
--
Lars Duening; lars@bearnip.com
PGP Key: http://www.bearnip.com/lars/pgp-lars.asc


Post a followup to this message

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