Skip to content

Commit

Permalink
add util to diagnose WORDS
Browse files Browse the repository at this point in the history
  • Loading branch information
devyn committed Aug 16, 2023
1 parent 70936b6 commit 6372853
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stage1/words.s
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ INITIAL_WORDS:
.ascii "unbox-integer$"
.balign 8

.quad WORDS
.byte 6
.byte LISP_OBJECT_TYPE_INTEGER
.ascii "words$"
.balign 8

# end
.quad 0
.quad 0
Expand Down
10 changes: 10 additions & 0 deletions stage2/03-list-util.lsp
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@
(eval scope (car args))
(eval scope (cadr args)))))))

; (range 0 5) => (0 1 2 3 4)
(define range
(proc args scope
(let1 start (eval scope (car args))
(let1 end (eval scope (cadr args))
(if (zero? (car (call-native -$ 1 end start)))
()
(cons start (range
(car (call-native +$ 1 start 1))
end)))))))
7 changes: 7 additions & 0 deletions stage2/22-words-util.lsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(define get-words (fn (index)
(let1 addr (peek.d (+ words$ (<< index 3)))
(seq
(call-native acquire-object$ 0 addr)
(deref addr))))))

;(map (fn (index) (length (get-words index))) (range 0 63))

0 comments on commit 6372853

Please sign in to comment.