diff options
author | dos-reis <gdr@axiomatics.org> | 2012-05-22 01:38:27 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2012-05-22 01:38:27 +0000 |
commit | 08967519aa894f0740d4e120df5db49ab4d2e8b6 (patch) | |
tree | f1a4befb60c982dec9d0a3b42014fd49358da4f4 /src/boot/ast.boot | |
parent | ec02c6670d57cbb6814c6a79e133e1e2b41ed0af (diff) | |
download | open-axiom-08967519aa894f0740d4e120df5db49ab4d2e8b6.tar.gz |
* boot/ast.boot (needsPROG): Remove.
(shoePROG): Likewise.
(declareLocalVars): New.
(maybeAddBlock): Likewise.
(hasReturn?): Likewise.
(shoeCompTran): Tidy.
Diffstat (limited to 'src/boot/ast.boot')
-rw-r--r-- | src/boot/ast.boot | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/boot/ast.boot b/src/boot/ast.boot index f4f4bedc..467caa3f 100644 --- a/src/boot/ast.boot +++ b/src/boot/ast.boot @@ -1008,23 +1008,29 @@ shoeCompTran x== body' := [["DECLARE",:$typings],:body'] if fvars := setDifference(deref dollarVars,deref fluidVars) then body' := [["DECLARE",["SPECIAL",:fvars]],:body'] - deref locVars or needsPROG body' => shoePROG(deref locVars,body') - body' + vars := deref locVars => declareLocalVars(vars,body') + maybeAddBlock body' if fl := shoeFluids args then body := [["DECLARE",["SPECIAL",:fl]],:body] [lamtype,args,:body] -needsPROG body == - body isnt [.,:.] => false - [op,:args] := body - op in '(RETURN RETURN_-FROM) => true - op in '(LET LET_* PROG LOOP BLOCK DECLARE LAMBDA) => false - or/[needsPROG t for t in body] - -shoePROG(v,b)== - b = nil => [["PROG", v]] - [:blist,blast] := b - [["PROG",v,:blist,["RETURN", blast]]] +declareLocalVars(vars,stmts) == + stmts is [["LET*",inits,:stmts]] => + [["LET*",[:inits,:vars],:maybeAddBlock stmts]] + [["LET*",vars,:maybeAddBlock stmts]] + +maybeAddBlock stmts == + [:decls,expr] := stmts + hasReturn? expr => + decls = nil => [["BLOCK","NIL",:stmts]] + [:decls,["BLOCK","NIL",expr]] + stmts + +hasReturn? x == + x isnt [.,:.] => false + x.op is 'RETURN => true + x.op in '(LOOP PROG BLOCK LAMBDA DECLARE) => false + or/[hasReturn? t for t in x] shoeFluids x== ident? x and bfBeginsDollar x => [x] |