1. Re: Win32Lib/Llama Status
Rob Craig writes:
> How the binder currently works:
>
> The binder takes a multi-file program, consisting of a main
> file and all necessary include files, and it converts it into
> a single large file. In general, this shouldn't be possible if there
> are local symbols in 2 different files that have the same name.
> However, the binder changes all names to short,
> meaningless names of it's own choosing. fred() in x.e
> might be changed to aa(), while fred() in y.e might be changed
> to bb(), so there's no conflict.
>
> Now, suppose the programmer has routine_id("fred") in his
> program. fred() has been changed to aa(), so this routine_id() call is
> now wrong. The binder will issue a warning, and you must rebind with
> -clear_routines. This will force the binder to leave fred() in x.e and
> fred() in y.e unchanged. But now when the second instance of fred is
> encountered, the binder will issue a warning, and change the 2nd fred
> anyway, in the hope that you aren't calling routine_id for the second
> fred(). If you ignore the warning, you can run, but things will likely
> fail.
I think this could be averted by changing bind in the following way...
get rid of the -clear_routines option.
whenever the routine_id() function is used, replace "routine_id" with
another unique meaningless name. Then have bind generate a function for
that meaningless name and insert the new function body somewhere before
the place where routine_id() is called. The code that goes in the
function will translate an unmangled name to the meaningless name for each
routine currently visible at the place where routine_id was called.
For example:
procedure foo() --> gets renamed to aa() by bind
-- ...
end procedure
procedure bar() --> gets renamed to ab() by bind
integer id
id = routine_id("foo") --> routine_id gets renamed to ac() by bind
end procedure
Bind will output something equivalent to:
procedure ab() --> this used to be foo()
-- ..
end procedure
function ac(sequence routine) --> this is a generated routine_id()
sequence names
sequence ids
integer id
-- list of names currently visible
names = {"foo"}
-- only bind will know this list of meaningless names
ids = {"ab"}
-- lookup the desired routine name
id = find(routines, names)
-- is it valid?
if id > 0 then
-- return the routine_id of the actual routine
return routine_id(ids[id])
end if
-- unknown routine
return -1
end function
procedure ab() --> this used to be bar()
integer id
id = ac("foo") --> this used to be routine_id()
end procedure
A difficulty I forsee in this method is the problem of inserting the
generated routine_id() functions before the place where they are called.
Bind may have to buffer routines or nested statements, in case they used
routine_id() so that they can be output after the new routine_id()
function. Also, using routine_id() in many different places can generate
a lot of extra code for each new routine_id() function.
A trick I used in Peu for routine_id was to define routine_id internally
to accept *two* parameters, one for the name and the other for an index
into the symbol table. And then the parser watches for a call to
routine_id and secretly passes the extra parameter for the currently
visible symbol table. That way routine_id can figure out the
correct id by looking in the right symbol table based on where routine_id
was called from. Perhaps bind could do something similar.
> In the redesign, I hope to get away from the concept
> of creating "one" file. The source file
> boundaries would be retained somehow, solving this
> routine_id situation and making other features available,
> such as the option to bind clear, unshrouded source, and
> get proper ex.err dumps etc.
The Peu symbol table keeps track of file boundaries by storing special
symbols for the start and end of each include file. When searching for a
name in the table, it sees when it enters into an include file so that it
can skip over non-global names. These special symbols could be
made available to the programmer (or bind) as euphoria keywords such as
"namespace" and "end namespace"
> Regards,
> Rob Craig
> Rapid Deployment Software
> http://members.aol.com/FilesEu/
Regards,
_______ ______ _______ ______
[ _ \[ _ ][ _ _ ][ _ ]
[/| [_] |[/| [_\][/ | | \][/| [_\]
| ___/ | _] | | | _]
[\| [/] [\| [_/] [\| |/] [\| [_/]
[_____] [______] [_____] [______]
xseal at harborside.com ICQ:13466657
http://www.harborside.com/home/x/xseal/euphoria/