|Stack Machine and Parameters firstname.lastname@example.org (Jens Kallup) (2004-11-29)|
|Re: Stack Machine and Parameters email@example.com (amal) (2004-12-16)|
|Date:||16 Dec 2004 00:48:37 -0500|
|Posted-Date:||16 Dec 2004 00:48:37 EST|
Jens Kallup wrote:
> Hello Newsgroup,
> I trying to program an interpreter in stack machine behavior.
> It works fine at now - IF ELSE ENDIF FOR loops and
> variable definitions like "b0 = 100".
> But now, I reached the point where parameters of functions
> should be interpreted. I don't know how it possible.
> I pushed parameters on stack of functions that are fixed and
> know by me - but how works with unknow procedure
> Here a little code snippet of the parsed interpreter code:
> enter main
> npush 10
> vpush b0
> nassign b0
> call @test
evaluate the arguments. push them to the stack ( assuming call by
value) . on function invocation pop as many arguments as the arity of
the function. do the functions job.
CALL MAX ( 1, A+B+C, SQUARE( A - B)) can be translated as
lets assume we evaluate from left to right.
Return to the
Search the comp.compilers archives again.