mirror of
https://github.com/open-goal/jak-project
synced 2026-08-19 22:12:24 -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:
+26
-32
@@ -3,7 +3,7 @@
|
||||
|
||||
;; definition for method 15 of type collide-cache
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod reset collide-cache ((this collide-cache))
|
||||
(defmethod reset ((this collide-cache))
|
||||
(set! (-> this num-tris) 0)
|
||||
(set! (-> this num-prims) 0)
|
||||
(set! (-> this ignore-processes 0) #f)
|
||||
@@ -16,11 +16,11 @@
|
||||
;; definition for method 18 of type collide-cache
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod fill-from-bg collide-cache ((this collide-cache)
|
||||
(arg0 (function collide-hash int collide-list collide-query int))
|
||||
(arg1 (function collide-cache collide-list collide-query none))
|
||||
(arg2 collide-query)
|
||||
)
|
||||
(defmethod fill-from-bg ((this collide-cache)
|
||||
(arg0 (function collide-hash int collide-list collide-query int))
|
||||
(arg1 (function collide-cache collide-list collide-query none))
|
||||
(arg2 collide-query)
|
||||
)
|
||||
(set! *already-printed-exeeded-max-cache-tris* #f)
|
||||
(set! (-> *collide-list* num-items) 0)
|
||||
(if *collide-list-boxes*
|
||||
@@ -65,7 +65,7 @@
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
;; WARN: Function (method 21 collide-cache) has a return type of none, but the expression builder found a return statement.
|
||||
(defmethod fill-from-water collide-cache ((this collide-cache) (arg0 water-control))
|
||||
(defmethod fill-from-water ((this collide-cache) (arg0 water-control))
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
@@ -143,7 +143,7 @@
|
||||
|
||||
;; definition for method 12 of type collide-cache
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod fill-using-bounding-box collide-cache ((this collide-cache) (arg0 collide-query))
|
||||
(defmethod fill-using-bounding-box ((this collide-cache) (arg0 collide-query))
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
@@ -225,7 +225,7 @@
|
||||
|
||||
;; definition for method 13 of type collide-cache
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod fill-using-line-sphere collide-cache ((this collide-cache) (arg0 collide-query))
|
||||
(defmethod fill-using-line-sphere ((this collide-cache) (arg0 collide-query))
|
||||
(local-vars (v1-11 float) (v1-20 float))
|
||||
(rlet ((acc :class vf)
|
||||
(Q :class vf)
|
||||
@@ -493,7 +493,7 @@
|
||||
|
||||
;; definition for method 19 of type collide-cache
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod fill-from-fg-boxes collide-cache ((this collide-cache))
|
||||
(defmethod fill-from-fg-boxes ((this collide-cache))
|
||||
(let ((s5-0 (-> this collide-with)))
|
||||
(set! *actor-list-length* 0)
|
||||
(if (logtest? s5-0 (collide-spec hit-by-others-list))
|
||||
@@ -581,7 +581,7 @@
|
||||
|
||||
;; definition for method 10 of type collide-shape-prim
|
||||
;; WARN: Return type mismatch object vs none.
|
||||
(defmethod add-fg-prim-using-box collide-shape-prim ((this collide-shape-prim) (arg0 collide-cache))
|
||||
(defmethod add-fg-prim-using-box ((this collide-shape-prim) (arg0 collide-cache))
|
||||
(format 0 "ERROR: Illegal collide-shape-prim type passed to collide-shape-prim::add-fg-prim-using-box!~%")
|
||||
(none)
|
||||
)
|
||||
@@ -600,7 +600,7 @@
|
||||
|
||||
;; definition for method 20 of type collide-cache
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod fill-from-fg-line-sphere collide-cache ((this collide-cache) (arg0 collide-query))
|
||||
(defmethod fill-from-fg-line-sphere ((this collide-cache) (arg0 collide-query))
|
||||
(local-vars (v1-9 float))
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
@@ -729,7 +729,7 @@
|
||||
|
||||
;; definition for method 11 of type collide-shape-prim
|
||||
;; WARN: Return type mismatch object vs none.
|
||||
(defmethod add-fg-prim-using-line-sphere collide-shape-prim ((this collide-shape-prim) (arg0 collide-cache) (arg1 object))
|
||||
(defmethod add-fg-prim-using-line-sphere ((this collide-shape-prim) (arg0 collide-cache) (arg1 object))
|
||||
(format
|
||||
0
|
||||
"ERROR: Illegal collide-shape-prim type passed to collide-shape-prim::add-fg-prim-using-line-sphere!~%"
|
||||
@@ -750,24 +750,21 @@
|
||||
(defmethod-mips2c "(method 11 collide-shape-prim-group)" 11 collide-shape-prim-group)
|
||||
|
||||
;; definition for method 10 of type collide-cache
|
||||
(defmethod fill-and-probe-using-line-sphere collide-cache ((this collide-cache) (arg0 collide-query))
|
||||
(defmethod fill-and-probe-using-line-sphere ((this collide-cache) (arg0 collide-query))
|
||||
(fill-using-line-sphere this arg0)
|
||||
(probe-using-line-sphere this arg0)
|
||||
)
|
||||
|
||||
;; definition of type collide-puls-work
|
||||
(deftype collide-puls-work (structure)
|
||||
((ignore-pat pat-surface :offset-assert 0)
|
||||
(bsphere sphere :inline :offset-assert 16)
|
||||
(move-dist vector :inline :offset-assert 32)
|
||||
((ignore-pat pat-surface)
|
||||
(bsphere sphere :inline)
|
||||
(move-dist vector :inline)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x30
|
||||
:flag-assert #x900000030
|
||||
)
|
||||
|
||||
;; definition for method 3 of type collide-puls-work
|
||||
(defmethod inspect collide-puls-work ((this collide-puls-work))
|
||||
(defmethod inspect ((this collide-puls-work))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -781,7 +778,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 16 of type collide-cache
|
||||
(defmethod probe-using-line-sphere collide-cache ((this collide-cache) (arg0 collide-query))
|
||||
(defmethod probe-using-line-sphere ((this collide-cache) (arg0 collide-query))
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
@@ -853,18 +850,15 @@
|
||||
|
||||
;; definition of type lsmi-work
|
||||
(deftype lsmi-work (structure)
|
||||
((best-u float :offset-assert 0)
|
||||
(orig-best-u float :offset-assert 4)
|
||||
(action uint32 :offset-assert 8)
|
||||
(cquery collide-query :inline :offset-assert 16)
|
||||
((best-u float)
|
||||
(orig-best-u float)
|
||||
(action uint32)
|
||||
(cquery collide-query :inline)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x22c
|
||||
:flag-assert #x90000022c
|
||||
)
|
||||
|
||||
;; definition for method 3 of type lsmi-work
|
||||
(defmethod inspect lsmi-work ((this lsmi-work))
|
||||
(defmethod inspect ((this lsmi-work))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -887,13 +881,13 @@
|
||||
(defmethod-mips2c "(method 10 collide-cache-prim)" 10 collide-cache-prim)
|
||||
|
||||
;; definition for method 11 of type collide-cache
|
||||
(defmethod fill-and-probe-using-spheres collide-cache ((this collide-cache) (arg0 collide-query))
|
||||
(defmethod fill-and-probe-using-spheres ((this collide-cache) (arg0 collide-query))
|
||||
(fill-using-spheres this arg0)
|
||||
(probe-using-spheres this arg0)
|
||||
)
|
||||
|
||||
;; definition for method 14 of type collide-cache
|
||||
(defmethod fill-using-spheres collide-cache ((this collide-cache) (arg0 collide-query))
|
||||
(defmethod fill-using-spheres ((this collide-cache) (arg0 collide-query))
|
||||
(new 'stack-no-clear 'bounding-box)
|
||||
(set-from-spheres!
|
||||
(-> arg0 bbox)
|
||||
|
||||
Reference in New Issue
Block a user