on master help sign in
put toSC in the right place
commit782d0f707227f784015e9140b2a8b0a826b22e45 authorEdwin Brady <eb@cs.st-andrews.ac.uk> dateMon 21 May 2012, 16:58 (14 years ago) parent6554c7d
4 files changed+15−11
src/Idris/AbsSyntax.hs+1−1 src/Idris/REPL.hs+3−2 src/RTS/Bytecode.hs−8 src/RTS/SC.hs+11
src/Idris/AbsSyntax.hs+1−1
@@ -67,7 +67,7 @@ data IState = IState { tt_ctxt :: Context,
6767 syntax_keywords :: [String],
6868 imported :: [FilePath],
6969 idris_prims :: [(Name, ([E.Name], E.Term))],
70− idris_scprims :: [(Name, ([CType], CType, SPrim))],
70+ idris_scprims :: Prims,
7171 idris_objs :: [FilePath],
7272 idris_libs :: [String],
7373 idris_hdrs :: [String],
src/Idris/REPL.hs+3−2
@@ -199,9 +199,10 @@ process fn (DebugInfo n)
199199 let d = lookupDef Nothing n (tt_ctxt i)
200200 when (not (null d)) $ liftIO $
201201 do print (head d)
202− print (toSC i (n, head d))
202+ let prims = idris_scprims i
203+ print (toSC prims (n, head d))
203204 putStrLn (showSep "\n"
204− (map show (bcdefs (toSC i (n, head d)))))
205+ (map show (bcdefs (toSC prims (n, head d)))))
205206process fn (Info n) = do i <- get
206207 case lookupCtxt Nothing n (idris_classes i) of
207208 [c] -> classInfo c
src/RTS/Bytecode.hs−8
@@ -42,14 +42,6 @@ type Bytecode = [BCOp]
4242data BCProg = BCProg [(Name, Bytecode)]
4343 deriving Show
4444
45−toSC :: IState -> (Name, Def) -> [(Name, SCDef)]
46−toSC i (n, d) = case lookup n (idris_scprims i) of
47− Nothing -> sclift (n, d)
48− Just (args, rt, op) ->
49− let anames = zipWith mkA args [0..] in
50− [(n, SCDef anames (SPrimOp op (map (SRef . fst) anames)))]
51− where mkA t i = (MN i "primArg", t)
52−
5345bcdefs :: [(Name, SCDef)] -> [(Name, Bytecode)]
5446bcdefs = map (\ (n, s) -> (n, bc [] s))
5547
src/RTS/SC.hs+11
@@ -52,6 +52,8 @@ data SAlt = SConCase Tag [Name] SCExp
5252 | SDefaultCase SCExp
5353 deriving Show
5454
55+type Prims = [(Name, ([CType], CType, SPrim))]
56+
5557sInt, sFloat, sChar, sString, sPtr, sBigInt :: CType
5658sInt = Just IType
5759sFloat = Just FlType
@@ -62,6 +64,15 @@ sBigInt = Just BIType
6264
6365type SCState = ([(Name, SCDef)], Name)
6466
67+toSC :: Prims -> (Name, Def) -> [(Name, SCDef)]
68+toSC prims (n, d)
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)
75+
6576sclift :: (Name, Def) -> [(Name, SCDef)]
6677sclift (n, d) = fst (execState (sc [] d) ([], n))
6778