1 module WrapSubtrans 2 3 where 4 5 import FAtypes 6 import FAsubtrans 7 8 import Syntax 9 import Ids 10 import Semantik 11 import Options 12 13 import FA2Exp 14 15 subtrans :: Opts -> Env Auto Auto -> [Exp] -> FIO (Auto, Env Auto Auto) 16 subtrans opts env args = 17 do { moops (length args /= 2) 18 ( "subtrans needs exactly 2 arguments" ++ show args ) 19 ; let [f, a] = args 20 ; v <- case f of 21 App id _ -> return id 22 _ -> oops ("first arg of subtrans must be function name " 23 ++ show args) 24 ; (w, _) <- comp opts env a 25 26 -- for converting auto to exp 27 ; let opts1 = addListToOpts opts 28 [("expand","off"),("foldconst","off"),("foldnonrec","off")] 29 30 -- for computing intermediate results 31 ; let opts2 = addListToOpts opts 32 [("min","off"),("det","off")] 33 34 ; return ( subtransTNFA opts 35 (\ opts a -> docomp opts2 env 36 (App v [tnfa2exp opts1 a])) 37 w 38 , env ) 39 }