From 7a8d437ec5431e0e33285c35478e76ec7f07580d Mon Sep 17 00:00:00 2001 From: dos-reis Date: Thu, 3 Feb 2011 03:21:29 +0000 Subject: * interp/compiler.boot (finishLambdaExpression): Tidy. Don't generate Lisp code directly. (canReturn): Don't look into CLOSEDFN forms. --- src/interp/compiler.boot | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/interp') diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot index 5df5091d..a222dd37 100644 --- a/src/interp/compiler.boot +++ b/src/interp/compiler.boot @@ -331,25 +331,19 @@ finishLambdaExpression(expr is ["LAMBDA",vars,.],env) == ["LAMBDA",[:vars,var],:CDDR expandedFunction] scode := nil -- list of multiple used variables, need local bindings. slist := nil -- list of single used variables, no local bindings. - i := -1 - for v in frees repeat - i := i+1 + for v in frees for i in 0.. repeat + val := ['%vref,"$$",i] vec := [first v,:vec] - rest v = 1 => slist := [[first v,"getShellEntry","$$",i],:slist] - scode := [[first v,["getShellEntry","$$",i]],:scode] + rest v = 1 => slist := [[first v,:val],:slist] + scode := [[first v,val],:scode] body := slist => SUBLISNQ(slist,CDDR expandedFunction) CDDR expandedFunction if scode ~= nil then - body := - body is [["DECLARE",:.],:.] => - [first body,["PROG",nreverse scode, - ["RETURN",["PROGN",:rest body]]]] - [["LET",nreverse scode,:body]] - vec := ["VECTOR",:nreverse vec] + body := [['%bind,nreverse scode,:body]] + vec := ['%veclit,:nreverse vec] ["LAMBDA",[:vars,"$$"],:body] fname := ["CLOSEDFN",expandedFunction] --Like QUOTE, but gets compiled - frees = nil => ["LIST",fname] ["CONS",fname,vec] compWithMappingMode(x,m is ["Mapping",m',:sl],oldE) == @@ -1261,7 +1255,8 @@ compIf(["IF",a,b,c],m,E) == canReturn(expr,level,exitCount,ValueFlag) == --SPAD: exit and friends atom expr => ValueFlag and level=exitCount - (op:= expr.op)="QUOTE" => ValueFlag and level=exitCount + op := expr.op + op in '(QUOTE CLOSEDFN) => ValueFlag and level=exitCount op="TAGGEDexit" => expr is [.,count,data] => canReturn(data.expr,level,count,count=level) level=exitCount and not ValueFlag => nil -- cgit v1.2.3