Commit 057ce061 authored by John van Groningen's avatar John van Groningen

initPtr modifies the *World

parent e52f3653
......@@ -23,7 +23,7 @@ sreadPtr :: !(Ptr v) !(Heap v) -> v
allocPtr :: Ptr v;
initPtr :: !(Ptr v) !v !*(Heap v) -> .Heap v;
initPtr :: !(Ptr v) !v !*(Heap v) !*World -> (!.Heap v,!*World);
ptrToInt :: !(Ptr w) -> Int
......
......@@ -46,6 +46,27 @@ allocPtr = code {
pop_a 2
};
initPtr :: !(Ptr v) !v !*(Heap v) !*World -> (!.Heap v,!*World);
initPtr p v h w
= code {
push_args 0 2 2
pop_a 1
eq_desc _Cons 0 0
pop_a 1
jmp_false init_pointer_error
push_a 2
push_a 2
fill1_r e_Heap_kPtr 2 0 2 011
.keep 0 2
pop_a 2
.d 2 0
rtn
:init_pointer_error
pop_a 3
print "initPtr: Pointer already initialized"
halt
};
/*
initPtr :: !(Ptr v) !v !*(Heap v) -> .Heap v;
initPtr p v h
= code {
......@@ -66,6 +87,7 @@ initPtr p v h
print "initPtr: Pointer already initialized"
halt
};
*/
readPtr :: !(Ptr v) !u:(Heap v) -> (!v,!u:Heap v);
readPtr p h = code {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment