aboutsummaryrefslogtreecommitdiff
path: root/frontend/Heap.dcl
blob: b6f3329fff9a3c54de6f65d3c61787f2f151b6a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
definition module Heap

import StdClass

:: Heap v = {heap::!.HeapN v}
:: .HeapN v
:: Ptr v = {pointer::!.(PtrN v)};
:: PtrN v = Ptr !v !(HeapN v);

newHeap		:: .Heap v

nilPtr		:: Ptr v

isNilPtr 	:: !(Ptr v) -> Bool

newPtr		:: !v !*(Heap v) -> (!.Ptr v,!.Heap v)

readPtr		:: !(Ptr v) !u:(Heap v) -> (!v,!u:Heap v)

writePtr	:: !(Ptr v) !v !*(Heap v) -> .Heap v

sreadPtr	:: !(Ptr v) !(Heap v) -> v

allocPtr :: Ptr v;

initPtr :: !(Ptr v) !v !*(Heap v) !*World -> (!.Heap v,!*World);

ptrToInt 	:: !(Ptr w) -> Int

(<:=) infixl 
(<:=) heap ptr_and_val :== writePtr ptr val heap 
where
	(ptr, val) = ptr_and_val

instance == (Ptr a)