Files
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

280 lines
12 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type gui-connection
(deftype gui-connection (connection)
((priority float :overlay-at param0)
(action gui-action :overlay-at param1)
(channel gui-channel :offset 21)
(anim-part uint8 :offset 22)
(flags gui-connection-flags :offset 23)
(name string :overlay-at param2)
(id sound-id :overlay-at param3)
(handle handle :overlay-at next0)
(time-stamp time-frame :overlay-at next1)
(hold-time time-frame)
(fo-min int16)
(fo-max int16)
(fo-curve int8)
(fade uint8)
(pad uint8 2)
)
)
;; definition for method 3 of type gui-connection
(defmethod inspect ((this gui-connection))
(when (not this)
(set! this this)
(goto cfg-116)
)
(format #t "[~8x] ~A~%" this 'gui-connection)
(format #t "~1Tnext0: ~`connectable`P~%" (-> this next0))
(format #t "~1Tprev0: ~`connectable`P~%" (-> this prev0))
(format #t "~1Tnext1: ~`connectable`P~%" (-> this next1))
(format #t "~1Tprev1: ~`connectable`P~%" (-> this prev1))
(format #t "~1Tparam0: ~A~%" (-> this priority))
(format #t "~1Tparam1: ~A~%" (-> this param1))
(format #t "~1Tparam2: ~A~%" (-> this param2))
(format #t "~1Tparam3: ~A~%" (-> this param3))
(format #t "~1Tquad[2] @ #x~X~%" (&-> this next0))
(format #t "~1Tpriority: ~f~%" (-> this priority))
(let ((t9-11 format)
(a0-12 #t)
(a1-11 "~1Taction: #x~X : ~S~%")
(a2-11 (-> this action))
(v1-2 (-> this action))
)
(t9-11 a0-12 a1-11 a2-11 (cond
((= v1-2 (gui-action queue))
"queue"
)
((= v1-2 (gui-action stop))
"stop"
)
((= v1-2 (gui-action play))
"play"
)
((= v1-2 (gui-action hide))
"hide"
)
((= v1-2 (gui-action fade))
"fade"
)
((= v1-2 (gui-action none))
"none"
)
((= v1-2 (gui-action abort))
"abort"
)
((= v1-2 (gui-action stopping))
"stopping"
)
((= v1-2 (gui-action hidden))
"hidden"
)
((= v1-2 (gui-action playing))
"playing"
)
(else
"*unknown*"
)
)
)
)
(let ((t9-12 format)
(a0-13 #t)
(a1-12 "~1Tchannel: #x~X : ~S~%")
(a2-12 (-> this channel))
(v1-3 (-> this channel))
)
(t9-12 a0-13 a1-12 a2-12 (cond
((= v1-3 (gui-channel hud-lower-left))
"hud-lower-left"
)
((= v1-3 (gui-channel citizen))
"citizen"
)
((= v1-3 (gui-channel ashelin))
"ashelin"
)
((= v1-3 (gui-channel hud-lower-left-1))
"hud-lower-left-1"
)
((= v1-3 (gui-channel message))
"message"
)
((= v1-3 (gui-channel hud-middle-left))
"hud-middle-left"
)
((= v1-3 (gui-channel hud-upper-center-2))
"hud-upper-center-2"
)
((= v1-3 (gui-channel hud-middle-right))
"hud-middle-right"
)
((= v1-3 (gui-channel subtitle))
"subtitle"
)
((= v1-3 (gui-channel notice))
"notice"
)
((= v1-3 (gui-channel voicebox))
"voicebox"
)
((= v1-3 (gui-channel art-load-next))
"art-load-next"
)
((= v1-3 (gui-channel mog))
"mog"
)
((= v1-3 (gui-channel sig))
"sig"
)
((= v1-3 (gui-channel hud-center-left))
"hud-center-left"
)
((= v1-3 (gui-channel hud-upper-right))
"hud-upper-right"
)
((= v1-3 (gui-channel hud-center-right))
"hud-center-right"
)
((= v1-3 (gui-channel alert))
"alert"
)
((= v1-3 (gui-channel jinx))
"jinx"
)
((= v1-3 (gui-channel hud-upper-left))
"hud-upper-left"
)
((= v1-3 (gui-channel query))
"query"
)
((= v1-3 (gui-channel grim))
"grim"
)
((= v1-3 (gui-channel kor))
"kor"
)
((= v1-3 (gui-channel hud-lower-right))
"hud-lower-right"
)
((= v1-3 (gui-channel screen))
"screen"
)
((= v1-3 (gui-channel guard))
"guard"
)
((= v1-3 (gui-channel supertitle))
"supertitle"
)
((= v1-3 (gui-channel hal))
"hal"
)
((= v1-3 (gui-channel hud-upper-center))
"hud-upper-center"
)
((= v1-3 (gui-channel blackout))
"blackout"
)
((= v1-3 (gui-channel bbush))
"bbush"
)
((= v1-3 (gui-channel hud))
"hud"
)
((= v1-3 (gui-channel voice))
"voice"
)
((= v1-3 (gui-channel max))
"max"
)
((= v1-3 (gui-channel none))
"none"
)
((= v1-3 (gui-channel notice-low))
"notice-low"
)
((= v1-3 (gui-channel art-load))
"art-load"
)
((= v1-3 (gui-channel kid))
"kid"
)
((= v1-3 (gui-channel jak))
"jak"
)
((= v1-3 (gui-channel daxter))
"daxter"
)
((= v1-3 (gui-channel krew))
"krew"
)
((= v1-3 (gui-channel hud-lower-left-2))
"hud-lower-left-2"
)
((= v1-3 (gui-channel background))
"background"
)
((= v1-3 (gui-channel crocadog))
"crocadog"
)
((= v1-3 (gui-channel movie))
"movie"
)
(else
"*unknown*"
)
)
)
)
(format #t "~1Tanim-part: ~D~%" (-> this anim-part))
(format #t "~1Tflags: ~D~%" (-> this flags))
(format #t "~1Tname: ~A~%" (-> this name))
(format #t "~1Tid: ~D~%" (-> this id))
(format #t "~1Thandle: ~D~%" (-> this handle))
(format #t "~1Ttime-stamp: ~D~%" (-> this time-stamp))
(format #t "~1Thold-time: ~D~%" (-> this hold-time))
(format #t "~1Tfo-min: ~D~%" (-> this fo-min))
(format #t "~1Tfo-max: ~D~%" (-> this fo-max))
(format #t "~1Tfo-curve: ~D~%" (-> this fo-curve))
(format #t "~1Tfade: ~D~%" (-> this fade))
(label cfg-116)
this
)
;; definition of type gui-control
(deftype gui-control (basic)
((engine engine)
(update-time time-frame)
(connections gui-connection 32 :inline)
(spool-connections gui-connection 4 :inline)
(ids sound-id 96)
(times time-frame 96)
(cmd pair 96)
)
(:methods
(new (symbol type int) _type_)
(add-process (_type_ process gui-channel gui-action string float time-frame) sound-id)
(remove-process (_type_ process gui-channel) none)
(stop-str (_type_ gui-connection) int)
(gui-control-method-12 (_type_ process gui-channel gui-action string int float sound-id) sound-id)
(update (_type_ symbol) int)
(lookup-gui-connection-id (_type_ string gui-channel gui-action) sound-id)
(lookup-gui-connection (_type_ process gui-channel string sound-id) gui-connection)
(set-action! (_type_ gui-action sound-id gui-channel gui-action string (function gui-connection symbol) process) int)
(get-status (_type_ sound-id) gui-status)
(gui-control-method-18 (_type_ gui-channel) symbol)
(handle-command-list (_type_ gui-channel gui-connection) symbol)
(set-falloff! (_type_ sound-id symbol int int int) gui-connection)
(gui-control-method-21 (_type_ gui-connection vector) int)
(gui-control-method-22 (_type_ gui-connection process symbol) none)
(handle-command (_type_ gui-channel gui-channel symbol gui-connection) symbol)
(channel-id-set! (_type_ gui-connection sound-id) int)
)
)
;; failed to figure out what this is:
0