|Absolute beginner - Need some pointers firstname.lastname@example.org (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 email@example.com (Bartc) (2008-02-29)|
|Re: Absolute beginner - Need some pointers firstname.lastname@example.org (2008-03-02)|
|Re: Absolute beginner - Need some pointers email@example.com (2008-03-03)|
|Re: Absolute beginner - Need some pointers firstname.lastname@example.org (2008-03-04)|
|Re: Absolute beginner - Need some pointers email@example.com (glen herrmannsfeldt) (2008-03-05)|
|Re: Absolute beginner - Need some pointers firstname.lastname@example.org (Soeren Sandmann) (2008-03-07)|
|From:||email@example.com (Anton Ertl)|
|Date:||Mon, 03 Mar 2008 19:06:50 GMT|
|Organization:||Institut fuer Computersprachen, Technische Universitaet Wien|
|Posted-Date:||03 Mar 2008 16:17:40 EST|
firstname.lastname@example.org (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.
M. Anton Ertl
[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]
Return to the
Search the comp.compilers archives again.