Files
jak-project/test/decompiler/reference/jak2/engine/level/region-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

247 lines
6.7 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type region
(deftype region (structure)
((id uint32)
(on-enter pair)
(on-inside pair)
(on-exit pair)
)
(:methods
(region-method-9 (_type_ vector) symbol)
)
)
;; definition for method 3 of type region
(defmethod inspect ((this region))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'region)
(format #t "~1Tid: ~D~%" (-> this id))
(format #t "~1Ton-enter: ~A~%" (-> this on-enter))
(format #t "~1Ton-inside: ~A~%" (-> this on-inside))
(format #t "~1Ton-exit: ~A~%" (-> this on-exit))
(label cfg-4)
this
)
;; definition of type region-array
(deftype region-array (inline-array-class)
((data region :inline :dynamic)
)
)
;; definition for method 3 of type region-array
(defmethod inspect ((this region-array))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tlength: ~D~%" (-> this length))
(format #t "~1Tallocated-length: ~D~%" (-> this allocated-length))
(format #t "~1Tdata[0] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; failed to figure out what this is:
(set! (-> region-array heap-base) (the-as uint 16))
;; definition of type drawable-region-prim
(deftype drawable-region-prim (drawable)
((region region :offset 8)
)
(:methods
(debug-draw-region (_type_ int) none)
(track-region (_type_ region-prim-area) symbol)
(within-area? (_type_ region-prim-area) symbol)
)
)
;; definition for method 3 of type drawable-region-prim
(defmethod inspect ((this drawable-region-prim))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tid: ~D~%" (-> this id))
(format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere))
(format #t "~1Tregion: #<region @ #x~X>~%" (-> this region))
(label cfg-4)
this
)
;; definition of type drawable-tree-region-prim
(deftype drawable-tree-region-prim (drawable-tree)
((name basic :offset 8)
(data2 drawable-inline-array :dynamic :offset 32)
)
(:methods
(drawable-tree-region-prim-method-17 (_type_ vector) symbol)
(debug-print (_type_ vector object) none)
)
)
;; definition for method 3 of type drawable-tree-region-prim
(defmethod inspect ((this drawable-tree-region-prim))
(when (not this)
(set! this this)
(goto cfg-7)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tid: ~D~%" (-> this id))
(format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere))
(format #t "~1Tlength: ~D~%" (-> this length))
(format #t "~1Tdata[0] @ #x~X~%" (-> this data2))
(dotimes (s5-0 (-> this length))
(format #t "~T [~D]~1Tdata: ~A~%" s5-0 (-> this data2 s5-0))
)
(format #t "~1Tname: ~A~%" (-> this name))
(label cfg-7)
this
)
;; definition of type drawable-inline-array-region-prim
(deftype drawable-inline-array-region-prim (drawable-inline-array)
((data drawable-region-prim 1 :inline)
(pad uint8 4)
)
)
;; definition of type drawable-region-sphere
(deftype drawable-region-sphere (drawable-region-prim)
()
)
;; definition for method 3 of type drawable-region-sphere
(defmethod inspect ((this drawable-region-sphere))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tid: ~D~%" (-> this id))
(format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere))
(format #t "~1Tregion: #<region @ #x~X>~%" (-> this region))
(label cfg-4)
this
)
;; definition of type region-face-data
(deftype region-face-data (structure)
((normal vector :inline)
(normal-offset float :overlay-at (-> normal data 3))
(num-points uint32)
(points vector :inline :dynamic)
)
)
;; definition for method 3 of type region-face-data
(defmethod inspect ((this region-face-data))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'region-face-data)
(format #t "~1Tnormal: #<vector @ #x~X>~%" (-> this normal))
(format #t "~1Tnormal-offset: ~f~%" (-> this normal w))
(format #t "~1Tnum-points: ~D~%" (-> this num-points))
(format #t "~1Tpoints[0] @ #x~X~%" (-> this points))
(label cfg-4)
this
)
;; definition of type drawable-region-face
(deftype drawable-region-face (drawable-region-prim)
((data region-face-data :offset 12)
)
)
;; definition for method 3 of type drawable-region-face
(defmethod inspect ((this drawable-region-face))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tid: ~D~%" (-> this id))
(format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere))
(format #t "~1Tregion: #<region @ #x~X>~%" (-> this region))
(format #t "~1Tdata: #<region-face-data @ #x~X>~%" (-> this data))
(label cfg-4)
this
)
;; definition of type region-face-array
(deftype region-face-array (inline-array-class)
((data drawable-region-face :inline :dynamic :offset 16)
(pad0 uint8 4)
)
)
;; definition for method 3 of type region-face-array
(defmethod inspect ((this region-face-array))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tlength: ~D~%" (-> this length))
(format #t "~1Tallocated-length: ~D~%" (-> this allocated-length))
(format #t "~1Tdata[0] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; failed to figure out what this is:
(set! (-> region-face-array heap-base) (the-as uint 32))
;; definition of type drawable-region-volume
(deftype drawable-region-volume (drawable-region-prim)
((faces region-face-array :offset 12)
)
)
;; definition for method 3 of type drawable-region-volume
(defmethod inspect ((this drawable-region-volume))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tid: ~D~%" (-> this id))
(format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere))
(format #t "~1Tregion: #<region @ #x~X>~%" (-> this region))
(format #t "~1Tfaces: ~A~%" (-> this faces))
(label cfg-4)
this
)
;; definition of type region-prim-list
(deftype region-prim-list (structure)
((num-items int32)
(items drawable-region-prim 320)
)
)
;; definition for method 3 of type region-prim-list
(defmethod inspect ((this region-prim-list))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'region-prim-list)
(format #t "~1Tnum-items: ~D~%" (-> this num-items))
(format #t "~1Titems[320] @ #x~X~%" (-> this items))
(label cfg-4)
this
)
;; failed to figure out what this is:
0