Skip to content

Commit

Permalink
#578 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 20, 2022
1 parent 0dc94a4 commit 8a72613
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/gray/heap.eo
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,17 @@
[address length] > pointer
address > @

# Increment this pointer by x steps forward
[x] > add
&.^.pointer > @
address.add
length.mul x
length

# Decrement this pointer by x steps backward
[x] > sub
&.add > @
x.mul -1

# One block in the heap.
[len inverse] > block /?
12 changes: 9 additions & 3 deletions eo-runtime/src/test/eo/org/eolang/gray/heap-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@
[] > increments-pointer
heap 1024 > h
h.pointer 0 2 > p1
p1.add 1 > p2
p1.add 2 > p2
p2.sub 1 > p3
and. > @
(p1.block 4).write ("DUDE".as-bytes)
(p1.block 6).write ("HELLO!".as-bytes)
eq.
p2.block
2
[b] (b.as-string > @)
"DE"
"O!"
eq.
p3.block
2
[b] (b.as-string > @)
"LL"

0 comments on commit 8a72613

Please sign in to comment.