diff options
author | dos-reis <gdr@axiomatics.org> | 2011-12-02 01:48:21 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-12-02 01:48:21 +0000 |
commit | cd82f3461e43f3bbfa4acc8c6152322f774cad24 (patch) | |
tree | c9b8291059243e3d44b0e66e6d6b9ff7dcf17e57 /src/interp | |
parent | 020475072e466165432ff92e35d9008eaf36ee2e (diff) | |
download | open-axiom-cd82f3461e43f3bbfa4acc8c6152322f774cad24.tar.gz |
* interp/g-opt.boot (changeVariableDefinitionToStore): Handle SEQ
forms too.
(groupVariableDefinitions): Handle %bind and %loop forms.
* interp/lisp-backend.boot (expandLoop): Special code for case
where there is explicit exit condition, for better pretty-printing.
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/g-opt.boot | 10 | ||||
-rw-r--r-- | src/interp/lisp-backend.boot | 7 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 67b6aca9..066e2097 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -81,7 +81,7 @@ changeVariableDefinitionToStore(form,vars) == form.op is '%when => for clause in form.args repeat -- variable defined in clause predicates are visible - -- subsequent predicates + -- in subsequent predicates vars := changeVariableDefinitionToStore(first clause,vars) -- but those defined in branches are local. changeVariableDefinitionToStore(rest clause,vars) @@ -97,6 +97,10 @@ changeVariableDefinitionToStore(form,vars) == abstractionOperator? form.op => changeVariableDefinitionToStore(form.absBody,[:form.absParms,:vars]) vars + form is ['SEQ,:stmts,['EXIT,val]] => + for s in stmts repeat + vars := changeVariableDefinitionToStore(s,vars) + changeVariableDefinitionToStore(val,vars) for x in form repeat vars := changeVariableDefinitionToStore(x,vars) vars @@ -125,8 +129,12 @@ groupVariableDefinitions form == form form is ['%labelled,tag,expr] => [form.op,tag,groupVariableDefinitions expr] + form is ['%bind,inits,expr] => + [form.op,inits,groupVariableDefinitions expr] form is ['%lambda,:.] => [form.absKind,form.absParms,groupVariableDefinitions form.absBody] + form is ['%loop,:iters,body,val] => + [form.op,:iters,groupVariableDefinitions body,val] form isnt ['SEQ,:stmts,['EXIT,val]] => form defs := nil for x in stmts while nonExitingSingleAssignment? x repeat diff --git a/src/interp/lisp-backend.boot b/src/interp/lisp-backend.boot index 61d53837..316a4ef9 100644 --- a/src/interp/lisp-backend.boot +++ b/src/interp/lisp-backend.boot @@ -168,9 +168,10 @@ expandLoop ['%loop,:iters,body,ret] == body := mkpf([:filters,body],"AND") -- If there is any body-wide initialization, now is the time. body := massageFreeVarInits(body,bodyInits) - exits := ["COND", - [mkpf(exits,"OR"),["RETURN",expandToVMForm ret]], - [true,body]] + exits := + exits = nil => body + ["COND",[mkpf(exits,"OR"),["RETURN",expandToVMForm ret]], + [true,body]] body := ["LOOP",exits,:cont] -- Finally, set up loop-wide initializations. massageFreeVarInits(body,loopInits) |