Remove some stacks
This commit is contained in:
parent
fa9befd8b0
commit
66856cf99f
@ -100,7 +100,7 @@
|
||||
;; 5 types x 1 function = 5 instructions
|
||||
(generate-functions [:boolean :char :float :integer :string] [_eq])
|
||||
|
||||
;; 8 types x 12 function = 96 instructions
|
||||
;; 7 types x 12 function = 84 instructions
|
||||
(generate-functions
|
||||
[:boolean :char :code :exec :float :integer :string]
|
||||
[_dup _duptimes _dupitems _empty _flush _pop _rot _shove _stackdepth
|
||||
|
@ -1,35 +1,23 @@
|
||||
(ns propeller.push.state)
|
||||
|
||||
;; Set of all stacks used by the Push interpreter
|
||||
(defonce stacks #{:auxiliary
|
||||
:boolean
|
||||
:char
|
||||
:code
|
||||
:environment
|
||||
:exec
|
||||
:float
|
||||
:genome
|
||||
:gtm
|
||||
:input
|
||||
:integer
|
||||
:output
|
||||
:return
|
||||
:string
|
||||
:tag
|
||||
:vector_boolean
|
||||
:vector_float
|
||||
:vector_integer
|
||||
:vector_string
|
||||
:zip})
|
||||
|
||||
;; Record-based states for performance
|
||||
(defmacro define-push-state []
|
||||
`(defrecord ~'State [~@(map #(symbol (name %)) stacks)]))
|
||||
|
||||
(define-push-state)
|
||||
|
||||
;; Empty push state - each stack type is nil
|
||||
(defonce empty-state (map->State {}))
|
||||
;; Empty push state - all available stacks are empty
|
||||
(defonce empty-state {:auxiliary '()
|
||||
:boolean '()
|
||||
:char '()
|
||||
:code '()
|
||||
:environment '()
|
||||
:exec '()
|
||||
:float '()
|
||||
:genome '()
|
||||
:input {}
|
||||
:integer '()
|
||||
:return '()
|
||||
:string '()
|
||||
:tag '()
|
||||
:vector_boolean '()
|
||||
:vector_float '()
|
||||
:vector_integer '()
|
||||
:vector_string '()})
|
||||
|
||||
(def example-push-state
|
||||
{:exec '()
|
||||
|
@ -32,7 +32,7 @@
|
||||
;; Pretty-prints a Push state, for logging or debugging purposes
|
||||
(defn print-state
|
||||
[state]
|
||||
(doseq [stack state/stacks]
|
||||
(doseq [stack (keys state/empty-state)]
|
||||
(printf "%-15s = " stack)
|
||||
(prn (if (get state stack) (get state stack) '()))
|
||||
(flush)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user