diff options
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 == |