Re: forward routine_id (was Re: Comments on ORAC)

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

Bernie Ryan wrote:
> 
> All though I do not understand how the code works now;
> The way I see this implemented is:
> 
> Pass 1:
> 
>      Build a table with each function/procedure name and routine_id       
> 
>      At the end of the pass if there are any duplicate names in the table;
>      issue and namespace error message.
> 
> Pass 2:
> 
>      Build the symbol table and resolve the the forward references.

In the current interpreter, everything happens in Pass 1.  The symbol table
is built as the code is parsed.  Duplicate names don't cause problems
by themselves, since there are ways to resolve them.  If the resolution
can't disambiguate, then you get a compile error.

The routine_id resolution happens at runtime.  Each time routine_id is 
called, the specified routine is added to the routine_id table for later
use by call_func/proc or call_back.

The translator works a bit differently, and makes many passes over the code
while it tries to optimize.  The routine id table is actually built at 
compile time (so don't expect routine_ids to be the same after translating!)
The resolution is still done at runtime, however.

If we wanted to do forward referencing, we'd probably just put the reference
on a patch list (this technique is used for other things in the interpreter)
and patch it up whenever an appropriate symbol was discovered.  Or maybe at
the end, to be assured of proper disambiguation, etc.  Any dangling or
ambiguous references could then throw an error.  Of course, routine_id calls
could just return -1 like they do now.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu