From d5088a15f1073ad01d8be9de9d4b6242dd5ed426 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Mon, 4 Feb 2008 01:16:51 +0000 Subject: * boot/translator.boot (translateToplevelExpression): New. (bpOutItem): Use it. * boot/ast.boot (needsPROG): New. (shoeCompTran): Use it. Tidy. (bfMain): Define cache variables before functions manipulating them. * boot/strap/: Update cached Lisp translations. * interp/g-timer.boot: Use assignment instead of SETANDFILEQ at toplevel. * interp/i-syscmd.boot: Likewise. * interp/pf2atree.boot: Likewise. * interp/trace.boot: Likewise. --- src/boot/translator.boot | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/boot/translator.boot') diff --git a/src/boot/translator.boot b/src/boot/translator.boot index cabf8d5a..f8adef8b 100644 --- a/src/boot/translator.boot +++ b/src/boot/translator.boot @@ -360,6 +360,20 @@ genDeclaration(n,t) == ["DECLAIM",["FTYPE",["FUNCTION",argTypes,valType],n]] ["DECLAIM",["TYPE",t,n]] + +++ A non declarative expression `expr' appears at toplevel and its +++ translation needs embeddeding in an `EVAL-WHEN'. +translateToplevelExpression expr == + expr' := rest rest shoeCompTran ["LAMBDA",["x"],expr] + -- replace "DECLARE"s with "DECLAIM"s, as the former can't appear + -- at toplevel. + for t in expr' repeat + t is ["DECLARE",:.] => + RPLACA(t,"DECLAIM") + shoeEVALANDFILEACTQ + #expr' > 1 => ["PROGN",:expr'] + first expr' + bpOutItem()== $op := nil bpComma() or bpTrap() @@ -388,8 +402,7 @@ bpOutItem()== bpPush [["DEFCONSTANT", n, e]] otherwise => - b:=shoeCompTran ["LAMBDA",["x"],b] - bpPush [shoeEVALANDFILEACTQ CADDR b] + bpPush [translateToplevelExpression b] --shoeStartsAt (sz,name,stream)== -- bStreamNull stream => ['nullstream] -- cgit v1.2.3