Files
jak-project/test/decompiler/reference/jak1/engine/anim/mspace-h_REF.gc
T
ManDude cd68cb671e 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>
2023-10-30 03:20:02 +00:00

144 lines
3.8 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type joint
(deftype joint (basic)
((name string)
(number int32)
(parent joint)
(bind-pose matrix :inline)
)
)
;; definition for method 3 of type joint
(defmethod inspect ((this joint))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tname: ~A~%" (-> this name))
(format #t "~Tnumber: ~D~%" (-> this number))
(format #t "~Tparent: ~A~%" (-> this parent))
(format #t "~Tbind-pose: #<matrix @ #x~X>~%" (-> this bind-pose))
this
)
;; definition of type bone-cache
(deftype bone-cache (structure)
((bone-matrix uint32)
(parent-matrix uint32)
(dummy uint32)
(frame uint32)
)
)
;; definition for method 3 of type bone-cache
(defmethod inspect ((this bone-cache))
(format #t "[~8x] ~A~%" this 'bone-cache)
(format #t "~Tbone-matrix: ~D~%" (-> this bone-matrix))
(format #t "~Tparent-matrix: ~D~%" (-> this parent-matrix))
(format #t "~Tdummy: ~D~%" (-> this dummy))
(format #t "~Tframe: ~D~%" (-> this frame))
this
)
;; definition of type bone
(deftype bone (structure)
((transform matrix :inline)
(position vector :inline :overlay-at (-> transform vector 3))
(scale vector :inline)
(cache bone-cache :inline)
)
)
;; definition for method 3 of type bone
(defmethod inspect ((this bone))
(format #t "[~8x] ~A~%" this 'bone)
(format #t "~Ttransform: #<matrix @ #x~X>~%" (-> this transform))
(format #t "~Tposition: #<vector @ #x~X>~%" (-> this transform vector 3))
(format #t "~Tscale: #<vector @ #x~X>~%" (-> this scale))
(format #t "~Tcache: #<bone-cache @ #x~X>~%" (-> this cache))
this
)
;; definition of type skeleton
(deftype skeleton (inline-array-class)
((bones bone :inline :dynamic)
)
)
;; definition for method 3 of type skeleton
(defmethod inspect ((this skeleton))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tlength: ~D~%" (-> this length))
(format #t "~Tallocated-length: ~D~%" (-> this allocated-length))
(format #t "~Tdata[0] @ #x~X~%" (-> this bones))
this
)
;; failed to figure out what this is:
(set! (-> skeleton heap-base) (the-as uint 96))
;; definition of type cspace
(deftype cspace (structure)
((parent cspace)
(joint joint)
(joint-num int16)
(geo basic)
(bone bone)
(param0 function)
(param1 basic)
(param2 basic)
)
(:methods
(new (symbol type basic) _type_)
(reset-and-assign-geo! (_type_ basic) _type_)
)
)
;; definition for method 3 of type cspace
(defmethod inspect ((this cspace))
(format #t "[~8x] ~A~%" this 'cspace)
(format #t "~Tparent: #<cspace @ #x~X>~%" (-> this parent))
(format #t "~Tjoint: ~A~%" (-> this joint))
(format #t "~Tjoint-num: ~D~%" (-> this joint-num))
(format #t "~Tgeo: ~A~%" (-> this geo))
(format #t "~Tbone: #<bone @ #x~X>~%" (-> this bone))
(format #t "~Tparam0: ~A~%" (-> this param0))
(format #t "~Tparam1: ~A~%" (-> this param1))
(format #t "~Tparam2: ~A~%" (-> this param2))
this
)
;; definition of type cspace-array
(deftype cspace-array (inline-array-class)
((data cspace :inline :dynamic)
)
)
;; definition for method 3 of type cspace-array
(defmethod inspect ((this cspace-array))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tlength: ~D~%" (-> this length))
(format #t "~Tallocated-length: ~D~%" (-> this allocated-length))
(format #t "~Tdata[0] @ #x~X~%" (-> this data))
this
)
;; failed to figure out what this is:
(set! (-> cspace-array heap-base) (the-as uint 32))
;; definition for method 2 of type cspace
(defmethod print ((this cspace))
(format
#t
"#<cspace ~S @ #x~X>"
(if (-> this joint)
(-> this joint name)
"nojoint"
)
this
)
this
)
;; failed to figure out what this is:
0