--- sml/trunk/src/compiler/FLINT/opt/fixfix.sml 1998/10/12 03:31:38 160 +++ sml/trunk/src/compiler/FLINT/opt/fixfix.sml 1998/10/27 22:16:21 162 @@ -40,6 +40,9 @@ val cplv = LambdaVar.dupLvar +(* to limit the amount of uncurrying *) +val maxargs = Control.FLINT.maxargs + structure SccNode = struct type node = LambdaVar.lvar val eq = (op =) @@ -72,19 +75,24 @@ fun fdcon (fv,(s,Access.EXN(Access.LVAR lv),lty)) = addv(fv, F.VAR lv) | fdcon (fv,_) = fv - (* recognize the curried essence of a function. *) - fun curry (head,r) (le as (F.FIX([(fk,f,args,body)], F.RET[F.VAR lv]))) = + (* recognize the curried essence of a function. + * - hd:bool identifies the head of the (potentially) curried function + * - r:bool indicates whether the head was recursive + * - na:int gives the number of args still allowed *) + fun curry (hd,r,na) (le as (F.FIX([(fk,f,args,body)], F.RET[F.VAR lv]))) = if lv = f then case fk of F.FK_FCT => ([], le) (* don't bother *) | F.FK_FUN {inline=true,...} => ([], le) (* don't bother *) | F.FK_FUN fk' => let val fisrec = isSome(#isrec fk') - in if head orelse r orelse not fisrec then + val na = na - length args + in if na >= 0 andalso (hd orelse r orelse not fisrec) then (* recursive functions are only accepted for uncurrying * if they are the head of the function or if the head * is already recursive *) - let val (funs,body) = curry (false, r orelse fisrec) body + let val (funs,body) = + curry (false, r orelse fisrec, na) body in ((fk,f,args)::funs,body) end else ([], le) @@ -212,7 +220,7 @@ (* process each fun *) fun ffun (fdec as (fk,f,args,body):F.fundec,(s,fv,funs,m)) = - case curry (true,false) (F.FIX([fdec], F.RET[F.VAR f])) + case curry (true,false,!maxargs) (F.FIX([fdec], F.RET[F.VAR f])) of (args as _::_::_,body) => (* curried function *) let val ((fk,f,fargs,fbody),(fk',f',fargs',fbody')) = uncurry(args,body)
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: ed function *) let val ((fk,f,fargs,fbody),(fk',f',fargs',fbody')) = uncurry(args,body)