mirror of
https://github.com/open-goal/jak-project
synced 2026-09-06 19:21:00 -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:
+20
-26
@@ -3,21 +3,18 @@
|
||||
|
||||
;; definition of type script-form
|
||||
(deftype script-form (structure)
|
||||
((name symbol :offset-assert 0)
|
||||
(spec pair :offset-assert 4)
|
||||
(func (function script-context object) :offset-assert 8)
|
||||
((name symbol)
|
||||
(spec pair)
|
||||
(func (function script-context object))
|
||||
)
|
||||
:pack-me
|
||||
:method-count-assert 10
|
||||
:size-assert #xc
|
||||
:flag-assert #xa0000000c
|
||||
(:methods
|
||||
(script-form-method-9 () none 9)
|
||||
(script-form-method-9 () none)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type script-form
|
||||
(defmethod inspect script-form ((this script-form))
|
||||
(defmethod inspect ((this script-form))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
@@ -32,30 +29,27 @@
|
||||
|
||||
;; definition of type script-context
|
||||
(deftype script-context (structure)
|
||||
((load-state load-state :offset-assert 0)
|
||||
(key object :offset-assert 4)
|
||||
(process process :offset-assert 8)
|
||||
(trans vector :offset-assert 12)
|
||||
(side-effect? symbol :offset-assert 16)
|
||||
(got-error? symbol :offset-assert 20)
|
||||
(expr pair :offset-assert 24)
|
||||
(param-count int32 :offset-assert 28)
|
||||
(param object 16 :offset-assert 32)
|
||||
(param-type object 16 :offset-assert 96)
|
||||
((load-state load-state)
|
||||
(key object)
|
||||
(process process)
|
||||
(trans vector)
|
||||
(side-effect? symbol)
|
||||
(got-error? symbol)
|
||||
(expr pair)
|
||||
(param-count int32)
|
||||
(param object 16)
|
||||
(param-type object 16)
|
||||
)
|
||||
:method-count-assert 12
|
||||
:size-assert #xa0
|
||||
:flag-assert #xc000000a0
|
||||
(:methods
|
||||
(new (symbol type object process vector) _type_ 0)
|
||||
(eval! (_type_ pair) object 9)
|
||||
(script-context-method-10 (_type_ object pair) object 10)
|
||||
(script-context-method-11 (_type_ pair pair symbol) symbol 11)
|
||||
(new (symbol type object process vector) _type_)
|
||||
(eval! (_type_ pair) object)
|
||||
(script-context-method-10 (_type_ object pair) object)
|
||||
(script-context-method-11 (_type_ pair pair symbol) symbol)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type script-context
|
||||
(defmethod inspect script-context ((this script-context))
|
||||
(defmethod inspect ((this script-context))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-10)
|
||||
|
||||
Reference in New Issue
Block a user