From: plugd Date: Fri, 15 Oct 2021 16:25:12 +0000 (+0200) Subject: Fleshing out object functions. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=ez.git;a=commitdiff_plain;h=7f12e2648faccb7dc10494e11748181bcc6a85f9 Fleshing out object functions. --- diff --git a/ez.el b/ez.el index e899ab4..f1ef37e 100644 --- a/ez.el +++ b/ez.el @@ -105,16 +105,6 @@ ;; Object tree -(defun ez-make-obj (&optional name attribs props parent first-child next-sibling) - (list name attribs props parent first-child next-sibling)) - -(defun ez-obj-name (obj) (elt obj 0)) -(defun ez-obj-attribs (obj) (elt obj 1)) -(defun ez-obj-props (obj) (elt obj 2)) -(defun ez-obj-parent (obj) (elt obj 3)) -(defun ez-obj-first-child (obj) (elt obj 4)) -(defun ez-obj-next-sibling (obj) (elt obj 5)) - (defvar ez-property-defaults nil) (defun ez-load-property-defaults () @@ -122,6 +112,31 @@ (dotimes (i 31) (aset ez-property-defaults i (aref ez-memory (+ ez-objtab-addr (* 2 i)))))) +(defun ez-get-obj-addr (obj-id) + (+ ez-objtab-addr (* 2 31) (* 9 (- obj-id 1)))) + +(defun ez-get-obj-parent (obj-id) + (let ((addr (ez-get-obj-addr obj-id))) + (ez-mem-ref-byte (+ addr 4)))) + +(defun ez-get-obj-sibling (obj-id) + (let ((addr (ez-get-obj-addr obj-id))) + (ez-mem-ref-byte (+ addr 5)))) + +(defun ez-get-obj-child (obj-id) + (let ((addr (ez-get-obj-addr obj-id))) + (ez-mem-ref-byte (+ addr 6)))) + +(defun ez-get-obj-plist-addr (obj-id) + (let ((addr (ez-get-obj-addr obj-id))) + (ez-mem-ref-word (+ addr 7)))) + +(defun ez-get-obj-name (obj-id) + (let ((plist-addr (ez-get-obj-plist-addr obj-id))) + (if (> (ez-mem-ref-byte plist-addr) 0) + (ez-get-zstring (+ 1 (ez-get-obj-plist-addr obj-id))) + nil))) + (defun ez-get-obj (obj-id) (let ((addr (+ ez-objtab-addr (* 2 31) @@ -135,7 +150,7 @@ (let ((plist-addr (ez-mem-ref-word (+ addr 7)))) (if (> (ez-mem-ref-byte plist-addr) 0) (ez-get-zstring (+ 1 plist-addr)) - ""))))) + nil))))) ;; Z-strings @@ -183,9 +198,9 @@ ((memq char '(1 2 3)) ;Abbreviation (setq abbrev-char char)) ((= char 4) - (setq cur (mod (+ cur 1) 2))) + (setq cur (mod (+ cur 1) 3))) ((= char 5) - (setq cur (mod (+ 2 (- cur 1)) 2))) + (setq cur (mod (+ 3 (- cur 1)) 3))) (t (setq s (concat s (substring (elt ez-zstring-alphabets cur) char (+ char 1)))) @@ -331,7 +346,7 @@ operand-types (cdr operands-and-types))))) (let ((table-row (assoc (list optype opcode) ez-op-table))) (unless table-row - (error "Unsupported op" optype opcode)) + (error "Unsupported op" instr-pc optype opcode operands operand-types)) (let ((mnemonic (elt table-row 1))) (message "PC:%x Optype:%s Opcode:%x Mnemonic:%s Operands:%s" instr-pc optype opcode mnemonic operands)) @@ -527,8 +542,14 @@ (setq ez-call-stack (list (ez-make-call-stack-frame ez-start-pc))) (ez-execute-instr) +(while (ez-execute-instr)) + (binformat #x97) "10010111" +(ez-get-obj 208) +(binformat #x57) +"01010111" + ez-call-stack