Fix the add-node function
This commit is contained in:
parent
d324fdd5d7
commit
1a39377ca1
2 changed files with 7 additions and 4 deletions
|
@ -115,7 +115,7 @@
|
|||
(define (ppr-node a)
|
||||
(cond
|
||||
[(integer? a)
|
||||
(iseq-append "NNum" (number->string a))]
|
||||
(iseq-append "NNum " (number->string a))]
|
||||
[(not (eq? (car a) 'define))
|
||||
(let ([fun (first a)]
|
||||
[arg (second a)])
|
||||
|
@ -136,7 +136,7 @@
|
|||
(let ([ppr-stack-item
|
||||
: (-> Addr ISeq)
|
||||
(λ (addr) (iseq-append (ppr-fwaddr addr) ": " (ppr-stack-node heap (lookup-node heap addr))))])
|
||||
(iseq-append "Stk [" (list 'Hang -1 (ppr-list ppr-stack-item 'Newline stack)))))
|
||||
(iseq-append "Stk [" (list 'Hang 0 (ppr-list ppr-stack-item 'Newline stack)) "]")))
|
||||
|
||||
(: ppr-state (-> State ISeq))
|
||||
(define (ppr-state st)
|
||||
|
@ -170,3 +170,5 @@
|
|||
[(? string?) (display i s)]))])
|
||||
(go l a)
|
||||
(get-output-string s))))
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
|
|
@ -48,8 +48,9 @@
|
|||
|
||||
(: allocate-node (-> Heap Node (Values Heap Addr)))
|
||||
(define (allocate-node heap node)
|
||||
(let ([heap (treelist-add heap node)])
|
||||
(values heap (treelist-length heap))))
|
||||
(let ([addr (treelist-length heap)]
|
||||
[heap (treelist-add heap node)])
|
||||
(values heap addr)))
|
||||
|
||||
(: lookup-node (-> Heap Addr Node))
|
||||
(define lookup-node treelist-ref)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue