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