 (def *inst-width* 4)
 
 (def *vm-inst-list*
-     '[(VM_DUMMY nil)
+     '[(:VM_DUMMY nil)
 
        ;; basic stack and register operation
-       (VM_IVAL lispval)
-       (VM_IVAL_PUSH lispval)
-       (VM_VREF_PUSH lispval-symbol)
-       (VM_PUSH nil)
-       (VM_POP nil)
+       (:VM_IVAL lispval)
+       (:VM_IVAL_PUSH lispval)
+       (:VM_VREF_PUSH lispval-symbol)
+       (:VM_PUSH nil)
+       (:VM_POP nil)
 
        ;; control flow
-       (VM_JMP integer)
-       (VM_BIF integer)
-       (VM_BIFN integer)
-       (VM_PUSH_FRAME nil)
-       (VM_FUNCALL lispval)
+       (:VM_JMP integer)
+       (:VM_BIF integer)
+       (:VM_BIFN integer)
+       (:VM_PUSH_FRAME nil)
+       (:VM_FUNCALL lispval)
 
        ;; lisp namespace operation
-       (VM_BIND lispval-symbol)	;; bind stack-top value to symbol(operand)
-       (VM_UNBIND integer) ;; unbind symbol(operand)
-       (VM_VREF lispval-symbol)	  ;; refer value of symbol(operand)
-       (VM_VSET lispval-symbol)	  ;; overwrite symbol(operand) by %val
+       (:VM_BIND lispval-symbol)	;; bind stack-top value to symbol(operand)
+       (:VM_UNBIND integer) ;; unbind symbol(operand)
+       (:VM_VREF lispval-symbol)	  ;; refer value of symbol(operand)
+       (:VM_VSET lispval-symbol)	  ;; overwrite symbol(operand) by %val
 
        ;; basic arithmetic operation
-       (VM_LT nil)
-       (VM_GT nil)
-       (VM_LE nil)
-       (VM_GE nil)
-       (VM_EQ nil)
-       (VM_PLUS nil)
-       (VM_MINUS nil)
+       (:VM_LT nil)
+       (:VM_GT nil)
+       (:VM_LE nil)
+       (:VM_GE nil)
+       (:VM_EQ nil)
+       (:VM_PLUS nil)
+       (:VM_MINUS nil)
 
        ;; lisp data operation
-       (VM_CONS nil)	      ;; (cons <stack-top> <%val>)
-       (VM_IVAL_CONS lispval) ;; (cons <stack-top> <immval>)
+       (:VM_CONS nil)	      ;; (cons <stack-top> <%val>)
+       (:VM_IVAL_CONS lispval) ;; (cons <stack-top> <immval>)
        ])
 
 (def *vm-builtin-funs*

(defn pp-program [insts]
  (dotimes [i (count insts)]
    (let [inst (nth insts i),
	  inst-name (unqualify-symbol (first inst))
	  inst-spec (some (fn [spec] (and (= inst-name (first spec)) spec))
			  *vm-inst-list*)
	  inst-operand (second inst)

	(recur (+ idx 1) pred (rest coll)))))
  (inner-index 0 pred coll))

(defn #^{:doc "Encode a VM instruction to bytes"}
  encode-inst [inst]
  (let [inst-name (first inst),
	inst-operand (or (second inst) 0),
	inst-spec (some (fn [inst-spec] (= inst-name (first inst-spec)))
			*vm-inst-list*)]
