mirror of
https://github.com/open-goal/jak-project
synced 2026-09-09 12:14:10 -04:00
deftype and defmethod syntax major changes (#3094)
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
This commit is contained in:
+39
-42
@@ -12,7 +12,7 @@
|
||||
|
||||
;; definition for method 8 of type drawable-actor
|
||||
;; WARN: Return type mismatch int vs drawable-actor.
|
||||
(defmethod mem-usage drawable-actor ((this drawable-actor) (arg0 memory-usage-block) (arg1 int))
|
||||
(defmethod mem-usage ((this drawable-actor) (arg0 memory-usage-block) (arg1 int))
|
||||
(set! (-> arg0 length) (max 44 (-> arg0 length)))
|
||||
(set! (-> arg0 data 43 name) "entity")
|
||||
(+! (-> arg0 data 43 count) 1)
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
;; definition for method 8 of type drawable-inline-array-actor
|
||||
;; WARN: Return type mismatch int vs drawable-inline-array-actor.
|
||||
(defmethod mem-usage drawable-inline-array-actor ((this drawable-inline-array-actor) (arg0 memory-usage-block) (arg1 int))
|
||||
(defmethod mem-usage ((this drawable-inline-array-actor) (arg0 memory-usage-block) (arg1 int))
|
||||
(set! (-> arg0 length) (max 1 (-> arg0 length)))
|
||||
(set! (-> arg0 data 0 name) (symbol->string 'drawable-group))
|
||||
(+! (-> arg0 data 0 count) 1)
|
||||
@@ -41,13 +41,13 @@
|
||||
)
|
||||
|
||||
;; definition for method 2 of type entity-links
|
||||
(defmethod print entity-links ((this entity-links))
|
||||
(defmethod print ((this entity-links))
|
||||
(format #t "#<entity-links :process ~A @ #x~X>" (-> this process) this)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for method 2 of type entity-perm
|
||||
(defmethod print entity-perm ((this entity-perm))
|
||||
(defmethod print ((this entity-perm))
|
||||
(format
|
||||
#t
|
||||
"#<entity-perm :aid ~D :task ~D :status #x~X :data #x~X @ #x~X>"
|
||||
@@ -61,7 +61,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 2 of type actor-group
|
||||
(defmethod print actor-group ((this actor-group))
|
||||
(defmethod print ((this actor-group))
|
||||
(format #t "#<actor-group")
|
||||
(dotimes (s5-0 (-> this length))
|
||||
(format #t " ~A" (-> this data s5-0 actor))
|
||||
@@ -71,7 +71,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 3 of type actor-group
|
||||
(defmethod inspect actor-group ((this actor-group))
|
||||
(defmethod inspect ((this actor-group))
|
||||
(format #t "[~8x] ~A~%" this (-> this type))
|
||||
(format #t "~Tlength: ~D~%" (-> this length))
|
||||
(format #t "~Tallocated-length: ~D~%" (-> this allocated-length))
|
||||
@@ -83,25 +83,25 @@
|
||||
)
|
||||
|
||||
;; definition for method 22 of type entity
|
||||
(defmethod birth! entity ((this entity))
|
||||
(defmethod birth! ((this entity))
|
||||
(format #t "birth ~A~%" this)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for method 23 of type entity
|
||||
(defmethod kill! entity ((this entity))
|
||||
(defmethod kill! ((this entity))
|
||||
(format #t "kill ~A~%" this)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for method 2 of type entity
|
||||
(defmethod print entity ((this entity))
|
||||
(defmethod print ((this entity))
|
||||
(format #t "#<~A :name ~S @ #x~X>" (-> this type) (res-lump-struct this 'name structure) this)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for method 26 of type entity
|
||||
(defmethod get-level entity ((this entity))
|
||||
(defmethod get-level ((this entity))
|
||||
(dotimes (v1-0 (-> *level* length))
|
||||
(let ((a1-3 (-> *level* level v1-0)))
|
||||
(when (= (-> a1-3 status) 'active)
|
||||
@@ -257,7 +257,7 @@
|
||||
|
||||
;; definition for method 18 of type level-group
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod update-nav-meshes-method level-group ((this level-group))
|
||||
(defmethod update-nav-meshes-method ((this level-group))
|
||||
"Clashes with a function name"
|
||||
(when (not (paused?))
|
||||
(dotimes (s5-0 (-> this length))
|
||||
@@ -530,7 +530,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 2 of type process
|
||||
(defmethod print process ((this process))
|
||||
(defmethod print ((this process))
|
||||
(cond
|
||||
((and (-> this top-thread) (!= (-> this status) 'dead))
|
||||
(format
|
||||
@@ -572,7 +572,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 3 of type entity
|
||||
(defmethod inspect entity ((this entity))
|
||||
(defmethod inspect ((this entity))
|
||||
(call-parent-method this)
|
||||
(format #t "~Ttrans: ~`vector`P~%" (-> this trans))
|
||||
(format #t "~Taid: ~D~%" (-> this aid))
|
||||
@@ -580,7 +580,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 3 of type entity-nav-mesh
|
||||
(defmethod inspect entity-nav-mesh ((this entity-nav-mesh))
|
||||
(defmethod inspect ((this entity-nav-mesh))
|
||||
((the-as (function object object) (find-parent-method entity-nav-mesh 3)) this)
|
||||
(format #t "~Tnav-mesh ~A~%" (-> this nav-mesh))
|
||||
(if (and (-> this nav-mesh) (nonzero? (-> this nav-mesh)))
|
||||
@@ -590,7 +590,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 3 of type entity-actor
|
||||
(defmethod inspect entity-actor ((this entity-actor))
|
||||
(defmethod inspect ((this entity-actor))
|
||||
(call-parent-method this)
|
||||
(format #t "~Tetype: ~A~%" (-> this etype))
|
||||
(format #t "~Ttask: ~d~%" (-> this task))
|
||||
@@ -662,7 +662,7 @@
|
||||
|
||||
;; definition for method 29 of type entity-actor
|
||||
;; WARN: Return type mismatch entity-actor vs none.
|
||||
(defmethod debug-print entity-actor ((this entity-actor) (arg0 symbol) (arg1 type))
|
||||
(defmethod debug-print ((this entity-actor) (arg0 symbol) (arg1 type))
|
||||
(let ((s4-0 (-> this etype)))
|
||||
(when (or (not arg1) (and s4-0 (valid? s4-0 type (the-as string #f) #f 0) (type-type? s4-0 arg1)))
|
||||
(format #t "~5D #x~8X ~-26S" (-> this extra vis-id) this (res-lump-struct this 'name structure))
|
||||
@@ -736,7 +736,7 @@
|
||||
|
||||
;; definition for method 14 of type level-group
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod debug-print-entities level-group ((this level-group) (arg0 symbol) (arg1 type))
|
||||
(defmethod debug-print-entities ((this level-group) (arg0 symbol) (arg1 type))
|
||||
(let ((t9-0 format)
|
||||
(a0-1 #t)
|
||||
(a1-1
|
||||
@@ -776,7 +776,7 @@
|
||||
;; definition for method 24 of type entity-actor
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch entity-actor vs none.
|
||||
(defmethod add-to-level! entity-actor ((this entity-actor) (arg0 level-group) (arg1 level) (arg2 actor-id))
|
||||
(defmethod add-to-level! ((this entity-actor) (arg0 level-group) (arg1 level) (arg2 actor-id))
|
||||
(let ((v1-4 (-> arg1 entity data (-> arg1 entity length))))
|
||||
(+! (-> arg1 entity length) 1)
|
||||
(set! (-> v1-4 process) #f)
|
||||
@@ -848,7 +848,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 25 of type entity
|
||||
(defmethod remove-from-level! entity ((this entity) (arg0 level-group))
|
||||
(defmethod remove-from-level! ((this entity) (arg0 level-group))
|
||||
(let ((v1-0 (-> this extra)))
|
||||
(cond
|
||||
((= (-> v1-0 next-link) v1-0)
|
||||
@@ -887,7 +887,7 @@
|
||||
|
||||
;; definition for method 25 of type level-group
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod update-vis-volumes level-group ((this level-group))
|
||||
(defmethod update-vis-volumes ((this level-group))
|
||||
(local-vars (sv-16 pointer) (sv-20 pointer) (sv-24 pointer) (sv-28 process))
|
||||
(dotimes (s5-0 (-> this length))
|
||||
(let ((v1-3 (-> this level s5-0)))
|
||||
@@ -986,7 +986,7 @@
|
||||
;; WARN: Stack slot offset 32 signed mismatch
|
||||
;; WARN: Stack slot offset 32 signed mismatch
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod update-vis-volumes-from-nav-mesh level-group ((this level-group))
|
||||
(defmethod update-vis-volumes-from-nav-mesh ((this level-group))
|
||||
(local-vars
|
||||
(sv-16 pointer)
|
||||
(sv-20 vector)
|
||||
@@ -1092,7 +1092,7 @@
|
||||
;; WARN: Stack slot offset 20 signed mismatch
|
||||
;; WARN: Stack slot offset 20 signed mismatch
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod print-volume-sizes level-group ((this level-group))
|
||||
(defmethod print-volume-sizes ((this level-group))
|
||||
(local-vars
|
||||
(sv-16 pointer)
|
||||
(sv-20 float)
|
||||
@@ -1195,18 +1195,15 @@
|
||||
|
||||
;; definition of type debug-actor-info
|
||||
(deftype debug-actor-info (basic)
|
||||
((name basic :offset-assert 4)
|
||||
(handle handle :offset-assert 8)
|
||||
(process basic :offset-assert 16)
|
||||
(pid int32 :offset-assert 20)
|
||||
((name basic)
|
||||
(handle handle)
|
||||
(process basic)
|
||||
(pid int32)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x18
|
||||
:flag-assert #x900000018
|
||||
)
|
||||
|
||||
;; definition for method 3 of type debug-actor-info
|
||||
(defmethod inspect debug-actor-info ((this debug-actor-info))
|
||||
(defmethod inspect ((this debug-actor-info))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -1403,7 +1400,7 @@
|
||||
;; definition for method 15 of type level-group
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod debug-draw-actors level-group ((this level-group) (arg0 symbol))
|
||||
(defmethod debug-draw-actors ((this level-group) (arg0 symbol))
|
||||
(local-vars
|
||||
(sv-16 symbol)
|
||||
(sv-20 vector)
|
||||
@@ -1777,13 +1774,13 @@
|
||||
)
|
||||
|
||||
;; definition for method 22 of type entity-camera
|
||||
(defmethod birth! entity-camera ((this entity-camera))
|
||||
(defmethod birth! ((this entity-camera))
|
||||
(add-connection *camera-engine* *camera* nothing this #f #f)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for method 23 of type entity-camera
|
||||
(defmethod kill! entity-camera ((this entity-camera))
|
||||
(defmethod kill! ((this entity-camera))
|
||||
(remove-by-param1 *camera-engine* (the-as int this))
|
||||
this
|
||||
)
|
||||
@@ -1800,7 +1797,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 22 of type entity-actor
|
||||
(defmethod birth! entity-actor ((this entity-actor))
|
||||
(defmethod birth! ((this entity-actor))
|
||||
(let* ((s5-0 (-> this etype))
|
||||
(v1-0 (entity-info-lookup s5-0))
|
||||
(s4-0 (get-process *default-dead-pool* s5-0 (if v1-0
|
||||
@@ -1844,7 +1841,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 23 of type entity-actor
|
||||
(defmethod kill! entity-actor ((this entity-actor))
|
||||
(defmethod kill! ((this entity-actor))
|
||||
(let ((a0-1 (-> this extra process)))
|
||||
(if a0-1
|
||||
(deactivate a0-1)
|
||||
@@ -1859,7 +1856,7 @@
|
||||
;; WARN: Return type mismatch bsp-header vs none.
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 s5, Count]
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count]
|
||||
(defmethod birth bsp-header ((this bsp-header))
|
||||
(defmethod birth ((this bsp-header))
|
||||
(local-vars (v1-74 int) (s5-0 int) (sv-16 int))
|
||||
(.mfc0 s5-0 Count)
|
||||
(let ((a2-0 (if (nonzero? (-> this actors))
|
||||
@@ -2039,7 +2036,7 @@
|
||||
|
||||
;; definition for method 18 of type bsp-header
|
||||
;; WARN: Return type mismatch bsp-header vs none.
|
||||
(defmethod deactivate-entities bsp-header ((this bsp-header))
|
||||
(defmethod deactivate-entities ((this bsp-header))
|
||||
(let ((v1-1 (-> this level heap base))
|
||||
(a0-2 (-> this level heap top-base))
|
||||
)
|
||||
@@ -2149,7 +2146,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 9 of type entity-perm
|
||||
(defmethod update entity-perm ((this entity-perm) (arg0 symbol) (arg1 entity-perm-status))
|
||||
(defmethod update ((this entity-perm) (arg0 symbol) (arg1 entity-perm-status))
|
||||
(cond
|
||||
((= arg0 'game)
|
||||
(logclear! (-> this status) arg1)
|
||||
@@ -2285,7 +2282,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 12 of type process-drawable
|
||||
(defmethod run-logic? process-drawable ((this process-drawable))
|
||||
(defmethod run-logic? ((this process-drawable))
|
||||
(or (not (logtest? (-> this mask) (process-mask actor-pause)))
|
||||
(or (>= (+ (-> *ACTOR-bank* pause-dist) (-> this root pause-adjust-distance))
|
||||
(vector-vector-distance (-> this root trans) (math-camera-pos))
|
||||
@@ -2297,7 +2294,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 9 of type entity-links
|
||||
(defmethod birth? entity-links ((this entity-links) (arg0 vector))
|
||||
(defmethod birth? ((this entity-links) (arg0 vector))
|
||||
(and (not (logtest? (-> this perm status) (entity-perm-status bit-0 dead)))
|
||||
(< (vector-vector-distance (-> this trans) arg0) (-> *ACTOR-bank* birth-dist))
|
||||
)
|
||||
@@ -2311,7 +2308,7 @@
|
||||
;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
;; WARN: Function (method 17 level-group) has a return type of none, but the expression builder found a return statement.
|
||||
(defmethod actors-update level-group ((this level-group))
|
||||
(defmethod actors-update ((this level-group))
|
||||
(local-vars
|
||||
(sv-16 vector)
|
||||
(sv-24 int)
|
||||
@@ -2547,7 +2544,7 @@
|
||||
|
||||
;; definition for method 30 of type entity-actor
|
||||
;; WARN: Return type mismatch entity-perm-status vs none.
|
||||
(defmethod toggle-status entity-actor ((this entity-actor) (arg0 entity-perm-status) (arg1 symbol))
|
||||
(defmethod toggle-status ((this entity-actor) (arg0 entity-perm-status) (arg1 symbol))
|
||||
(let ((v1-0 (-> this extra)))
|
||||
(if arg1
|
||||
(logior! (-> v1-0 perm status) arg0)
|
||||
|
||||
Reference in New Issue
Block a user