diff options
Diffstat (limited to 'CStack.icl')
-rw-r--r-- | CStack.icl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/CStack.icl b/CStack.icl new file mode 100644 index 0000000..f549c4f --- /dev/null +++ b/CStack.icl @@ -0,0 +1,21 @@ +implementation module ABC.CStack + +import StdEnv + +import ABC.Def + +cs_init :: CStack +cs_init = [] + +cs_get :: CSrc CStack -> InstrId +cs_get _ [] = abortn "cs_get: index too large" +cs_get 0 [i:_] = i +cs_get i [_:s] = cs_get (i-1) s + +cs_popn :: CSrc CStack -> CStack +cs_popn 0 s = s +cs_popn _ [] = abortn "cs_popn: popping too many elements" +cs_popn i [_:s] = cs_popn (i-1) s + +cs_push :: InstrId CStack -> CStack +cs_push i s = [i:s] |