[m-rev.] for review: fix some problems with erlang code generator

Peter Ross pro at missioncriticalit.com
Fri Jun 1 14:03:43 AEST 2007


On Fri, Jun 01, 2007 at 01:08:45PM +1000, Peter Wang wrote:
> Estimated hours taken: 15
> Branches: main
> 
> Fix some problems with the Erlang code generator.
> 
> One problem was that success expressions which got duplicated into different
> branches of a conditional statement could contain assignments to local
> variables (which the Erlang compiler could warn about in some cases).  We now
> rename apart these variables when success expressions are duplicated.
> 
> Another problem was that we were duplicating large success expressions into
> branches of an if-then-else.  We now handle this as we do for disjunctions and
> switches, by inserting calls to a closure containing the success expression
> rather than the success expression itself.
> 
> The third problem occurred when a conditional branch contained an erroneous
> goal that bound a variable.  In Mercury, if a different, non-erroneous, branch
> was taken then the same variable could be bound later.  However, the Erlang
> compiler would declare the code we generated unsafe because it does not know
> which procedures will throw exceptions.  We fix this by renaming away variables
> which are assigned in erroneous goals.
> 
> compiler/erl_code_gen.m:
> 	Fix the problems described above.
> 
> 	Reenable duplication of small success exceptions.
> 
> compiler/erl_code_util.m:
> 	Add `erl_fix_success_expr' that renames apart local variables in a
> 	success expression.
> 
> 	Add `erl_rename_vars_in_expr_except' to rename apart all variables in
> 	an ELDS expression _except_ those listed.
> 
> 	Add `erl_expr_vars' which returns the set of variables appearing in an
> 	ELDS expression.
> 
> 	Make `erl_create_renaming' give names to new variables based on the old
> 	variable names.
> 
> compiler/elds.m:
> 	Add `maybe_join_exprs1' utility predicate. 
> 
> compiler/instmap.m:
> 	Add predicate `instmap_bound_vars' to return variables in an instmap
> 	which are bound.
> 
> 
Looks fine.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list