From dd99f144ce50c2c3d2a1e1685a2d74ff533f6535 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Tue, 25 May 2010 05:55:12 +0000 Subject: * interp/g-util.boot: Implement expansion of %collect forms. * interp/c-util.boot (middleEndExpand): Tidy. * interp/g-opt.boot (changeThrowToExit): Don't look into %collect forms. * interp/i-map.boot (getUserIdentifiersIn): Factorize. Handle %collect forms same as COLLECT forms. (findLocalVars1): Likewise. * interp/i-spec1.boot (evalCOLLECT): Now generate %collect forms. (checkForFreeVariables): Factorize. Handle %collect forms same as COLLECT forms. --- src/interp/i-spec1.boot | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/interp/i-spec1.boot') diff --git a/src/interp/i-spec1.boot b/src/interp/i-spec1.boot index cf2c649d..769af133 100644 --- a/src/interp/i-spec1.boot +++ b/src/interp/i-spec1.boot @@ -544,7 +544,7 @@ evalCOLLECT(op,[:itrl,body],m) == iters := [evalLoopIter itr for itr in itrl] bod := getArgValue(body,computedMode body) if bod isnt ['SPADCALL,:.] then bod := ['unwrap,bod] - code := timedOptimization asTupleNewCode0(second m, ['COLLECT,:iters,bod]) + code := timedOptimization asTupleNewCode0(second m, ["%collect",:iters,bod]) putValue(op,object(code,m)) falseFun(x) == nil @@ -817,20 +817,13 @@ checkForFreeVariables(v,locals) == op in '(LAMBDA QUOTE getValueFromEnvironment) => v op = "LETT" => -- Expands to a SETQ. ["SETF",:[checkForFreeVariables(a,locals) for a in args]] - op = "COLLECT" => -- Introduces a new bound variable? + op in '(COLLECT REPEAT %collect) => -- Introduces a new bound variable? first(args) is ["STEP",var,:.] => $boundVariables := [var,:$boundVariables] - r := ["COLLECT",:[checkForFreeVariables(a,locals) for a in args]] + r := [op,:[checkForFreeVariables(a,locals) for a in args]] $boundVariables := delete(var,$boundVariables) r - ["COLLECT",:[checkForFreeVariables(a,locals) for a in args]] - op = "REPEAT" => -- Introduces a new bound variable? - first(args) is ["STEP",var,:.] => - $boundVariables := [var,:$boundVariables] - r := ["REPEAT",:[checkForFreeVariables(a,locals) for a in args]] - $boundVariables := delete(var,$boundVariables) - r - ["REPEAT",:[checkForFreeVariables(a,locals) for a in args]] + [op,:[checkForFreeVariables(a,locals) for a in args]] op = "%LET" => args is [var,form,name] => -- This is some bizarre %LET, not what one would expect in Common Lisp! -- cgit v1.2.3