diff options
author | dos-reis <gdr@axiomatics.org> | 2011-02-12 01:11:29 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-02-12 01:11:29 +0000 |
commit | 0ac37df817059cca37fd38f0512f3f6f3e269833 (patch) | |
tree | 3a66e9648606e5f4b88d95361061fd3a27077a81 | |
parent | f80c643a39ac6a3870e6a3b7cc967b8e6a3d0915 (diff) | |
download | open-axiom-0ac37df817059cca37fd38f0512f3f6f3e269833.tar.gz |
* interp/g-opt.boot (changeVariableDefinitionToStore): Tidy.
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 34 |
2 files changed, 32 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 339c91ac..e67ca95e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-02-11 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/g-opt.boot (changeVariableDefinitionToStore): Tidy. + +2011-02-11 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/g-opt.boot (dependentVars): New. (canInlineVarDefinition): Use it to safely inline vardefs. diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index d777bc58..4ff87150 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -70,14 +70,36 @@ emitIndirectCall(fn,args,x) == ++ updated as opposed to being defined. `vars' is the list of ++ all variable definitions in scope. changeVariableDefinitionToStore(form,vars) == - atomic? form => nil + atomic? form or form.op is 'CLOSEDFN => vars form is ['%LET,v,expr] => - changeVariableDefinitionToStore(expr,vars) - if v in vars then form.op := '%store - for x in form repeat - changeVariableDefinitionToStore(x,vars) - x is ['%LET,v,:.] and not (v in vars) => + vars := changeVariableDefinitionToStore(expr,vars) + if v in vars then + form.op := '%store + else vars := [v,:vars] + vars + form.op is '%when => + for clause in form.args repeat + -- variable defined in clause predicates are visible + -- subsequent predicates + vars := changeVariableDefinitionToStore(first clause,vars) + -- but those defined in branches are local. + changeVariableDefinitionToStore(rest clause,vars) + vars + -- local bindings are, well, local. + form.op in '(%bind LET) => + vars' := vars + for [v,init] in second form repeat + vars' := changeVariableDefinitionToStore(init,vars') + vars' := [v,:vars'] + changeVariableDefinitionToStore(third form,vars') + vars + form.op in $AbstractionOperator => + changeVariableDefinitionToStore(third form,[:second form,:vars]) + vars + for x in form repeat + vars := changeVariableDefinitionToStore(x,vars) + vars ++ Return true if `x' contains control transfer to a point outside itself. jumpToToplevel? x == |