@@ -52,6 +52,8 @@ data SAlt = SConCase Tag [Name] SCExp
52 | SDefaultCase SCExp
52 | SDefaultCase SCExp
53 deriving Show
53 deriving Show
55+type Prims = [(Name, ([CType], CType, SPrim))]
55sInt, sFloat, sChar, sString, sPtr, sBigInt :: CType
57sInt, sFloat, sChar, sString, sPtr, sBigInt :: CType
56sInt = Just IType
58sInt = Just IType
57sFloat = Just FlType
59sFloat = Just FlType
@@ -62,6 +64,15 @@ sBigInt = Just BIType
63type SCState = ([(Name, SCDef)], Name)
65type SCState = ([(Name, SCDef)], Name)
67+toSC :: Prims -> (Name, Def) -> [(Name, SCDef)]
69+ = case lookup n prims of
70+ Nothing -> sclift (n, d)
71+ Just (args, rt, op) ->
72+ let anames = zipWith mkA args [0..] in
73+ [(n, SCDef anames (SPrimOp op (map (SRef . fst) anames)))]
74+ where mkA t i = (MN i "primArg", t)
65sclift :: (Name, Def) -> [(Name, SCDef)]
76sclift :: (Name, Def) -> [(Name, SCDef)]
66sclift (n, d) = fst (execState (sc [] d) ([], n))
77sclift (n, d) = fst (execState (sc [] d) ([], n))