on master help sign in
Added malloc and trace_malloc

*** This will need the latest EpiVM ***

commit02003d7ad5d2fbebabde6f7cc6de0c76df1ed872 authorEdwin Brady <eb@cs.st-andrews.ac.uk> dateMon 27 Feb 2012, 16:11 (15 years ago) parentd466a82
3 files changed+14−1
lib/builtins.idr+6 samples/interp.idr+1−1 src/Idris/Compiler.hs+7
lib/builtins.idr+6
@@ -21,6 +21,12 @@ sym refl = refl
2121lazy : a -> a
2222lazy x = x -- compiled specially
2323
24+malloc : Int -> a -> a
25+malloc size x = x -- compiled specially
26+
27+trace_malloc : a -> a
28+trace_malloc x = x -- compiled specially
29+
2430believe_me : a -> b -- compiled specially as id, use with care!
2531believe_me x = prim__believe_me _ _ x
2632
samples/interp.idr+1−1
@@ -92,5 +92,5 @@ testFac : Int
9292testFac = interp [] eFac 4
9393
9494main : IO ()
95−main = print testFac
95+main = malloc 79856 (print testFac)
9696
src/Idris/Compiler.hs+7
@@ -102,6 +102,13 @@ instance ToEpic (TT Name) where
102102 = do v' <- epic' env v
103103 k' <- epic' env k
104104 return (k' @@ (effect_ v'))
105+ | (P _ (UN "malloc") _, [_,size,t]) <- unApply tm
106+ = do size' <- epic' env size
107+ t' <- epic' env t
108+ return $ malloc_ size' t'
109+ | (P _ (UN "trace_malloc") _, [_,t]) <- unApply tm
110+ = do t' <- epic' env t
111+ return $ mallocTrace_ t'
105112 | (P (DCon t a) n _, args) <- unApply tm
106113 = epicCon env t a n args
107114 epic' env (P (DCon t a) n _) = return $ con_ t