Skip to content

Commit

Permalink
interpreter/state: add 'runtime' field to 'State' for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
pdarragh committed Jun 30, 2022
1 parent df85e9f commit 21cd7d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions interpreter/state.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
;; memory:
;; A [Memory] object from ["memory.rkt"], representing the current stack.
;;
;; runtime:
;; A hash mapping external function names to implementations.
;;
;; TODO: Remove transparency?
;; TODO: Revise implementations of recording devices for consistency? Currently,
;; the registers and flags are meant to be updated functionally while the
Expand All @@ -47,11 +50,14 @@
labels
registers
flags
memory)
memory
runtime)
#:transparent)

;; Given a [Program], initializes the machine state.
(define (initialize-state program)
(define (initialize-state program [runtime #f])
(unless runtime
(set! runtime (hash)))
(let*-values
([(ip sp memory)
(initialize-memory (Program-instructions program))]
Expand All @@ -65,4 +71,4 @@
#f (next-word-aligned-address sp))]
[(registers)
(hash-set new-registers 'rsp sp)])
(State 0 ip ip sp labels registers new-flags memory)))
(State 0 ip ip sp labels registers new-flags memory runtime)))

0 comments on commit 21cd7d9

Please sign in to comment.