(* Exp to Function name *) structure fnNames= struct structure Op = TreeOps structure Ty = TreeILTypes structure IL=TreeIL structure CE=clangEin val default=[] val defaultExp="Exp-default" fun q n=Int.toString n (*Returns names for functions*) fun OptoCString rator = (case rator of Op.prodScaV n => CE.applyfn(CE.rtnVec n,CE.scale n,CE. Sconcat [CE.argReal,CE.argVec n]) | Op.sumVec n => CE.applyfn(CE.rtnReal, CE.sum n,CE.argVec n) | Op.imgAddr _ => default | Op.imgLoad _ => default | _ => default (* end case *)) fun flat [] = [] | flat (l::ls) = l @ flat ls; (*return:resultTy and fnName*) fun ExptoCString2 exp=(case exp of IL.E_Op(Op, exps) =>let val fnName = OptoCString Op val argName=flat(List.map ExptoCString2 exps) in fnName@argName end | IL.E_LoadVec(fullTy, origTy, exp, offset) =>let val fnName = CE.loadVec(fullTy,origTy) (* [IL.E_Lit( offset)*) val m = String.concat[CE.argInt,",",CE.argVec origTy] in CE.applyfn(CE.rtnVec fullTy ,fnName,m)@(ExptoCString2 exp) end | IL.E_mkVec(fullTy,origTy,Ty.vectorLength peices,exps) =>let val fnName=CE.mkVec(origTy,fullTy) val argName= flat(List.map ExptoCString2 exps) val m=String.concatWith "," (List.map CE.argVec peices) in CE.applyfn(CE.rtnVec origTy,fnName,m)@argName end | IL.E_Cons _ => [] | IL.E_Var _ => [] | IL.E_Lit _ => [] | _=>[defaultExp] (*end case*)) fun ExptoCStringPnt(IL.S_Assign (_,exp))= let val a= ExptoCString2 exp val _=print("\n \t Function names:\n \t\t ") val _=print (String.concatWith"\n\t\t" a) in a end fun ExptoCString(IL.S_Assign (_,exp))= ExptoCString2 exp (*Filter Types, Just one of each *) fun m([],rest)=rest | m (e1::es, rest)=(case (List.find(fn x=> (x=e1)) rest) of NONE=> m (es, rest@[e1]) | _ => m (es, rest) (*end case*)) fun gotFiltered []= (print(String.concat["\n \t No Function Name"]);1) | gotFiltered fnName= let val names=m (fnName,[]) val pnstr= print(String.concat[" Final function Calls:\n ",String.concatWith "\n\t\t" names,"\n\n "]) in 1 end end
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: Final function Calls:\n ",String.concatWith "\n\t\t" names,"\n\n "]) in 1 end end