mirror of
https://github.com/open-goal/jak-project
synced 2026-08-08 18:44:15 -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:
+76
-98
@@ -3,34 +3,31 @@
|
||||
|
||||
;; definition of type joint-exploder-tuning
|
||||
(deftype joint-exploder-tuning (structure)
|
||||
((explosion uint64 :offset-assert 0)
|
||||
(duration time-frame :offset-assert 8)
|
||||
(gravity float :offset-assert 16)
|
||||
(rot-speed float :offset-assert 20)
|
||||
(bounds-inflate float :offset-assert 24)
|
||||
(max-probe-width float :offset-assert 28)
|
||||
(max-probe-height float :offset-assert 32)
|
||||
(max-probe-depth float :offset-assert 36)
|
||||
(fountain-rand-transv-lo vector :inline :offset-assert 48)
|
||||
(fountain-rand-transv-hi vector :inline :offset-assert 64)
|
||||
(away-from-focal-pt vector :inline :offset 48)
|
||||
(away-from-rand-transv-xz-lo float :offset 64)
|
||||
(away-from-rand-transv-xz-hi float :offset 68)
|
||||
(away-from-rand-transv-y-lo float :offset 72)
|
||||
(away-from-rand-transv-y-hi float :offset 76)
|
||||
(hit-xz-reaction float :offset-assert 80)
|
||||
(hit-y-reaction float :offset-assert 84)
|
||||
((explosion uint64)
|
||||
(duration time-frame)
|
||||
(gravity float)
|
||||
(rot-speed float)
|
||||
(bounds-inflate float)
|
||||
(max-probe-width float)
|
||||
(max-probe-height float)
|
||||
(max-probe-depth float)
|
||||
(fountain-rand-transv-lo vector :inline)
|
||||
(fountain-rand-transv-hi vector :inline)
|
||||
(away-from-focal-pt vector :inline :overlay-at fountain-rand-transv-lo)
|
||||
(away-from-rand-transv-xz-lo float :overlay-at (-> fountain-rand-transv-hi data 0))
|
||||
(away-from-rand-transv-xz-hi float :overlay-at (-> fountain-rand-transv-hi data 1))
|
||||
(away-from-rand-transv-y-lo float :overlay-at (-> fountain-rand-transv-hi data 2))
|
||||
(away-from-rand-transv-y-hi float :overlay-at (-> fountain-rand-transv-hi data 3))
|
||||
(hit-xz-reaction float)
|
||||
(hit-y-reaction float)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x58
|
||||
:flag-assert #x900000058
|
||||
(:methods
|
||||
(new (symbol type uint) _type_ 0)
|
||||
(new (symbol type uint) _type_)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type joint-exploder-tuning
|
||||
(defmethod inspect joint-exploder-tuning ((this joint-exploder-tuning))
|
||||
(defmethod inspect ((this joint-exploder-tuning))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -59,16 +56,13 @@
|
||||
|
||||
;; definition of type joint-exploder-static-joint-params
|
||||
(deftype joint-exploder-static-joint-params (structure)
|
||||
((joint-index int16 :offset-assert 0)
|
||||
(parent-joint-index int16 :offset-assert 2)
|
||||
((joint-index int16)
|
||||
(parent-joint-index int16)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x4
|
||||
:flag-assert #x900000004
|
||||
)
|
||||
|
||||
;; definition for method 3 of type joint-exploder-static-joint-params
|
||||
(defmethod inspect joint-exploder-static-joint-params ((this joint-exploder-static-joint-params))
|
||||
(defmethod inspect ((this joint-exploder-static-joint-params))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -82,17 +76,14 @@
|
||||
|
||||
;; definition of type joint-exploder-static-params
|
||||
(deftype joint-exploder-static-params (basic)
|
||||
((joints (array joint-exploder-static-joint-params) :offset-assert 4)
|
||||
(collide-spec uint32 :offset-assert 8)
|
||||
(art-level symbol :offset-assert 12)
|
||||
((joints (array joint-exploder-static-joint-params))
|
||||
(collide-spec uint32)
|
||||
(art-level symbol)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x10
|
||||
:flag-assert #x900000010
|
||||
)
|
||||
|
||||
;; definition for method 3 of type joint-exploder-static-params
|
||||
(defmethod inspect joint-exploder-static-params ((this joint-exploder-static-params))
|
||||
(defmethod inspect ((this joint-exploder-static-params))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -107,22 +98,19 @@
|
||||
|
||||
;; definition of type joint-exploder-joint
|
||||
(deftype joint-exploder-joint (structure)
|
||||
((next int16 :offset-assert 0)
|
||||
(prev int16 :offset-assert 2)
|
||||
(joint-index int16 :offset-assert 4)
|
||||
(mat matrix :inline :offset-assert 16)
|
||||
(rmat matrix :inline :offset-assert 80)
|
||||
(update-rmat matrix :inline :offset-assert 144)
|
||||
(transv vector :inline :offset-assert 208)
|
||||
(prev-pos vector :inline :offset-assert 224)
|
||||
((next int16)
|
||||
(prev int16)
|
||||
(joint-index int16)
|
||||
(mat matrix :inline)
|
||||
(rmat matrix :inline)
|
||||
(update-rmat matrix :inline)
|
||||
(transv vector :inline)
|
||||
(prev-pos vector :inline)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #xf0
|
||||
:flag-assert #x9000000f0
|
||||
)
|
||||
|
||||
;; definition for method 3 of type joint-exploder-joint
|
||||
(defmethod inspect joint-exploder-joint ((this joint-exploder-joint))
|
||||
(defmethod inspect ((this joint-exploder-joint))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -142,19 +130,16 @@
|
||||
|
||||
;; definition of type joint-exploder-joints
|
||||
(deftype joint-exploder-joints (basic)
|
||||
((num-joints int32 :offset-assert 4)
|
||||
(joint joint-exploder-joint :inline :dynamic :offset-assert 16)
|
||||
((num-joints int32)
|
||||
(joint joint-exploder-joint :inline :dynamic)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x10
|
||||
:flag-assert #x900000010
|
||||
(:methods
|
||||
(new (symbol type joint-exploder-static-params) _type_ 0)
|
||||
(new (symbol type joint-exploder-static-params) _type_)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type joint-exploder-joints
|
||||
(defmethod inspect joint-exploder-joints ((this joint-exploder-joints))
|
||||
(defmethod inspect ((this joint-exploder-joints))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -168,19 +153,16 @@
|
||||
|
||||
;; definition of type joint-exploder-list
|
||||
(deftype joint-exploder-list (structure)
|
||||
((head int32 :offset-assert 0)
|
||||
(pre-moved? symbol :offset-assert 4)
|
||||
(bbox-valid? symbol :offset-assert 8)
|
||||
(probeless? symbol :offset-assert 12)
|
||||
(bbox bounding-box :inline :offset-assert 16)
|
||||
((head int32)
|
||||
(pre-moved? symbol)
|
||||
(bbox-valid? symbol)
|
||||
(probeless? symbol)
|
||||
(bbox bounding-box :inline)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x30
|
||||
:flag-assert #x900000030
|
||||
)
|
||||
|
||||
;; definition for method 3 of type joint-exploder-list
|
||||
(defmethod inspect joint-exploder-list ((this joint-exploder-list))
|
||||
(defmethod inspect ((this joint-exploder-list))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -197,30 +179,26 @@
|
||||
|
||||
;; definition of type joint-exploder
|
||||
(deftype joint-exploder (process-drawable)
|
||||
((die-if-below-y float :offset-assert 200)
|
||||
(die-if-beyond-xz-dist-sqrd float :offset-assert 204)
|
||||
(joints joint-exploder-joints :offset-assert 208)
|
||||
(static-params joint-exploder-static-params :offset-assert 212)
|
||||
(anim art-joint-anim :offset-assert 216)
|
||||
(scale-vector vector :inline :offset-assert 224)
|
||||
(tuning joint-exploder-tuning :inline :offset-assert 240)
|
||||
(lists joint-exploder-list 5 :inline :offset-assert 336)
|
||||
((die-if-below-y float)
|
||||
(die-if-beyond-xz-dist-sqrd float)
|
||||
(joints joint-exploder-joints)
|
||||
(static-params joint-exploder-static-params)
|
||||
(anim art-joint-anim)
|
||||
(scale-vector vector :inline)
|
||||
(tuning joint-exploder-tuning :inline)
|
||||
(lists joint-exploder-list 5 :inline)
|
||||
)
|
||||
:heap-base #x1c0
|
||||
:method-count-assert 30
|
||||
:size-assert #x240
|
||||
:flag-assert #x1e01c00240
|
||||
(:methods
|
||||
(add-joint-to-list (_type_ joint-exploder-list int) int 20)
|
||||
(update-bbox-for-joint (_type_ joint-exploder-list joint-exploder-joint) none 21)
|
||||
(do-collision-response (_type_ joint-exploder-list) none 22)
|
||||
(init-joint-list (_type_) none 23)
|
||||
(remove-from-list-and-reset (_type_ joint-exploder-list int) int 24)
|
||||
(final-adjust (_type_ joint-exploder-list int) int 25)
|
||||
(integrate-and-kill (_type_ joint-exploder-list) none 26)
|
||||
(remove-joint-from-list (_type_ joint-exploder-list int) int 27)
|
||||
(adjust-bbox-for-limits-along-axis (_type_ joint-exploder-list int) joint-exploder-list 28)
|
||||
(adjust-bbox-for-limits (_type_ joint-exploder-list) none 29)
|
||||
(add-joint-to-list (_type_ joint-exploder-list int) int)
|
||||
(update-bbox-for-joint (_type_ joint-exploder-list joint-exploder-joint) none)
|
||||
(do-collision-response (_type_ joint-exploder-list) none)
|
||||
(init-joint-list (_type_) none)
|
||||
(remove-from-list-and-reset (_type_ joint-exploder-list int) int)
|
||||
(final-adjust (_type_ joint-exploder-list int) int)
|
||||
(integrate-and-kill (_type_ joint-exploder-list) none)
|
||||
(remove-joint-from-list (_type_ joint-exploder-list int) int)
|
||||
(adjust-bbox-for-limits-along-axis (_type_ joint-exploder-list int) joint-exploder-list)
|
||||
(adjust-bbox-for-limits (_type_ joint-exploder-list) none)
|
||||
)
|
||||
(:states
|
||||
joint-exploder-shatter
|
||||
@@ -228,7 +206,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 3 of type joint-exploder
|
||||
(defmethod inspect joint-exploder ((this joint-exploder))
|
||||
(defmethod inspect ((this joint-exploder))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -250,7 +228,7 @@
|
||||
|
||||
;; definition for method 5 of type joint-exploder-joints
|
||||
;; WARN: Return type mismatch uint vs int.
|
||||
(defmethod asize-of joint-exploder-joints ((this joint-exploder-joints))
|
||||
(defmethod asize-of ((this joint-exploder-joints))
|
||||
(the-as int (+ (-> this type size) (* 240 (-> this num-joints))))
|
||||
)
|
||||
|
||||
@@ -300,7 +278,7 @@
|
||||
|
||||
;; definition for method 24 of type joint-exploder
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod remove-from-list-and-reset joint-exploder ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(defmethod remove-from-list-and-reset ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(let ((v0-0 (remove-joint-from-list this arg0 arg1)))
|
||||
(let* ((v1-1 (-> this joints))
|
||||
(v1-2 (-> v1-1 joint arg1))
|
||||
@@ -315,7 +293,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 27 of type joint-exploder
|
||||
(defmethod remove-joint-from-list joint-exploder ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(defmethod remove-joint-from-list ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(let* ((v1-0 (-> this joints))
|
||||
(a2-1 (-> v1-0 joint arg1))
|
||||
(a0-4 (-> a2-1 prev))
|
||||
@@ -347,7 +325,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 20 of type joint-exploder
|
||||
(defmethod add-joint-to-list joint-exploder ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(defmethod add-joint-to-list ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(let* ((v1-0 (-> this joints))
|
||||
(a3-0 (-> v1-0 joint arg1))
|
||||
(a0-4 (-> arg0 head))
|
||||
@@ -364,7 +342,7 @@
|
||||
|
||||
;; definition for method 21 of type joint-exploder
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod update-bbox-for-joint joint-exploder ((this joint-exploder) (arg0 joint-exploder-list) (arg1 joint-exploder-joint))
|
||||
(defmethod update-bbox-for-joint ((this joint-exploder) (arg0 joint-exploder-list) (arg1 joint-exploder-joint))
|
||||
(let ((a1-1 (-> arg1 mat trans)))
|
||||
(cond
|
||||
((-> arg0 bbox-valid?)
|
||||
@@ -383,7 +361,7 @@
|
||||
|
||||
;; definition for method 28 of type joint-exploder
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod adjust-bbox-for-limits-along-axis joint-exploder ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(defmethod adjust-bbox-for-limits-along-axis ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(local-vars
|
||||
(sv-16 int)
|
||||
(sv-32 int)
|
||||
@@ -507,7 +485,7 @@
|
||||
;; definition for method 25 of type joint-exploder
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch symbol vs int.
|
||||
(defmethod final-adjust joint-exploder ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(defmethod final-adjust ((this joint-exploder) (arg0 joint-exploder-list) (arg1 int))
|
||||
(local-vars (sv-48 int) (sv-64 (inline-array joint-exploder-list)) (sv-80 joint-exploder-joint))
|
||||
(set! (-> arg0 bbox-valid?) #f)
|
||||
(let ((s3-0 (-> this joints))
|
||||
@@ -554,7 +532,7 @@
|
||||
|
||||
;; definition for method 29 of type joint-exploder
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod adjust-bbox-for-limits joint-exploder ((this joint-exploder) (arg0 joint-exploder-list))
|
||||
(defmethod adjust-bbox-for-limits ((this joint-exploder) (arg0 joint-exploder-list))
|
||||
(when (and (-> arg0 bbox-valid?) (>= (-> arg0 head) 0) (not (-> arg0 probeless?)))
|
||||
(let ((a2-0 -1))
|
||||
(cond
|
||||
@@ -585,7 +563,7 @@
|
||||
;; definition for method 26 of type joint-exploder
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod integrate-and-kill joint-exploder ((this joint-exploder) (arg0 joint-exploder-list))
|
||||
(defmethod integrate-and-kill ((this joint-exploder) (arg0 joint-exploder-list))
|
||||
(set! (-> arg0 bbox-valid?) #f)
|
||||
(set! (-> arg0 pre-moved?) #t)
|
||||
(let ((s4-0 (-> this joints))
|
||||
@@ -621,7 +599,7 @@
|
||||
;; definition for method 22 of type joint-exploder
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod do-collision-response joint-exploder ((this joint-exploder) (arg0 joint-exploder-list))
|
||||
(defmethod do-collision-response ((this joint-exploder) (arg0 joint-exploder-list))
|
||||
(let ((s5-0 (new 'stack-no-clear 'collide-query)))
|
||||
(set! (-> s5-0 collide-with) (the-as collide-spec (-> this static-params collide-spec)))
|
||||
(set! (-> s5-0 ignore-process0) this)
|
||||
@@ -739,7 +717,7 @@
|
||||
;; definition for method 23 of type joint-exploder
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod init-joint-list joint-exploder ((this joint-exploder))
|
||||
(defmethod init-joint-list ((this joint-exploder))
|
||||
(let ((gp-0 (-> this joints)))
|
||||
(dotimes (s4-0 (-> gp-0 num-joints))
|
||||
(let ((v1-2 (-> this static-params joints s4-0))
|
||||
@@ -845,7 +823,7 @@
|
||||
|
||||
;; definition for method 7 of type joint-exploder
|
||||
;; WARN: Return type mismatch process-drawable vs joint-exploder.
|
||||
(defmethod relocate joint-exploder ((this joint-exploder) (arg0 int))
|
||||
(defmethod relocate ((this joint-exploder) (arg0 int))
|
||||
(if (nonzero? (-> this joints))
|
||||
(&+! (-> this joints) arg0)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user