[opengoal] make none a child of object (#3001)

Previously, `object` and `none` were both top-level types. This made
decompilation rather messy as they have no LCA and resulted in a lot of
variables coming out as type `none` which is very very wrong and
additionally there were plenty of casts to `object`. This changes it so
`none` becomes a child of `object` (it is still represented by
`NullType` which remains unusable in compilation).

This change makes `object` the sole top-level type, and the type that
can represent *any* GOAL object. I believe this matches the original
GOAL built-in type structure. A function that has a return type of
`object` can now return an integer or a `none` at the same time.
However, keep in mind that the return value of `(none)` is still
undefined, just as before. This also makes a cast to `object`
meaningless in 90% of the situations it showed up in (as every single
thing is already an `object`) and the decompiler will no longer emit
them. Casts to `none` are also reduced. Yay!

Additionally, state handlers also don't get the final `(none)` printed
out anymore. The return type of a state handler is completely
meaningless outside the event handler (which is return type `object`
anyway) so there are no limitations on what the last form needs to be. I
did this instead of making them return `object` to trick the decompiler
into not trying to output a variable to be used as a return value
(internally, in the decompiler they still have return type `none`, but
they have `object` elsewhere).

Fixes #1703 
Fixes #830 
Fixes #928
This commit is contained in:
ManDude
2023-09-22 10:54:49 +01:00
committed by GitHub
parent 697b07abd5
commit fe491c2b5e
964 changed files with 24949 additions and 39444 deletions
@@ -57,6 +57,7 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
)
;; definition for method 37 of type process-taskable
;; WARN: Return type mismatch object vs none.
(defmethod process-taskable-method-37 process-taskable ((obj process-taskable))
(let ((v1-1 (-> obj draw shadow-ctrl)))
(cond
@@ -78,16 +79,15 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
;; failed to figure out what this is:
(defstate hide (process-taskable)
:virtual #t
:event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block))
(the-as object (case event-type
(('say)
(let ((v0-0 (current-time)))
(set! (-> self want-to-say) v0-0)
v0-0
)
)
)
)
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('say)
(let ((v0-0 (current-time)))
(set! (-> self want-to-say) v0-0)
v0-0
)
)
)
)
:enter (behavior ()
(set! (-> self state-time) (current-time))
@@ -97,7 +97,6 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
(set! (-> v1-6 prim-core collide-with) (collide-spec))
)
0
(none)
)
:exit (behavior ()
(logclear! (-> self draw status) (draw-control-status no-draw-bounds))
@@ -105,7 +104,6 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
(set! (-> v1-3 prim-core collide-as) (-> self root backup-collide-as))
(set! (-> v1-3 prim-core collide-with) (-> self root backup-collide-with))
)
(none)
)
:trans (behavior ()
(let ((v1-1 (get-current-task-event (-> self task))))
@@ -117,7 +115,6 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
(go-virtual idle)
)
)
(none)
)
:code (the-as (function none :behavior process-taskable) sleep-code)
)
@@ -125,8 +122,8 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
;; failed to figure out what this is:
(defstate idle (process-taskable)
:virtual #t
:event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block))
(case event-type
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('attack)
(if (-> self bounce-away)
(send-event
@@ -138,7 +135,7 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
)
)
(('touch)
(send-shoves (-> self root) proc (the-as touching-shapes-entry (-> event param 0)) 0.7 6144.0 16384.0)
(send-shoves (-> self root) proc (the-as touching-shapes-entry (-> block param 0)) 0.7 6144.0 16384.0)
)
(('say)
(let ((v0-0 (the-as object (current-time))))
@@ -150,11 +147,9 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
)
:enter (behavior ()
(set! (-> self state-time) (current-time))
(none)
)
:exit (behavior ()
(logclear! (-> self draw status) (draw-control-status no-draw))
(none)
)
:trans (behavior ()
(let ((gp-0 (get-current-task-event (-> self task))))
@@ -271,11 +266,9 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
)
)
(process-taskable-method-37 self)
(none)
)
:code (behavior ()
(process-taskable-anim-loop (the-as (function process-taskable object) true-func))
(none)
)
:post (behavior ()
(if (and (-> self hide-during-movie) (movie?))
@@ -288,7 +281,6 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
)
)
(transform-post)
(none)
)
)
@@ -300,7 +292,6 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
(set! (-> self want-to-say) 0)
(process-entity-status! self (entity-perm-status no-kill) #t)
(logclear! (-> self mask) (process-mask actor-pause))
(none)
)
:exit (behavior ()
(set! (-> self last-talk) (-> *display* game-clock frame-counter))
@@ -315,7 +306,6 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
(set! (-> v1-13 prim-core collide-as) (-> self root backup-collide-as))
(set! (-> v1-13 prim-core collide-with) (-> self root backup-collide-with))
)
(none)
)
:code (behavior ((arg0 game-task-event))
(when (-> arg0 scene)
@@ -335,7 +325,6 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
)
)
(go-virtual hide)
(none)
)
)
@@ -351,7 +340,6 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
)
)
(go-virtual hide)
(none)
)
:post (-> (method-of-type process-taskable idle) post)
)
@@ -474,7 +462,3 @@ This commonly includes things such as:
(go (method-of-object obj hide))
(none)
)