Re: Need help with PD source (again)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Vincent wrote:
> 
> Matt Lewis wrote:
> > 
> > Pete Lomax wrote:
> 
> Awasome Matt & Pete, thanks so much for responding ...
> 
> I've implemented the "continue" keyword in emit.e, keylist.e,
> opnames.e, and reswords.e. Matt, I implemented your
> Continue_statement() in parser.e.
> 
> In parser.e I made stacks variables to hold the values in
> For_statement() and While_statement().. like this
> (tell me if Im wrong)..

Here's how I did it.  The loop_bp_stack is different based on whether
it's a WHILE or FOR loop:
procedure For_statement()
    -- ...

    emit_addr(0) -- will be patched - don't straighten 

    -- begin mwl
    loop_stack &= FOR
    loop_sym_stack &= loop_var_sym
    loop_bp_stack &= bp1
    -- end mwl

    -- ...
    -- begin mwl
    loop_stack = loop_stack[1..$-1]
    loop_sym_stack = loop_sym_stack[1..$-1]
    loop_bp_stack = loop_bp_stack[1..$-1]
    -- ene mwl
end procedure

procedure While_statement()
    -- ...
    -- begin mwl
    loop_stack &= WHILE
    loop_sym_stack &= 0
    loop_bp_stack &= {{bp1, bp2}}
    -- end mwl
	    
    call_proc(forward_Statement_list, {})

    -- ...

    -- begin mwl
    loop_stack = loop_stack[1..$-1]
    loop_sym_stack = loop_sym_stack[1..$-1]
    loop_bp_stack = loop_bp_stack[1..$-1]
    -- ene mwl
end procedure

  
> Matt... I noticed in Continue_statement(), you put
> 
> s = Pop() & Pop()
> 
> and I'm not sure whats in it.. could you post the Pop() code
> and tell where I could place the routine?

Pop() is defined in emit.e.  I just made it and Push() global.  They
manipulate the cg_stack (code generation stack).  Basically, an ENDFOR
opcode pops two values off the stack.  Since I'm adding an 'artificial'
ENDFOR, I need to duplicate the top two items on the stack.
 
> I'm not sure what I should add in execute.e (backend) to
> opFOR(), opFOR_GENERAL(), opENDFOR_INT_UP1(), opWHILE(),
> etc..

Don't need to change anything in execute.e, since you're using already 
defined opcodes, just in a more creative way.
 
You also need to add a call to Continue_statement() into the giant
if-elsif statements in Statement_list() and parser() in parser.e.

Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu