Re: Absolute beginner - Need some pointers

anton@mips.complang.tuwien.ac.at (Anton Ertl)
Mon, 03 Mar 2008 19:06:50 GMT

          From comp.compilers

Related articles
Absolute beginner - Need some pointers nacarlson@gmail.com (NickCarlson) (2008-02-27)
Re: Absolute beginner - Need some pointers DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-02-28)
Re: Absolute beginner - Need some pointers bc@freeuk.com (Bartc) (2008-02-29)
Re: Absolute beginner - Need some pointers anton@mips.complang.tuwien.ac.at (2008-03-02)
Re: Absolute beginner - Need some pointers anton@mips.complang.tuwien.ac.at (2008-03-03)
Re: Absolute beginner - Need some pointers anton@mips.complang.tuwien.ac.at (2008-03-04)
Re: Absolute beginner - Need some pointers gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-03-05)
Re: Absolute beginner - Need some pointers sandmann@daimi.au.dk (Soeren Sandmann) (2008-03-07)
| List of all articles for this month |
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: Mon, 03 Mar 2008 19:06:50 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 08-02-091 08-03-008
Keywords: interpreter
Posted-Date: 03 Mar 2008 16:17:40 EST



anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>[I've found the painful part of bytecode is the flow control. I
>suppose that if you do a goto-less version with codes like begin loop,
>end loop, and break it would be similar to trees, but for me the trees
>have the nice advantage that the block structure doesn't have to be
>discovered, it's right there. -John]


Why would one want to discover the block structure (if the language
has any)? The primary purpose of VM code is execution, and you don't
need to discover the block structure for that.


If you have any other purposes in mind, yes, you can enhance the VM as
you suggested, or build a separate structure that describes the block
structure, or indeed use a tree intermediate representation (maybe
even a syntax tree).


On second thought, I know a counter-example: JVM try blocks. They are
needed during execution (if an exception is thrown); they are
represented in the JVM by a separate data structure that specifies the
start and the end of each block.


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/
[Not the block structure of the source language, the loops in the
object code. When you get to the bottom of the loop, you need
something that tells the interpreter to go back to the top of the
loop. I've done it with assembler style gotos that require some sort
of symbol table and backpatching, which is doable but unpleasant. If
you're interpreting trees, you just keep a stack of how you got there.
I agree that interpreting a parse tree is ill-advised, but an AST seems
pretty nice. -John]



Post a followup to this message

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