aboutsummaryrefslogtreecommitdiff
path: root/frontend/Heap.icl
diff options
context:
space:
mode:
authorsjakie2000-02-07 13:03:01 +0000
committersjakie2000-02-07 13:03:01 +0000
commitf22483910cad05eb43c88dcbddd296f3809cfc6d (patch)
tree515042fad28547e3e9307a77ca4db3db10adb437 /frontend/Heap.icl
parentbug fix: Observations (diff)
commit for Sjaak by RWS
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@83 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'frontend/Heap.icl')
-rw-r--r--frontend/Heap.icl18
1 files changed, 15 insertions, 3 deletions
diff --git a/frontend/Heap.icl b/frontend/Heap.icl
index a50b10a..3a99c89 100644
--- a/frontend/Heap.icl
+++ b/frontend/Heap.icl
@@ -1,6 +1,6 @@
implementation module Heap;
-import StdOverloaded;
+import StdOverloaded,StdMisc;
:: Heap v = {heap::!.(HeapN v)};
:: HeapN v = Heap !Int;
@@ -78,7 +78,13 @@ sreadPtr p h = code {
};
writePtr :: !(Ptr v) !v !*(Heap v) -> .Heap v;
-writePtr p v h = code {
+writePtr p v h
+ | isNilPtr p
+ = abort "writePtr: Nil pointer encountered\n";
+ = writePtr2 p v h;
+
+writePtr2 :: !(Ptr v) !v !*(Heap v) -> .Heap v;
+writePtr2 p v h = code {
push_a_b 2
push_r_args_b 0 1 1 1 1
eqI
@@ -101,7 +107,13 @@ writePtr p v h = code {
}
ptrToInt :: !(Ptr v) -> Int;
-ptrToInt p = code {
+ptrToInt p
+ | isNilPtr p
+ = 0;
+ = ptrToInt2 p;
+
+ptrToInt2 :: !(Ptr v) -> Int;
+ptrToInt2 p = code {
push_a_b 0
pop_a 1
build _Nil 0 _hnf