From: plugd Date: Thu, 18 Nov 2021 10:29:57 +0000 (+0100) Subject: More operations added. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=8ed7e627cfe9175458a7bae4cbf8bbb35cfc00b4;p=ez.git More operations added. --- diff --git a/ez.el b/ez.el index 1efc2d6..1fb0f65 100644 --- a/ez.el +++ b/ez.el @@ -147,14 +147,14 @@ (let ((addr (ez-get-obj-addr obj))) (ez-mem-set-byte (+ addr 6) new-child))) -(defun ez-get-obj-plist-addr (obj-id) - (let ((addr (ez-get-obj-addr obj-id))) +(defun ez-get-obj-plist-addr (obj) + (let ((addr (ez-get-obj-addr obj))) (ez-mem-ref-word (+ addr 7)))) -(defun ez-get-obj-name (obj-id) - (let ((plist-addr (ez-get-obj-plist-addr obj-id))) +(defun ez-get-obj-name (obj) + (let ((plist-addr (ez-get-obj-plist-addr obj))) (if (> (ez-mem-ref-byte plist-addr) 0) - (ez-get-zstring (+ 1 (ez-get-obj-plist-addr obj-id))) + (ez-get-zstring (+ 1 (ez-get-obj-plist-addr obj))) nil))) (defun ez-get-prop-default (prop) @@ -527,6 +527,8 @@ ((var #x02) storeb ez-op-storeb) ((2op #x10) loadb ez-op-loadb) ((2op #x01) je ez-op-je) + ((2op #x02) jl ez-op-jl) + ((2op #x06) jin ez-op-jin) ((2op #x08) or ez-op-or) ((2op #x09) and ez-op-and) ((2op #x14) add ez-op-add) @@ -544,10 +546,12 @@ ((1op #x09) remove_obj ez-op-remove-obj) ((2op #x0E) insert_obj ez-op-insert-obj) ((var #x03) put_prop ez-op-put-prop) + ((2op #x11) get_prop ez-op-get-prop) ((0op #x02) print ez-op-print) ((0op #x0B) new_line ez-op-new-line) ((var #x06) print_num ez-op-print-num) - ((var #x05) print_char ez-op-print-char))) + ((var #x05) print_char ez-op-print-char) + ((1op #x0A) print_obj ez-op-print-obj))) (defun ez-op-ret (operands &optional operand-types) (let ((retval (car operands))) @@ -595,6 +599,12 @@ (ez-op-jl (cons (ez-get-var var) (cdr operands)) (cons 'w (cdr operand-types)))) t) +(defun ez-op-jin (operands operand-types) + (let ((obj (car operands)) + (n (cadr operands))) + (ez-do-branch (or (= n 0) + (= n (ez-get-obj-parent obj))))) + t) (defun ez-op-jump (operands operand-types) (let ((offset (if (eq (car operand-types) 'b) @@ -721,20 +731,19 @@ (defun ez-op-get-sibling (operands operand-types) (let ((sib (ez-get-obj-sibling (car operands)))) (ez-set-var (ez-read-pc-byte-and-inc) sib) - (ez-do-branch (> sib 0)) - t)) + (ez-do-branch (> sib 0))) + t) (defun ez-op-get-child (operands operand-types) (let ((child (ez-get-obj-child (car operands)))) (ez-set-var (ez-read-pc-byte-and-inc) child) - (ez-do-branch (> child 0)) - t)) + (ez-do-branch (> child 0))) + t) (defun ez-op-get-parent (operands operand-types) (let ((parent (ez-get-obj-parent (car operands)))) - (ez-set-var (ez-read-pc-byte-and-inc) parent) - (ez-do-branch (> parent 0)) - t)) + (ez-set-var (ez-read-pc-byte-and-inc) parent)) + t) (defun ez-op-remove-obj (operands operand-types) (let ((obj (car operands))) @@ -751,8 +760,15 @@ (let* ((obj (car operands)) (prop (cadr operands)) (a (caddr operands))) - (ez-set-obj-prop obj prop a) - t)) + (ez-set-obj-prop obj prop a)) + t) + +(defun ez-op-get-prop (operands operand-types) + (let* ((obj (car operands)) + (prop (cadr operands))) + (ez-set-var (ez-read-pc-byte-and-inc) + (ez-get-obj-prop obj prop))) + t) (defun ez-op-print (operands operand-types) (let* ((word-count-and-string (ez-get-zstring-and-length (ez-get-pc))) @@ -776,6 +792,10 @@ (ez-print (string c))) t) +(defun ez-op-print-obj (operands operand-types) + (let ((obj (car operands))) + (ez-print (ez-get-obj-name obj))) + t) ;; Execution loop