From 69caa163c994443363bb74914cb0a72bab852e15 Mon Sep 17 00:00:00 2001 From: water Date: Sat, 23 Sep 2023 13:31:53 -0400 Subject: [PATCH] jak 1 --- decompiler/IR2/AtomicOpTypeAnalysis.cpp | 83 +++++++++++-------- decompiler/IR2/FormExpressionAnalysis.cpp | 17 ++++ .../config/jak1/ntsc_v1/type_casts.jsonc | 21 +---- .../jak1/engine/common-obs/collectables.gc | 2 +- goal_src/jak1/engine/target/target2.gc | 2 +- goal_src/jak1/kernel/gstate.gc | 21 +++++ goal_src/jak1/levels/beach/pelican.gc | 5 +- goal_src/jak1/levels/citadel/citadel-obs.gc | 2 +- goal_src/jak1/levels/citadel/citb-plat.gc | 4 +- goal_src/jak1/levels/jungle/fisher.gc | 4 +- .../jak1/levels/jungle/jungle-elevator.gc | 2 +- .../jak1/levels/misty/babak-with-cannon.gc | 2 +- goal_src/jak1/levels/swamp/billy.gc | 2 +- goal_src/jak1/levels/swamp/swamp-obs.gc | 2 +- goal_src/jak1/levels/swamp/swamp-rat.gc | 2 +- .../jak1/levels/village1/fishermans-boat.gc | 8 +- goal_src/jak1/levels/village1/village-obs.gc | 5 +- .../jak1/levels/village2/sunken-elevator.gc | 2 +- .../levels/village_common/villagep-obs.gc | 2 +- goalc/compiler/Compiler.h | 7 +- goalc/compiler/Util.cpp | 4 +- goalc/compiler/compilation/Atoms.cpp | 2 + goalc/compiler/compilation/Type.cpp | 41 +++++++++ .../reference/jak1/decompiler-macros.gc | 20 +++++ .../engine/common-obs/collectables_REF.gc | 2 +- .../jak1/engine/common-obs/nav-enemy_REF.gc | 4 +- .../jak1/engine/common-obs/rigid-body_REF.gc | 9 +- .../jak1/engine/common-obs/sharkey_REF.gc | 2 +- .../jak1/engine/target/logic-target_REF.gc | 2 +- .../jak1/engine/target/target2_REF.gc | 2 +- .../jak1/levels/beach/beach-obs_REF.gc | 6 +- .../jak1/levels/beach/beach-rocks_REF.gc | 5 +- .../jak1/levels/beach/pelican_REF.gc | 6 +- .../jak1/levels/citadel/citadel-obs_REF.gc | 20 ++--- .../jak1/levels/citadel/citadel-sages_REF.gc | 8 +- .../jak1/levels/citadel/citb-plat_REF.gc | 6 +- .../levels/common/battlecontroller_REF.gc | 8 +- .../jak1/levels/jungle/fisher_REF.gc | 6 +- .../jak1/levels/jungle/hopper_REF.gc | 2 +- .../jak1/levels/jungle/jungle-elevator_REF.gc | 2 +- .../jak1/levels/jungle/jungle-obs_REF.gc | 6 +- .../jak1/levels/jungle/junglefish_REF.gc | 2 +- .../jak1/levels/jungleb/plant-boss_REF.gc | 6 +- .../jak1/levels/lavatube/lavatube-obs_REF.gc | 6 +- .../jak1/levels/maincave/baby-spider_REF.gc | 2 +- .../levels/maincave/driller-lurker_REF.gc | 6 +- .../jak1/levels/maincave/gnawer_REF.gc | 6 +- .../levels/misty/babak-with-cannon_REF.gc | 2 +- .../jak1/levels/misty/balloonlurker_REF.gc | 6 +- .../jak1/levels/misty/misty-conveyor_REF.gc | 6 +- .../jak1/levels/misty/misty-obs_REF.gc | 7 +- .../jak1/levels/ogre/ogre-obs_REF.gc | 26 +++--- .../jak1/levels/ogre/ogreboss_REF.gc | 9 +- .../jak1/levels/robocave/cave-trap_REF.gc | 6 +- .../jak1/levels/snow/ice-cube_REF.gc | 3 +- .../jak1/levels/snow/snow-ball_REF.gc | 7 +- .../jak1/levels/snow/snow-bumper_REF.gc | 6 +- .../jak1/levels/snow/snow-obs_REF.gc | 6 +- .../reference/jak1/levels/snow/yeti_REF.gc | 3 +- .../reference/jak1/levels/sunken/bully_REF.gc | 6 +- .../jak1/levels/sunken/helix-water_REF.gc | 6 +- .../jak1/levels/sunken/puffer_REF.gc | 6 +- .../jak1/levels/sunken/qbert-plat_REF.gc | 2 +- .../jak1/levels/sunken/square-platform_REF.gc | 6 +- .../jak1/levels/sunken/steam-cap_REF.gc | 6 +- .../jak1/levels/sunken/sunken-pipegame_REF.gc | 6 +- .../reference/jak1/levels/swamp/billy_REF.gc | 10 +-- .../reference/jak1/levels/swamp/kermit_REF.gc | 2 +- .../jak1/levels/swamp/swamp-bat_REF.gc | 6 +- .../jak1/levels/swamp/swamp-obs_REF.gc | 2 +- .../jak1/levels/swamp/swamp-rat_REF.gc | 2 +- .../jak1/levels/training/training-obs_REF.gc | 2 +- .../levels/village1/fishermans-boat_REF.gc | 9 +- .../jak1/levels/village1/village-obs_REF.gc | 6 +- .../levels/village2/sunken-elevator_REF.gc | 2 +- .../jak1/levels/village2/swamp-blimp_REF.gc | 6 +- .../jak1/levels/village2/village2-obs_REF.gc | 2 +- .../levels/village_common/villagep-obs_REF.gc | 9 +- 78 files changed, 261 insertions(+), 308 deletions(-) diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index fb7872202c..f1c1502dd0 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -1421,55 +1421,70 @@ TypeState CallOp::propagate_types_internal(const TypeState& input, if (in_tp.kind == TP_Type::Kind::FIND_PARENT_METHOD_FUNCTION) { bool can_use_call_parent = true; - // should be calling this from a method: - if (env.func->guessed_name.kind != FunctionName::FunctionKind::METHOD) { + TypeSpec call_parent_result_type; + const auto& guessed_name = env.func->guessed_name; + + if (guessed_name.kind == FunctionName::FunctionKind::METHOD || + guessed_name.kind == FunctionName::FunctionKind::V_STATE) { + // should call something like: + // (find-parent-method sharkey 39) + const auto& type_arg = input.get(Register(Reg::GPR, Reg::A0)); + if (can_use_call_parent && type_arg.kind != TP_Type::Kind::TYPE_OF_TYPE_NO_VIRTUAL) { + lg::warn( + "Can't use call-parent-method because the first argument to find-parent-method is a " + "{}, which should be a type", + type_arg.print()); + can_use_call_parent = false; + } + + if (can_use_call_parent && type_arg.get_type_objects_typespec() != guessed_name.type_name) { + lg::warn( + "Can't use call-parent-method because the first argument type is wrong: got {}, but " + "expected {}", + type_arg.get_type_objects_typespec().print(), guessed_name.type_name); + can_use_call_parent = false; + } + const auto& id_arg = input.get(Register(Reg::GPR, Reg::A1)); + int expected_id = -1; + if (guessed_name.kind == FunctionName::FunctionKind::V_STATE) { + auto state_info = dts.ts.lookup_method(guessed_name.type_name, guessed_name.state_name); + expected_id = state_info.id; + call_parent_result_type = + state_info.type.substitute_for_method_call(guessed_name.type_name); + } else { + expected_id = guessed_name.method_id; + call_parent_result_type = env.func->type; // same type as this method! + } + if (can_use_call_parent && !id_arg.is_integer_constant(expected_id)) { + lg::warn( + "Can't use call-parent-method because the second argument is wrong: got {}, but " + "expected a constant integer {}", + id_arg.print(), expected_id); + can_use_call_parent = false; + } + + } else { can_use_call_parent = false; lg::warn( "Can't use call-parent-method because find-parent-method was called in {}, which isn't a " - "method.", + "method or state handler.", env.func->name()); } - // should call something like: - // (find-parent-method sharkey 39) - const auto& type_arg = input.get(Register(Reg::GPR, Reg::A0)); - if (can_use_call_parent && type_arg.kind != TP_Type::Kind::TYPE_OF_TYPE_NO_VIRTUAL) { - lg::warn( - "Can't use call-parent-method because the first argument to find-parent-method is a {}, " - "which should be a type", - type_arg.print()); - can_use_call_parent = false; - } - - if (can_use_call_parent && type_arg.get_type_objects_typespec() != env.func->method_of_type) { - lg::warn( - "Can't use call-parent-method because the first argument type is wrong: got {}, but " - "expected {}", - type_arg.get_type_objects_typespec().print(), env.func->method_of_type); - can_use_call_parent = false; - } - const auto& id_arg = input.get(Register(Reg::GPR, Reg::A1)); - if (can_use_call_parent && !id_arg.is_integer_constant(env.func->guessed_name.method_id)) { - lg::warn( - "Can't use call-parent-method because the second argument is wrong: got {}, but expected " - "a constant integer {}", - id_arg.print(), env.func->guessed_name.method_id); - can_use_call_parent = false; - } if (can_use_call_parent) { - end_types.get(Register(Reg::GPR, Reg::V0)) = TP_Type::make_from_ts(env.func->type); + end_types.get(Register(Reg::GPR, Reg::V0)) = TP_Type::make_from_ts(call_parent_result_type); use_normal_last_arg = false; } } - if (use_normal_last_arg) { - end_types.get(Register(Reg::GPR, Reg::V0)) = TP_Type::make_from_ts(in_type.last_arg()); - } - if (in_type.arg_count() < 1) { throw std::runtime_error("Called a function, but we do not know its type"); } + if (use_normal_last_arg) { + end_types.get(Register(Reg::GPR, Reg::V0)) = TP_Type::make_from_ts(in_type.last_arg()); + } + // set the call type! m_call_type = in_type; m_call_type_set = true; diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 68e3e113d8..fbedb68b36 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -3896,6 +3896,7 @@ void FunctionCallElement::update_from_stack(const Env& env, { const auto& guessed_name = env.func->guessed_name; if (guessed_name.kind == FunctionName::FunctionKind::METHOD) { + // detect stuff like: ((find-parent-method...) arg...) auto mr_find_parent = match(Matcher::func(Matcher::symbol("find-parent-method"), {Matcher::symbol(env.func->method_of_type), @@ -3908,6 +3909,22 @@ void FunctionCallElement::update_from_stack(const Env& env, GenericOperator::make_function(pool.form("call-parent-method")), arg_forms); } + } else if (guessed_name.kind == FunctionName::FunctionKind::V_STATE && arg_forms.size() == 2) { + // here, simply detect (find-parent-method...) + // + auto mr_find_parent = match(Matcher::symbol("find-parent-method"), unstacked.at(0)); + if (mr_find_parent.matched) { + auto state_info = + env.dts->ts.lookup_method(guessed_name.type_name, guessed_name.state_name); + if (arg_forms.at(0)->to_string(env) == guessed_name.type_name && + arg_forms.at(1)->to_string(env) == std::to_string(state_info.id)) { + new_form = pool.alloc_element( + GenericOperator::make_function(pool.form("find-parent-state"))); + } else { + printf("BAD match [%s] [%s]\n", arg_forms.at(0)->to_string(env).c_str(), + arg_forms.at(1)->to_string(env).c_str()); + } + } } } diff --git a/decompiler/config/jak1/ntsc_v1/type_casts.jsonc b/decompiler/config/jak1/ntsc_v1/type_casts.jsonc index 45fc93c87a..9d554f33cd 100644 --- a/decompiler/config/jak1/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak1/ntsc_v1/type_casts.jsonc @@ -1603,10 +1603,6 @@ [49, "v1", "village2cam"] ], - "(trans plat-button-move-downward sunken-elevator)": [ - [13, "v0", "(state sunken-elevator)"] - ], - "(method 27 sunken-elevator)": [[37, "v1", "art-joint-anim"]], "nav-enemy-set-base-collide-sphere-collide-with": [ @@ -2288,10 +2284,6 @@ [42, "s3", "(inline-array sparticle-cpuinfo)"] ], - "(trans plat-button-move-downward jungle-elevator)": [ - [11, "v0", "(state plat-button)"] - ], - "(code plat-button-at-end jungle-elevator)": [ [43, "t9", "(function none :behavior plat-button)"] ], @@ -2760,8 +2752,6 @@ "(code babak-with-cannon-jump-off-cannon)": [[28, "v1", "art-joint-anim"]], - "(trans nav-enemy-die babak-with-cannon)": [[40, "v0", "(state nav-enemy)"]], - "(enter othercam-running)": [ [50, "gp", "process-taskable"], [53, "gp", "process-taskable"] @@ -3155,6 +3145,8 @@ [20, "s3", "hud-fuel-cell"] ], + "(enter pickup fuel-cell)": [[9, "v0", "(state eco-collectable)"]], + "(method 15 hud-pickups)": [ [51, "v1", "dma-packet"], [52, "v1", "dma-packet"] @@ -3671,10 +3663,6 @@ [69, "v1", "float"] ], - "(trans play-accept fisher)": [[101, "v0", "state"]], - - "(trans idle fisher)": [[4, "v0", "state"]], - "(code idle fisher)": [ [132, "v1", "art-joint-anim"], [35, "v1", "float"] @@ -4135,7 +4123,6 @@ ], "(code battlecontroller-die citb-battlecontroller)": [ - [9, "v0", "(state battlecontroller)"], [11, "t9", "(function none :behavior battlecontroller)"] ], @@ -4749,8 +4736,6 @@ [22, "v1", "collide-shape-prim-group"] ], - "(enter nav-enemy-victory billy-rat)": [[4, "v0", "(state nav-enemy)"]], - "(code billy-rat-salivate)": [[43, "v1", "art-joint-anim"]], "(code idle billy)": [ @@ -4884,8 +4869,6 @@ "(event wait fuel-cell)": [[95, "a0", "vector"]], - "(enter pickup fuel-cell)": [[9, "v0", "(state eco-collectable)"]], - "(code ecovalve-idle)": [[41, "v1", "process-drawable"]], "(code vent-pickup)": [ diff --git a/goal_src/jak1/engine/common-obs/collectables.gc b/goal_src/jak1/engine/common-obs/collectables.gc index be91f0b5f7..a537ed0e0a 100644 --- a/goal_src/jak1/engine/common-obs/collectables.gc +++ b/goal_src/jak1/engine/common-obs/collectables.gc @@ -1495,7 +1495,7 @@ :enter (behavior ((arg0 object) (arg1 handle)) (set! (-> self state-time) (-> *display* base-frame-counter)) (set! (-> self state-object) #t) - (let ((t9-1 (-> (the-as (state eco-collectable) (find-parent-method fuel-cell 23)) enter))) + (let ((t9-1 (-> (the-as (state eco-collectable) (find-parent-state)) enter))) (if t9-1 (t9-1) ) diff --git a/goal_src/jak1/engine/target/target2.gc b/goal_src/jak1/engine/target/target2.gc index 0802616f83..72ea977769 100644 --- a/goal_src/jak1/engine/target/target2.gc +++ b/goal_src/jak1/engine/target/target2.gc @@ -175,7 +175,7 @@ ) (enable-hud) (set! (-> *target* fp-hud) (the-as handle #f)) - ((the-as (function process none) (find-parent-method first-person-hud 10)) obj) + (call-parent-method obj) (none) ) diff --git a/goal_src/jak1/kernel/gstate.gc b/goal_src/jak1/kernel/gstate.gc index aba54d7955..1726854ada 100644 --- a/goal_src/jak1/kernel/gstate.gc +++ b/goal_src/jak1/kernel/gstate.gc @@ -144,6 +144,10 @@ It type checks the arguments for the entry function. (set! *defstate-type-stack* '()) `(none) ) + +(seval (define *defstate-current-type* #f)) +(seval (define *defstate-current-state-name* #f)) + ;; *no-state* is just used for the compiler to know whether a handler was actually set or not (defmacro defstate (state-name parents &key (virtual #f) @@ -163,6 +167,11 @@ It type checks the arguments for the entry function. *defstate-type-stack*) ) (set! *defstate-type-stack* '()) + (when virtual + (set! *defstate-current-type* defstate-type) + (set! *defstate-current-state-name* state-name) + ) + ;; check for default handlers (let ((default-handlers (assoc defstate-type *default-state-handlers*))) (when default-handlers @@ -225,6 +234,18 @@ It type checks the arguments for the entry function. ) ) +(defmacro find-parent-state () + (when (or (not *defstate-current-type*) + (not *defstate-current-state-name*)) + (error "use of find-parent-state outside of a defstate.") + ) + `(cast-to-method-type + ,*defstate-current-type* + ,*defstate-current-state-name* + (find-parent-method ,*defstate-current-type* (method-id-of-type ,*defstate-current-type* ,*defstate-current-state-name*)) + ) + ) + (defmacro behavior (bindings &rest body) "Define an anonymous behavior for a process state. This may only be used inside a defstate!" diff --git a/goal_src/jak1/levels/beach/pelican.gc b/goal_src/jak1/levels/beach/pelican.gc index 0ccc3a55f8..36a88e5762 100644 --- a/goal_src/jak1/levels/beach/pelican.gc +++ b/goal_src/jak1/levels/beach/pelican.gc @@ -95,10 +95,7 @@ (if (nonzero? (-> obj neck)) (&+! (-> obj neck) arg0) ) - (the-as - pelican - ((the-as (function process-drawable int process-drawable) (find-parent-method pelican 7)) obj arg0) - ) + (call-parent-method obj arg0) ) (defskelgroup *pelican-sg* pelican pelican-lod0-jg pelican-fly-ja diff --git a/goal_src/jak1/levels/citadel/citadel-obs.gc b/goal_src/jak1/levels/citadel/citadel-obs.gc index c645018b3c..15431a2faa 100644 --- a/goal_src/jak1/levels/citadel/citadel-obs.gc +++ b/goal_src/jak1/levels/citadel/citadel-obs.gc @@ -1541,7 +1541,7 @@ :virtual #t :code (behavior () (process-entity-status! self (entity-perm-status complete) #t) - (let ((t9-2 (-> (the-as (state battlecontroller) (find-parent-method citb-battlecontroller 26)) code))) + (let ((t9-2 (-> (find-parent-state) code))) (if t9-2 ((the-as (function none :behavior battlecontroller) t9-2)) ) diff --git a/goal_src/jak1/levels/citadel/citb-plat.gc b/goal_src/jak1/levels/citadel/citb-plat.gc index 631c39999b..83c5d8d4bb 100644 --- a/goal_src/jak1/levels/citadel/citb-plat.gc +++ b/goal_src/jak1/levels/citadel/citb-plat.gc @@ -1035,7 +1035,7 @@ :trans (behavior () (let ((gp-0 (new 'stack-no-clear 'vector))) (set! (-> gp-0 quad) (-> self root-override trans quad)) - (let ((t9-1 (-> (the-as (state plat-button) (find-parent-method citb-exit-plat 23)) trans))) + (let ((t9-1 (-> (the-as (state plat-button) (find-parent-state)) trans))) (if t9-1 (t9-1) ) @@ -1051,7 +1051,7 @@ :trans (behavior () (let ((gp-0 (new 'stack-no-clear 'vector))) (set! (-> gp-0 quad) (-> self root-override trans quad)) - (let ((t9-1 (-> (the-as (state plat-button) (find-parent-method citb-exit-plat 24)) trans))) + (let ((t9-1 (-> (the-as (state plat-button) (find-parent-state)) trans))) (if t9-1 (t9-1) ) diff --git a/goal_src/jak1/levels/jungle/fisher.gc b/goal_src/jak1/levels/jungle/fisher.gc index c064fa65e8..673a86b4bd 100644 --- a/goal_src/jak1/levels/jungle/fisher.gc +++ b/goal_src/jak1/levels/jungle/fisher.gc @@ -1755,7 +1755,7 @@ (fisher-fish-water gp-0 (+ 32768.0 (vector-y-angle (-> self node-list data 80 bone transform vector 1)))) ) ) - (let ((t9-14 (-> (the-as state (find-parent-method fisher 24)) trans))) + (let ((t9-14 (-> (find-parent-state) trans))) (if t9-14 (t9-14) ) @@ -1766,7 +1766,7 @@ (defstate idle (fisher) :virtual #t :trans (behavior () - (let ((t9-1 (-> (the-as state (find-parent-method fisher 30)) trans))) + (let ((t9-1 (-> (find-parent-state) trans))) (if t9-1 (t9-1) ) diff --git a/goal_src/jak1/levels/jungle/jungle-elevator.gc b/goal_src/jak1/levels/jungle/jungle-elevator.gc index a9a605fa64..2c9f429a4e 100644 --- a/goal_src/jak1/levels/jungle/jungle-elevator.gc +++ b/goal_src/jak1/levels/jungle/jungle-elevator.gc @@ -49,7 +49,7 @@ (gp-0 (new 'stack-no-clear 'vector)) ) (set! (-> s5-0 quad) (-> self root-override trans quad)) - (let ((t9-1 (-> (the-as (state plat-button) (find-parent-method jungle-elevator 23)) trans))) + (let ((t9-1 (-> (find-parent-state) trans))) (if t9-1 (t9-1) ) diff --git a/goal_src/jak1/levels/misty/babak-with-cannon.gc b/goal_src/jak1/levels/misty/babak-with-cannon.gc index 3b458638a2..5685cb3cc1 100644 --- a/goal_src/jak1/levels/misty/babak-with-cannon.gc +++ b/goal_src/jak1/levels/misty/babak-with-cannon.gc @@ -308,7 +308,7 @@ nav-enemy-default-event-handler (if (and *target* (= (-> *target* current-level name) 'misty)) (spool-push *art-control* "mistycam-cannon" 0 self -1.0) ) - (let ((t9-3 (-> (the-as (state nav-enemy) (find-parent-method babak-with-cannon 23)) trans))) + (let ((t9-3 (-> (find-parent-state) trans))) (if t9-3 (t9-3) ) diff --git a/goal_src/jak1/levels/swamp/billy.gc b/goal_src/jak1/levels/swamp/billy.gc index ee659d1197..bee37e0b7c 100644 --- a/goal_src/jak1/levels/swamp/billy.gc +++ b/goal_src/jak1/levels/swamp/billy.gc @@ -204,7 +204,7 @@ (defstate nav-enemy-victory (billy-rat) :virtual #t :enter (behavior () - (let ((t9-1 (-> (the-as (state nav-enemy) (find-parent-method billy-rat 33)) enter))) + (let ((t9-1 (-> (find-parent-state) enter))) (if t9-1 (t9-1) ) diff --git a/goal_src/jak1/levels/swamp/swamp-obs.gc b/goal_src/jak1/levels/swamp/swamp-obs.gc index 6e5289015a..bff7e9e9ca 100644 --- a/goal_src/jak1/levels/swamp/swamp-obs.gc +++ b/goal_src/jak1/levels/swamp/swamp-obs.gc @@ -748,7 +748,7 @@ ) (defmethod rigid-body-platform-method-23 tar-plat ((obj tar-plat) (arg0 float)) - ((the-as (function rigid-body-platform basic none) (find-parent-method tar-plat 23)) obj (the-as basic arg0)) + (call-parent-method obj arg0) (rigid-body-platform-method-27 obj (-> obj anchor-point)) 0 (none) diff --git a/goal_src/jak1/levels/swamp/swamp-rat.gc b/goal_src/jak1/levels/swamp/swamp-rat.gc index 030c388c53..0f0279d5a0 100644 --- a/goal_src/jak1/levels/swamp/swamp-rat.gc +++ b/goal_src/jak1/levels/swamp/swamp-rat.gc @@ -85,7 +85,7 @@ swamp-rat-default-event-handler (vector-z-quaternion! (new-stack-vector0) (-> obj collide-info quat)) (-> obj up-vector) ) - ((the-as (function nav-enemy none) (find-parent-method swamp-rat 39)) obj) + (call-parent-method obj) (none) ) diff --git a/goal_src/jak1/levels/village1/fishermans-boat.gc b/goal_src/jak1/levels/village1/fishermans-boat.gc index 0148fdcbad..4e0b857640 100644 --- a/goal_src/jak1/levels/village1/fishermans-boat.gc +++ b/goal_src/jak1/levels/village1/fishermans-boat.gc @@ -1218,13 +1218,7 @@ (if (nonzero? (-> obj propeller)) (&+! (-> obj propeller) arg0) ) - (the-as - fishermans-boat - ((the-as (function rigid-body-platform int rigid-body-platform) (find-parent-method fishermans-boat 7)) - obj - arg0 - ) - ) + (call-parent-method obj arg0) ) (defmethod rigid-body-platform-method-30 fishermans-boat ((obj fishermans-boat)) diff --git a/goal_src/jak1/levels/village1/village-obs.gc b/goal_src/jak1/levels/village1/village-obs.gc index e701bb41d6..1ae710e79d 100644 --- a/goal_src/jak1/levels/village1/village-obs.gc +++ b/goal_src/jak1/levels/village1/village-obs.gc @@ -924,10 +924,7 @@ (if (nonzero? (-> obj pivot)) (&+! (-> obj pivot) arg0) ) - (the-as - hutlamp - ((the-as (function process-drawable int process-drawable) (find-parent-method hutlamp 7)) obj arg0) - ) + (call-parent-method obj arg0) ) (defskelgroup *hutlamp-sg* hutlamp hutlamp-lod0-jg hutlamp-idle-ja diff --git a/goal_src/jak1/levels/village2/sunken-elevator.gc b/goal_src/jak1/levels/village2/sunken-elevator.gc index c1d4794185..ff4b956f61 100644 --- a/goal_src/jak1/levels/village2/sunken-elevator.gc +++ b/goal_src/jak1/levels/village2/sunken-elevator.gc @@ -148,7 +148,7 @@ ) (set! *teleport* #t) (set! (-> s5-0 quad) (-> self root-override trans quad)) - (let ((t9-1 (-> (the-as (state sunken-elevator) (find-parent-method sunken-elevator 23)) trans))) + (let ((t9-1 (-> (find-parent-state) trans))) (if t9-1 (t9-1) ) diff --git a/goal_src/jak1/levels/village_common/villagep-obs.gc b/goal_src/jak1/levels/village_common/villagep-obs.gc index b851534954..32733dc069 100644 --- a/goal_src/jak1/levels/village_common/villagep-obs.gc +++ b/goal_src/jak1/levels/village_common/villagep-obs.gc @@ -842,7 +842,7 @@ ) ) ) - (let ((t9-10 (-> (the-as (state basebutton) (find-parent-method warp-gate-switch 21)) code))) + (let ((t9-10 (-> (the-as (state basebutton) (find-parent-state)) code))) (if t9-10 ((the-as (function none :behavior basebutton) t9-10)) ) diff --git a/goalc/compiler/Compiler.h b/goalc/compiler/Compiler.h index 67c0f36ed2..0763475995 100644 --- a/goalc/compiler/Compiler.h +++ b/goalc/compiler/Compiler.h @@ -219,8 +219,8 @@ class Compiler { const std::vector>& unnamed, const std::unordered_map>>& named); - std::string as_string(const goos::Object& o); - std::string symbol_string(const goos::Object& o); + const std::string& as_string(const goos::Object& o); + const std::string& symbol_string(const goos::Object& o); std::string quoted_sym_as_string(const goos::Object& o); goos::Object unquote(const goos::Object& o); bool is_quoted_sym(const goos::Object& o); @@ -696,6 +696,7 @@ class Compiler { Val* compile_car(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_cdr(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_method_of_type(const goos::Object& form, const goos::Object& rest, Env* env); + Val* compile_method_id_of_type(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_method_of_object(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_addr_of(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_declare_type(const goos::Object& form, const goos::Object& rest, Env* env); @@ -706,7 +707,7 @@ class Compiler { Val* compile_psize_of(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_current_method_id(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_current_method_type(const goos::Object& form, const goos::Object& rest, Env* env); - + Val* compile_cast_to_method_type(const goos::Object& form, const goos::Object& rest, Env* env); // State Val* compile_define_state_hook(const goos::Object& form, const goos::Object& rest, Env* env); diff --git a/goalc/compiler/Util.cpp b/goalc/compiler/Util.cpp index 5ca62d8e11..81b1b41c0d 100644 --- a/goalc/compiler/Util.cpp +++ b/goalc/compiler/Util.cpp @@ -214,14 +214,14 @@ void Compiler::for_each_in_list(const goos::Object& list, /*! * Convert a goos::Object that's a string to a std::string. Must be a string. */ -std::string Compiler::as_string(const goos::Object& o) { +const std::string& Compiler::as_string(const goos::Object& o) { return o.as_string()->data; } /*! * Convert a goos::Object that's a symbol to a std::string. Must be a string. */ -std::string Compiler::symbol_string(const goos::Object& o) { +const std::string& Compiler::symbol_string(const goos::Object& o) { return o.as_symbol()->name; } diff --git a/goalc/compiler/compilation/Atoms.cpp b/goalc/compiler/compilation/Atoms.cpp index 03c4ca4619..aa9e47c6f7 100644 --- a/goalc/compiler/compilation/Atoms.cpp +++ b/goalc/compiler/compilation/Atoms.cpp @@ -207,12 +207,14 @@ const std::unordered_map< {"car", {"", &Compiler::compile_car}}, {"cdr", {"", &Compiler::compile_cdr}}, {"method-of-type", {"", &Compiler::compile_method_of_type}}, + {"method-id-of-type", {"", &Compiler::compile_method_id_of_type}}, {"method-of-object", {"", &Compiler::compile_method_of_object}}, {"declare-type", {"", &Compiler::compile_declare_type}}, {"none", {"", &Compiler::compile_none}}, {"size-of", {"", &Compiler::compile_size_of}}, {"psize-of", {"", &Compiler::compile_psize_of}}, {"current-method-id", {"", &Compiler::compile_current_method_id}}, + {"cast-to-method-type", {"", &Compiler::compile_cast_to_method_type}}, // LAMBDA {"lambda", {"", &Compiler::compile_lambda}}, diff --git a/goalc/compiler/compilation/Type.cpp b/goalc/compiler/compilation/Type.cpp index 12c1815366..1fbea4517f 100644 --- a/goalc/compiler/compilation/Type.cpp +++ b/goalc/compiler/compilation/Type.cpp @@ -1309,6 +1309,47 @@ Val* Compiler::compile_method_of_type(const goos::Object& form, return get_none(); } +Val* Compiler::compile_method_id_of_type(const goos::Object& form, + const goos::Object& rest, + Env* env) { + auto args = get_va(form, rest); + va_check(form, args, {{goos::ObjectType::SYMBOL}, {goos::ObjectType::SYMBOL}}, {}); + auto arg = args.unnamed.at(0); + if (m_ts.fully_defined_type_exists(symbol_string(arg))) { + auto info = m_ts.lookup_method(symbol_string(arg), symbol_string(args.unnamed.at(1))); + return compile_integer(info.id, env); + } else if (m_ts.partially_defined_type_exists(symbol_string(arg))) { + throw_compiler_error( + form, "The method-id-of-type form is ambiguous when used on a forward declared type."); + } else { + throw_compiler_error(form, "unknown type"); + } +} + +Val* Compiler::compile_cast_to_method_type(const goos::Object& form, + const goos::Object& rest, + Env* env) { + auto args = get_va(form, rest); + va_check(form, args, {{goos::ObjectType::SYMBOL}, {goos::ObjectType::SYMBOL}, {}}, {}); + auto arg = args.unnamed.at(0); + if (m_ts.fully_defined_type_exists(symbol_string(arg))) { + auto info = m_ts.lookup_method(symbol_string(arg), symbol_string(args.unnamed.at(1))); + + auto base = compile_error_guard(args.unnamed.at(2), env); + auto result = env->function_env()->alloc_val(info.type, base); + if (base->settable()) { + result->mark_as_settable(); + } + + return result; + } else if (m_ts.partially_defined_type_exists(symbol_string(arg))) { + throw_compiler_error( + form, "The cast-to-method-type form is ambiguous when used on a forward declared type."); + } else { + throw_compiler_error(form, "unknown type"); + } +} + Val* Compiler::compile_method_of_object(const goos::Object& form, const goos::Object& rest, Env* env) { diff --git a/test/decompiler/reference/jak1/decompiler-macros.gc b/test/decompiler/reference/jak1/decompiler-macros.gc index 40d02ddb20..6f2b22ebef 100644 --- a/test/decompiler/reference/jak1/decompiler-macros.gc +++ b/test/decompiler/reference/jak1/decompiler-macros.gc @@ -395,6 +395,9 @@ ) ) +(seval (define *defstate-current-type* #f)) +(seval (define *defstate-current-state-name* #f)) + ;; use a compile-time list to keep track of the type of an anonymous behavior. (seval (define *defstate-type-stack* '())) (desfun def-state-check-behavior (beh-form beh-type) @@ -427,6 +430,11 @@ *defstate-type-stack*) ) (set! *defstate-type-stack* '()) + (when virtual + (set! *defstate-current-type* defstate-type) + (set! *defstate-current-state-name* state-name) + ) + ;; check for default handlers (let ((default-handlers (assoc defstate-type *default-state-handlers*))) (when default-handlers @@ -489,6 +497,18 @@ ) ) +(defmacro find-parent-state () + (when (or (not *defstate-current-type*) + (not *defstate-current-state-name*)) + (error "use of find-parent-state outside of a defstate.") + ) + `(cast-to-method-type + ,*defstate-current-type* + ,*defstate-current-state-name* + (find-parent-method ,*defstate-current-type* (method-id-of-type ,*defstate-current-type* ,*defstate-current-state-name*)) + ) + ) + (defmacro behavior (bindings &rest body) "Define an anonymous behavior for a process state. This may only be used inside a defstate!" diff --git a/test/decompiler/reference/jak1/engine/common-obs/collectables_REF.gc b/test/decompiler/reference/jak1/engine/common-obs/collectables_REF.gc index d556af4cfb..3334db83cf 100644 --- a/test/decompiler/reference/jak1/engine/common-obs/collectables_REF.gc +++ b/test/decompiler/reference/jak1/engine/common-obs/collectables_REF.gc @@ -1635,7 +1635,7 @@ :enter (behavior ((arg0 object) (arg1 handle)) (set! (-> self state-time) (-> *display* base-frame-counter)) (set! (-> self state-object) #t) - (let ((t9-1 (-> (the-as (state eco-collectable) (find-parent-method fuel-cell 23)) enter))) + (let ((t9-1 (-> (the-as (state eco-collectable) (find-parent-state)) enter))) (if t9-1 (t9-1) ) diff --git a/test/decompiler/reference/jak1/engine/common-obs/nav-enemy_REF.gc b/test/decompiler/reference/jak1/engine/common-obs/nav-enemy_REF.gc index 1276f7cbd6..1680504559 100644 --- a/test/decompiler/reference/jak1/engine/common-obs/nav-enemy_REF.gc +++ b/test/decompiler/reference/jak1/engine/common-obs/nav-enemy_REF.gc @@ -36,7 +36,6 @@ ) ;; definition for method 9 of type trajectory -;; INFO: this function exists in multiple non-identical object files (defmethod eval-position! trajectory ((obj trajectory) (time float) (result vector)) (vector+float*! result (-> obj initial-position) (-> obj initial-velocity) time) (+! (-> result y) (* 0.5 time time (-> obj gravity))) @@ -44,7 +43,6 @@ ) ;; definition for method 7 of type nav-enemy -;; INFO: Return type mismatch none vs nav-enemy. (defmethod relocate nav-enemy ((obj nav-enemy) (arg0 int)) (if (nonzero? (-> obj neck)) (set! (-> obj neck) (the-as joint-mod (+ (the-as int (-> obj neck)) arg0))) @@ -52,7 +50,7 @@ (if (nonzero? (-> obj rand-gen)) (set! (-> obj rand-gen) (the-as random-generator (+ (the-as int (-> obj rand-gen)) arg0))) ) - (the-as nav-enemy ((the-as (function process-drawable int none) (find-parent-method nav-enemy 7)) obj arg0)) + (call-parent-method obj arg0) ) ;; definition for method 42 of type nav-enemy diff --git a/test/decompiler/reference/jak1/engine/common-obs/rigid-body_REF.gc b/test/decompiler/reference/jak1/engine/common-obs/rigid-body_REF.gc index d78c459a3f..6cc213a19a 100644 --- a/test/decompiler/reference/jak1/engine/common-obs/rigid-body_REF.gc +++ b/test/decompiler/reference/jak1/engine/common-obs/rigid-body_REF.gc @@ -401,20 +401,13 @@ ) ;; definition for method 7 of type rigid-body-platform -;; INFO: Return type mismatch process-drawable vs rigid-body-platform. (defmethod relocate rigid-body-platform ((obj rigid-body-platform) (arg0 int)) (if (nonzero? (-> obj control-point-array)) (set! (-> obj control-point-array) (the-as rigid-body-control-point-inline-array (+ (the-as int (-> obj control-point-array)) arg0)) ) ) - (the-as - rigid-body-platform - ((the-as (function process-drawable int process-drawable) (find-parent-method rigid-body-platform 7)) - obj - arg0 - ) - ) + (call-parent-method obj arg0) ) ;; definition for method 22 of type rigid-body-platform diff --git a/test/decompiler/reference/jak1/engine/common-obs/sharkey_REF.gc b/test/decompiler/reference/jak1/engine/common-obs/sharkey_REF.gc index 24b4b37653..c03d9e74aa 100644 --- a/test/decompiler/reference/jak1/engine/common-obs/sharkey_REF.gc +++ b/test/decompiler/reference/jak1/engine/common-obs/sharkey_REF.gc @@ -180,7 +180,7 @@ nav-enemy-default-event-handler (set! (-> obj last-y) f28-0) ) ) - ((the-as (function nav-enemy none) (find-parent-method sharkey 39)) obj) + (call-parent-method obj) 0 (none) ) diff --git a/test/decompiler/reference/jak1/engine/target/logic-target_REF.gc b/test/decompiler/reference/jak1/engine/target/logic-target_REF.gc index 49eddf5caf..399840700d 100644 --- a/test/decompiler/reference/jak1/engine/target/logic-target_REF.gc +++ b/test/decompiler/reference/jak1/engine/target/logic-target_REF.gc @@ -2106,7 +2106,7 @@ ;; definition for method 10 of type target (defmethod deactivate target ((obj target)) (set-zero! *camera-smush-control*) - ((the-as (function process-drawable none) (find-parent-method target 10)) obj) + (call-parent-method obj) (none) ) diff --git a/test/decompiler/reference/jak1/engine/target/target2_REF.gc b/test/decompiler/reference/jak1/engine/target/target2_REF.gc index f6f94cfea9..bf5ad20f1f 100644 --- a/test/decompiler/reference/jak1/engine/target/target2_REF.gc +++ b/test/decompiler/reference/jak1/engine/target/target2_REF.gc @@ -184,7 +184,7 @@ ) (enable-hud) (set! (-> *target* fp-hud) (the-as handle #f)) - ((the-as (function process none) (find-parent-method first-person-hud 10)) obj) + (call-parent-method obj) (none) ) diff --git a/test/decompiler/reference/jak1/levels/beach/beach-obs_REF.gc b/test/decompiler/reference/jak1/levels/beach/beach-obs_REF.gc index e543becc65..f6dd31a3ed 100644 --- a/test/decompiler/reference/jak1/levels/beach/beach-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/beach/beach-obs_REF.gc @@ -1067,15 +1067,11 @@ ) ;; definition for method 7 of type flutflutegg -;; INFO: Return type mismatch process-drawable vs flutflutegg. (defmethod relocate flutflutegg ((obj flutflutegg) (arg0 int)) (if (nonzero? (-> obj wobbler)) (&+! (-> obj wobbler) arg0) ) - (the-as - flutflutegg - ((the-as (function process-drawable int process-drawable) (find-parent-method flutflutegg 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 20 of type flutflutegg diff --git a/test/decompiler/reference/jak1/levels/beach/beach-rocks_REF.gc b/test/decompiler/reference/jak1/levels/beach/beach-rocks_REF.gc index 755e4944af..c6206725c4 100644 --- a/test/decompiler/reference/jak1/levels/beach/beach-rocks_REF.gc +++ b/test/decompiler/reference/jak1/levels/beach/beach-rocks_REF.gc @@ -267,7 +267,6 @@ ) ;; definition for method 7 of type beach-rock -;; INFO: Return type mismatch none vs beach-rock. (defmethod relocate beach-rock ((obj beach-rock) (arg0 int)) (if (nonzero? (-> obj part-falling)) (set! (-> obj part-falling) (the-as sparticle-launch-control (+ (the-as int (-> obj part-falling)) arg0))) @@ -275,7 +274,7 @@ (if (nonzero? (-> obj part-landing)) (set! (-> obj part-landing) (the-as sparticle-launch-control (+ (the-as int (-> obj part-landing)) arg0))) ) - (the-as beach-rock ((the-as (function process-drawable int none) (find-parent-method beach-rock 7)) obj arg0)) + (call-parent-method obj arg0) ) ;; definition for method 10 of type beach-rock @@ -286,7 +285,7 @@ (if (nonzero? (-> obj part-landing)) (kill-and-free-particles (-> obj part-landing)) ) - ((the-as (function process-drawable none) (find-parent-method beach-rock 10)) obj) + (call-parent-method obj) (none) ) diff --git a/test/decompiler/reference/jak1/levels/beach/pelican_REF.gc b/test/decompiler/reference/jak1/levels/beach/pelican_REF.gc index adc03e1b49..9508396329 100644 --- a/test/decompiler/reference/jak1/levels/beach/pelican_REF.gc +++ b/test/decompiler/reference/jak1/levels/beach/pelican_REF.gc @@ -126,7 +126,6 @@ ) ;; definition for method 7 of type pelican -;; INFO: Return type mismatch process-drawable vs pelican. (defmethod relocate pelican ((obj pelican) (arg0 int)) (countdown (v1-0 8) (if (nonzero? (-> obj path-data v1-0)) @@ -139,10 +138,7 @@ (if (nonzero? (-> obj neck)) (&+! (-> obj neck) arg0) ) - (the-as - pelican - ((the-as (function process-drawable int process-drawable) (find-parent-method pelican 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak1/levels/citadel/citadel-obs_REF.gc b/test/decompiler/reference/jak1/levels/citadel/citadel-obs_REF.gc index 0751a6acd6..ab7846f5bb 100644 --- a/test/decompiler/reference/jak1/levels/citadel/citadel-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/citadel/citadel-obs_REF.gc @@ -213,7 +213,7 @@ ;; definition for method 21 of type citb-arm ;; INFO: Return type mismatch int vs none. (defmethod setup-new-process! citb-arm ((obj citb-arm)) - ((the-as (function citb-arm-section none) (find-parent-method citb-arm 21)) obj) + (call-parent-method obj) (set! (-> obj draw origin-joint-index) (the-as uint 4)) (set-vector! (-> obj cull-dir-local) 0.0 0.0 -1.0 1.0) (set! (-> obj cull-dot) (cos 5461.3335)) @@ -241,7 +241,7 @@ ;; definition for method 21 of type citb-arm-shoulder ;; INFO: Return type mismatch int vs none. (defmethod setup-new-process! citb-arm-shoulder ((obj citb-arm-shoulder)) - ((the-as (function citb-arm-section none) (find-parent-method citb-arm-shoulder 21)) obj) + (call-parent-method obj) (set! (-> obj draw origin-joint-index) (the-as uint 4)) (set-vector! (-> obj cull-dir-local) 1.0 0.0 1.0 1.0) (set! (-> obj cull-dot) (cos 8374.045)) @@ -355,7 +355,7 @@ ;; INFO: Return type mismatch int vs none. (defmethod setup-new-process! citb-arm-a ((obj citb-arm-a)) (initialize-skeleton obj *citb-arm-a-sg* '()) - ((the-as (function citb-arm none) (find-parent-method citb-arm-a 21)) obj) + (call-parent-method obj) (set! (-> obj root-override root-prim local-sphere z) -184320.0) 0 (none) @@ -365,7 +365,7 @@ ;; INFO: Return type mismatch int vs none. (defmethod setup-new-process! citb-arm-b ((obj citb-arm-b)) (initialize-skeleton obj *citb-arm-b-sg* '()) - ((the-as (function citb-arm none) (find-parent-method citb-arm-b 21)) obj) + (call-parent-method obj) (set! (-> obj root-override root-prim local-sphere z) -225280.0) 0 (none) @@ -375,7 +375,7 @@ ;; INFO: Return type mismatch int vs none. (defmethod setup-new-process! citb-arm-c ((obj citb-arm-c)) (initialize-skeleton obj *citb-arm-c-sg* '()) - ((the-as (function citb-arm none) (find-parent-method citb-arm-c 21)) obj) + (call-parent-method obj) (set! (-> obj root-override root-prim local-sphere z) -266240.0) 0 (none) @@ -385,7 +385,7 @@ ;; INFO: Return type mismatch int vs none. (defmethod setup-new-process! citb-arm-d ((obj citb-arm-d)) (initialize-skeleton obj *citb-arm-d-sg* '()) - ((the-as (function citb-arm none) (find-parent-method citb-arm-d 21)) obj) + (call-parent-method obj) (set! (-> obj root-override root-prim local-sphere z) -307200.0) 0 (none) @@ -395,7 +395,7 @@ ;; INFO: Return type mismatch int vs none. (defmethod setup-new-process! citb-arm-shoulder-a ((obj citb-arm-shoulder-a)) (initialize-skeleton obj *citb-arm-shoulder-a-sg* '()) - ((the-as (function citb-arm none) (find-parent-method citb-arm-shoulder-a 21)) (the-as citb-arm obj)) + (call-parent-method obj) 0 (none) ) @@ -404,7 +404,7 @@ ;; INFO: Return type mismatch int vs none. (defmethod setup-new-process! citb-arm-shoulder-b ((obj citb-arm-shoulder-b)) (initialize-skeleton obj *citb-arm-shoulder-b-sg* '()) - ((the-as (function citb-arm none) (find-parent-method citb-arm-shoulder-b 21)) (the-as citb-arm obj)) + (call-parent-method obj) 0 (none) ) @@ -1883,7 +1883,7 @@ :virtual #t :code (behavior () (process-entity-status! self (entity-perm-status complete) #t) - (let ((t9-2 (-> (the-as (state battlecontroller) (find-parent-method citb-battlecontroller 26)) code))) + (let ((t9-2 (-> (find-parent-state) code))) (if t9-2 ((the-as (function none :behavior battlecontroller) t9-2)) ) @@ -1894,7 +1894,7 @@ ;; definition for method 27 of type citb-battlecontroller ;; INFO: Return type mismatch int vs none. (defmethod battlecontroller-method-27 citb-battlecontroller ((obj citb-battlecontroller)) - ((the-as (function battlecontroller none) (find-parent-method citb-battlecontroller 27)) obj) + (call-parent-method obj) (set! (-> obj activate-distance) 143360.0) 0 (none) diff --git a/test/decompiler/reference/jak1/levels/citadel/citadel-sages_REF.gc b/test/decompiler/reference/jak1/levels/citadel/citadel-sages_REF.gc index 1b03af2435..9dd133bf75 100644 --- a/test/decompiler/reference/jak1/levels/citadel/citadel-sages_REF.gc +++ b/test/decompiler/reference/jak1/levels/citadel/citadel-sages_REF.gc @@ -587,7 +587,7 @@ ) ) (set! (-> obj sound-name) "redsage-fires") - ((the-as (function citb-sage none) (find-parent-method red-sagecage 44)) obj) + (call-parent-method obj) (the-as symbol 0) ) @@ -723,7 +723,7 @@ ) ) (set! (-> obj sound-name) "bluesage-fires") - ((the-as (function citb-sage none) (find-parent-method blue-sagecage 44)) obj) + (call-parent-method obj) (the-as symbol 0) ) @@ -854,7 +854,7 @@ ) ) (set! (-> obj sound-name) "yellsage-fire") - ((the-as (function citb-sage none) (find-parent-method yellow-sagecage 44)) obj) + (call-parent-method obj) (the-as symbol 0) ) @@ -953,7 +953,7 @@ ) ) (set! (-> obj sound-name) "greensage-fires") - ((the-as (function citb-sage none) (find-parent-method green-sagecage 44)) obj) + (call-parent-method obj) (the-as symbol 0) ) diff --git a/test/decompiler/reference/jak1/levels/citadel/citb-plat_REF.gc b/test/decompiler/reference/jak1/levels/citadel/citb-plat_REF.gc index 05a8d3963a..4ff10c3a86 100644 --- a/test/decompiler/reference/jak1/levels/citadel/citb-plat_REF.gc +++ b/test/decompiler/reference/jak1/levels/citadel/citb-plat_REF.gc @@ -517,7 +517,7 @@ ;; definition for method 23 of type citb-chain-plat ;; INFO: Return type mismatch int vs none. (defmethod rigid-body-platform-method-23 citb-chain-plat ((obj citb-chain-plat) (arg0 float)) - ((the-as (function rigid-body-platform float none) (find-parent-method citb-chain-plat 23)) obj arg0) + (call-parent-method obj arg0) (rigid-body-platform-method-27 obj (-> obj orig-trans)) 0 (none) @@ -1206,7 +1206,7 @@ :trans (behavior () (let ((gp-0 (new 'stack-no-clear 'vector))) (set! (-> gp-0 quad) (-> self root-override trans quad)) - (let ((t9-1 (-> (the-as (state plat-button) (find-parent-method citb-exit-plat 23)) trans))) + (let ((t9-1 (-> (the-as (state plat-button) (find-parent-state)) trans))) (if t9-1 (t9-1) ) @@ -1223,7 +1223,7 @@ :trans (behavior () (let ((gp-0 (new 'stack-no-clear 'vector))) (set! (-> gp-0 quad) (-> self root-override trans quad)) - (let ((t9-1 (-> (the-as (state plat-button) (find-parent-method citb-exit-plat 24)) trans))) + (let ((t9-1 (-> (the-as (state plat-button) (find-parent-state)) trans))) (if t9-1 (t9-1) ) diff --git a/test/decompiler/reference/jak1/levels/common/battlecontroller_REF.gc b/test/decompiler/reference/jak1/levels/common/battlecontroller_REF.gc index 4d997d0f8c..d4cac37aea 100644 --- a/test/decompiler/reference/jak1/levels/common/battlecontroller_REF.gc +++ b/test/decompiler/reference/jak1/levels/common/battlecontroller_REF.gc @@ -664,7 +664,6 @@ battlecontroller-default-event-handler ) ;; definition for method 7 of type battlecontroller -;; INFO: Return type mismatch process-drawable vs battlecontroller. (defmethod relocate battlecontroller ((obj battlecontroller) (arg0 int)) (dotimes (v1-0 (-> obj spawner-count)) (let ((a0-3 (-> obj spawner-array v1-0))) @@ -676,10 +675,7 @@ battlecontroller-default-event-handler (if (nonzero? (-> obj path-spawn)) (&+! (-> obj path-spawn) arg0) ) - (the-as - battlecontroller - ((the-as (function process-drawable int process-drawable) (find-parent-method battlecontroller 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 10 of type battlecontroller @@ -691,7 +687,7 @@ battlecontroller-default-event-handler (battlecontroller-off) (set! pp gp-0) ) - ((the-as (function process-drawable none) (find-parent-method battlecontroller 10)) obj) + (call-parent-method obj) 0 (none) ) diff --git a/test/decompiler/reference/jak1/levels/jungle/fisher_REF.gc b/test/decompiler/reference/jak1/levels/jungle/fisher_REF.gc index 315cd277b5..eb4dfe3aee 100644 --- a/test/decompiler/reference/jak1/levels/jungle/fisher_REF.gc +++ b/test/decompiler/reference/jak1/levels/jungle/fisher_REF.gc @@ -1275,7 +1275,7 @@ (go (method-of-object obj play-anim)) ) (else - ((the-as (function fisher none) (find-parent-method fisher 38)) obj) + (call-parent-method obj) ) ) (none) @@ -1828,7 +1828,7 @@ (fisher-fish-water gp-0 (+ 32768.0 (vector-y-angle (-> self node-list data 80 bone transform vector 1)))) ) ) - (let ((t9-14 (-> (the-as state (find-parent-method fisher 24)) trans))) + (let ((t9-14 (-> (find-parent-state) trans))) (if t9-14 (t9-14) ) @@ -1840,7 +1840,7 @@ (defstate idle (fisher) :virtual #t :trans (behavior () - (let ((t9-1 (-> (the-as state (find-parent-method fisher 30)) trans))) + (let ((t9-1 (-> (find-parent-state) trans))) (if t9-1 (t9-1) ) diff --git a/test/decompiler/reference/jak1/levels/jungle/hopper_REF.gc b/test/decompiler/reference/jak1/levels/jungle/hopper_REF.gc index 2075562dec..0315d6f914 100644 --- a/test/decompiler/reference/jak1/levels/jungle/hopper_REF.gc +++ b/test/decompiler/reference/jak1/levels/jungle/hopper_REF.gc @@ -40,7 +40,7 @@ nav-enemy-default-event-handler (set! (-> v1-1 settings bot-plane w) (- (- (-> obj shadow-min-y) (-> obj collide-info trans y)))) ) 0 - ((the-as (function nav-enemy none) (find-parent-method hopper 39)) obj) + (call-parent-method obj) 0 (none) ) diff --git a/test/decompiler/reference/jak1/levels/jungle/jungle-elevator_REF.gc b/test/decompiler/reference/jak1/levels/jungle/jungle-elevator_REF.gc index 312e9976c5..64e8f018df 100644 --- a/test/decompiler/reference/jak1/levels/jungle/jungle-elevator_REF.gc +++ b/test/decompiler/reference/jak1/levels/jungle/jungle-elevator_REF.gc @@ -56,7 +56,7 @@ (gp-0 (new 'stack-no-clear 'vector)) ) (set! (-> s5-0 quad) (-> self root-override trans quad)) - (let ((t9-1 (-> (the-as (state plat-button) (find-parent-method jungle-elevator 23)) trans))) + (let ((t9-1 (-> (find-parent-state) trans))) (if t9-1 (t9-1) ) diff --git a/test/decompiler/reference/jak1/levels/jungle/jungle-obs_REF.gc b/test/decompiler/reference/jak1/levels/jungle/jungle-obs_REF.gc index 7fb59b2c26..402db2a8f5 100644 --- a/test/decompiler/reference/jak1/levels/jungle/jungle-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/jungle/jungle-obs_REF.gc @@ -1266,15 +1266,11 @@ ) ;; definition for method 7 of type jngpusher -;; INFO: Return type mismatch process-drawable vs jngpusher. (defmethod relocate jngpusher ((obj jngpusher) (arg0 int)) (if (nonzero? (-> obj back-prim)) (&+! (-> obj back-prim) arg0) ) - (the-as - jngpusher - ((the-as (function process-drawable int process-drawable) (find-parent-method jngpusher 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak1/levels/jungle/junglefish_REF.gc b/test/decompiler/reference/jak1/levels/jungle/junglefish_REF.gc index b209d05684..03edc78dcc 100644 --- a/test/decompiler/reference/jak1/levels/jungle/junglefish_REF.gc +++ b/test/decompiler/reference/jak1/levels/jungle/junglefish_REF.gc @@ -31,7 +31,7 @@ nav-enemy-default-event-handler ;; INFO: Return type mismatch int vs none. (defmethod common-post junglefish ((obj junglefish)) (water-control-method-10 (-> obj water)) - ((the-as (function nav-enemy none) (find-parent-method junglefish 39)) obj) + (call-parent-method obj) 0 (none) ) diff --git a/test/decompiler/reference/jak1/levels/jungleb/plant-boss_REF.gc b/test/decompiler/reference/jak1/levels/jungleb/plant-boss_REF.gc index c57153c7bf..e5f130e633 100644 --- a/test/decompiler/reference/jak1/levels/jungleb/plant-boss_REF.gc +++ b/test/decompiler/reference/jak1/levels/jungleb/plant-boss_REF.gc @@ -72,7 +72,6 @@ ) ;; definition for method 7 of type plant-boss -;; INFO: Return type mismatch process-drawable vs plant-boss. (defmethod relocate plant-boss ((obj plant-boss) (arg0 int)) (if (nonzero? (-> obj neck)) (&+! (-> obj neck) arg0) @@ -88,10 +87,7 @@ (&+! (-> obj death-prim v1-8) arg0) ) ) - (the-as - plant-boss - ((the-as (function process-drawable int process-drawable) (find-parent-method plant-boss 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition of type plant-boss-arm diff --git a/test/decompiler/reference/jak1/levels/lavatube/lavatube-obs_REF.gc b/test/decompiler/reference/jak1/levels/lavatube/lavatube-obs_REF.gc index 6ebac18490..c1990177dd 100644 --- a/test/decompiler/reference/jak1/levels/lavatube/lavatube-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/lavatube/lavatube-obs_REF.gc @@ -482,15 +482,11 @@ ) ;; definition for method 7 of type darkecobarrel -;; INFO: Return type mismatch darkecobarrel-base vs darkecobarrel. (defmethod relocate darkecobarrel ((obj darkecobarrel) (arg0 int)) (if (nonzero? (-> obj spawn-array)) (&+! (-> obj spawn-array) arg0) ) - (the-as - darkecobarrel - ((the-as (function darkecobarrel-base int darkecobarrel-base) (find-parent-method darkecobarrel 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak1/levels/maincave/baby-spider_REF.gc b/test/decompiler/reference/jak1/levels/maincave/baby-spider_REF.gc index fa03fcb357..3eb23145d0 100644 --- a/test/decompiler/reference/jak1/levels/maincave/baby-spider_REF.gc +++ b/test/decompiler/reference/jak1/levels/maincave/baby-spider_REF.gc @@ -272,7 +272,7 @@ baby-spider-default-event-handler (vector-z-quaternion! (new-stack-vector0) (-> obj collide-info quat)) (-> obj up-vector) ) - ((the-as (function nav-enemy none) (find-parent-method baby-spider 39)) obj) + (call-parent-method obj) (none) ) diff --git a/test/decompiler/reference/jak1/levels/maincave/driller-lurker_REF.gc b/test/decompiler/reference/jak1/levels/maincave/driller-lurker_REF.gc index cc6f867b7c..84fafe5067 100644 --- a/test/decompiler/reference/jak1/levels/maincave/driller-lurker_REF.gc +++ b/test/decompiler/reference/jak1/levels/maincave/driller-lurker_REF.gc @@ -984,7 +984,6 @@ ) ;; definition for method 7 of type driller-lurker -;; INFO: Return type mismatch process-drawable vs driller-lurker. (defmethod relocate driller-lurker ((obj driller-lurker) (arg0 int)) (if (nonzero? (-> obj neck)) (&+! (-> obj neck) arg0) @@ -995,10 +994,7 @@ (if (nonzero? (-> obj sound2)) (&+! (-> obj sound2) arg0) ) - (the-as - driller-lurker - ((the-as (function process-drawable int process-drawable) (find-parent-method driller-lurker 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 10 of type driller-lurker diff --git a/test/decompiler/reference/jak1/levels/maincave/gnawer_REF.gc b/test/decompiler/reference/jak1/levels/maincave/gnawer_REF.gc index 145ee8dab4..2ea7dfa483 100644 --- a/test/decompiler/reference/jak1/levels/maincave/gnawer_REF.gc +++ b/test/decompiler/reference/jak1/levels/maincave/gnawer_REF.gc @@ -1413,7 +1413,6 @@ ) ;; definition for method 7 of type gnawer -;; INFO: Return type mismatch nav-enemy vs gnawer. (defmethod relocate gnawer ((obj gnawer) (arg0 int)) (if (nonzero? (-> obj part2)) (&+! (-> obj part2) arg0) @@ -1421,10 +1420,7 @@ (if (nonzero? (-> obj sound2)) (&+! (-> obj sound2) arg0) ) - (the-as - gnawer - ((the-as (function nav-enemy int nav-enemy) (find-parent-method gnawer 7)) (the-as nav-enemy obj) arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type gnawer diff --git a/test/decompiler/reference/jak1/levels/misty/babak-with-cannon_REF.gc b/test/decompiler/reference/jak1/levels/misty/babak-with-cannon_REF.gc index 039c1bd2d0..fc314e2c60 100644 --- a/test/decompiler/reference/jak1/levels/misty/babak-with-cannon_REF.gc +++ b/test/decompiler/reference/jak1/levels/misty/babak-with-cannon_REF.gc @@ -324,7 +324,7 @@ nav-enemy-default-event-handler (if (and *target* (= (-> *target* current-level name) 'misty)) (spool-push *art-control* "mistycam-cannon" 0 self -1.0) ) - (let ((t9-3 (-> (the-as (state nav-enemy) (find-parent-method babak-with-cannon 23)) trans))) + (let ((t9-3 (-> (find-parent-state) trans))) (if t9-3 (t9-3) ) diff --git a/test/decompiler/reference/jak1/levels/misty/balloonlurker_REF.gc b/test/decompiler/reference/jak1/levels/misty/balloonlurker_REF.gc index c821711a7b..3ce0eeb149 100644 --- a/test/decompiler/reference/jak1/levels/misty/balloonlurker_REF.gc +++ b/test/decompiler/reference/jak1/levels/misty/balloonlurker_REF.gc @@ -894,7 +894,6 @@ ) ;; definition for method 7 of type balloonlurker -;; INFO: Return type mismatch process-drawable vs balloonlurker. (defmethod relocate balloonlurker ((obj balloonlurker) (arg0 int)) (if (nonzero? (-> obj propeller)) (&+! (-> obj propeller) arg0) @@ -908,10 +907,7 @@ (if (nonzero? (-> obj mine 1)) (&+! (-> obj mine 1) arg0) ) - (the-as - balloonlurker - ((the-as (function process-drawable int process-drawable) (find-parent-method balloonlurker 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak1/levels/misty/misty-conveyor_REF.gc b/test/decompiler/reference/jak1/levels/misty/misty-conveyor_REF.gc index 6d4d736b40..aa1b7d6c94 100644 --- a/test/decompiler/reference/jak1/levels/misty/misty-conveyor_REF.gc +++ b/test/decompiler/reference/jak1/levels/misty/misty-conveyor_REF.gc @@ -612,15 +612,11 @@ ) ;; definition for method 7 of type keg-conveyor -;; INFO: Return type mismatch process-drawable vs keg-conveyor. (defmethod relocate keg-conveyor ((obj keg-conveyor) (arg0 int)) (if (nonzero? (-> obj pivot)) (&+! (-> obj pivot) arg0) ) - (the-as - keg-conveyor - ((the-as (function process-drawable int process-drawable) (find-parent-method keg-conveyor 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type keg-conveyor diff --git a/test/decompiler/reference/jak1/levels/misty/misty-obs_REF.gc b/test/decompiler/reference/jak1/levels/misty/misty-obs_REF.gc index b4cd85f5c5..c04db92da9 100644 --- a/test/decompiler/reference/jak1/levels/misty/misty-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/misty/misty-obs_REF.gc @@ -1725,10 +1725,7 @@ ;; definition for method 23 of type bone-platform ;; INFO: Return type mismatch int vs none. (defmethod rigid-body-platform-method-23 bone-platform ((obj bone-platform) (arg0 float)) - ((the-as (function rigid-body-platform basic none) (find-parent-method bone-platform 23)) - obj - (the-as basic arg0) - ) + (call-parent-method obj arg0) (rigid-body-platform-method-27 obj (-> obj anchor-point)) 0 (none) @@ -1960,7 +1957,7 @@ ;; definition for method 27 of type misty-battlecontroller ;; INFO: Return type mismatch int vs none. (defmethod battlecontroller-method-27 misty-battlecontroller ((obj misty-battlecontroller)) - ((the-as (function battlecontroller none) (find-parent-method misty-battlecontroller 27)) obj) + (call-parent-method obj) (set! (-> obj misty-ambush-collision-hack) #t) 0 (none) diff --git a/test/decompiler/reference/jak1/levels/ogre/ogre-obs_REF.gc b/test/decompiler/reference/jak1/levels/ogre/ogre-obs_REF.gc index 5f0d60c5a4..9a1d3b1676 100644 --- a/test/decompiler/reference/jak1/levels/ogre/ogre-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/ogre/ogre-obs_REF.gc @@ -489,7 +489,7 @@ ;; definition for method 23 of type ogre-plat ;; INFO: Return type mismatch int vs none. (defmethod rigid-body-platform-method-23 ogre-plat ((obj ogre-plat) (arg0 float)) - ((the-as (function rigid-body-platform basic none) (find-parent-method ogre-plat 23)) obj (the-as basic arg0)) + (call-parent-method obj arg0) (rigid-body-platform-method-27 obj (-> obj anchor-point)) 0 (none) @@ -674,7 +674,7 @@ (set! (-> obj float-y-offset) 0.0) (+! (-> obj root-overlay trans y) (-> obj idle-y-offset)) (rigid-body-platform-method-29 obj *ogre-step-constants*) - ((the-as (function ogre-plat none) (find-parent-method ogre-step 31)) obj) + (call-parent-method obj) (let ((a0-5 (entity-actor-lookup (-> obj entity) 'alt-actor 0))) (if (and a0-5 (logtest? (-> a0-5 extra perm status) (entity-perm-status complete))) (set! (-> obj active) #t) @@ -768,7 +768,7 @@ (defmethod rigid-body-platform-method-31 ogre-step-a ((obj ogre-step-a)) (set-vector! (-> obj root-overlay root-prim local-sphere) 0.0 12288.0 0.0 20480.0) (initialize-skeleton obj *ogre-step-a-sg* '()) - ((the-as (function ogre-step none) (find-parent-method ogre-step-a 31)) obj) + (call-parent-method obj) 0 (none) ) @@ -778,7 +778,7 @@ (defmethod rigid-body-platform-method-31 ogre-step-b ((obj ogre-step-b)) (set-vector! (-> obj root-overlay root-prim local-sphere) 0.0 12288.0 0.0 20480.0) (initialize-skeleton obj *ogre-step-b-sg* '()) - ((the-as (function ogre-step none) (find-parent-method ogre-step-b 31)) obj) + (call-parent-method obj) 0 (none) ) @@ -788,7 +788,7 @@ (defmethod rigid-body-platform-method-31 ogre-step-c ((obj ogre-step-c)) (set-vector! (-> obj root-overlay root-prim local-sphere) 0.0 12288.0 0.0 26624.0) (initialize-skeleton obj *ogre-step-c-sg* '()) - ((the-as (function ogre-step none) (find-parent-method ogre-step-c 31)) obj) + (call-parent-method obj) 0 (none) ) @@ -798,7 +798,7 @@ (defmethod rigid-body-platform-method-31 ogre-step-d ((obj ogre-step-d)) (set-vector! (-> obj root-overlay root-prim local-sphere) 0.0 12288.0 0.0 20480.0) (initialize-skeleton obj *ogre-step-b-sg* '()) - ((the-as (function ogre-step none) (find-parent-method ogre-step-d 31)) obj) + (call-parent-method obj) 0 (none) ) @@ -854,7 +854,7 @@ (set! (-> obj idle-y-offset) -6144.0) (set! (-> obj float-y-offset) 4096.0) (rigid-body-platform-method-29 obj *ogre-isle-constants*) - ((the-as (function ogre-plat none) (find-parent-method ogre-isle 31)) obj) + (call-parent-method obj) (set! (-> obj active) #t) 0 (none) @@ -917,7 +917,7 @@ (+! (-> obj root-overlay trans x) -8192.0) (set-vector! (-> obj root-overlay root-prim local-sphere) 0.0 8192.0 0.0 24576.0) (initialize-skeleton obj *ogre-isle-b-sg* '()) - ((the-as (function ogre-isle none) (find-parent-method ogre-isle-b 31)) obj) + (call-parent-method obj) 0 (none) ) @@ -928,7 +928,7 @@ (+! (-> obj root-overlay trans x) -8192.0) (set-vector! (-> obj root-overlay root-prim local-sphere) 0.0 8192.0 0.0 24576.0) (initialize-skeleton obj *ogre-isle-b-sg* '()) - ((the-as (function ogre-isle none) (find-parent-method ogre-isle-c 31)) obj) + (call-parent-method obj) 0 (none) ) @@ -940,7 +940,7 @@ (+! (-> obj root-overlay trans z) -8192.0) (set-vector! (-> obj root-overlay root-prim local-sphere) 0.0 8192.0 0.0 22528.0) (initialize-skeleton obj *ogre-isle-d-sg* '()) - ((the-as (function ogre-isle none) (find-parent-method ogre-isle-d 31)) obj) + (call-parent-method obj) 0 (none) ) @@ -981,17 +981,13 @@ ) ;; definition for method 7 of type ogre-bridge -;; INFO: Return type mismatch process-drawable vs ogre-bridge. (defmethod relocate ogre-bridge ((obj ogre-bridge) (arg0 int)) (dotimes (v1-0 8) (if (nonzero? (-> obj joint-mod-array v1-0)) (&+! (-> obj joint-mod-array v1-0) arg0) ) ) - (the-as - ogre-bridge - ((the-as (function process-drawable int process-drawable) (find-parent-method ogre-bridge 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for function ogre-bridge-update-joints diff --git a/test/decompiler/reference/jak1/levels/ogre/ogreboss_REF.gc b/test/decompiler/reference/jak1/levels/ogre/ogreboss_REF.gc index 3f0e3989e6..82be211092 100644 --- a/test/decompiler/reference/jak1/levels/ogre/ogreboss_REF.gc +++ b/test/decompiler/reference/jak1/levels/ogre/ogreboss_REF.gc @@ -771,18 +771,11 @@ ) ;; definition for method 7 of type ogreboss-super-boulder -;; INFO: Return type mismatch process-drawable vs ogreboss-super-boulder. (defmethod relocate ogreboss-super-boulder ((obj ogreboss-super-boulder) (arg0 int)) (if (nonzero? (-> obj joint)) (&+! (-> obj joint) arg0) ) - (the-as - ogreboss-super-boulder - ((the-as (function process-drawable int process-drawable) (find-parent-method ogreboss-super-boulder 7)) - obj - arg0 - ) - ) + (call-parent-method obj arg0) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak1/levels/robocave/cave-trap_REF.gc b/test/decompiler/reference/jak1/levels/robocave/cave-trap_REF.gc index 211975a7be..092a612fb8 100644 --- a/test/decompiler/reference/jak1/levels/robocave/cave-trap_REF.gc +++ b/test/decompiler/reference/jak1/levels/robocave/cave-trap_REF.gc @@ -322,15 +322,11 @@ ) ;; definition for method 7 of type cave-trap -;; INFO: Return type mismatch process-drawable vs cave-trap. (defmethod relocate cave-trap ((obj cave-trap) (arg0 int)) (if (nonzero? (-> obj alt-actors)) (&+! (-> obj alt-actors) arg0) ) - (the-as - cave-trap - ((the-as (function process-drawable int process-drawable) (find-parent-method cave-trap 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type cave-trap diff --git a/test/decompiler/reference/jak1/levels/snow/ice-cube_REF.gc b/test/decompiler/reference/jak1/levels/snow/ice-cube_REF.gc index 4034190050..027df9a3f7 100644 --- a/test/decompiler/reference/jak1/levels/snow/ice-cube_REF.gc +++ b/test/decompiler/reference/jak1/levels/snow/ice-cube_REF.gc @@ -623,7 +623,6 @@ ) ;; definition for method 7 of type ice-cube -;; INFO: Return type mismatch nav-enemy vs ice-cube. (defmethod relocate ice-cube ((obj ice-cube) (arg0 int)) (if (nonzero? (-> obj part2)) (&+! (-> obj part2) arg0) @@ -634,7 +633,7 @@ (if (nonzero? (-> obj part4)) (&+! (-> obj part4) arg0) ) - (the-as ice-cube ((the-as (function nav-enemy int nav-enemy) (find-parent-method ice-cube 7)) obj arg0)) + (call-parent-method obj arg0) ) ;; definition for method 11 of type ice-cube diff --git a/test/decompiler/reference/jak1/levels/snow/snow-ball_REF.gc b/test/decompiler/reference/jak1/levels/snow/snow-ball_REF.gc index 141b08c0ac..1a06800f53 100644 --- a/test/decompiler/reference/jak1/levels/snow/snow-ball_REF.gc +++ b/test/decompiler/reference/jak1/levels/snow/snow-ball_REF.gc @@ -633,18 +633,13 @@ ) ;; definition for method 7 of type snow-ball -;; INFO: Return type mismatch process-drawable vs snow-ball. (defmethod relocate snow-ball ((obj snow-ball) (arg0 int)) (dotimes (v1-0 2) (if (nonzero? (-> obj path v1-0)) (&+! (-> obj path v1-0) arg0) ) ) - (the-as snow-ball ((the-as (function process-drawable int process-drawable) (find-parent-method snow-ball 7)) - (the-as process-drawable obj) - arg0 - ) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type snow-ball diff --git a/test/decompiler/reference/jak1/levels/snow/snow-bumper_REF.gc b/test/decompiler/reference/jak1/levels/snow/snow-bumper_REF.gc index c4b1e538c5..5b25d377e4 100644 --- a/test/decompiler/reference/jak1/levels/snow/snow-bumper_REF.gc +++ b/test/decompiler/reference/jak1/levels/snow/snow-bumper_REF.gc @@ -316,15 +316,11 @@ ) ;; definition for method 7 of type snow-bumper -;; INFO: Return type mismatch process-drawable vs snow-bumper. (defmethod relocate snow-bumper ((obj snow-bumper) (arg0 int)) (if (nonzero? (-> obj part2)) (&+! (-> obj part2) arg0) ) - (the-as - snow-bumper - ((the-as (function process-drawable int process-drawable) (find-parent-method snow-bumper 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type snow-bumper diff --git a/test/decompiler/reference/jak1/levels/snow/snow-obs_REF.gc b/test/decompiler/reference/jak1/levels/snow/snow-obs_REF.gc index 640f2ec078..8eb1473e78 100644 --- a/test/decompiler/reference/jak1/levels/snow/snow-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/snow/snow-obs_REF.gc @@ -1089,7 +1089,6 @@ ) ;; definition for method 7 of type snow-fort-gate -;; INFO: Return type mismatch process-drawable vs snow-fort-gate. (defmethod relocate snow-fort-gate ((obj snow-fort-gate) (arg0 int)) (if (nonzero? (-> obj part2)) (&+! (-> obj part2) arg0) @@ -1097,10 +1096,7 @@ (if (nonzero? (-> obj part3)) (&+! (-> obj part3) arg0) ) - (the-as - snow-fort-gate - ((the-as (function process-drawable int process-drawable) (find-parent-method snow-fort-gate 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type snow-fort-gate diff --git a/test/decompiler/reference/jak1/levels/snow/yeti_REF.gc b/test/decompiler/reference/jak1/levels/snow/yeti_REF.gc index 7b8c50be67..d1ed11388c 100644 --- a/test/decompiler/reference/jak1/levels/snow/yeti_REF.gc +++ b/test/decompiler/reference/jak1/levels/snow/yeti_REF.gc @@ -572,12 +572,11 @@ ) ;; definition for method 7 of type yeti-slave -;; INFO: Return type mismatch nav-enemy vs yeti-slave. (defmethod relocate yeti-slave ((obj yeti-slave) (arg0 int)) (if (nonzero? (-> obj part2)) (&+! (-> obj part2) arg0) ) - (the-as yeti-slave ((the-as (function nav-enemy int nav-enemy) (find-parent-method yeti-slave 7)) obj arg0)) + (call-parent-method obj arg0) ) ;; definition for function yeti-slave-init-by-other diff --git a/test/decompiler/reference/jak1/levels/sunken/bully_REF.gc b/test/decompiler/reference/jak1/levels/sunken/bully_REF.gc index 01bee5ac4a..2089098fe1 100644 --- a/test/decompiler/reference/jak1/levels/sunken/bully_REF.gc +++ b/test/decompiler/reference/jak1/levels/sunken/bully_REF.gc @@ -779,15 +779,11 @@ ) ;; definition for method 7 of type bully -;; INFO: Return type mismatch process-drawable vs bully. (defmethod relocate bully ((obj bully) (arg0 int)) (if (nonzero? (-> obj neck)) (&+! (-> obj neck) arg0) ) - (the-as - bully - ((the-as (function process-drawable int process-drawable) (find-parent-method bully 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type bully diff --git a/test/decompiler/reference/jak1/levels/sunken/helix-water_REF.gc b/test/decompiler/reference/jak1/levels/sunken/helix-water_REF.gc index c7e39abb5d..8766e4fb2c 100644 --- a/test/decompiler/reference/jak1/levels/sunken/helix-water_REF.gc +++ b/test/decompiler/reference/jak1/levels/sunken/helix-water_REF.gc @@ -715,15 +715,11 @@ ) ;; definition for method 7 of type helix-water -;; INFO: Return type mismatch process-drawable vs helix-water. (defmethod relocate helix-water ((obj helix-water) (arg0 int)) (if (nonzero? (-> obj alt-actors)) (&+! (-> obj alt-actors) arg0) ) - (the-as - helix-water - ((the-as (function process-drawable int process-drawable) (find-parent-method helix-water 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type helix-water diff --git a/test/decompiler/reference/jak1/levels/sunken/puffer_REF.gc b/test/decompiler/reference/jak1/levels/sunken/puffer_REF.gc index d8d845c7ea..650079bdf2 100644 --- a/test/decompiler/reference/jak1/levels/sunken/puffer_REF.gc +++ b/test/decompiler/reference/jak1/levels/sunken/puffer_REF.gc @@ -1124,15 +1124,11 @@ ) ;; definition for method 7 of type puffer -;; INFO: Return type mismatch process-drawable vs puffer. (defmethod relocate puffer ((obj puffer) (arg0 int)) (if (nonzero? (-> obj neck)) (&+! (-> obj neck) arg0) ) - (the-as - puffer - ((the-as (function process-drawable int process-drawable) (find-parent-method puffer 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type puffer diff --git a/test/decompiler/reference/jak1/levels/sunken/qbert-plat_REF.gc b/test/decompiler/reference/jak1/levels/sunken/qbert-plat_REF.gc index 01ac6e0054..83defc12b8 100644 --- a/test/decompiler/reference/jak1/levels/sunken/qbert-plat_REF.gc +++ b/test/decompiler/reference/jak1/levels/sunken/qbert-plat_REF.gc @@ -328,7 +328,7 @@ ;; definition for method 23 of type qbert-plat ;; INFO: Return type mismatch int vs none. (defmethod rigid-body-platform-method-23 qbert-plat ((obj qbert-plat) (arg0 float)) - ((the-as (function rigid-body-platform float none) (find-parent-method qbert-plat 23)) obj arg0) + (call-parent-method obj arg0) (rigid-body-platform-method-27 obj (-> obj anchor-point)) 0 (none) diff --git a/test/decompiler/reference/jak1/levels/sunken/square-platform_REF.gc b/test/decompiler/reference/jak1/levels/sunken/square-platform_REF.gc index efc555fe5d..261a3c700f 100644 --- a/test/decompiler/reference/jak1/levels/sunken/square-platform_REF.gc +++ b/test/decompiler/reference/jak1/levels/sunken/square-platform_REF.gc @@ -446,7 +446,6 @@ ) ;; definition for method 7 of type square-platform -;; INFO: Return type mismatch baseplat vs square-platform. (defmethod relocate square-platform ((obj square-platform) (arg0 int)) (if (nonzero? (-> obj part2)) (&+! (-> obj part2) arg0) @@ -457,10 +456,7 @@ (if (nonzero? (-> obj part4)) (&+! (-> obj part4) arg0) ) - (the-as - square-platform - ((the-as (function baseplat int baseplat) (find-parent-method square-platform 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type square-platform diff --git a/test/decompiler/reference/jak1/levels/sunken/steam-cap_REF.gc b/test/decompiler/reference/jak1/levels/sunken/steam-cap_REF.gc index cc8acc26e6..0d6fb198d7 100644 --- a/test/decompiler/reference/jak1/levels/sunken/steam-cap_REF.gc +++ b/test/decompiler/reference/jak1/levels/sunken/steam-cap_REF.gc @@ -690,7 +690,6 @@ ) ;; definition for method 7 of type steam-cap -;; INFO: Return type mismatch process-drawable vs steam-cap. (defmethod relocate steam-cap ((obj steam-cap) (arg0 int)) (if (nonzero? (-> obj part2)) (&+! (-> obj part2) arg0) @@ -698,10 +697,7 @@ (if (nonzero? (-> obj part3)) (&+! (-> obj part3) arg0) ) - (the-as - steam-cap - ((the-as (function process-drawable int process-drawable) (find-parent-method steam-cap 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 10 of type steam-cap diff --git a/test/decompiler/reference/jak1/levels/sunken/sunken-pipegame_REF.gc b/test/decompiler/reference/jak1/levels/sunken/sunken-pipegame_REF.gc index c6d6c81b3f..bd3b50da50 100644 --- a/test/decompiler/reference/jak1/levels/sunken/sunken-pipegame_REF.gc +++ b/test/decompiler/reference/jak1/levels/sunken/sunken-pipegame_REF.gc @@ -972,7 +972,6 @@ ) ;; definition for method 7 of type sunken-pipegame -;; INFO: Return type mismatch process-drawable vs sunken-pipegame. (defmethod relocate sunken-pipegame ((obj sunken-pipegame) (arg0 int)) (dotimes (v1-0 3) (let ((a0-4 (-> obj prize v1-0))) @@ -988,10 +987,7 @@ ) ) ) - (the-as - sunken-pipegame - ((the-as (function process-drawable int process-drawable) (find-parent-method sunken-pipegame 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition for method 11 of type sunken-pipegame diff --git a/test/decompiler/reference/jak1/levels/swamp/billy_REF.gc b/test/decompiler/reference/jak1/levels/swamp/billy_REF.gc index 380f325240..1001b252c3 100644 --- a/test/decompiler/reference/jak1/levels/swamp/billy_REF.gc +++ b/test/decompiler/reference/jak1/levels/swamp/billy_REF.gc @@ -52,17 +52,13 @@ ) ;; definition for method 7 of type billy -;; INFO: Return type mismatch process-drawable vs billy. (defmethod relocate billy ((obj billy) (arg0 int)) (countdown (v1-0 3) (if (nonzero? (-> obj path-data v1-0)) (&+! (-> obj path-data v1-0) arg0) ) ) - (the-as - billy - ((the-as (function process-drawable int process-drawable) (find-parent-method billy 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition of type billy-snack @@ -257,7 +253,7 @@ (defstate nav-enemy-victory (billy-rat) :virtual #t :enter (behavior () - (let ((t9-1 (-> (the-as (state nav-enemy) (find-parent-method billy-rat 33)) enter))) + (let ((t9-1 (-> (find-parent-state) enter))) (if t9-1 (t9-1) ) @@ -499,7 +495,7 @@ (go (method-of-object obj play-anim)) ) (else - ((the-as (function nav-enemy none) (find-parent-method billy 38)) (the-as nav-enemy obj)) + (call-parent-method obj) ) ) (none) diff --git a/test/decompiler/reference/jak1/levels/swamp/kermit_REF.gc b/test/decompiler/reference/jak1/levels/swamp/kermit_REF.gc index 21879b9bbe..cbed4f6907 100644 --- a/test/decompiler/reference/jak1/levels/swamp/kermit_REF.gc +++ b/test/decompiler/reference/jak1/levels/swamp/kermit_REF.gc @@ -926,7 +926,7 @@ nav-enemy-default-event-handler ;; definition for method 39 of type kermit ;; INFO: Return type mismatch int vs none. (defmethod common-post kermit ((obj kermit)) - ((the-as (function nav-enemy none) (find-parent-method kermit 39)) obj) + (call-parent-method obj) (when (-> obj charged-up) ) 0 diff --git a/test/decompiler/reference/jak1/levels/swamp/swamp-bat_REF.gc b/test/decompiler/reference/jak1/levels/swamp/swamp-bat_REF.gc index b7635a3c22..4f0a36c09a 100644 --- a/test/decompiler/reference/jak1/levels/swamp/swamp-bat_REF.gc +++ b/test/decompiler/reference/jak1/levels/swamp/swamp-bat_REF.gc @@ -74,17 +74,13 @@ ) ;; definition for method 7 of type swamp-bat -;; INFO: Return type mismatch process-drawable vs swamp-bat. (defmethod relocate swamp-bat ((obj swamp-bat) (arg0 int)) (dotimes (v1-0 2) (if (nonzero? (-> obj path-list v1-0)) (&+! (-> obj path-list v1-0) arg0) ) ) - (the-as - swamp-bat - ((the-as (function process-drawable int process-drawable) (find-parent-method swamp-bat 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; definition of type swamp-bat-slave diff --git a/test/decompiler/reference/jak1/levels/swamp/swamp-obs_REF.gc b/test/decompiler/reference/jak1/levels/swamp/swamp-obs_REF.gc index aba5efaeac..025d65cf67 100644 --- a/test/decompiler/reference/jak1/levels/swamp/swamp-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/swamp/swamp-obs_REF.gc @@ -821,7 +821,7 @@ ;; definition for method 23 of type tar-plat ;; INFO: Return type mismatch int vs none. (defmethod rigid-body-platform-method-23 tar-plat ((obj tar-plat) (arg0 float)) - ((the-as (function rigid-body-platform basic none) (find-parent-method tar-plat 23)) obj (the-as basic arg0)) + (call-parent-method obj arg0) (rigid-body-platform-method-27 obj (-> obj anchor-point)) 0 (none) diff --git a/test/decompiler/reference/jak1/levels/swamp/swamp-rat_REF.gc b/test/decompiler/reference/jak1/levels/swamp/swamp-rat_REF.gc index 6495591d99..67009347f2 100644 --- a/test/decompiler/reference/jak1/levels/swamp/swamp-rat_REF.gc +++ b/test/decompiler/reference/jak1/levels/swamp/swamp-rat_REF.gc @@ -100,7 +100,7 @@ swamp-rat-default-event-handler (vector-z-quaternion! (new-stack-vector0) (-> obj collide-info quat)) (-> obj up-vector) ) - ((the-as (function nav-enemy none) (find-parent-method swamp-rat 39)) obj) + (call-parent-method obj) (none) ) diff --git a/test/decompiler/reference/jak1/levels/training/training-obs_REF.gc b/test/decompiler/reference/jak1/levels/training/training-obs_REF.gc index 741c180ab7..81be752db0 100644 --- a/test/decompiler/reference/jak1/levels/training/training-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/training/training-obs_REF.gc @@ -279,7 +279,7 @@ ;; definition for method 23 of type tra-pontoon ;; INFO: Return type mismatch int vs none. (defmethod rigid-body-platform-method-23 tra-pontoon ((obj tra-pontoon) (arg0 float)) - ((the-as (function rigid-body-platform float none) (find-parent-method tra-pontoon 23)) obj arg0) + (call-parent-method obj arg0) (rigid-body-platform-method-27 obj (-> obj anchor-point)) 0 (none) diff --git a/test/decompiler/reference/jak1/levels/village1/fishermans-boat_REF.gc b/test/decompiler/reference/jak1/levels/village1/fishermans-boat_REF.gc index 4222e538e6..129b76f85e 100644 --- a/test/decompiler/reference/jak1/levels/village1/fishermans-boat_REF.gc +++ b/test/decompiler/reference/jak1/levels/village1/fishermans-boat_REF.gc @@ -1347,19 +1347,12 @@ ) ;; definition for method 7 of type fishermans-boat -;; INFO: Return type mismatch rigid-body-platform vs fishermans-boat. (defmethod relocate fishermans-boat ((obj fishermans-boat) (arg0 int)) (relocate (-> obj controller) arg0) (if (nonzero? (-> obj propeller)) (&+! (-> obj propeller) arg0) ) - (the-as - fishermans-boat - ((the-as (function rigid-body-platform int rigid-body-platform) (find-parent-method fishermans-boat 7)) - obj - arg0 - ) - ) + (call-parent-method obj arg0) ) ;; definition for method 30 of type fishermans-boat diff --git a/test/decompiler/reference/jak1/levels/village1/village-obs_REF.gc b/test/decompiler/reference/jak1/levels/village1/village-obs_REF.gc index a0845faefc..dde3a13f90 100644 --- a/test/decompiler/reference/jak1/levels/village1/village-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/village1/village-obs_REF.gc @@ -1060,15 +1060,11 @@ ) ;; definition for method 7 of type hutlamp -;; INFO: Return type mismatch process-drawable vs hutlamp. (defmethod relocate hutlamp ((obj hutlamp) (arg0 int)) (if (nonzero? (-> obj pivot)) (&+! (-> obj pivot) arg0) ) - (the-as - hutlamp - ((the-as (function process-drawable int process-drawable) (find-parent-method hutlamp 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak1/levels/village2/sunken-elevator_REF.gc b/test/decompiler/reference/jak1/levels/village2/sunken-elevator_REF.gc index b243d0d1ca..f5199aa967 100644 --- a/test/decompiler/reference/jak1/levels/village2/sunken-elevator_REF.gc +++ b/test/decompiler/reference/jak1/levels/village2/sunken-elevator_REF.gc @@ -158,7 +158,7 @@ ) (set! *teleport* #t) (set! (-> s5-0 quad) (-> self root-override trans quad)) - (let ((t9-1 (-> (the-as (state sunken-elevator) (find-parent-method sunken-elevator 23)) trans))) + (let ((t9-1 (-> (find-parent-state) trans))) (if t9-1 (t9-1) ) diff --git a/test/decompiler/reference/jak1/levels/village2/swamp-blimp_REF.gc b/test/decompiler/reference/jak1/levels/village2/swamp-blimp_REF.gc index 044404571f..f14809e404 100644 --- a/test/decompiler/reference/jak1/levels/village2/swamp-blimp_REF.gc +++ b/test/decompiler/reference/jak1/levels/village2/swamp-blimp_REF.gc @@ -747,7 +747,6 @@ ) ;; definition for method 7 of type swamp-blimp -;; INFO: Return type mismatch process-drawable vs swamp-blimp. (defmethod relocate swamp-blimp ((obj swamp-blimp) (arg0 int)) (if (nonzero? (-> obj gondola)) (&+! (-> obj gondola) arg0) @@ -755,10 +754,7 @@ (if (nonzero? (-> obj bag)) (&+! (-> obj bag) arg0) ) - (the-as - swamp-blimp - ((the-as (function process-drawable int process-drawable) (find-parent-method swamp-blimp 7)) obj arg0) - ) + (call-parent-method obj arg0) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak1/levels/village2/village2-obs_REF.gc b/test/decompiler/reference/jak1/levels/village2/village2-obs_REF.gc index be29b4b68d..d94a6d9141 100644 --- a/test/decompiler/reference/jak1/levels/village2/village2-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/village2/village2-obs_REF.gc @@ -210,7 +210,7 @@ ;; definition for method 23 of type pontoon ;; INFO: Return type mismatch int vs none. (defmethod rigid-body-platform-method-23 pontoon ((obj pontoon) (arg0 float)) - ((the-as (function rigid-body-platform basic none) (find-parent-method pontoon 23)) obj (the-as basic arg0)) + (call-parent-method obj arg0) (rigid-body-platform-method-27 obj (-> obj anchor-point)) 0 (none) diff --git a/test/decompiler/reference/jak1/levels/village_common/villagep-obs_REF.gc b/test/decompiler/reference/jak1/levels/village_common/villagep-obs_REF.gc index e67da98b04..fec73f10cd 100644 --- a/test/decompiler/reference/jak1/levels/village_common/villagep-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/village_common/villagep-obs_REF.gc @@ -629,7 +629,6 @@ ) ;; definition for method 31 of type warp-gate-switch -;; INFO: Return type mismatch none vs int. (defmethod press! warp-gate-switch ((obj warp-gate-switch) (arg0 symbol)) (with-pp (when arg0 @@ -664,11 +663,7 @@ ) ) ) - (the-as int ((the-as (function basebutton symbol none) (find-parent-method warp-gate-switch 31)) - (the-as basebutton arg0) - arg0 - ) - ) + (call-parent-method (the-as warp-gate-switch arg0) arg0) ) ) @@ -888,7 +883,7 @@ ) ) ) - (let ((t9-10 (-> (the-as (state basebutton) (find-parent-method warp-gate-switch 21)) code))) + (let ((t9-10 (-> (the-as (state basebutton) (find-parent-state)) code))) (if t9-10 ((the-as (function none :behavior basebutton) t9-10)) )