diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index af1e8859c6..43e570a6df 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -2922,16 +2922,51 @@ void DerefElement::inline_nested() { /////////////////// void UntilElement::push_to_stack(const Env& env, FormPool& pool, FormStack& stack) { + // in asm: + // LTOP: + // body + // condition + // jump to top + // so we can end up getting the body/condition wrong. + // the way the CfgPass works means that we put too much in condition. + // we can safely move stuff from the top of condition to the bottom of body. + mark_popped(); - for (auto form : {condition, body}) { - FormStack temp_stack(false); - for (auto& entry : form->elts()) { - entry->push_to_stack(env, pool, temp_stack); + + std::vector condition_to_body; + { + FormStack condition_temp_stack(false); + for (auto& entry : condition->elts()) { + entry->push_to_stack(env, pool, condition_temp_stack); } - auto new_entries = temp_stack.rewrite(pool, env); - form->clear(); + condition_to_body = condition_temp_stack.rewrite(pool, env); + condition->clear(); + assert(!condition_to_body.empty()); + condition->push_back(condition_to_body.back()); + condition_to_body.pop_back(); + } + + { + FormStack body_temp_stack(false); + for (auto& entry : body->elts()) { + entry->push_to_stack(env, pool, body_temp_stack); + } + auto new_entries = body_temp_stack.rewrite(pool, env); + body->clear(); + for (auto e : new_entries) { - form->push_back(e); + if (!dynamic_cast(e)) { + body->push_back(e); + } + } + for (auto e : condition_to_body) { + if (!dynamic_cast(e)) { + body->push_back(e); + } + } + + if (body->size() == 0) { + body->push_back(pool.alloc_element()); } } diff --git a/goal_src/kernel/gcommon.gc b/goal_src/kernel/gcommon.gc index 0857e2f890..625175501d 100644 --- a/goal_src/kernel/gcommon.gc +++ b/goal_src/kernel/gcommon.gc @@ -318,13 +318,11 @@ (let ((obj-type (-> obj type)) (end-type object) ) - (until (begin - (set! obj-type (-> obj-type parent)) - (= obj-type end-type) - ) + (until (= obj-type end-type) (if (= obj-type parent-type) (return #t) ) + (set! obj-type (-> obj-type parent)) ) ) #f @@ -335,13 +333,11 @@ It is safe to use this on a type that is not fully set up, but in this case it will return #f." (let ((end-type object)) - (until (begin - (set! child-type (-> child-type parent)) - (or (= child-type end-type) (zero? child-type)) - ) + (until (or (= child-type end-type) (zero? child-type)) (if (= child-type parent-type) (return #t) ) + (set! child-type (-> child-type parent)) ) ) #f diff --git a/goal_src/kernel/gstring.gc b/goal_src/kernel/gstring.gc index 201146878a..1830116e78 100644 --- a/goal_src/kernel/gstring.gc +++ b/goal_src/kernel/gstring.gc @@ -383,35 +383,21 @@ ) (defun string-cat-to-last-char ((base-str string) (append-str string) (char uint)) - "Append append-str to the end of of base-str, up to the last occurance of char in append-str" - (local-vars - (location-of-char (pointer uint8)) - (end-of-append (pointer uint8)) - ) - - ;; point to one before the beginning of the append string (kind of a hack) - (set! end-of-append (&-> (the-as (pointer uint8) append-str) 3)) - ;; try to find char in append-str - (set! location-of-char (string-skip-to-char (-> append-str data) char)) - (when (= (-> location-of-char 0) char) - ;; found it! - (until - (begin - ;; update the location of the last find - (set! end-of-append location-of-char) - ;; try to find another - (set! location-of-char (string-skip-to-char (&-> location-of-char 1) char)) - ;; did we succeed? - (!= (-> location-of-char 0) char) - ) - (none) + "Append append-str to the end of base-str, up to the last occurance of char in append-str" + (let ((end-of-append (&-> (the-as (pointer uint8) append-str) 3))) + (let ((location-of-char (string-skip-to-char (-> append-str data) char))) + (when (= (-> location-of-char 0) char) + (until (!= (-> location-of-char 0) char) + (set! end-of-append location-of-char) + (set! location-of-char (string-skip-to-char (&-> location-of-char 1) char)) + ) + ) ) + (cat-string<-string_to_charp base-str append-str end-of-append) ) - ;; now location-of-char points to the last occurance. - ;; or to 1 before the start of append-str if we never found it. - (cat-string<-string_to_charp base-str append-str end-of-append) ) + (defmacro is-whitespace-char? (c) ;; 32 = space ;; 9 = \t diff --git a/goal_src/levels/common/nav-enemy.gc b/goal_src/levels/common/nav-enemy.gc index a1d201c61a..319be8837d 100644 --- a/goal_src/levels/common/nav-enemy.gc +++ b/goal_src/levels/common/nav-enemy.gc @@ -946,22 +946,7 @@ nav-enemy-default-event-handler (-> self collide-info status) (logand -8 (-> self collide-info status)) ) - (until (begin - (suspend) - (let ((a0-13 (-> self skel root-channel 0))) - (set! - (-> a0-13 param 0) - (the float (+ (-> a0-13 frame-group data 0 length) -1)) - ) - (set! (-> a0-13 param 1) arg2) - (joint-control-channel-group-eval! - a0-13 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) + (until (ja-done? 0) (cond ((nonzero? (-> self align)) (when (not s4-1) @@ -995,6 +980,19 @@ nav-enemy-default-event-handler ) ) ) + (suspend) + (let ((a0-13 (-> self skel root-channel 0))) + (set! + (-> a0-13 param 0) + (the float (+ (-> a0-13 frame-group data 0 length) -1)) + ) + (set! (-> a0-13 param 1) arg2) + (joint-control-channel-group-eval! + a0-13 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) ) @@ -1334,23 +1332,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-2 (-> self skel root-channel 0))) - (set! - (-> a0-2 param 0) - (the float (+ (-> a0-2 frame-group data 0 length) -1)) - ) - (set! (-> a0-2 param 1) f30-0) - (joint-control-channel-group-eval! - a0-2 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-2 (-> self skel root-channel 0))) + (set! + (-> a0-2 param 0) + (the float (+ (-> a0-2 frame-group data 0 length) -1)) + ) + (set! (-> a0-2 param 1) f30-0) + (joint-control-channel-group-eval! + a0-2 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) (when (nav-enemy-rnd-go-idle? 0.2) (let ((a0-5 (-> self skel root-channel 0))) @@ -1400,28 +1395,23 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (ja-blend-eval) - (suspend) - (let ((a0-9 (-> self skel root-channel 0))) - (set! - (-> a0-9 param 0) - (the float (+ (-> a0-9 frame-group data 0 length) -1)) - ) - (set! (-> a0-9 param 1) f30-0) - (joint-control-channel-group-eval! - a0-9 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (ja-blend-eval) + (suspend) + (let ((a0-9 (-> self skel root-channel 0))) + (set! + (-> a0-9 param 0) + (the float (+ (-> a0-9 frame-group data 0 length) -1)) + ) + (set! (-> a0-9 param 1) f30-0) + (joint-control-channel-group-eval! + a0-9 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) - (until (begin - (not (nav-enemy-rnd-go-idle? 0.2)) - ) + (until (not (nav-enemy-rnd-go-idle? 0.2)) (let ((a0-11 (-> self skel root-channel 0))) (set! (-> a0-11 frame-group) @@ -1459,23 +1449,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-12 (-> self skel root-channel 0))) - (set! - (-> a0-12 param 0) - (the float (+ (-> a0-12 frame-group data 0 length) -1)) - ) - (set! (-> a0-12 param 1) f30-0) - (joint-control-channel-group-eval! - a0-12 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-12 (-> self skel root-channel 0))) + (set! + (-> a0-12 param 0) + (the float (+ (-> a0-12 frame-group data 0 length) -1)) + ) + (set! (-> a0-12 param 1) f30-0) + (joint-control-channel-group-eval! + a0-12 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (logior! (-> self nav-enemy-flags) 8) @@ -1525,24 +1512,21 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (ja-blend-eval) - (suspend) - (let ((a0-18 (-> self skel root-channel 0))) - (set! - (-> a0-18 param 0) - (the float (+ (-> a0-18 frame-group data 0 length) -1)) - ) - (set! (-> a0-18 param 1) f30-0) - (joint-control-channel-group-eval! - a0-18 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (ja-blend-eval) + (suspend) + (let ((a0-18 (-> self skel root-channel 0))) + (set! + (-> a0-18 param 0) + (the float (+ (-> a0-18 frame-group data 0 length) -1)) + ) + (set! (-> a0-18 param 1) f30-0) + (joint-control-channel-group-eval! + a0-18 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) ) @@ -1620,29 +1604,26 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (seek-toward-heading-vec! - (-> self collide-info) - (-> self nav travel) - (-> self rotate-speed) - (the-as int (-> self turn-time)) - ) - (suspend) - (let ((a0-4 (-> self skel root-channel 0))) - (set! - (-> a0-4 param 0) - (the float (+ (-> a0-4 frame-group data 0 length) -1)) - ) - (set! (-> a0-4 param 1) f30-0) - (joint-control-channel-group-eval! - a0-4 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (seek-toward-heading-vec! + (-> self collide-info) + (-> self nav travel) + (-> self rotate-speed) + (the-as int (-> self turn-time)) + ) + (suspend) + (let ((a0-4 (-> self skel root-channel 0))) + (set! + (-> a0-4 param 0) + (the float (+ (-> a0-4 frame-group data 0 length) -1)) + ) + (set! (-> a0-4 param 1) f30-0) + (joint-control-channel-group-eval! + a0-4 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (go-virtual nav-enemy-chase) @@ -1752,23 +1733,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! - (-> a0-3 param 0) - (the float (+ (-> a0-3 frame-group data 0 length) -1)) - ) - (set! (-> a0-3 param 1) f30-0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! + (-> a0-3 param 0) + (the float (+ (-> a0-3 frame-group data 0 length) -1)) + ) + (set! (-> a0-3 param 1) f30-0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) (ja-channel-push! 1 60) (while #t @@ -1809,23 +1787,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-7 (-> self skel root-channel 0))) - (set! - (-> a0-7 param 0) - (the float (+ (-> a0-7 frame-group data 0 length) -1)) - ) - (set! (-> a0-7 param 1) f30-0) - (joint-control-channel-group-eval! - a0-7 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-7 (-> self skel root-channel 0))) + (set! + (-> a0-7 param 0) + (the float (+ (-> a0-7 frame-group data 0 length) -1)) + ) + (set! (-> a0-7 param 1) f30-0) + (joint-control-channel-group-eval! + a0-7 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) ) @@ -2354,23 +2329,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! - (-> a0-3 param 0) - (the float (+ (-> a0-3 frame-group data 0 length) -1)) - ) - (set! (-> a0-3 param 1) f30-0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! + (-> a0-3 param 0) + (the float (+ (-> a0-3 frame-group data 0 length) -1)) + ) + (set! (-> a0-3 param 1) f30-0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (go-virtual nav-enemy-stare) @@ -2625,21 +2597,18 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (ja-blend-eval) - (suspend) - (let ((s3-1 (-> self skel root-channel 0))) - (set! (-> s3-1 param 0) (ja-aframe arg1 0)) - (set! (-> s3-1 param 1) arg2) - (joint-control-channel-group-eval! - s3-1 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (ja-blend-eval) + (suspend) + (let ((s3-1 (-> self skel root-channel 0))) + (set! (-> s3-1 param 0) (ja-aframe arg1 0)) + (set! (-> s3-1 param 1) arg2) + (joint-control-channel-group-eval! + s3-1 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (set! (-> self collide-info status) (logand -8 (-> self collide-info status))) @@ -2793,24 +2762,21 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (ja-blend-eval) - (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! - (-> a0-3 param 0) - (the float (+ (-> a0-3 frame-group data 0 length) -1)) - ) - (set! (-> a0-3 param 1) 1.0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (ja-blend-eval) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! + (-> a0-3 param 0) + (the float (+ (-> a0-3 frame-group data 0 length) -1)) + ) + (set! (-> a0-3 param 1) 1.0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) 0 (none) @@ -3094,19 +3060,16 @@ nav-enemy-default-event-handler (let ((gp-0 (nav-enemy-rnd-int-range 0 150)) (s5-0 (-> *display* base-frame-counter)) ) - (until (begin - (let ((a0-12 (-> self skel root-channel 0))) - (set! (-> a0-12 param 0) f30-0) - (joint-control-channel-group-eval! - a0-12 - (the-as art-joint-anim #f) - num-func-loop! - ) - ) - (suspend) - (>= (the-as int (- (-> *display* base-frame-counter) s5-0)) gp-0) - ) - (empty) + (until (>= (the-as int (- (-> *display* base-frame-counter) s5-0)) gp-0) + (let ((a0-12 (-> self skel root-channel 0))) + (set! (-> a0-12 param 0) f30-0) + (joint-control-channel-group-eval! + a0-12 + (the-as art-joint-anim #f) + num-func-loop! + ) + ) + (suspend) ) ) ) diff --git a/goal_src/levels/misty/misty-teetertotter.gc b/goal_src/levels/misty/misty-teetertotter.gc index 1982219350..14715881f0 100644 --- a/goal_src/levels/misty/misty-teetertotter.gc +++ b/goal_src/levels/misty/misty-teetertotter.gc @@ -186,7 +186,6 @@ ) :code (behavior () - (local-vars (v1-16 symbol) (f0-4 float)) (set! (-> self launched-player) #f) (let ((a0-0 (-> self skel root-channel 0))) (set! @@ -216,26 +215,26 @@ num-func-seek! ) ) - (until (begin - (set! (-> self rock-is-dangerous) (and v1-16 (>= 76.0 f0-4))) - (suspend) - (let ((a0-2 (-> self skel root-channel 0))) - (set! - (-> a0-2 param 0) - (the float (+ (-> a0-2 frame-group data 0 length) -1)) - ) - (set! (-> a0-2 param 1) 1.0) - (joint-control-channel-group-eval! - a0-2 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (set! f0-4 (ja-aframe-num 0)) - (set! (-> self in-launch-window) (and (>= f0-4 76.0) (>= 82.0 f0-4))) - (set! v1-16 (>= f0-4 12.0)) + (until (ja-done? 0) + (let ((f0-4 (ja-aframe-num 0))) + (set! (-> self in-launch-window) (and (>= f0-4 76.0) (>= 82.0 f0-4))) + (let ((v1-16 (>= f0-4 12.0))) + (set! (-> self rock-is-dangerous) (and v1-16 (>= 76.0 f0-4))) + ) + ) + (suspend) + (let ((a0-2 (-> self skel root-channel 0))) + (set! + (-> a0-2 param 0) + (the float (+ (-> a0-2 frame-group data 0 length) -1)) + ) + (set! (-> a0-2 param 1) 1.0) + (joint-control-channel-group-eval! + a0-2 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) (go teetertotter-idle) (none) @@ -276,23 +275,20 @@ num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-1 (-> self skel root-channel 0))) - (set! - (-> a0-1 param 0) - (the float (+ (-> a0-1 frame-group data 0 length) -1)) - ) - (set! (-> a0-1 param 1) 1.0) - (joint-control-channel-group-eval! - a0-1 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-1 (-> self skel root-channel 0))) + (set! + (-> a0-1 param 0) + (the float (+ (-> a0-1 frame-group data 0 length) -1)) + ) + (set! (-> a0-1 param 1) 1.0) + (joint-control-channel-group-eval! + a0-1 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) (go teetertotter-idle) (none) diff --git a/goal_src/levels/misty/misty-warehouse.gc b/goal_src/levels/misty/misty-warehouse.gc index 7e58377fd8..7bd725c2cc 100644 --- a/goal_src/levels/misty/misty-warehouse.gc +++ b/goal_src/levels/misty/misty-warehouse.gc @@ -104,17 +104,12 @@ ) (camera-change-to "camera-160" 150 #f) (let ((gp-0 (-> *display* base-frame-counter))) - (until (begin - (suspend) - (>= - (the-as - int - (- (-> *display* base-frame-counter) gp-0) - ) - 900 - ) - ) - (empty) + (until + (>= + (the-as int (- (-> *display* base-frame-counter) gp-0)) + 900 + ) + (suspend) ) ) (while @@ -151,11 +146,8 @@ ) (set! (-> self state-time) (-> *display* base-frame-counter)) (let ((gp-1 (-> *display* base-frame-counter))) - (until (begin - (suspend) - (>= (the-as int (- (-> *display* base-frame-counter) gp-1)) 300) - ) - (empty) + (until (>= (the-as int (- (-> *display* base-frame-counter) gp-1)) 300) + (suspend) ) ) (sound-play-by-name @@ -195,22 +187,19 @@ num-func-seek! ) ) - (until (begin - (rider-trans) - (rider-post) - (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! (-> a0-3 param 0) (-> self anim-limit)) - (set! (-> a0-3 param 1) 1.0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (rider-trans) + (rider-post) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! (-> a0-3 param 0) (-> self anim-limit)) + (set! (-> a0-3 param 1) 1.0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (let ((gp-1 (-> self skel root-channel 0))) diff --git a/test/decompiler/reference/engine/load/loader_REF.gc b/test/decompiler/reference/engine/load/loader_REF.gc index 320375eb6d..ae2723349f 100644 --- a/test/decompiler/reference/engine/load/loader_REF.gc +++ b/test/decompiler/reference/engine/load/loader_REF.gc @@ -1081,6 +1081,7 @@ (arg3 (function process-drawable symbol)) ) (local-vars + (v0-39 int) (spool-part int) (sv-24 float) (old-skel-status uint) @@ -1286,75 +1287,7 @@ ) (set! sv-72 (current-str-pos spool-sound)) (set! sv-40 (the-as int (-> *display* base-frame-counter))) - (until (begin - (let* ((a0-55 *art-control*) - (t9-32 (method-of-object a0-55 spool-push)) - (a1-24 (-> arg0 name)) - (a2-17 spool-part) - (t0-6 -20.0) - ) - (t9-32 a0-55 a1-24 a2-17 self t0-6) - ) - (cond - ((< (+ spool-part 1) (-> arg0 parts)) - (let* ((a0-57 *art-control*) - (t9-33 (method-of-object a0-57 spool-push)) - (a1-25 (-> arg0 name)) - (a2-18 (+ spool-part 1)) - (t0-7 -10.0) - ) - (t9-33 a0-57 a1-25 a2-18 self t0-7) - ) - ) - (else - (set! (-> self skel status) (logand -5 (-> self skel status))) - ) - ) - (dummy-16 *load-state* (ja-aframe-num 0)) - (cond - ((and (< sv-32 sv-72) (= (current-str-id) spool-sound)) - (set! - sv-56 - (+ - sv-56 - (- - (-> *display* base-frame-counter) - (-> *display* old-base-frame-counter) - ) - ) - ) - (set! sv-40 (the-as int (-> *display* base-frame-counter))) - ) - (else - 0 - ) - ) - (set! sv-32 sv-72) - (set! sv-48 (the-as int (-> *display* base-frame-counter))) - (suspend) - (let - ((f0-14 - (* (- (the float (current-str-pos spool-sound)) sv-24) f30-0) - ) - (a0-69 (-> self skel root-channel 0)) - ) - (set! - (-> a0-69 param 0) - (the float (+ (-> a0-69 frame-group data 0 length) -1)) - ) - (set! (-> a0-69 param 1) 1.0) - (set! (-> a0-69 frame-num) f0-14) - (joint-control-channel-group! - a0-69 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (let ((v0-39 (current-str-pos spool-sound))) - (set! sv-72 v0-39) - (>= (the float v0-39) f28-0) - ) - ) + (until (>= (the float v0-39) f28-0) (if (= (-> self skel root-channel 0) (-> self skel channel)) (logior! (-> self skel status) 32) ) @@ -1369,6 +1302,69 @@ ) (goto cfg-88) ) + (let* ((a0-55 *art-control*) + (t9-32 (method-of-object a0-55 spool-push)) + (a1-24 (-> arg0 name)) + (a2-17 spool-part) + (t0-6 -20.0) + ) + (t9-32 a0-55 a1-24 a2-17 self t0-6) + ) + (cond + ((< (+ spool-part 1) (-> arg0 parts)) + (let* ((a0-57 *art-control*) + (t9-33 (method-of-object a0-57 spool-push)) + (a1-25 (-> arg0 name)) + (a2-18 (+ spool-part 1)) + (t0-7 -10.0) + ) + (t9-33 a0-57 a1-25 a2-18 self t0-7) + ) + ) + (else + (set! (-> self skel status) (logand -5 (-> self skel status))) + ) + ) + (dummy-16 *load-state* (ja-aframe-num 0)) + (cond + ((and (< sv-32 sv-72) (= (current-str-id) spool-sound)) + (set! + sv-56 + (+ + sv-56 + (- + (-> *display* base-frame-counter) + (-> *display* old-base-frame-counter) + ) + ) + ) + (set! sv-40 (the-as int (-> *display* base-frame-counter))) + ) + (else + 0 + ) + ) + (set! sv-32 sv-72) + (set! sv-48 (the-as int (-> *display* base-frame-counter))) + (suspend) + (let + ((f0-14 (* (- (the float (current-str-pos spool-sound)) sv-24) f30-0)) + (a0-69 (-> self skel root-channel 0)) + ) + (set! + (-> a0-69 param 0) + (the float (+ (-> a0-69 frame-group data 0 length) -1)) + ) + (set! (-> a0-69 param 1) 1.0) + (set! (-> a0-69 frame-num) f0-14) + (joint-control-channel-group! + a0-69 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) + (set! v0-39 (current-str-pos spool-sound)) + (set! sv-72 v0-39) ) (set! sv-24 f28-0) ) diff --git a/test/decompiler/reference/kernel/gcommon_REF.gc b/test/decompiler/reference/kernel/gcommon_REF.gc index c77f74d905..7232574634 100644 --- a/test/decompiler/reference/kernel/gcommon_REF.gc +++ b/test/decompiler/reference/kernel/gcommon_REF.gc @@ -171,13 +171,11 @@ (let ((obj-type (-> obj type)) (end-type object) ) - (until (begin - (set! obj-type (-> obj-type parent)) - (= obj-type end-type) - ) + (until (= obj-type end-type) (if (= obj-type parent-type) (return #t) ) + (set! obj-type (-> obj-type parent)) ) ) #f @@ -186,13 +184,11 @@ ;; definition for function type-type? (defun type-type? ((child-type type) (parent-type type)) (let ((end-type object)) - (until (begin - (set! child-type (-> child-type parent)) - (or (= child-type end-type) (zero? child-type)) - ) + (until (or (= child-type end-type) (zero? child-type)) (if (= child-type parent-type) (return #t) ) + (set! child-type (-> child-type parent)) ) ) #f diff --git a/test/decompiler/reference/kernel/gstring_REF.gc b/test/decompiler/reference/kernel/gstring_REF.gc index 471ec01584..afeb758c19 100644 --- a/test/decompiler/reference/kernel/gstring_REF.gc +++ b/test/decompiler/reference/kernel/gstring_REF.gc @@ -356,15 +356,12 @@ (let ((end-of-append (&-> (the-as (pointer uint8) append-str) 3))) (let ((location-of-char (string-skip-to-char (-> append-str data) char))) (when (= (-> location-of-char 0) char) - (until (begin - (set! end-of-append location-of-char) - (set! - location-of-char - (string-skip-to-char (&-> location-of-char 1) char) - ) - (!= (-> location-of-char 0) char) - ) - (empty) + (until (!= (-> location-of-char 0) char) + (set! end-of-append location-of-char) + (set! + location-of-char + (string-skip-to-char (&-> location-of-char 1) char) + ) ) ) ) diff --git a/test/decompiler/reference/levels/common/nav-enemy_REF.gc b/test/decompiler/reference/levels/common/nav-enemy_REF.gc index 04fdd99bb4..b69685d776 100644 --- a/test/decompiler/reference/levels/common/nav-enemy_REF.gc +++ b/test/decompiler/reference/levels/common/nav-enemy_REF.gc @@ -942,22 +942,7 @@ nav-enemy-default-event-handler (-> self collide-info status) (logand -8 (-> self collide-info status)) ) - (until (begin - (suspend) - (let ((a0-13 (-> self skel root-channel 0))) - (set! - (-> a0-13 param 0) - (the float (+ (-> a0-13 frame-group data 0 length) -1)) - ) - (set! (-> a0-13 param 1) arg2) - (joint-control-channel-group-eval! - a0-13 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) + (until (ja-done? 0) (cond ((nonzero? (-> self align)) (when (not s4-1) @@ -991,6 +976,19 @@ nav-enemy-default-event-handler ) ) ) + (suspend) + (let ((a0-13 (-> self skel root-channel 0))) + (set! + (-> a0-13 param 0) + (the float (+ (-> a0-13 frame-group data 0 length) -1)) + ) + (set! (-> a0-13 param 1) arg2) + (joint-control-channel-group-eval! + a0-13 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) ) @@ -1330,23 +1328,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-2 (-> self skel root-channel 0))) - (set! - (-> a0-2 param 0) - (the float (+ (-> a0-2 frame-group data 0 length) -1)) - ) - (set! (-> a0-2 param 1) f30-0) - (joint-control-channel-group-eval! - a0-2 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-2 (-> self skel root-channel 0))) + (set! + (-> a0-2 param 0) + (the float (+ (-> a0-2 frame-group data 0 length) -1)) + ) + (set! (-> a0-2 param 1) f30-0) + (joint-control-channel-group-eval! + a0-2 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) (when (nav-enemy-rnd-go-idle? 0.2) (let ((a0-5 (-> self skel root-channel 0))) @@ -1396,28 +1391,23 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (ja-blend-eval) - (suspend) - (let ((a0-9 (-> self skel root-channel 0))) - (set! - (-> a0-9 param 0) - (the float (+ (-> a0-9 frame-group data 0 length) -1)) - ) - (set! (-> a0-9 param 1) f30-0) - (joint-control-channel-group-eval! - a0-9 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (ja-blend-eval) + (suspend) + (let ((a0-9 (-> self skel root-channel 0))) + (set! + (-> a0-9 param 0) + (the float (+ (-> a0-9 frame-group data 0 length) -1)) + ) + (set! (-> a0-9 param 1) f30-0) + (joint-control-channel-group-eval! + a0-9 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) - (until (begin - (not (nav-enemy-rnd-go-idle? 0.2)) - ) + (until (not (nav-enemy-rnd-go-idle? 0.2)) (let ((a0-11 (-> self skel root-channel 0))) (set! (-> a0-11 frame-group) @@ -1455,23 +1445,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-12 (-> self skel root-channel 0))) - (set! - (-> a0-12 param 0) - (the float (+ (-> a0-12 frame-group data 0 length) -1)) - ) - (set! (-> a0-12 param 1) f30-0) - (joint-control-channel-group-eval! - a0-12 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-12 (-> self skel root-channel 0))) + (set! + (-> a0-12 param 0) + (the float (+ (-> a0-12 frame-group data 0 length) -1)) + ) + (set! (-> a0-12 param 1) f30-0) + (joint-control-channel-group-eval! + a0-12 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (logior! (-> self nav-enemy-flags) 8) @@ -1521,24 +1508,21 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (ja-blend-eval) - (suspend) - (let ((a0-18 (-> self skel root-channel 0))) - (set! - (-> a0-18 param 0) - (the float (+ (-> a0-18 frame-group data 0 length) -1)) - ) - (set! (-> a0-18 param 1) f30-0) - (joint-control-channel-group-eval! - a0-18 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (ja-blend-eval) + (suspend) + (let ((a0-18 (-> self skel root-channel 0))) + (set! + (-> a0-18 param 0) + (the float (+ (-> a0-18 frame-group data 0 length) -1)) + ) + (set! (-> a0-18 param 1) f30-0) + (joint-control-channel-group-eval! + a0-18 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) ) @@ -1616,29 +1600,26 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (seek-toward-heading-vec! - (-> self collide-info) - (-> self nav travel) - (-> self rotate-speed) - (the-as int (-> self turn-time)) - ) - (suspend) - (let ((a0-4 (-> self skel root-channel 0))) - (set! - (-> a0-4 param 0) - (the float (+ (-> a0-4 frame-group data 0 length) -1)) - ) - (set! (-> a0-4 param 1) f30-0) - (joint-control-channel-group-eval! - a0-4 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (seek-toward-heading-vec! + (-> self collide-info) + (-> self nav travel) + (-> self rotate-speed) + (the-as int (-> self turn-time)) + ) + (suspend) + (let ((a0-4 (-> self skel root-channel 0))) + (set! + (-> a0-4 param 0) + (the float (+ (-> a0-4 frame-group data 0 length) -1)) + ) + (set! (-> a0-4 param 1) f30-0) + (joint-control-channel-group-eval! + a0-4 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (go-virtual nav-enemy-chase) @@ -1748,23 +1729,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! - (-> a0-3 param 0) - (the float (+ (-> a0-3 frame-group data 0 length) -1)) - ) - (set! (-> a0-3 param 1) f30-0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! + (-> a0-3 param 0) + (the float (+ (-> a0-3 frame-group data 0 length) -1)) + ) + (set! (-> a0-3 param 1) f30-0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) (ja-channel-push! 1 60) (while #t @@ -1805,23 +1783,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-7 (-> self skel root-channel 0))) - (set! - (-> a0-7 param 0) - (the float (+ (-> a0-7 frame-group data 0 length) -1)) - ) - (set! (-> a0-7 param 1) f30-0) - (joint-control-channel-group-eval! - a0-7 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-7 (-> self skel root-channel 0))) + (set! + (-> a0-7 param 0) + (the float (+ (-> a0-7 frame-group data 0 length) -1)) + ) + (set! (-> a0-7 param 1) f30-0) + (joint-control-channel-group-eval! + a0-7 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) ) @@ -2350,23 +2325,20 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! - (-> a0-3 param 0) - (the float (+ (-> a0-3 frame-group data 0 length) -1)) - ) - (set! (-> a0-3 param 1) f30-0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! + (-> a0-3 param 0) + (the float (+ (-> a0-3 frame-group data 0 length) -1)) + ) + (set! (-> a0-3 param 1) f30-0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (go-virtual nav-enemy-stare) @@ -2621,21 +2593,18 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (ja-blend-eval) - (suspend) - (let ((s3-1 (-> self skel root-channel 0))) - (set! (-> s3-1 param 0) (ja-aframe arg1 0)) - (set! (-> s3-1 param 1) arg2) - (joint-control-channel-group-eval! - s3-1 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (ja-blend-eval) + (suspend) + (let ((s3-1 (-> self skel root-channel 0))) + (set! (-> s3-1 param 0) (ja-aframe arg1 0)) + (set! (-> s3-1 param 1) arg2) + (joint-control-channel-group-eval! + s3-1 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (set! (-> self collide-info status) (logand -8 (-> self collide-info status))) @@ -2789,24 +2758,21 @@ nav-enemy-default-event-handler num-func-seek! ) ) - (until (begin - (ja-blend-eval) - (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! - (-> a0-3 param 0) - (the float (+ (-> a0-3 frame-group data 0 length) -1)) - ) - (set! (-> a0-3 param 1) 1.0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (ja-blend-eval) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! + (-> a0-3 param 0) + (the float (+ (-> a0-3 frame-group data 0 length) -1)) + ) + (set! (-> a0-3 param 1) 1.0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) 0 (none) @@ -3090,19 +3056,16 @@ nav-enemy-default-event-handler (let ((gp-0 (nav-enemy-rnd-int-range 0 150)) (s5-0 (-> *display* base-frame-counter)) ) - (until (begin - (let ((a0-12 (-> self skel root-channel 0))) - (set! (-> a0-12 param 0) f30-0) - (joint-control-channel-group-eval! - a0-12 - (the-as art-joint-anim #f) - num-func-loop! - ) - ) - (suspend) - (>= (the-as int (- (-> *display* base-frame-counter) s5-0)) gp-0) - ) - (empty) + (until (>= (the-as int (- (-> *display* base-frame-counter) s5-0)) gp-0) + (let ((a0-12 (-> self skel root-channel 0))) + (set! (-> a0-12 param 0) f30-0) + (joint-control-channel-group-eval! + a0-12 + (the-as art-joint-anim #f) + num-func-loop! + ) + ) + (suspend) ) ) ) diff --git a/test/decompiler/reference/levels/misty/misty-teetertotter_REF.gc b/test/decompiler/reference/levels/misty/misty-teetertotter_REF.gc index 6c8c8b29a4..61a2199aa3 100644 --- a/test/decompiler/reference/levels/misty/misty-teetertotter_REF.gc +++ b/test/decompiler/reference/levels/misty/misty-teetertotter_REF.gc @@ -186,7 +186,6 @@ ) :code (behavior () - (local-vars (v1-16 symbol) (f0-4 float)) (set! (-> self launched-player) #f) (let ((a0-0 (-> self skel root-channel 0))) (set! @@ -216,26 +215,26 @@ num-func-seek! ) ) - (until (begin - (set! (-> self rock-is-dangerous) (and v1-16 (>= 76.0 f0-4))) - (suspend) - (let ((a0-2 (-> self skel root-channel 0))) - (set! - (-> a0-2 param 0) - (the float (+ (-> a0-2 frame-group data 0 length) -1)) - ) - (set! (-> a0-2 param 1) 1.0) - (joint-control-channel-group-eval! - a0-2 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (set! f0-4 (ja-aframe-num 0)) - (set! (-> self in-launch-window) (and (>= f0-4 76.0) (>= 82.0 f0-4))) - (set! v1-16 (>= f0-4 12.0)) + (until (ja-done? 0) + (let ((f0-4 (ja-aframe-num 0))) + (set! (-> self in-launch-window) (and (>= f0-4 76.0) (>= 82.0 f0-4))) + (let ((v1-16 (>= f0-4 12.0))) + (set! (-> self rock-is-dangerous) (and v1-16 (>= 76.0 f0-4))) + ) + ) + (suspend) + (let ((a0-2 (-> self skel root-channel 0))) + (set! + (-> a0-2 param 0) + (the float (+ (-> a0-2 frame-group data 0 length) -1)) + ) + (set! (-> a0-2 param 1) 1.0) + (joint-control-channel-group-eval! + a0-2 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) (go teetertotter-idle) (none) @@ -276,23 +275,20 @@ num-func-seek! ) ) - (until (begin - (suspend) - (let ((a0-1 (-> self skel root-channel 0))) - (set! - (-> a0-1 param 0) - (the float (+ (-> a0-1 frame-group data 0 length) -1)) - ) - (set! (-> a0-1 param 1) 1.0) - (joint-control-channel-group-eval! - a0-1 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (suspend) + (let ((a0-1 (-> self skel root-channel 0))) + (set! + (-> a0-1 param 0) + (the float (+ (-> a0-1 frame-group data 0 length) -1)) + ) + (set! (-> a0-1 param 1) 1.0) + (joint-control-channel-group-eval! + a0-1 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) (go teetertotter-idle) (none) diff --git a/test/decompiler/reference/levels/misty/misty-warehouse_REF.gc b/test/decompiler/reference/levels/misty/misty-warehouse_REF.gc index 4ac3ffe996..b9f6d29621 100644 --- a/test/decompiler/reference/levels/misty/misty-warehouse_REF.gc +++ b/test/decompiler/reference/levels/misty/misty-warehouse_REF.gc @@ -101,17 +101,12 @@ ) (camera-change-to "camera-160" 150 #f) (let ((gp-0 (-> *display* base-frame-counter))) - (until (begin - (suspend) - (>= - (the-as - int - (- (-> *display* base-frame-counter) gp-0) - ) - 900 - ) - ) - (empty) + (until + (>= + (the-as int (- (-> *display* base-frame-counter) gp-0)) + 900 + ) + (suspend) ) ) (while @@ -148,11 +143,8 @@ ) (set! (-> self state-time) (-> *display* base-frame-counter)) (let ((gp-1 (-> *display* base-frame-counter))) - (until (begin - (suspend) - (>= (the-as int (- (-> *display* base-frame-counter) gp-1)) 300) - ) - (empty) + (until (>= (the-as int (- (-> *display* base-frame-counter) gp-1)) 300) + (suspend) ) ) (sound-play-by-name @@ -192,22 +184,19 @@ num-func-seek! ) ) - (until (begin - (rider-trans) - (rider-post) - (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! (-> a0-3 param 0) (-> self anim-limit)) - (set! (-> a0-3 param 1) 1.0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (ja-done? 0) - ) - (empty) + (until (ja-done? 0) + (rider-trans) + (rider-post) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! (-> a0-3 param 0) (-> self anim-limit)) + (set! (-> a0-3 param 1) 1.0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim #f) + num-func-seek! + ) + ) ) ) (let ((gp-1 (-> self skel root-channel 0))) diff --git a/test/decompiler/test_FormExpressionBuild.cpp b/test/decompiler/test_FormExpressionBuild.cpp index ee4faf3c7a..0e07b611c2 100644 --- a/test/decompiler/test_FormExpressionBuild.cpp +++ b/test/decompiler/test_FormExpressionBuild.cpp @@ -454,11 +454,14 @@ TEST_F(FormRegressionTest, ExprBasicTypeP) { std::string type = "(function basic type symbol)"; std::string expected = "(begin\n" - " (let\n" - " ((v1-0 (-> arg0 type)) (a0-1 object))\n" - " (until\n" - " (begin (set! v1-0 (-> v1-0 parent)) (= v1-0 a0-1))\n" - " (if (= v1-0 arg1) (return #t))\n" + " (let ((v1-0 (-> arg0 type))\n" + " (a0-1 object)\n" + " )\n" + " (until (= v1-0 a0-1)\n" + " (if (= v1-0 arg1)\n" + " (return #t)\n" + " )\n" + " (set! v1-0 (-> v1-0 parent))\n" " )\n" " )\n" " #f\n" @@ -494,11 +497,14 @@ TEST_F(FormRegressionTest, FinalBasicTypeP) { std::string type = "(function basic type symbol)"; std::string expected = "(defun test-function ((arg0 basic) (arg1 type))\n" - " (let\n" - " ((v1-0 (-> arg0 type)) (a0-1 object))\n" - " (until\n" - " (begin (set! v1-0 (-> v1-0 parent)) (= v1-0 a0-1))\n" - " (if (= v1-0 arg1) (return #t))\n" + " (let ((v1-0 (-> arg0 type))\n" + " (a0-1 object)\n" + " )\n" + " (until (= v1-0 a0-1)\n" + " (if (= v1-0 arg1)\n" + " (return #t)\n" + " )\n" + " (set! v1-0 (-> v1-0 parent))\n" " )\n" " )\n" " #f\n" @@ -547,11 +553,12 @@ TEST_F(FormRegressionTest, ExprTypeTypep) { std::string expected = "(begin\n" - " (let\n" - " ((v1-0 object))\n" - " (until\n" - " (begin (set! arg0 (-> arg0 parent)) (or (= arg0 v1-0) (zero? arg0)))\n" - " (if (= arg0 arg1) (return #t))\n" + " (let ((v1-0 object))\n" + " (until (or (= arg0 v1-0) (zero? arg0))\n" + " (if (= arg0 arg1)\n" + " (return #t)\n" + " )\n" + " (set! arg0 (-> arg0 parent))\n" " )\n" " )\n" " #f\n"