diff options
author | dos-reis <gdr@axiomatics.org> | 2010-06-20 22:12:10 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2010-06-20 22:12:10 +0000 |
commit | bf21f6c3c98ea62bbd952ecd2382b63f4cd370bb (patch) | |
tree | 7a5bbd28009759b1c787d3df4c4ba5960cd11280 /src/interp | |
parent | 9cde874de258533a18944602afa62c9e56ac991a (diff) | |
download | open-axiom-bf21f6c3c98ea62bbd952ecd2382b63f4cd370bb.tar.gz |
* interp/g-opt.boot (changeVariableDefinitionToStore): New.
(optimizeFunctionDef): Use it.
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/g-opt.boot | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 119da259..e47f7be0 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -65,7 +65,20 @@ emitIndirectCall(fn,args,x) == x --% OPTIMIZER - + +++ Change (%LET id expr) to (%store id expr) if `id' is being +++ updated as opposed to being defined. `vars' is the list of +++ all variable definitions in scope. +changeVariableDefinitionToStore(form,vars) == + isAtomicForm form => nil + 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 := [v,:vars] + optimizeFunctionDef(def) == if $reportOptimization then sayBrightlyI bright '"Original LISP code:" @@ -95,6 +108,7 @@ optimizeFunctionDef(def) == atom x => nil replaceThrowByReturn(first x,g) replaceThrowByReturn(rest x,g) + changeVariableDefinitionToStore(body',args) [name,[slamOrLam,args,body']] optimize x == |