diff options
author | sjakie | 2000-02-07 13:03:01 +0000 |
---|---|---|
committer | sjakie | 2000-02-07 13:03:01 +0000 |
commit | f22483910cad05eb43c88dcbddd296f3809cfc6d (patch) | |
tree | 515042fad28547e3e9307a77ca4db3db10adb437 /frontend/Heap.icl | |
parent | bug 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.icl | 18 |
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 |