diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index f5553c80a3..df47048ee9 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -939,9 +939,13 @@ goos::Object BreakElement::to_form_internal(const Env& env) const { forms.push_back(pretty_print::build_list(return_code->to_form(env))); forms.push_back(pretty_print::build_list(dead_code->to_form(env))); } else { - forms.push_back(pretty_print::to_symbol("begin")); - return_code->inline_forms(forms, env); - forms.push_back(pretty_print::build_list(fmt::format("goto cfg-{}", lid))); + if (return_code->try_as_element()) { + return pretty_print::build_list(fmt::format("goto cfg-{}", lid)); + } else { + forms.push_back(pretty_print::to_symbol("begin")); + return_code->inline_forms(forms, env); + forms.push_back(pretty_print::build_list(fmt::format("goto cfg-{}", lid))); + } } return pretty_print::build_list(forms); } diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index a8df31fc8e..658ba88ac0 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -2804,6 +2804,18 @@ void CondWithElseElement::push_to_stack(const Env& env, FormPool& pool, FormStac } } + // merge conds in the else block. + auto else_as_another_cond = else_ir->try_as_element(); + if (else_as_another_cond) { + while (else_as_another_cond) { + for (auto& e : else_as_another_cond->entries) { + entries.push_back(e); + } + else_ir = else_as_another_cond->else_ir; + else_as_another_cond = else_ir->try_as_element(); + } + } + if (rewrite_as_set) { if (set_unused) { stack.push_form_element(this, true); @@ -4492,17 +4504,22 @@ void LabelElement::push_to_stack(const Env&, FormPool&, FormStack& stack) { void BreakElement::push_to_stack(const Env& env, FormPool& pool, FormStack& stack) { mark_popped(); - FormStack temp_stack(false); for (auto& elt : return_code->elts()) { elt->push_to_stack(env, pool, temp_stack); } - auto new_entries = temp_stack.rewrite(pool, env); + std::vector new_entries; + new_entries = temp_stack.rewrite(pool, env); + + assert(!new_entries.empty()); return_code->clear(); - for (auto e : new_entries) { - return_code->push_back(e); + + for (int i = 0; i < ((int)new_entries.size()); i++) { + stack.push_form_element(new_entries.at(i), true); } + + return_code->push_back(pool.alloc_element()); stack.push_form_element(this, true); } diff --git a/docs/markdown/progress-notes/changelog.md b/docs/markdown/progress-notes/changelog.md index 19dadf9560..1b617dcf12 100644 --- a/docs/markdown/progress-notes/changelog.md +++ b/docs/markdown/progress-notes/changelog.md @@ -178,4 +178,6 @@ - `defbehavior` has been added to define a global behavior. - Auto-generated inspect methods of process now start by calling the parent type's inspect, like in GOAL. - Fields with type `(inline-array thing)` can now be set in statics. -- `meters`, `degrees`, and `seconds` types have been added. \ No newline at end of file +- `meters`, `degrees`, and `seconds` types have been added. +- Bitfields with `symbol` fields used in an immediate `(new 'static ...)` can now define the symbol in the `new` form. +- Bitfields with `float` fields used in an immediate `(new 'static ...)` in code can use a non-constant floating point value. \ No newline at end of file diff --git a/goal_src/engine/anim/aligner.gc b/goal_src/engine/anim/aligner.gc index dcf9b4b9da..acbb227088 100644 --- a/goal_src/engine/anim/aligner.gc +++ b/goal_src/engine/anim/aligner.gc @@ -58,11 +58,11 @@ ((or (not v1-16) (!= (-> obj frame-group) v1-16)) (set! a0-9 #t) ) + ((= (-> a0-8 num-func) num-func-loop!) + (set! a0-9 (< (* (-> a0-8 param 0) (- f0-0 (-> obj frame-num))) 0.0)) + ) (else - (if (= (-> a0-8 num-func) num-func-loop!) - (set! a0-9 (< (* (-> a0-8 param 0) (- f0-0 (-> obj frame-num))) 0.0)) - (set! a0-9 (= f0-0 0.0)) - ) + (set! a0-9 (= f0-0 0.0)) ) ) (if a0-9 diff --git a/goal_src/engine/data/res.gc b/goal_src/engine/data/res.gc index 7103f93646..152f0f101a 100644 --- a/goal_src/engine/data/res.gc +++ b/goal_src/engine/data/res.gc @@ -41,7 +41,6 @@ This is updated from the entity system used in Crash 2, which had most of these (defmethod print res-tag ((obj res-tag)) "print a res-tag." - (let ((obj obj)) (if (res-ref? obj) (format #t "#" @@ -60,7 +59,6 @@ This is updated from the entity system used in Crash 2, which had most of these ) obj - ) ) (defmethod length res-tag ((obj res-tag)) diff --git a/goal_src/engine/debug/menu.gc b/goal_src/engine/debug/menu.gc index 43dfa02efb..5b2951f197 100644 --- a/goal_src/engine/debug/menu.gc +++ b/goal_src/engine/debug/menu.gc @@ -753,131 +753,127 @@ (the-as int (car (cdr (cdr (cdr arg1))))) ) ) - (else - (cond - ((or - (= s4-0 'int-var) - (= s4-0 'int-var-gat1) - (= s4-0 'hex-var) - ) - (set! - s5-0 - (new - 'debug - 'debug-menu-item-var - (the-as string s5-1) - (the-as int (car (cdr (cdr arg1)))) - (the-as int (ref arg1 4)) - ) - ) - (let ((s3-4 debug-menu-item-var-make-int) - (s2-3 (the-as debug-menu-item-var s5-0)) - (s1-3 - (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) - ) - (s0-1 (/ (the-as int (ref arg1 5)) 8)) - ) - (set! sv-16 (ref arg1 6)) - (set! sv-32 (/ (the-as int (ref arg1 7)) 8)) - (let ((t1-0 (/ (the-as int (ref arg1 8)) 8)) - (t2-0 (= s4-0 'hex-var)) - ) - (s3-4 - s2-3 - (the-as (function int int int int int) s1-3) - s0-1 - (the-as symbol sv-16) - sv-32 - t1-0 - t2-0 - ) - ) - ) - (set! (-> (the-as debug-menu-item-var s5-0) ifloat-p) #t) - s5-0 - ) - ((= s4-0 'float-var) - (set! - s5-0 - (new - 'debug - 'debug-menu-item-var - (the-as string s5-1) - (the-as int (car (cdr (cdr arg1)))) - (the-as int (ref arg1 4)) - ) - ) - (let ((s4-5 debug-menu-item-var-make-float) - (s3-6 (the-as debug-menu-item-var s5-0)) - (s2-5 - (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) - ) - (s1-5 (the float (/ (the-as int (ref arg1 5)) 8))) - (s0-2 (ref arg1 6)) - ) - (set! sv-48 (the float (/ (the-as int (ref arg1 7)) 8))) - (set! sv-64 (the float (/ (the-as int (ref arg1 8)) 8))) - (let ((t2-1 (/ (the-as int (ref arg1 9)) 8))) - (s4-5 - s3-6 - (the-as (function int int float float int) s2-5) - s1-5 - (the-as symbol s0-2) - sv-48 - sv-64 - (the-as symbol t2-1) - ) - ) - ) - s5-0 - ) - ((= s4-0 'float-fixed-var) - (set! - s5-0 - (new - 'debug - 'debug-menu-item-var - (the-as string s5-1) - (the-as int (car (cdr (cdr arg1)))) - (the-as int (ref arg1 4)) - ) - ) - (let ((s4-7 debug-menu-item-var-make-float) - (s3-8 (the-as debug-menu-item-var s5-0)) - (s2-7 - (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) - ) - (s1-7 - (* 0.001 (the float (/ (the-as int (ref arg1 5)) 8))) - ) - (s0-3 (ref arg1 6)) - ) - (set! - sv-80 - (* 0.001 (the float (/ (the-as int (ref arg1 7)) 8))) - ) - (set! - sv-96 - (* 0.001 (the float (/ (the-as int (ref arg1 8)) 8))) - ) - (let ((t2-2 (/ (the-as int (ref arg1 9)) 8))) - (s4-7 - s3-8 - (the-as (function int int float float int) s2-7) - s1-7 - (the-as symbol s0-3) - sv-80 - sv-96 - (the-as symbol t2-2) - ) - ) - ) - s5-0 - ) - (else - (the-as debug-menu-node #f) + ((or + (= s4-0 'int-var) + (= s4-0 'int-var-gat1) + (= s4-0 'hex-var) + ) + (set! + s5-0 + (new + 'debug + 'debug-menu-item-var + (the-as string s5-1) + (the-as int (car (cdr (cdr arg1)))) + (the-as int (ref arg1 4)) ) ) + (let ((s3-4 debug-menu-item-var-make-int) + (s2-3 (the-as debug-menu-item-var s5-0)) + (s1-3 + (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) + ) + (s0-1 (/ (the-as int (ref arg1 5)) 8)) + ) + (set! sv-16 (ref arg1 6)) + (set! sv-32 (/ (the-as int (ref arg1 7)) 8)) + (let ((t1-0 (/ (the-as int (ref arg1 8)) 8)) + (t2-0 (= s4-0 'hex-var)) + ) + (s3-4 + s2-3 + (the-as (function int int int int int) s1-3) + s0-1 + (the-as symbol sv-16) + sv-32 + t1-0 + t2-0 + ) + ) + ) + (set! (-> (the-as debug-menu-item-var s5-0) ifloat-p) #t) + s5-0 + ) + ((= s4-0 'float-var) + (set! + s5-0 + (new + 'debug + 'debug-menu-item-var + (the-as string s5-1) + (the-as int (car (cdr (cdr arg1)))) + (the-as int (ref arg1 4)) + ) + ) + (let ((s4-5 debug-menu-item-var-make-float) + (s3-6 (the-as debug-menu-item-var s5-0)) + (s2-5 + (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) + ) + (s1-5 (the float (/ (the-as int (ref arg1 5)) 8))) + (s0-2 (ref arg1 6)) + ) + (set! sv-48 (the float (/ (the-as int (ref arg1 7)) 8))) + (set! sv-64 (the float (/ (the-as int (ref arg1 8)) 8))) + (let ((t2-1 (/ (the-as int (ref arg1 9)) 8))) + (s4-5 + s3-6 + (the-as (function int int float float int) s2-5) + s1-5 + (the-as symbol s0-2) + sv-48 + sv-64 + (the-as symbol t2-1) + ) + ) + ) + s5-0 + ) + ((= s4-0 'float-fixed-var) + (set! + s5-0 + (new + 'debug + 'debug-menu-item-var + (the-as string s5-1) + (the-as int (car (cdr (cdr arg1)))) + (the-as int (ref arg1 4)) + ) + ) + (let ((s4-7 debug-menu-item-var-make-float) + (s3-8 (the-as debug-menu-item-var s5-0)) + (s2-7 + (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) + ) + (s1-7 + (* 0.001 (the float (/ (the-as int (ref arg1 5)) 8))) + ) + (s0-3 (ref arg1 6)) + ) + (set! + sv-80 + (* 0.001 (the float (/ (the-as int (ref arg1 7)) 8))) + ) + (set! + sv-96 + (* 0.001 (the float (/ (the-as int (ref arg1 8)) 8))) + ) + (let ((t2-2 (/ (the-as int (ref arg1 9)) 8))) + (s4-7 + s3-8 + (the-as (function int int float float int) s2-7) + s1-7 + (the-as symbol s0-3) + sv-80 + sv-96 + (the-as symbol t2-2) + ) + ) + ) + s5-0 + ) + (else + (the-as debug-menu-node #f) ) ) ) @@ -1072,11 +1068,11 @@ 16 ) ) + ((zero? arg3) + 17 + ) (else - (if (zero? arg3) - 17 - 18 - ) + 18 ) ) ) @@ -1332,11 +1328,11 @@ (set! v1-6 (car (cdr v1-4))) ) ) + ((null? a0-1) + (set! v1-6 (car (last (-> s5-0 items)))) + ) (else - (if (null? a0-1) - (set! v1-6 (car (last (-> s5-0 items)))) - (set! v1-6 (car a0-1)) - ) + (set! v1-6 (car a0-1)) ) ) ) diff --git a/goal_src/engine/dma/dma-disasm.gc b/goal_src/engine/dma/dma-disasm.gc index 1cf639b61d..fd233a0e7d 100644 --- a/goal_src/engine/dma/dma-disasm.gc +++ b/goal_src/engine/dma/dma-disasm.gc @@ -406,6 +406,9 @@ `(disasm-dma-list (the dma-packet (-> ,buff data-buffer)) 'details #t #t 0) ) + +;; NOTE: the decompiler currently outputs something nicer looking for the nexted conds, +;; but keeping the old version with nicer comments for now. (defun disasm-dma-list ((data dma-packet) (mode symbol) (verbose symbol) (stream symbol) (expected-size int)) "Disassemble a dma list, starting from the given packet." (local-vars diff --git a/goal_src/engine/geometry/geometry.gc b/goal_src/engine/geometry/geometry.gc index c4d479d81e..cc1613eaac 100644 --- a/goal_src/engine/geometry/geometry.gc +++ b/goal_src/engine/geometry/geometry.gc @@ -848,45 +848,56 @@ ) (defun point-in-plane-<-point+normal! ((arg0 vector) (arg1 vector) (arg2 vector)) - (let ((f0-3 (+ (+ (* (-> arg2 x) (-> arg1 x)) (* (-> arg2 y) (-> arg1 y))) - (* (-> arg2 z) (-> arg1 z)) - ) - ) - ) - (set! (-> arg0 w) 1.0) - (let ((f1-7 (fabs (-> arg2 x))) - (f2-3 (fabs (-> arg2 y))) - (f3-1 (fabs (-> arg2 z))) - ) - (cond - ((and (< f2-3 f1-7) (< f3-1 f1-7)) - (set! (-> arg0 y) (+ 4096.0 (-> arg1 y))) - (set! (-> arg0 z) (+ 4096.0 (-> arg1 z))) - (set! (-> arg0 x) - (/ (+ (- (- (* (-> arg2 y) (-> arg0 y))) (* (-> arg2 z) (-> arg0 z))) f0-3) (-> arg2 x)) - ) - ) - (else - (cond - ((and (< f1-7 f2-3) (< f3-1 f2-3)) - (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) - (set! (-> arg0 z) (+ 4096.0 (-> arg1 z))) - (set! (-> arg0 y) - (/ (- (- f0-3 (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 z) (-> arg0 z))) (-> arg2 y)) - ) - ) - (else - (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) - (set! (-> arg0 y) (+ 4096.0 (-> arg1 y))) - (set! (-> arg0 z) - (/ (+ (- (- (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 y) (-> arg0 y))) f0-3) (-> arg2 z)) - ) - ) - ) - ) - ) + (let + ((f0-3 + (+ + (+ (* (-> arg2 x) (-> arg1 x)) (* (-> arg2 y) (-> arg1 y))) + (* (-> arg2 z) (-> arg1 z)) ) + ) ) + (set! (-> arg0 w) 1.0) + (let ((f1-7 (fabs (-> arg2 x))) + (f2-3 (fabs (-> arg2 y))) + (f3-1 (fabs (-> arg2 z))) + ) + (cond + ((and (< f2-3 f1-7) (< f3-1 f1-7)) + (set! (-> arg0 y) (+ 4096.0 (-> arg1 y))) + (set! (-> arg0 z) (+ 4096.0 (-> arg1 z))) + (set! + (-> arg0 x) + (/ + (+ (- (- (* (-> arg2 y) (-> arg0 y))) (* (-> arg2 z) (-> arg0 z))) f0-3) + (-> arg2 x) + ) + ) + ) + ((and (< f1-7 f2-3) (< f3-1 f2-3)) + (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) + (set! (-> arg0 z) (+ 4096.0 (-> arg1 z))) + (set! + (-> arg0 y) + (/ + (- (- f0-3 (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 z) (-> arg0 z))) + (-> arg2 y) + ) + ) + ) + (else + (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) + (set! (-> arg0 y) (+ 4096.0 (-> arg1 y))) + (set! + (-> arg0 z) + (/ + (+ (- (- (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 y) (-> arg0 y))) f0-3) + (-> arg2 z) + ) + ) + ) + ) + ) + ) arg0 ) diff --git a/goal_src/engine/gfx/hw/gs.gc b/goal_src/engine/gfx/hw/gs.gc index 7a95a53bb5..78c9e07537 100644 --- a/goal_src/engine/gfx/hw/gs.gc +++ b/goal_src/engine/gfx/hw/gs.gc @@ -53,37 +53,47 @@ (defun psm-size ((arg0 gs-psm)) "Convert texture format to some type of size." (cond - ((= arg0 (gs-psm mt8)) 64) - ((= arg0 (gs-psm mt4)) 32) - (else - (if (or (= arg0 (gs-psm ct16)) - (= arg0 (gs-psm ct16s)) - (= arg0 (gs-psm mz16)) - (= arg0 (gs-psm mz16s)) - ) - 128 - 256 - ) - ) + ((= arg0 (gs-psm mt8)) + 64 ) + ((= arg0 (gs-psm mt4)) + 32 + ) + ((or + (= arg0 (gs-psm ct16)) + (= arg0 (gs-psm ct16s)) + (= arg0 (gs-psm mz16)) + (= arg0 (gs-psm mz16s)) + ) + 128 + ) + (else + 256 + ) + ) ) (defun psm-page-height ((arg0 gs-psm)) "Convert texture format to some type of page height" (cond - ((= arg0 (gs-psm mt8)) 64) - ((= arg0 (gs-psm mt4)) 128) - (else - (if (or (= arg0 (gs-psm ct16)) - (= arg0 (gs-psm ct16s)) - (= arg0 (gs-psm mz16)) - (= arg0 (gs-psm mz16s)) - ) - 64 - 32 - ) - ) + ((= arg0 (gs-psm mt8)) + 64 ) + ((= arg0 (gs-psm mt4)) + 128 + ) + ((or + (= arg0 (gs-psm ct16)) + (= arg0 (gs-psm ct16s)) + (= arg0 (gs-psm mz16)) + (= arg0 (gs-psm mz16s)) + ) + 64 + ) + (else + 32 + ) + ) ) (defun psm->string ((arg0 gs-psm)) diff --git a/goal_src/engine/gfx/mood-h.gc b/goal_src/engine/gfx/mood-h.gc index 90935660a0..9d6104c914 100644 --- a/goal_src/engine/gfx/mood-h.gc +++ b/goal_src/engine/gfx/mood-h.gc @@ -93,52 +93,55 @@ (defmethod new mood-context ((allocation symbol) (type-to-make type)) - (local-vars - (v0-0 mood-context) - (v1 vector) - ) - (set! v0-0 - (object-new allocation type-to-make (the-as int (-> type-to-make size))) - ) - (set! v1 (-> v0-0 times 0)) - (set! (-> v1 data 0) 1.000000) - (set! (-> v1 data 1) 1.000000) - (set! (-> v1 data 2) 1.000000) - (set! (-> v1 data 3) 0.000000) - (set! v1 (-> v0-0 times 1)) - (set! (-> v1 data 0) 1.000000) - (set! (-> v1 data 1) 1.000000) - (set! (-> v1 data 2) 1.000000) - (set! (-> v1 data 3) 0.000000) - (set! v1 (-> v0-0 times 2)) - (set! (-> v1 data 0) 1.000000) - (set! (-> v1 data 1) 1.000000) - (set! (-> v1 data 2) 1.000000) - (set! (-> v1 data 3) 0.000000) - (set! v1 (-> v0-0 times 3)) - (set! (-> v1 data 0) 1.000000) - (set! (-> v1 data 1) 1.000000) - (set! (-> v1 data 2) 1.000000) - (set! (-> v1 data 3) 0.000000) - (set! v1 (-> v0-0 times 4)) - (set! (-> v1 data 0) 1.000000) - (set! (-> v1 data 1) 1.000000) - (set! (-> v1 data 2) 1.000000) - (set! (-> v1 data 3) 0.000000) - (set! v1 (-> v0-0 times 5)) - (set! (-> v1 data 0) 1.000000) - (set! (-> v1 data 1) 1.000000) - (set! (-> v1 data 2) 1.000000) - (set! (-> v1 data 3) 0.000000) - (set! v1 (-> v0-0 times 6)) - (set! (-> v1 data 0) 1.000000) - (set! (-> v1 data 1) 1.000000) - (set! (-> v1 data 2) 1.000000) - (set! (-> v1 data 3) 0.000000) - (set! v1 (-> v0-0 times 7)) - (set! (-> v1 data 0) 1.000000) - (set! (-> v1 data 1) 1.000000) - (set! (-> v1 data 2) 1.000000) - (set! (-> v1 data 3) 0.000000) - v0-0 + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (let ((v1-2 (-> v0-0 times))) + (set! (-> v1-2 0 x) 1.0) + (set! (-> v1-2 0 y) 1.0) + (set! (-> v1-2 0 z) 1.0) + (set! (-> v1-2 0 w) 0.0) + ) + (let ((v1-3 (-> v0-0 times 1))) + (set! (-> v1-3 x) 1.0) + (set! (-> v1-3 y) 1.0) + (set! (-> v1-3 z) 1.0) + (set! (-> v1-3 w) 0.0) + ) + (let ((v1-4 (-> v0-0 times 2))) + (set! (-> v1-4 x) 1.0) + (set! (-> v1-4 y) 1.0) + (set! (-> v1-4 z) 1.0) + (set! (-> v1-4 w) 0.0) + ) + (let ((v1-5 (-> v0-0 times 3))) + (set! (-> v1-5 x) 1.0) + (set! (-> v1-5 y) 1.0) + (set! (-> v1-5 z) 1.0) + (set! (-> v1-5 w) 0.0) + ) + (let ((v1-6 (-> v0-0 times 4))) + (set! (-> v1-6 x) 1.0) + (set! (-> v1-6 y) 1.0) + (set! (-> v1-6 z) 1.0) + (set! (-> v1-6 w) 0.0) + ) + (let ((v1-7 (-> v0-0 times 5))) + (set! (-> v1-7 x) 1.0) + (set! (-> v1-7 y) 1.0) + (set! (-> v1-7 z) 1.0) + (set! (-> v1-7 w) 0.0) + ) + (let ((v1-8 (-> v0-0 times 6))) + (set! (-> v1-8 x) 1.0) + (set! (-> v1-8 y) 1.0) + (set! (-> v1-8 z) 1.0) + (set! (-> v1-8 w) 0.0) + ) + (let ((v1-9 (-> v0-0 times 7))) + (set! (-> v1-9 x) 1.0) + (set! (-> v1-9 y) 1.0) + (set! (-> v1-9 z) 1.0) + (set! (-> v1-9 w) 0.0) + ) + v0-0 + ) ) diff --git a/goal_src/engine/gfx/texture.gc b/goal_src/engine/gfx/texture.gc index a016db7147..7ea2904c98 100644 --- a/goal_src/engine/gfx/texture.gc +++ b/goal_src/engine/gfx/texture.gc @@ -161,22 +161,20 @@ (defun texture-bpp ((arg0 gs-psm)) "Get the number of bits per pixel for the given texture format" - (let ((v1-0 arg0)) - (cond - ((= v1-0 (gs-psm mt8)) 8) - ((= v1-0 (gs-psm mt4)) 4) - (else - (if (or (= v1-0 (gs-psm ct16)) - (= v1-0 (gs-psm ct16s)) - (= v1-0 (gs-psm mz16)) - (= v1-0 (gs-psm mz16s)) - ) - 16 - 32 - ) - ) - ) + (case arg0 + (((gs-psm mt8)) + 8 + ) + (((gs-psm mt4)) + 4 ) + (((gs-psm ct16) (gs-psm ct16s) (gs-psm mz16) (gs-psm mz16s)) + 16 + ) + (else + 32 + ) + ) ) (defun texture-qwc ((w int) (h int) (tex-format gs-psm)) @@ -364,88 +362,72 @@ ) (defun gs-page-width ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (if (or (zero? v1-0) - (= v1-0 (gs-psm ct24)) - (= v1-0 (gs-psm ct16)) - (= v1-0 (gs-psm ct16s)) - ) - 64 - (cond - ((or (= v1-0 (gs-psm mt8)) (= v1-0 (gs-psm mt4))) - 128 - ) - (else - (format #t "Warning: Unknown block width for psm ~D~%" arg0) - 1 - ) - ) - ) + (case arg0 + (((gs-psm ct32) (gs-psm ct24) (gs-psm ct16) (gs-psm ct16s)) + 64 + ) + (((gs-psm mt8) (gs-psm mt4)) + 128 ) + (else + (format #t "Warning: Unknown block width for psm ~D~%" arg0) + 1 + ) + ) ) (defun gs-page-height ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (if (or (zero? v1-0) (= v1-0 (gs-psm ct24))) - 32 - (cond - ((or (= v1-0 (gs-psm ct16)) (= v1-0 (gs-psm ct16s))) - 64 - ) - ((= v1-0 (gs-psm mt8)) - 64 - ) - ((= v1-0 (gs-psm mt4)) - 128 - ) - (else - (format #t "Warning: Unknown block width for psm ~D~%" arg0) - 1 - ) - ) - ) + (case arg0 + (((gs-psm ct32) (gs-psm ct24)) + 32 + ) + (((gs-psm ct16) (gs-psm ct16s)) + 64 ) + (((gs-psm mt8)) + 64 + ) + (((gs-psm mt4)) + 128 + ) + (else + (format #t "Warning: Unknown block width for psm ~D~%" arg0) + 1 + ) + ) ) (defun gs-block-width ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (if (or (zero? v1-0) (= v1-0 (gs-psm ct24))) - 8 - (cond - ((or (= v1-0 (gs-psm ct16)) (= v1-0 (gs-psm ct16s)) (= v1-0 (gs-psm mt8))) - 16 - ) - ((= v1-0 (gs-psm mt4)) - 32 - ) - (else - (format #t "Warning: Unknown block width for psm ~D~%" arg0) - 1 - ) + (case arg0 + (((gs-psm ct32) (gs-psm ct24)) + 8 ) + (((gs-psm ct16) (gs-psm ct16s) (gs-psm mt8)) + 16 + ) + (((gs-psm mt4)) + 32 + ) + (else + (format #t "Warning: Unknown block width for psm ~D~%" arg0) + 1 ) ) ) (defun gs-block-height ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (if (or (zero? v1-0) - (= v1-0 (gs-psm ct24)) - (= v1-0 (gs-psm ct16)) - (= v1-0 (gs-psm ct16s)) - ) - 8 - (cond - ((or (= v1-0 (gs-psm mt8)) (= v1-0 (gs-psm mt4))) - 16 - ) - (else - (format #t "Warning: Unknown block width for psm ~D~%" arg0) - 1 - ) - ) - ) + (case arg0 + (((gs-psm ct32) (gs-psm ct24) (gs-psm ct16) (gs-psm ct16s)) + 8 + ) + (((gs-psm mt8) (gs-psm mt4)) + 16 ) + (else + (format #t "Warning: Unknown block width for psm ~D~%" arg0) + 1 + ) + ) ) (defun gs-largest-block ((tex-width int) (tex-height int) (tex-format gs-psm)) @@ -533,33 +515,69 @@ (defmethod lookup-boot-common-id texture-pool ((obj texture-pool) (arg0 int)) "Map these special textures to a number betwen 0 and 19. For other textures, return -1. NOTE: hud means start menu + zoomer, not the usual health HUD." - (let ((v1-0 arg0)) - (cond - ((= v1-0 1032) 0) ;; hud (seg0 only) - ((= v1-0 1119) 1) ;; zoomer-hud (not actually loaded at boot) - ((= v1-0 1478) 2) ;; doesn't exist? (likely demo1) - ((= v1-0 1485) 3) ;; demo2 (seg0 only) - ((= v1-0 1486) 4) ;; demo3 (seg0 only) - ((= v1-0 1487) 5) ;; demo4 (seg0 only) - (else - (cond - ((or (= v1-0 635) (= v1-0 1609)) 6) ;; X or demo5j (seg0 only) - ((= v1-0 636) 7) ;; nope - ((= v1-0 637) 8) ;; nope - ((= v1-0 752) 9) ;; nope - ((= v1-0 1598) 10) ;; nope - ((= v1-0 1599) 11) ;; demo2f - ((= v1-0 1600) 12) ;; demo2g - ((= v1-0 1601) 13) ;; demo2i - ((= v1-0 1602) 14) ;; demo2s - ((= v1-0 1603) 15) ;; demo4e - ((= v1-0 1604) 16) ;; demo4f - ((= v1-0 1605) 17) ;; demo4g - ((= v1-0 1606) 18) ;; demo4i - ((= v1-0 1607) 19) ;; demo4s - (else -1) - ) + (case arg0 + ((1032) ;; hud (seg0 only) + 0 ) + ((1119) ;; zoomer-hud (not actually loaded at boot) + 1 + ) + ((1478) ;; doesn't exist? (likely demo1) + 2 + ) + ((1485) ;; demo2 (seg0 only) + 3 + ) + ((1486) ;; demo3 (seg0 only) + 4 + ) + ((1487) ;; demo4 (seg0 only) + 5 + ) + ((635 1609) ;; X or demo5j (seg0 only) + 6 + ) + ((636) ;; nope + 7 + ) + ((637) ;; nope + 8 + ) + ((752) ;; nope + 9 + ) + ((1598) ;; nope + 10 + ) + ((1599) ;; demo2f + 11 + ) + ((1600) ;; demo2g + 12 + ) + ((1601) ;; demo2i + 13 + ) + ((1602) ;; demo2s + 14 + ) + ((1603) ;; demo4e + 15 + ) + ((1604) ;; demo4f + 16 + ) + ((1605) ;; demo4g + 17 + ) + ((1606) ;; demo4i + 18 + ) + ((1607) ;; demo4s + 19 + ) + (else + -1 ) ) ) @@ -2873,12 +2891,10 @@ ;; iterate through all textures (dotimes (a0-1 (-> v1-0 length)) ;; found it! - (if (= arg0 (-> v1-0 entries a0-1 page)) - (begin - (set! a0-2 a0-1) - (goto cfg-7) - ) - ) + (when (= arg0 (-> v1-0 entries a0-1 page)) + (set! a0-2 a0-1) + (goto cfg-7) + ) ) (set! a0-2 -1) (label cfg-7) diff --git a/goal_src/kernel/gcommon.gc b/goal_src/kernel/gcommon.gc index 2136ca5ede..e2e9131d6b 100644 --- a/goal_src/kernel/gcommon.gc +++ b/goal_src/kernel/gcommon.gc @@ -757,107 +757,127 @@ "Print array." (format #t "#(") (cond - ((type-type? (-> obj content-type) integer) - (let ((content-type-sym (-> obj content-type symbol))) - (cond - ((= content-type-sym 'int32) - (dotimes (s5-0 (-> obj length)) - (format #t (if (zero? s5-0) "~D" " ~D") - (-> (the-as (array int32) obj) s5-0) + ((type-type? (-> obj content-type) integer) + (case (-> obj content-type symbol) + (('int32) + (dotimes (s5-0 (-> obj length)) + (format #t (if (zero? s5-0) + "~D" + " ~D" ) - ) - ) - ((= content-type-sym 'uint32) - (dotimes (s5-1 (-> obj length)) - (format #t (if (zero? s5-1) "~D" " ~D") - (-> (the-as (array uint32) obj) s5-1) - ) - ) - ) - ((= content-type-sym 'int64) - (dotimes (s5-2 (-> obj length)) - (format #t (if (zero? s5-2) "~D" " ~D") - (-> (the-as (array int64) obj) s5-2) - ) - ) - ) - ((= content-type-sym 'uint64) - (dotimes (s5-3 (-> obj length)) - (format #t (if (zero? s5-3) "#x~X" " #x~X") - (-> (the-as (array uint64) obj) s5-3) - ) - ) - ) - ((= content-type-sym 'int8) - (dotimes (s5-4 (-> obj length)) - (format #t (if (zero? s5-4) "~D" " ~D") - (-> (the-as (array int8) obj) s5-4) - ) - ) - ) - ((= content-type-sym 'uint8) - (dotimes (s5-5 (-> obj length)) - (format #t (if (zero? s5-5) "~D" " ~D") - (-> (the-as (array uint8) obj) s5-5) - ) - ) - ) - ((= content-type-sym 'int16) - (dotimes (s5-6 (-> obj length)) - (format #t (if (zero? s5-6) "~D" " ~D") - (-> (the-as (array int16) obj) s5-6) - ) - ) - ) - ((= content-type-sym 'uint16) - (dotimes (s5-7 (-> obj length)) - (format #t (if (zero? s5-7) "~D" " ~D") - (-> (the-as (array uint16) obj) s5-7) - ) - ) - ) - (else - (cond - ((or (= content-type-sym 'uint128) (= content-type-sym 'int128)) - (dotimes (s5-8 (-> obj length)) - (format #t (if (zero? s5-8) "#x~X" " #x~X") - (-> (the-as (array uint128) obj) s5-8) - ) - ) - ) - (else - (dotimes (s5-9 (-> obj length)) - (format #t (if (zero? s5-9) "~D" " ~D") - (-> (the-as (array int32) obj) s5-9) - ) - ) - ) - ) - ) + (-> (the-as (array int32) obj) s5-0) ) - ) - ) - (else - (cond - ((= (-> obj content-type) float) - (dotimes (s5-10 (-> obj length)) - (if (zero? s5-10) - (format #t "~f" (-> (the-as (array float) obj) s5-10)) - (format #t " ~f" (-> (the-as (array float) obj) s5-10)) - ) - ) - ) - (else - (dotimes (s5-11 (-> obj length)) - (if (zero? s5-11) - (format #t "~A" (-> (the-as (array basic) obj) s5-11)) - (format #t " ~A" (-> (the-as (array basic) obj) s5-11)) - ) - ) ) ) + (('uint32) + (dotimes (s5-1 (-> obj length)) + (format #t (if (zero? s5-1) + "~D" + " ~D" + ) + (-> (the-as (array uint32) obj) s5-1) + ) + ) + ) + (('int64) + (dotimes (s5-2 (-> obj length)) + (format #t (if (zero? s5-2) + "~D" + " ~D" + ) + (-> (the-as (array int64) obj) s5-2) + ) + ) + ) + (('uint64) + (dotimes (s5-3 (-> obj length)) + (format #t (if (zero? s5-3) + "#x~X" + " #x~X" + ) + (-> (the-as (array uint64) obj) s5-3) + ) + ) + ) + (('int8) + (dotimes (s5-4 (-> obj length)) + (format #t (if (zero? s5-4) + "~D" + " ~D" + ) + (-> (the-as (array int8) obj) s5-4) + ) + ) + ) + (('uint8) + (dotimes (s5-5 (-> obj length)) + (format #t (if (zero? s5-5) + "~D" + " ~D" + ) + (-> (the-as (array uint8) obj) s5-5) + ) + ) + ) + (('int16) + (dotimes (s5-6 (-> obj length)) + (format #t (if (zero? s5-6) + "~D" + " ~D" + ) + (-> (the-as (array int16) obj) s5-6) + ) + ) + ) + (('uint16) + (dotimes (s5-7 (-> obj length)) + (format #t (if (zero? s5-7) + "~D" + " ~D" + ) + (-> (the-as (array uint16) obj) s5-7) + ) + ) + ) + (('uint128 'int128) + (dotimes (s5-8 (-> obj length)) + (format #t (if (zero? s5-8) + "#x~X" + " #x~X" + ) + (-> (the-as (array uint128) obj) s5-8) + ) + ) + ) + (else + (dotimes (s5-9 (-> obj length)) + (format #t (if (zero? s5-9) + "~D" + " ~D" + ) + (-> (the-as (array int32) obj) s5-9) + ) + ) + ) ) ) + ((= (-> obj content-type) float) + (dotimes (s5-10 (-> obj length)) + (if (zero? s5-10) + (format #t "~f" (-> (the-as (array float) obj) s5-10)) + (format #t " ~f" (-> (the-as (array float) obj) s5-10)) + ) + ) + ) + (else + (dotimes (s5-11 (-> obj length)) + (if (zero? s5-11) + (format #t "~A" (-> (the-as (array basic) obj) s5-11)) + (format #t " ~A" (-> (the-as (array basic) obj) s5-11)) + ) + ) + ) + ) (format #t ")") obj ) @@ -871,86 +891,71 @@ (format #t "~Tcontent-type: ~A~%" (-> obj content-type)) (format #t "~Tdata[~D]: @ #x~X~%" (-> obj allocated-length) (-> obj data)) (cond - ((type-type? (-> obj content-type) integer) - (let ((content-type-sym (-> obj content-type symbol))) - (cond - ((= content-type-sym 'int32) - (dotimes (s5-0 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-0 (-> (the-as (array int32) obj) s5-0)) - ) - ) - ((= content-type-sym 'uint32) - (dotimes (s5-1 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-1 (-> (the-as (array uint32) obj) s5-1)) - ) - ) - ((= content-type-sym 'int64) - (dotimes (s5-2 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-2 (-> (the-as (array int64) obj) s5-2)) - ) - ) - ((= content-type-sym 'uint64) - (dotimes (s5-3 (-> obj length)) - (format #t "~T [~D] #x~X~%" s5-3 (-> (the-as (array uint64) obj) s5-3)) - ) - ) - ((= content-type-sym 'int8) - (dotimes (s5-4 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-4 (-> (the-as (array int8) obj) s5-4)) - ) - ) - ((= content-type-sym 'uint8) - (dotimes (s5-5 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-5 (-> (the-as (array int8) obj) s5-5)) - ) - ) - ((= content-type-sym 'int16) - (dotimes (s5-6 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-6 (-> (the-as (array int16) obj) s5-6)) - ) - ) - ((= content-type-sym 'uint16) - (dotimes (s5-7 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-7 (-> (the-as (array uint16) obj) s5-7)) - ) - ) - (else - (cond - ((or (= content-type-sym 'int128) (= content-type-sym 'uint128)) - (dotimes (s5-8 (-> obj length)) - (format - #t - "~T [~D] #x~X~%" - s5-8 - (-> (the-as (array uint128) obj) s5-8) - ) - ) - ) - (else - (dotimes (s5-9 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-9 (-> (the-as (array int32) obj) s5-9)) - ) - ) - ) - ) - ) - ) - ) - (else - (cond - ((= (-> obj content-type) float) - (dotimes (s5-10 (-> obj length)) - (format #t "~T [~D] ~f~%" s5-10 (-> (the-as (array float) obj) s5-10)) - ) - ) - (else - (dotimes (s5-11 (-> obj length)) - (format #t "~T [~D] ~A~%" s5-11 (-> (the-as (array basic) obj) s5-11)) - ) + ((type-type? (-> obj content-type) integer) + (case (-> obj content-type symbol) + (('int32) + (dotimes (s5-0 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-0 (-> (the-as (array int32) obj) s5-0)) ) ) + (('uint32) + (dotimes (s5-1 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-1 (-> (the-as (array uint32) obj) s5-1)) + ) + ) + (('int64) + (dotimes (s5-2 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-2 (-> (the-as (array int64) obj) s5-2)) + ) + ) + (('uint64) + (dotimes (s5-3 (-> obj length)) + (format #t "~T [~D] #x~X~%" s5-3 (-> (the-as (array uint64) obj) s5-3)) + ) + ) + (('int8) + (dotimes (s5-4 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-4 (-> (the-as (array int8) obj) s5-4)) + ) + ) + (('uint8) + (dotimes (s5-5 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-5 (-> (the-as (array int8) obj) s5-5)) + ) + ) + (('int16) + (dotimes (s5-6 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-6 (-> (the-as (array int16) obj) s5-6)) + ) + ) + (('uint16) + (dotimes (s5-7 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-7 (-> (the-as (array uint16) obj) s5-7)) + ) + ) + (('int128 'uint128) + (dotimes (s5-8 (-> obj length)) + (format #t "~T [~D] #x~X~%" s5-8 (-> (the-as (array uint128) obj) s5-8)) + ) + ) + (else + (dotimes (s5-9 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-9 (-> (the-as (array int32) obj) s5-9)) + ) + ) ) ) + ((= (-> obj content-type) float) + (dotimes (s5-10 (-> obj length)) + (format #t "~T [~D] ~f~%" s5-10 (-> (the-as (array float) obj) s5-10)) + ) + ) + (else + (dotimes (s5-11 (-> obj length)) + (format #t "~T [~D] ~A~%" s5-11 (-> (the-as (array basic) obj) s5-11)) + ) + ) + ) obj ) diff --git a/goalc/compiler/compilation/Static.cpp b/goalc/compiler/compilation/Static.cpp index 1d9b55a507..68a9c62403 100644 --- a/goalc/compiler/compilation/Static.cpp +++ b/goalc/compiler/compilation/Static.cpp @@ -379,10 +379,21 @@ Val* Compiler::compile_bitfield_definition(const goos::Object& form, float value = 0.f; if (!try_getting_constant_float(field_value, &value, env)) { - throw_compiler_error(form, - "Field {} is a float, but the value given couldn't " - "be converted to a float at compile time.", - field_name_def); + // failed to get as constant, add to dynamic or error. + if (allow_dynamic_construction) { + DynamicDef dyn; + dyn.definition = field_value; + dyn.field_offset = field_offset; + dyn.field_size = field_size; + dyn.field_name = field_name_def; + dyn.expected_type = TypeSpec("float"); + dynamic_defs.push_back(dyn); + } else { + throw_compiler_error(form, + "Field {} is a float, but the value given couldn't " + "be converted to a float at compile time.", + field_name_def); + } } u64 float_value = float_as_u32(value); bool start_lo = field_offset < 64; @@ -393,6 +404,20 @@ Val* Compiler::compile_bitfield_definition(const goos::Object& form, } else { constant_integer_part.hi |= (float_value << (field_offset - 64)); } + } else if (field_info.result_type == TypeSpec("symbol")) { + if (allow_dynamic_construction) { + DynamicDef dyn; + dyn.definition = field_value; + dyn.field_offset = field_offset; + dyn.field_size = field_size; + dyn.field_name = field_name_def; + dyn.expected_type = coerce_to_reg_type(field_info.result_type); + dynamic_defs.push_back(dyn); + } else { + throw_compiler_error( + form, "Field {} is a symbol, which cannot be constructed at compile time yet.", + field_name_def); + } } else { diff --git a/test/decompiler/reference/engine/anim/aligner_REF.gc b/test/decompiler/reference/engine/anim/aligner_REF.gc index 71adeb9ac7..0f90cf76b0 100644 --- a/test/decompiler/reference/engine/anim/aligner_REF.gc +++ b/test/decompiler/reference/engine/anim/aligner_REF.gc @@ -51,11 +51,11 @@ ((or (not v1-16) (!= (-> obj frame-group) v1-16)) (set! a0-9 #t) ) + ((= (-> a0-8 num-func) num-func-loop!) + (set! a0-9 (< (* (-> a0-8 param 0) (- f0-0 (-> obj frame-num))) 0.0)) + ) (else - (if (= (-> a0-8 num-func) num-func-loop!) - (set! a0-9 (< (* (-> a0-8 param 0) (- f0-0 (-> obj frame-num))) 0.0)) - (set! a0-9 (= f0-0 0.0)) - ) + (set! a0-9 (= f0-0 0.0)) ) ) (if a0-9 @@ -259,7 +259,3 @@ (-> obj process root) (none) ) - - - - diff --git a/test/decompiler/reference/engine/debug/menu_REF.gc b/test/decompiler/reference/engine/debug/menu_REF.gc index 9bc7cb216f..f8e07e571e 100644 --- a/test/decompiler/reference/engine/debug/menu_REF.gc +++ b/test/decompiler/reference/engine/debug/menu_REF.gc @@ -773,11 +773,9 @@ (sv-80 float) (sv-96 float) ) - (if (or (not arg1) (null? arg1)) - (begin - (set! s5-0 (the-as debug-menu-node #f)) - (goto cfg-41) - ) + (when (or (not arg1) (null? arg1)) + (set! s5-0 (the-as debug-menu-node #f)) + (goto cfg-41) ) (let ((s4-0 (car arg1)) (s5-1 (car (cdr arg1))) @@ -853,131 +851,127 @@ (the-as int (car (cdr (cdr (cdr arg1))))) ) ) - (else - (cond - ((or - (= s4-0 'int-var) - (= s4-0 'int-var-gat1) - (= s4-0 'hex-var) - ) - (set! - s5-0 - (new - 'debug - 'debug-menu-item-var - (the-as string s5-1) - (the-as int (car (cdr (cdr arg1)))) - (the-as int (ref arg1 4)) - ) - ) - (let ((s3-4 debug-menu-item-var-make-int) - (s2-3 (the-as debug-menu-item-var s5-0)) - (s1-3 - (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) - ) - (s0-1 (/ (the-as int (ref arg1 5)) 8)) - ) - (set! sv-16 (ref arg1 6)) - (set! sv-32 (/ (the-as int (ref arg1 7)) 8)) - (let ((t1-0 (/ (the-as int (ref arg1 8)) 8)) - (t2-0 (= s4-0 'hex-var)) - ) - (s3-4 - s2-3 - (the-as (function int int int int int) s1-3) - s0-1 - (the-as symbol sv-16) - sv-32 - t1-0 - t2-0 - ) - ) - ) - (set! (-> (the-as debug-menu-item-var s5-0) ifloat-p) #t) - s5-0 - ) - ((= s4-0 'float-var) - (set! - s5-0 - (new - 'debug - 'debug-menu-item-var - (the-as string s5-1) - (the-as int (car (cdr (cdr arg1)))) - (the-as int (ref arg1 4)) - ) - ) - (let ((s4-5 debug-menu-item-var-make-float) - (s3-6 (the-as debug-menu-item-var s5-0)) - (s2-5 - (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) - ) - (s1-5 (the float (/ (the-as int (ref arg1 5)) 8))) - (s0-2 (ref arg1 6)) - ) - (set! sv-48 (the float (/ (the-as int (ref arg1 7)) 8))) - (set! sv-64 (the float (/ (the-as int (ref arg1 8)) 8))) - (let ((t2-1 (/ (the-as int (ref arg1 9)) 8))) - (s4-5 - s3-6 - (the-as (function int int float float int) s2-5) - s1-5 - (the-as symbol s0-2) - sv-48 - sv-64 - (the-as symbol t2-1) - ) - ) - ) - s5-0 - ) - ((= s4-0 'float-fixed-var) - (set! - s5-0 - (new - 'debug - 'debug-menu-item-var - (the-as string s5-1) - (the-as int (car (cdr (cdr arg1)))) - (the-as int (ref arg1 4)) - ) - ) - (let ((s4-7 debug-menu-item-var-make-float) - (s3-8 (the-as debug-menu-item-var s5-0)) - (s2-7 - (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) - ) - (s1-7 - (* 0.001 (the float (/ (the-as int (ref arg1 5)) 8))) - ) - (s0-3 (ref arg1 6)) - ) - (set! - sv-80 - (* 0.001 (the float (/ (the-as int (ref arg1 7)) 8))) - ) - (set! - sv-96 - (* 0.001 (the float (/ (the-as int (ref arg1 8)) 8))) - ) - (let ((t2-2 (/ (the-as int (ref arg1 9)) 8))) - (s4-7 - s3-8 - (the-as (function int int float float int) s2-7) - s1-7 - (the-as symbol s0-3) - sv-80 - sv-96 - (the-as symbol t2-2) - ) - ) - ) - s5-0 - ) - (else - (the-as debug-menu-node #f) + ((or + (= s4-0 'int-var) + (= s4-0 'int-var-gat1) + (= s4-0 'hex-var) + ) + (set! + s5-0 + (new + 'debug + 'debug-menu-item-var + (the-as string s5-1) + (the-as int (car (cdr (cdr arg1)))) + (the-as int (ref arg1 4)) ) ) + (let ((s3-4 debug-menu-item-var-make-int) + (s2-3 (the-as debug-menu-item-var s5-0)) + (s1-3 + (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) + ) + (s0-1 (/ (the-as int (ref arg1 5)) 8)) + ) + (set! sv-16 (ref arg1 6)) + (set! sv-32 (/ (the-as int (ref arg1 7)) 8)) + (let ((t1-0 (/ (the-as int (ref arg1 8)) 8)) + (t2-0 (= s4-0 'hex-var)) + ) + (s3-4 + s2-3 + (the-as (function int int int int int) s1-3) + s0-1 + (the-as symbol sv-16) + sv-32 + t1-0 + t2-0 + ) + ) + ) + (set! (-> (the-as debug-menu-item-var s5-0) ifloat-p) #t) + s5-0 + ) + ((= s4-0 'float-var) + (set! + s5-0 + (new + 'debug + 'debug-menu-item-var + (the-as string s5-1) + (the-as int (car (cdr (cdr arg1)))) + (the-as int (ref arg1 4)) + ) + ) + (let ((s4-5 debug-menu-item-var-make-float) + (s3-6 (the-as debug-menu-item-var s5-0)) + (s2-5 + (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) + ) + (s1-5 (the float (/ (the-as int (ref arg1 5)) 8))) + (s0-2 (ref arg1 6)) + ) + (set! sv-48 (the float (/ (the-as int (ref arg1 7)) 8))) + (set! sv-64 (the float (/ (the-as int (ref arg1 8)) 8))) + (let ((t2-1 (/ (the-as int (ref arg1 9)) 8))) + (s4-5 + s3-6 + (the-as (function int int float float int) s2-5) + s1-5 + (the-as symbol s0-2) + sv-48 + sv-64 + (the-as symbol t2-1) + ) + ) + ) + s5-0 + ) + ((= s4-0 'float-fixed-var) + (set! + s5-0 + (new + 'debug + 'debug-menu-item-var + (the-as string s5-1) + (the-as int (car (cdr (cdr arg1)))) + (the-as int (ref arg1 4)) + ) + ) + (let ((s4-7 debug-menu-item-var-make-float) + (s3-8 (the-as debug-menu-item-var s5-0)) + (s2-7 + (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) + ) + (s1-7 + (* 0.001 (the float (/ (the-as int (ref arg1 5)) 8))) + ) + (s0-3 (ref arg1 6)) + ) + (set! + sv-80 + (* 0.001 (the float (/ (the-as int (ref arg1 7)) 8))) + ) + (set! + sv-96 + (* 0.001 (the float (/ (the-as int (ref arg1 8)) 8))) + ) + (let ((t2-2 (/ (the-as int (ref arg1 9)) 8))) + (s4-7 + s3-8 + (the-as (function int int float float int) s2-7) + s1-7 + (the-as symbol s0-3) + sv-80 + sv-96 + (the-as symbol t2-2) + ) + ) + ) + s5-0 + ) + (else + (the-as debug-menu-node #f) ) ) ) @@ -1006,25 +1000,21 @@ (set! arg1 (cdr arg1)) (let ((s5-0 (car s3-0))) (while (not (null? s3-0)) - (if + (when (string= (the-as string s4-1) (-> (the-as debug-menu-item s5-0) name)) - (begin - (if (type-type? (rtype-of s5-0) debug-menu-item-submenu) - (set! s4-0 (-> (the-as debug-menu-item-submenu s5-0) submenu)) - (set! s4-0 s5-0) - ) - (goto cfg-17) + (if (type-type? (rtype-of s5-0) debug-menu-item-submenu) + (set! s4-0 (-> (the-as debug-menu-item-submenu s5-0) submenu)) + (set! s4-0 s5-0) ) + (goto cfg-17) ) (set! s3-0 (cdr s3-0)) (set! s5-0 (car s3-0)) ) ) ) - (begin - (set! s4-0 #f) - (goto cfg-24) - ) + (set! s4-0 #f) + (goto cfg-24) ) (label cfg-24) (the-as debug-menu s4-0) @@ -1172,11 +1162,11 @@ 16 ) ) + ((zero? arg3) + 17 + ) (else - (if (zero? arg3) - 17 - 18 - ) + 18 ) ) ) @@ -1276,9 +1266,7 @@ ) (while (not (null? a0-1)) (if (= a1-1 arg3) - (begin - (goto cfg-7) - ) + (goto cfg-7) ) (+! v1-0 1) (set! a0-1 (cdr a0-1)) @@ -1407,23 +1395,19 @@ ) (let ((a3-0 (-> s5-0 items))) (while (not (null? a3-0)) - (if (= (car a3-0) a2-0) - (begin - (set! v1-4 a3-0) - (goto cfg-7) - ) + (when (= (car a3-0) a2-0) + (set! v1-4 a3-0) + (goto cfg-7) ) (set! a0-1 a3-0) (set! a3-0 (cdr a3-0)) ) ) (label cfg-7) - (if (null? v1-4) - (begin - (format 0 "ERROR: Couldn't find selected item in menu.~%") - (set! arg0 arg0) - (goto cfg-19) - ) + (when (null? v1-4) + (format 0 "ERROR: Couldn't find selected item in menu.~%") + (set! arg0 arg0) + (goto cfg-19) ) (cond ((>= arg1 0) @@ -1432,11 +1416,11 @@ (set! v1-6 (car (cdr v1-4))) ) ) + ((null? a0-1) + (set! v1-6 (car (last (-> s5-0 items)))) + ) (else - (if (null? a0-1) - (set! v1-6 (car (last (-> s5-0 items)))) - (set! v1-6 (car a0-1)) - ) + (set! v1-6 (car a0-1)) ) ) ) @@ -1462,12 +1446,10 @@ (+! a0-1 1) ) ) - (if (= v1-4 -1) - (begin - (format 0 "ERROR: Couldn't find selected item in menu.~%") - (set! arg0 arg0) - (goto cfg-25) - ) + (when (= v1-4 -1) + (format 0 "ERROR: Couldn't find selected item in menu.~%") + (set! arg0 arg0) + (goto cfg-25) ) (cond ((>= arg1 0) diff --git a/test/decompiler/reference/engine/dma/dma-disasm_REF.gc b/test/decompiler/reference/engine/dma/dma-disasm_REF.gc index 29513e9705..e8744f1ac5 100644 --- a/test/decompiler/reference/engine/dma/dma-disasm_REF.gc +++ b/test/decompiler/reference/engine/dma/dma-disasm_REF.gc @@ -707,169 +707,142 @@ (cond (end-condition ) - (else - (cond - ((or - (= (-> current-tag id) (dma-tag-id ref)) - (= (-> current-tag id) (dma-tag-id refs)) - (zero? (-> current-tag id)) - ) - (set! addr (-> current-tag addr)) - (set! qwc (the-as int (-> current-tag qwc))) - (when mode-2 - (let - ((v0-10 - (disasm-vif-tag (&-> data-2 vif0) 2 stream-2 (= mode-2 'details)) - ) - ) - (disasm-vif-tag - (the-as (pointer vif-tag) (+ addr (the-as uint v0-10))) - (the-as int (- (* qwc 4) (the-as uint (/ v0-10 4)))) - stream-2 - (= mode-2 'details) - ) + ((or + (= (-> current-tag id) (dma-tag-id ref)) + (= (-> current-tag id) (dma-tag-id refs)) + (zero? (-> current-tag id)) + ) + (set! addr (-> current-tag addr)) + (set! qwc (the-as int (-> current-tag qwc))) + (when mode-2 + (let + ((v0-10 + (disasm-vif-tag (&-> data-2 vif0) 2 stream-2 (= mode-2 'details)) ) ) - (set! - data-2 - (the-as dma-packet (&-> (the-as (pointer uint64) data-2) 2)) - ) - (if (= (-> current-tag id) (dma-tag-id refe)) - (set! end-condition #t) - ) - ) - (else - (cond - ((= (-> current-tag id) (dma-tag-id cnt)) - (set! addr (&-> (the-as (pointer uint64) data-2) 2)) - (set! qwc (the-as int (-> current-tag qwc))) - (if mode-2 - (disasm-vif-tag - (the-as - (pointer vif-tag) - (&-> (the-as (pointer uint64) data-2) 1) - ) - (the-as int (+ (* qwc 4) 2)) - stream-2 - (= mode-2 'details) - ) - ) - (set! - data-2 - (the-as - dma-packet - (+ (the-as uint data-2) (the-as uint (* (+ qwc 1) 16))) - ) - ) - data-2 - ) - ((= (-> current-tag id) (dma-tag-id next)) - (set! addr (&-> (the-as (pointer uint64) data-2) 2)) - (set! qwc (the-as int (-> current-tag qwc))) - (if mode-2 - (disasm-vif-tag - (the-as - (pointer vif-tag) - (&-> (the-as (pointer uint64) data-2) 1) - ) - (the-as int (+ (* qwc 4) 2)) - stream-2 - (= mode-2 'details) - ) - ) - (when (= data-2 (-> current-tag addr)) - (format stream-2 "ERROR: next tag creates infinite loop.~%") - (set! end-condition 'error) - ) - (set! data-2 (the-as dma-packet (-> current-tag addr))) - data-2 - ) - (else - (cond - ((= (-> current-tag id) (dma-tag-id call)) - (set! addr (&-> (the-as (pointer uint64) data-2) 2)) - (set! qwc (the-as int (-> current-tag qwc))) - (if mode-2 - (disasm-vif-tag - (the-as - (pointer vif-tag) - (&-> (the-as (pointer uint64) data-2) 1) - ) - (the-as int (+ (* qwc 4) 2)) - stream-2 - (= mode-2 'details) - ) - ) - (set! data-2 (the-as dma-packet (-> current-tag addr))) - (set! call-depth (+ call-depth 1)) - (cond - ((zero? call-depth) - (set! ra-1 (&+ addr qwc)) - (the-as (pointer uint64) ra-1) - ) - (else - (set! ra-2 (&+ addr qwc)) - (the-as (pointer uint64) ra-2) - ) - ) - ) - ((= (-> current-tag id) (dma-tag-id ret)) - (set! addr (&-> (the-as (pointer uint64) data-2) 2)) - (set! qwc (the-as int (-> current-tag qwc))) - (if mode-2 - (disasm-vif-tag - (the-as - (pointer vif-tag) - (&-> (the-as (pointer uint64) data-2) 1) - ) - (the-as int (+ (* qwc 4) 2)) - stream-2 - (= mode-2 'details) - ) - ) - (let ((v1-123 call-depth)) - (cond - ((zero? v1-123) - (set! data-2 (the-as dma-packet ra-1)) - data-2 - ) - ((= v1-123 1) - (set! data-2 (the-as dma-packet ra-2)) - data-2 - ) - (else - (set! end-condition #t) - ) - ) - ) - (set! call-depth (+ call-depth -1)) - call-depth - ) - ((= (-> current-tag id) (dma-tag-id end)) - (set! addr (&-> (the-as (pointer uint64) data-2) 2)) - (set! qwc (the-as int (-> current-tag qwc))) - (set! end-condition #t) - (if mode-2 - (disasm-vif-tag - (the-as - (pointer vif-tag) - (&-> (the-as (pointer uint64) data-2) 1) - ) - (the-as int (+ (* qwc 4) 2)) - stream-2 - (= mode-2 'details) - ) - ) - ) - (else - (format stream-2 "ERROR: Unknown DMA TAG command.~%") - (set! end-condition 'error) - ) - ) - ) + (disasm-vif-tag + (the-as (pointer vif-tag) (+ addr (the-as uint v0-10))) + (the-as int (- (* qwc 4) (the-as uint (/ v0-10 4)))) + stream-2 + (= mode-2 'details) ) ) ) + (set! + data-2 + (the-as dma-packet (&-> (the-as (pointer uint64) data-2) 2)) + ) + (if (= (-> current-tag id) (dma-tag-id refe)) + (set! end-condition #t) + ) + ) + ((= (-> current-tag id) (dma-tag-id cnt)) + (set! addr (&-> (the-as (pointer uint64) data-2) 2)) + (set! qwc (the-as int (-> current-tag qwc))) + (if mode-2 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) data-2) 1)) + (the-as int (+ (* qwc 4) 2)) + stream-2 + (= mode-2 'details) + ) + ) + (set! + data-2 + (the-as + dma-packet + (+ (the-as uint data-2) (the-as uint (* (+ qwc 1) 16))) + ) + ) + data-2 + ) + ((= (-> current-tag id) (dma-tag-id next)) + (set! addr (&-> (the-as (pointer uint64) data-2) 2)) + (set! qwc (the-as int (-> current-tag qwc))) + (if mode-2 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) data-2) 1)) + (the-as int (+ (* qwc 4) 2)) + stream-2 + (= mode-2 'details) + ) + ) + (when (= data-2 (-> current-tag addr)) + (format stream-2 "ERROR: next tag creates infinite loop.~%") + (set! end-condition 'error) + ) + (set! data-2 (the-as dma-packet (-> current-tag addr))) + data-2 + ) + ((= (-> current-tag id) (dma-tag-id call)) + (set! addr (&-> (the-as (pointer uint64) data-2) 2)) + (set! qwc (the-as int (-> current-tag qwc))) + (if mode-2 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) data-2) 1)) + (the-as int (+ (* qwc 4) 2)) + stream-2 + (= mode-2 'details) + ) + ) + (set! data-2 (the-as dma-packet (-> current-tag addr))) + (set! call-depth (+ call-depth 1)) + (cond + ((zero? call-depth) + (set! ra-1 (&+ addr qwc)) + (the-as (pointer uint64) ra-1) + ) + (else + (set! ra-2 (&+ addr qwc)) + (the-as (pointer uint64) ra-2) + ) + ) + ) + ((= (-> current-tag id) (dma-tag-id ret)) + (set! addr (&-> (the-as (pointer uint64) data-2) 2)) + (set! qwc (the-as int (-> current-tag qwc))) + (if mode-2 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) data-2) 1)) + (the-as int (+ (* qwc 4) 2)) + stream-2 + (= mode-2 'details) + ) + ) + (let ((v1-123 call-depth)) + (cond + ((zero? v1-123) + (set! data-2 (the-as dma-packet ra-1)) + data-2 + ) + ((= v1-123 1) + (set! data-2 (the-as dma-packet ra-2)) + data-2 + ) + (else + (set! end-condition #t) + ) + ) + ) + (set! call-depth (+ call-depth -1)) + call-depth + ) + ((= (-> current-tag id) (dma-tag-id end)) + (set! addr (&-> (the-as (pointer uint64) data-2) 2)) + (set! qwc (the-as int (-> current-tag qwc))) + (set! end-condition #t) + (if mode-2 + (disasm-vif-tag + (the-as (pointer vif-tag) (&-> (the-as (pointer uint64) data-2) 1)) + (the-as int (+ (* qwc 4) 2)) + stream-2 + (= mode-2 'details) + ) + ) + ) + (else + (format stream-2 "ERROR: Unknown DMA TAG command.~%") + (set! end-condition 'error) ) ) (+! total-qwc qwc) diff --git a/test/decompiler/reference/engine/game/fact-h_REF.gc b/test/decompiler/reference/engine/game/fact-h_REF.gc index 60aedd49d0..ec7405940e 100644 --- a/test/decompiler/reference/engine/game/fact-h_REF.gc +++ b/test/decompiler/reference/engine/game/fact-h_REF.gc @@ -250,17 +250,15 @@ ) ) (let ((ent (-> proc entity))) - (if (zero? obj) - (begin - (let ((go-func (the-as (function string none) enter-state)) - (a0-1 "memory") - ) - (set! (-> pp next-state) process-drawable-art-error) - (go-func a0-1) - ) - (set! obj (the-as fact-info 0)) - (goto cfg-10) + (when (zero? obj) + (let ((go-func (the-as (function string none) enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + (go-func a0-1) ) + (set! obj (the-as fact-info 0)) + (goto cfg-10) ) (set! (-> obj process) proc) (set! tag (new 'static 'res-tag)) diff --git a/test/decompiler/reference/engine/geometry/geometry_REF.gc b/test/decompiler/reference/engine/geometry/geometry_REF.gc index d75885a9ca..c7712f0bac 100644 --- a/test/decompiler/reference/engine/geometry/geometry_REF.gc +++ b/test/decompiler/reference/engine/geometry/geometry_REF.gc @@ -770,95 +770,85 @@ (nop!) (label cfg-3) (b! (nonzero? v1-4) cfg-6 :delay (set! v1-5 (the-as uint (+ v1-4 -1)))) - (begin - (vector-segment-distance-point! - arg1 - (the-as vector (-> arg2 vector)) - (-> arg2 vector 1) - arg0 - ) - (goto cfg-24) + (vector-segment-distance-point! + arg1 + (the-as vector (-> arg2 vector)) + (-> arg2 vector 1) + arg0 ) + (goto cfg-24) (label cfg-6) (b! (nonzero? v1-5) cfg-9 :delay (set! v1-6 (the-as uint (+ v1-5 -1)))) - (begin - (vector-segment-distance-point! - arg1 - (-> arg2 vector 1) - (-> arg2 vector 2) - arg0 - ) - (goto cfg-24) + (vector-segment-distance-point! + arg1 + (-> arg2 vector 1) + (-> arg2 vector 2) + arg0 ) + (goto cfg-24) (label cfg-9) (b! (nonzero? v1-6) cfg-14 :delay (set! v1-7 (the-as uint (+ v1-6 -1)))) - (begin - (let - ((f30-0 - (vector-segment-distance-point! - arg1 - (-> arg2 vector 1) - (the-as vector (-> arg2 vector)) - arg0 - ) + (let + ((f30-0 + (vector-segment-distance-point! + arg1 + (-> arg2 vector 1) + (the-as vector (-> arg2 vector)) + arg0 ) - (s3-0 (new 'stack-no-clear 'vector)) - ) - (if - (< - (vector-segment-distance-point! - arg1 - (-> arg2 vector 1) - (-> arg2 vector 2) - s3-0 - ) - f30-0 - ) - (set! (-> arg0 quad) (-> s3-0 quad)) ) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (if + (< + (vector-segment-distance-point! + arg1 + (-> arg2 vector 1) + (-> arg2 vector 2) + s3-0 + ) + f30-0 + ) + (set! (-> arg0 quad) (-> s3-0 quad)) ) - (goto cfg-24) ) + (goto cfg-24) (label cfg-14) (b! (nonzero? v1-7) cfg-17 :delay (set! v1-10 (the-as uint (+ v1-7 -1)))) - (begin - (vector-segment-distance-point! - arg1 - (-> arg2 vector 2) - (the-as vector (-> arg2 vector)) - arg0 - ) - (goto cfg-24) + (vector-segment-distance-point! + arg1 + (-> arg2 vector 2) + (the-as vector (-> arg2 vector)) + arg0 ) + (goto cfg-24) (label cfg-17) (b! (nonzero? v1-10) cfg-22) - (begin - (let - ((f30-1 - (vector-segment-distance-point! - arg1 - (the-as vector (-> arg2 vector)) - (-> arg2 vector 1) - arg0 - ) + (let + ((f30-1 + (vector-segment-distance-point! + arg1 + (the-as vector (-> arg2 vector)) + (-> arg2 vector 1) + arg0 ) - (s3-1 (new 'stack-no-clear 'vector)) - ) - (if - (< - (vector-segment-distance-point! - arg1 - (the-as vector (-> arg2 vector)) - (-> arg2 vector 2) - s3-1 - ) - f30-1 - ) - (set! (-> arg0 quad) (-> s3-1 quad)) ) + (s3-1 (new 'stack-no-clear 'vector)) + ) + (if + (< + (vector-segment-distance-point! + arg1 + (the-as vector (-> arg2 vector)) + (-> arg2 vector 2) + s3-1 + ) + f30-1 + ) + (set! (-> arg0 quad) (-> s3-1 quad)) ) - (goto cfg-24) ) + (goto cfg-24) (label cfg-22) (let ((f30-2 @@ -971,32 +961,25 @@ ) ) ) - (else - (cond - ((and (< f1-7 f2-3) (< f3-1 f2-3)) - (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) - (set! (-> arg0 z) (+ 4096.0 (-> arg1 z))) - (set! - (-> arg0 y) - (/ - (- (- f0-3 (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 z) (-> arg0 z))) - (-> arg2 y) - ) - ) + ((and (< f1-7 f2-3) (< f3-1 f2-3)) + (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) + (set! (-> arg0 z) (+ 4096.0 (-> arg1 z))) + (set! + (-> arg0 y) + (/ + (- (- f0-3 (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 z) (-> arg0 z))) + (-> arg2 y) ) - (else - (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) - (set! (-> arg0 y) (+ 4096.0 (-> arg1 y))) - (set! - (-> arg0 z) - (/ - (+ - (- (- (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 y) (-> arg0 y))) - f0-3 - ) - (-> arg2 z) - ) - ) + ) + ) + (else + (set! (-> arg0 x) (+ 4096.0 (-> arg1 x))) + (set! (-> arg0 y) (+ 4096.0 (-> arg1 y))) + (set! + (-> arg0 z) + (/ + (+ (- (- (* (-> arg2 x) (-> arg0 x))) (* (-> arg2 y) (-> arg0 y))) f0-3) + (-> arg2 z) ) ) ) diff --git a/test/decompiler/reference/engine/geometry/vol-h_REF.gc b/test/decompiler/reference/engine/geometry/vol-h_REF.gc index 7e8d4909d8..99b83cdc3b 100644 --- a/test/decompiler/reference/engine/geometry/vol-h_REF.gc +++ b/test/decompiler/reference/engine/geometry/vol-h_REF.gc @@ -87,17 +87,15 @@ ) ) ) - (if (zero? (the-as vol-control gp-0)) - (begin - (let ((t9-1 (the-as (function object object) enter-state)) - (a0-1 "memory") - ) - (set! (-> pp next-state) process-drawable-art-error) - (t9-1 a0-1) - ) - (set! gp-0 0) - (goto cfg-13) + (when (zero? (the-as vol-control gp-0)) + (let ((t9-1 (the-as (function object object) enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + (t9-1 a0-1) ) + (set! gp-0 0) + (goto cfg-13) ) (set! (-> (the-as vol-control gp-0) process) arg0) (let* diff --git a/test/decompiler/reference/engine/gfx/hw/gs_REF.gc b/test/decompiler/reference/engine/gfx/hw/gs_REF.gc index bcd3da3df8..484fe36639 100644 --- a/test/decompiler/reference/engine/gfx/hw/gs_REF.gc +++ b/test/decompiler/reference/engine/gfx/hw/gs_REF.gc @@ -36,17 +36,16 @@ ((= arg0 (gs-psm mt4)) 32 ) - (else - (if - (or - (= arg0 (gs-psm ct16)) - (= arg0 (gs-psm ct16s)) - (= arg0 (gs-psm mz16)) - (= arg0 (gs-psm mz16s)) - ) - 128 - 256 + ((or + (= arg0 (gs-psm ct16)) + (= arg0 (gs-psm ct16s)) + (= arg0 (gs-psm mz16)) + (= arg0 (gs-psm mz16s)) ) + 128 + ) + (else + 256 ) ) ) @@ -60,17 +59,16 @@ ((= arg0 (gs-psm mt4)) 128 ) - (else - (if - (or - (= arg0 (gs-psm ct16)) - (= arg0 (gs-psm ct16s)) - (= arg0 (gs-psm mz16)) - (= arg0 (gs-psm mz16s)) - ) - 64 - 32 + ((or + (= arg0 (gs-psm ct16)) + (= arg0 (gs-psm ct16s)) + (= arg0 (gs-psm mz16)) + (= arg0 (gs-psm mz16s)) ) + 64 + ) + (else + 32 ) ) ) diff --git a/test/decompiler/reference/engine/gfx/texture_REF.gc b/test/decompiler/reference/engine/gfx/texture_REF.gc index c896bd8458..d452b79a17 100644 --- a/test/decompiler/reference/engine/gfx/texture_REF.gc +++ b/test/decompiler/reference/engine/gfx/texture_REF.gc @@ -51,26 +51,18 @@ ;; definition for function texture-bpp (defun texture-bpp ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (cond - ((= v1-0 (gs-psm mt8)) + (case arg0 + (((gs-psm mt8)) 8 ) - ((= v1-0 (gs-psm mt4)) - 4 - ) - (else - (if - (or - (= v1-0 (gs-psm ct16)) - (= v1-0 (gs-psm ct16s)) - (= v1-0 (gs-psm mz16)) - (= v1-0 (gs-psm mz16s)) - ) - 16 - 32 - ) - ) + (((gs-psm mt4)) + 4 + ) + (((gs-psm ct16) (gs-psm ct16s) (gs-psm mz16) (gs-psm mz16s)) + 16 + ) + (else + 32 ) ) ) @@ -569,107 +561,73 @@ ;; definition for function gs-page-width (defun gs-page-width ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (cond - ((or - (= v1-0 (gs-psm ct32)) - (= v1-0 (gs-psm ct24)) - (= v1-0 (gs-psm ct16)) - (= v1-0 (gs-psm ct16s)) - ) + (case arg0 + (((gs-psm ct32) (gs-psm ct24) (gs-psm ct16) (gs-psm ct16s)) 64 ) - (else - (cond - ((or (= v1-0 (gs-psm mt8)) (= v1-0 (gs-psm mt4))) - 128 - ) - (else - (format #t "Warning: Unknown block width for psm ~D~%" arg0) - 1 - ) - ) - ) + (((gs-psm mt8) (gs-psm mt4)) + 128 + ) + (else + (format #t "Warning: Unknown block width for psm ~D~%" arg0) + 1 ) ) ) ;; definition for function gs-page-height (defun gs-page-height ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (cond - ((or (= v1-0 (gs-psm ct32)) (= v1-0 (gs-psm ct24))) + (case arg0 + (((gs-psm ct32) (gs-psm ct24)) 32 ) - (else - (cond - ((or (= v1-0 (gs-psm ct16)) (= v1-0 (gs-psm ct16s))) - 64 - ) - ((= v1-0 (gs-psm mt8)) - 64 - ) - ((= v1-0 (gs-psm mt4)) - 128 - ) - (else - (format #t "Warning: Unknown block width for psm ~D~%" arg0) - 1 - ) - ) - ) + (((gs-psm ct16) (gs-psm ct16s)) + 64 + ) + (((gs-psm mt8)) + 64 + ) + (((gs-psm mt4)) + 128 + ) + (else + (format #t "Warning: Unknown block width for psm ~D~%" arg0) + 1 ) ) ) ;; definition for function gs-block-width (defun gs-block-width ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (cond - ((or (= v1-0 (gs-psm ct32)) (= v1-0 (gs-psm ct24))) + (case arg0 + (((gs-psm ct32) (gs-psm ct24)) 8 ) - (else - (cond - ((or (= v1-0 (gs-psm ct16)) (= v1-0 (gs-psm ct16s)) (= v1-0 (gs-psm mt8))) - 16 - ) - ((= v1-0 (gs-psm mt4)) - 32 - ) - (else - (format #t "Warning: Unknown block width for psm ~D~%" arg0) - 1 - ) - ) - ) + (((gs-psm ct16) (gs-psm ct16s) (gs-psm mt8)) + 16 + ) + (((gs-psm mt4)) + 32 + ) + (else + (format #t "Warning: Unknown block width for psm ~D~%" arg0) + 1 ) ) ) ;; definition for function gs-block-height (defun gs-block-height ((arg0 gs-psm)) - (let ((v1-0 arg0)) - (cond - ((or - (= v1-0 (gs-psm ct32)) - (= v1-0 (gs-psm ct24)) - (= v1-0 (gs-psm ct16)) - (= v1-0 (gs-psm ct16s)) - ) + (case arg0 + (((gs-psm ct32) (gs-psm ct24) (gs-psm ct16) (gs-psm ct16s)) 8 ) - (else - (cond - ((or (= v1-0 (gs-psm mt8)) (= v1-0 (gs-psm mt4))) - 16 - ) - (else - (format #t "Warning: Unknown block width for psm ~D~%" arg0) - 1 - ) - ) - ) + (((gs-psm mt8) (gs-psm mt4)) + 16 + ) + (else + (format #t "Warning: Unknown block width for psm ~D~%" arg0) + 1 ) ) ) @@ -742,75 +700,69 @@ ;; definition for method 22 of type texture-pool (defmethod lookup-boot-common-id texture-pool ((obj texture-pool) (tpage-id int)) - (let ((v1-0 tpage-id)) - (cond - ((= v1-0 1032) + (case tpage-id + ((1032) 0 ) - ((= v1-0 1119) - 1 - ) - ((= v1-0 1478) - 2 - ) - ((= v1-0 1485) - 3 - ) - ((= v1-0 1486) - 4 - ) - ((= v1-0 1487) - 5 - ) - (else - (cond - ((or (= v1-0 635) (= v1-0 1609)) - 6 - ) - ((= v1-0 636) - 7 - ) - ((= v1-0 637) - 8 - ) - ((= v1-0 752) - 9 - ) - ((= v1-0 1598) - 10 - ) - ((= v1-0 1599) - 11 - ) - ((= v1-0 1600) - 12 - ) - ((= v1-0 1601) - 13 - ) - ((= v1-0 1602) - 14 - ) - ((= v1-0 1603) - 15 - ) - ((= v1-0 1604) - 16 - ) - ((= v1-0 1605) - 17 - ) - ((= v1-0 1606) - 18 - ) - ((= v1-0 1607) - 19 - ) - (else - -1 - ) - ) - ) + ((1119) + 1 + ) + ((1478) + 2 + ) + ((1485) + 3 + ) + ((1486) + 4 + ) + ((1487) + 5 + ) + ((635 1609) + 6 + ) + ((636) + 7 + ) + ((637) + 8 + ) + ((752) + 9 + ) + ((1598) + 10 + ) + ((1599) + 11 + ) + ((1600) + 12 + ) + ((1601) + 13 + ) + ((1602) + 14 + ) + ((1603) + 15 + ) + ((1604) + 16 + ) + ((1605) + 17 + ) + ((1606) + 18 + ) + ((1607) + 19 + ) + (else + -1 ) ) ) @@ -1069,30 +1021,23 @@ (set! chunks-to-upload-count (+ chunks-to-upload-count 1)) ) ) - (else - (cond - ((= (-> pool ids current-dest-chunk) tex-id) - (upload-vram-data - dma-buf - (the-as - int - (* - (+ tex-dest-base-chunk (the-as uint first-chunk-idx-to-upload)) - 64 - ) - ) - (&+ tex-data (shl first-chunk-idx-to-upload 14)) - (* chunks-to-upload-count 32) - ) - (+! total-upload-size chunks-to-upload-count) - (set! chunks-to-upload-count 0) - 0 - ) - (else - (set! (-> pool ids current-dest-chunk) tex-id) - (set! chunks-to-upload-count (+ chunks-to-upload-count 1)) + ((= (-> pool ids current-dest-chunk) tex-id) + (upload-vram-data + dma-buf + (the-as + int + (* (+ tex-dest-base-chunk (the-as uint first-chunk-idx-to-upload)) 64) ) + (&+ tex-data (shl first-chunk-idx-to-upload 14)) + (* chunks-to-upload-count 32) ) + (+! total-upload-size chunks-to-upload-count) + (set! chunks-to-upload-count 0) + 0 + ) + (else + (set! (-> pool ids current-dest-chunk) tex-id) + (set! chunks-to-upload-count (+ chunks-to-upload-count 1)) ) ) ) @@ -1223,16 +1168,12 @@ (+! modified-chunk-count 1) ) ) + ((= (-> pool ids vram-chunk) page-id) + (set! modified-chunk-count 0) + ) (else - (cond - ((= (-> pool ids vram-chunk) page-id) - (set! modified-chunk-count 0) - ) - (else - (set! (-> pool ids vram-chunk) page-id) - (+! modified-chunk-count 1) - ) - ) + (set! (-> pool ids vram-chunk) page-id) + (+! modified-chunk-count 1) ) ) ) @@ -1297,30 +1238,23 @@ (set! chunks-to-upload-count (+ chunks-to-upload-count 1)) ) ) - (else - (cond - ((or (= (-> pool ids current-dest-chunk) page-id) (not allow-cached)) - (upload-vram-data - dma-buf - (the-as - int - (* - (+ tex-dest-base-chunk (the-as uint first-chunk-idx-to-upload)) - 64 - ) - ) - (&+ tex-data (shl first-chunk-idx-to-upload 14)) - (* chunks-to-upload-count 32) - ) - (+! total-upload-size chunks-to-upload-count) - (set! chunks-to-upload-count 0) - 0 - ) - (else - (set! (-> pool ids current-dest-chunk) page-id) - (set! chunks-to-upload-count (+ chunks-to-upload-count 1)) + ((or (= (-> pool ids current-dest-chunk) page-id) (not allow-cached)) + (upload-vram-data + dma-buf + (the-as + int + (* (+ tex-dest-base-chunk (the-as uint first-chunk-idx-to-upload)) 64) ) + (&+ tex-data (shl first-chunk-idx-to-upload 14)) + (* chunks-to-upload-count 32) ) + (+! total-upload-size chunks-to-upload-count) + (set! chunks-to-upload-count 0) + 0 + ) + (else + (set! (-> pool ids current-dest-chunk) page-id) + (set! chunks-to-upload-count (+ chunks-to-upload-count 1)) ) ) ) @@ -3103,11 +3037,9 @@ (local-vars (a0-2 int)) (let ((v1-0 *texture-page-dir*)) (dotimes (a0-1 (-> v1-0 length)) - (if (= arg0 (-> v1-0 entries a0-1 page)) - (begin - (set! a0-2 a0-1) - (goto cfg-7) - ) + (when (= arg0 (-> v1-0 entries a0-1 page)) + (set! a0-2 a0-1) + (goto cfg-7) ) ) (set! a0-2 -1) diff --git a/test/decompiler/reference/engine/math/trigonometry_REF.gc b/test/decompiler/reference/engine/math/trigonometry_REF.gc index 0467eb7cbe..42e3ba6637 100644 --- a/test/decompiler/reference/engine/math/trigonometry_REF.gc +++ b/test/decompiler/reference/engine/math/trigonometry_REF.gc @@ -540,32 +540,28 @@ ((= arg1 0.0) (* 1.5707963 (sign arg0)) ) + ((and (< arg0 0.0) (< arg1 0.0)) + (let ((f30-1 MINUS_PI) + (f0-6 (/ arg0 arg1)) + ) + (+ f30-1 (atan-series-rad (/ (+ -1.0 f0-6) (+ 1.0 f0-6)))) + ) + ) + ((< arg0 0.0) + (let ((f0-14 (- (/ arg0 arg1)))) + (- (atan-series-rad (/ (+ -1.0 f0-14) (+ 1.0 f0-14)))) + ) + ) + ((< arg1 0.0) + (let ((f30-2 PI) + (f0-22 (- (/ arg0 arg1))) + ) + (- f30-2 (atan-series-rad (/ (+ -1.0 f0-22) (+ 1.0 f0-22)))) + ) + ) (else - (cond - ((and (< arg0 0.0) (< arg1 0.0)) - (let ((f30-1 MINUS_PI) - (f0-6 (/ arg0 arg1)) - ) - (+ f30-1 (atan-series-rad (/ (+ -1.0 f0-6) (+ 1.0 f0-6)))) - ) - ) - ((< arg0 0.0) - (let ((f0-14 (- (/ arg0 arg1)))) - (- (atan-series-rad (/ (+ -1.0 f0-14) (+ 1.0 f0-14)))) - ) - ) - ((< arg1 0.0) - (let ((f30-2 PI) - (f0-22 (- (/ arg0 arg1))) - ) - (- f30-2 (atan-series-rad (/ (+ -1.0 f0-22) (+ 1.0 f0-22)))) - ) - ) - (else - (let ((f0-28 (/ arg0 arg1))) - (atan-series-rad (/ (+ -1.0 f0-28) (+ 1.0 f0-28))) - ) - ) + (let ((f0-28 (/ arg0 arg1))) + (atan-series-rad (/ (+ -1.0 f0-28) (+ 1.0 f0-28))) ) ) ) @@ -666,21 +662,17 @@ ((and (= arg1 0.0) (= arg0 0.0)) 0.0 ) + ((and (< arg1 0.0) (< arg0 0.0)) + (+ -32768.0 (atan0 (- arg0) (- arg1))) + ) + ((< arg0 0.0) + (- (atan0 (- arg0) arg1)) + ) + ((< arg1 0.0) + (- 32768.0 (atan0 arg0 (- arg1))) + ) (else - (cond - ((and (< arg1 0.0) (< arg0 0.0)) - (+ -32768.0 (atan0 (- arg0) (- arg1))) - ) - ((< arg0 0.0) - (- (atan0 (- arg0) arg1)) - ) - ((< arg1 0.0) - (- 32768.0 (atan0 arg0 (- arg1))) - ) - (else - (atan0 arg0 arg1) - ) - ) + (atan0 arg0 arg1) ) ) ) diff --git a/test/decompiler/reference/engine/nav/navigate-h_REF.gc b/test/decompiler/reference/engine/nav/navigate-h_REF.gc index 6a2109816f..5f7eea4ada 100644 --- a/test/decompiler/reference/engine/nav/navigate-h_REF.gc +++ b/test/decompiler/reference/engine/nav/navigate-h_REF.gc @@ -558,17 +558,15 @@ ) ) ) - (if (zero? obj) - (begin - (let ((t9-1 (the-as function enter-state)) - (a0-1 "memory") - ) - (set! (-> pp next-state) process-drawable-art-error) - ((the-as (function string none) t9-1) a0-1) - ) - (set! obj (the-as nav-control 0)) - (goto cfg-4) + (when (zero? obj) + (let ((t9-1 (the-as function enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + ((the-as (function string none) t9-1) a0-1) ) + (set! obj (the-as nav-control 0)) + (goto cfg-4) ) (set! (-> obj max-spheres) sphere-count) (set! (-> obj flags) (nav-control-flags bit8 bit13)) diff --git a/test/decompiler/reference/engine/nav/path-h_REF.gc b/test/decompiler/reference/engine/nav/path-h_REF.gc index 65b2e517f5..5210d2736b 100644 --- a/test/decompiler/reference/engine/nav/path-h_REF.gc +++ b/test/decompiler/reference/engine/nav/path-h_REF.gc @@ -84,17 +84,15 @@ (object-new allocation type-to-make (the-as int (-> type-to-make size))) ) ) - (if (zero? obj) - (begin - (let ((t9-1 (the-as function enter-state)) - (a0-1 "memory") - ) - (set! (-> pp next-state) process-drawable-art-error) - ((the-as (function string none) t9-1) a0-1) - ) - (set! obj (the-as path-control 0)) - (goto cfg-9) + (when (zero? obj) + (let ((t9-1 (the-as function enter-state)) + (a0-1 "memory") + ) + (set! (-> pp next-state) process-drawable-art-error) + ((the-as (function string none) t9-1) a0-1) ) + (set! obj (the-as path-control 0)) + (goto cfg-9) ) (set! (-> obj process) (the-as process-drawable proc)) (set! (-> obj name) name) diff --git a/test/decompiler/reference/engine/nav/path_REF.gc b/test/decompiler/reference/engine/nav/path_REF.gc index 24b5c00320..d92cee38b1 100644 --- a/test/decompiler/reference/engine/nav/path_REF.gc +++ b/test/decompiler/reference/engine/nav/path_REF.gc @@ -126,15 +126,15 @@ ((>= f0-3 (the float (+ a1-1 -1))) (set! (-> arg0 quad) (-> obj cverts (+ a1-1 -1) quad)) ) + ((or (= arg2 'exact) (= f0-3 arg1)) + (set! (-> arg0 quad) (-> obj cverts (the int f0-3) quad)) + ) (else - (if (or (= arg2 'exact) (= f0-3 arg1)) - (set! (-> arg0 quad) (-> obj cverts (the int f0-3) quad)) - (vector-lerp! - arg0 - (-> obj cverts (the int f0-3)) - (-> obj cverts (the int (+ 1.0 f0-3))) - (- arg1 f0-3) - ) + (vector-lerp! + arg0 + (-> obj cverts (the int f0-3)) + (-> obj cverts (the int (+ 1.0 f0-3))) + (- arg1 f0-3) ) ) ) @@ -457,7 +457,3 @@ 0 (none) ) - - - - diff --git a/test/decompiler/reference/engine/target/surface-h_REF.gc b/test/decompiler/reference/engine/target/surface-h_REF.gc index 6b60a59225..353425a313 100644 --- a/test/decompiler/reference/engine/target/surface-h_REF.gc +++ b/test/decompiler/reference/engine/target/surface-h_REF.gc @@ -138,15 +138,14 @@ ) (-> src1 hook v1-3) ) - (else - (if - (and - (nonzero? (-> src0 hook v1-3)) - (!= (-> src0 hook v1-3) nothing) - ) - (-> src0 hook v1-3) - nothing + ((and + (nonzero? (-> src0 hook v1-3)) + (!= (-> src0 hook v1-3) nothing) ) + (-> src0 hook v1-3) + ) + (else + nothing ) ) ) @@ -170,15 +169,14 @@ ) (-> src1 hook v1-3) ) - (else - (if - (and - (nonzero? (-> src0 hook v1-3)) - (!= (-> src0 hook v1-3) nothing) - ) - (-> src0 hook v1-3) - nothing + ((and + (nonzero? (-> src0 hook v1-3)) + (!= (-> src0 hook v1-3) nothing) ) + (-> src0 hook v1-3) + ) + (else + nothing ) ) ) diff --git a/test/decompiler/reference/kernel/gcommon_REF.gc b/test/decompiler/reference/kernel/gcommon_REF.gc index db39a64e7a..0738b17965 100644 --- a/test/decompiler/reference/kernel/gcommon_REF.gc +++ b/test/decompiler/reference/kernel/gcommon_REF.gc @@ -562,9 +562,8 @@ (format #t "#(") (cond ((type-type? (-> obj content-type) integer) - (let ((content-type-sym (-> obj content-type symbol))) - (cond - ((= content-type-sym 'int32) + (case (-> obj content-type symbol) + (('int32) (dotimes (s5-0 (-> obj length)) (format #t (if (zero? s5-0) "~D" @@ -574,120 +573,111 @@ ) ) ) - ((= content-type-sym 'uint32) - (dotimes (s5-1 (-> obj length)) - (format #t (if (zero? s5-1) - "~D" - " ~D" - ) - (-> (the-as (array uint32) obj) s5-1) - ) + (('uint32) + (dotimes (s5-1 (-> obj length)) + (format #t (if (zero? s5-1) + "~D" + " ~D" + ) + (-> (the-as (array uint32) obj) s5-1) ) ) - ((= content-type-sym 'int64) - (dotimes (s5-2 (-> obj length)) - (format #t (if (zero? s5-2) - "~D" - " ~D" - ) - (-> (the-as (array int64) obj) s5-2) - ) + ) + (('int64) + (dotimes (s5-2 (-> obj length)) + (format #t (if (zero? s5-2) + "~D" + " ~D" + ) + (-> (the-as (array int64) obj) s5-2) ) ) - ((= content-type-sym 'uint64) - (dotimes (s5-3 (-> obj length)) - (format #t (if (zero? s5-3) - "#x~X" - " #x~X" - ) - (-> (the-as (array uint64) obj) s5-3) - ) + ) + (('uint64) + (dotimes (s5-3 (-> obj length)) + (format #t (if (zero? s5-3) + "#x~X" + " #x~X" + ) + (-> (the-as (array uint64) obj) s5-3) ) ) - ((= content-type-sym 'int8) - (dotimes (s5-4 (-> obj length)) - (format #t (if (zero? s5-4) - "~D" - " ~D" - ) - (-> (the-as (array int8) obj) s5-4) - ) + ) + (('int8) + (dotimes (s5-4 (-> obj length)) + (format #t (if (zero? s5-4) + "~D" + " ~D" + ) + (-> (the-as (array int8) obj) s5-4) ) ) - ((= content-type-sym 'uint8) - (dotimes (s5-5 (-> obj length)) - (format #t (if (zero? s5-5) - "~D" - " ~D" - ) - (-> (the-as (array uint8) obj) s5-5) - ) + ) + (('uint8) + (dotimes (s5-5 (-> obj length)) + (format #t (if (zero? s5-5) + "~D" + " ~D" + ) + (-> (the-as (array uint8) obj) s5-5) ) ) - ((= content-type-sym 'int16) - (dotimes (s5-6 (-> obj length)) - (format #t (if (zero? s5-6) - "~D" - " ~D" - ) - (-> (the-as (array int16) obj) s5-6) - ) + ) + (('int16) + (dotimes (s5-6 (-> obj length)) + (format #t (if (zero? s5-6) + "~D" + " ~D" + ) + (-> (the-as (array int16) obj) s5-6) ) ) - ((= content-type-sym 'uint16) - (dotimes (s5-7 (-> obj length)) - (format #t (if (zero? s5-7) - "~D" - " ~D" - ) - (-> (the-as (array uint16) obj) s5-7) - ) + ) + (('uint16) + (dotimes (s5-7 (-> obj length)) + (format #t (if (zero? s5-7) + "~D" + " ~D" + ) + (-> (the-as (array uint16) obj) s5-7) ) ) - (else - (cond - ((or (= content-type-sym 'uint128) (= content-type-sym 'int128)) - (dotimes (s5-8 (-> obj length)) - (format #t (if (zero? s5-8) - "#x~X" - " #x~X" - ) - (-> (the-as (array uint128) obj) s5-8) - ) - ) - ) - (else - (dotimes (s5-9 (-> obj length)) - (format #t (if (zero? s5-9) - "~D" - " ~D" - ) - (-> (the-as (array int32) obj) s5-9) - ) - ) - ) + ) + (('uint128 'int128) + (dotimes (s5-8 (-> obj length)) + (format #t (if (zero? s5-8) + "#x~X" + " #x~X" + ) + (-> (the-as (array uint128) obj) s5-8) + ) + ) + ) + (else + (dotimes (s5-9 (-> obj length)) + (format #t (if (zero? s5-9) + "~D" + " ~D" + ) + (-> (the-as (array int32) obj) s5-9) ) ) ) ) ) - (else - (cond - ((= (-> obj content-type) float) - (dotimes (s5-10 (-> obj length)) - (if (zero? s5-10) - (format #t "~f" (-> (the-as (array float) obj) s5-10)) - (format #t " ~f" (-> (the-as (array float) obj) s5-10)) - ) - ) + ((= (-> obj content-type) float) + (dotimes (s5-10 (-> obj length)) + (if (zero? s5-10) + (format #t "~f" (-> (the-as (array float) obj) s5-10)) + (format #t " ~f" (-> (the-as (array float) obj) s5-10)) ) - (else - (dotimes (s5-11 (-> obj length)) - (if (zero? s5-11) - (format #t "~A" (-> (the-as (array basic) obj) s5-11)) - (format #t " ~A" (-> (the-as (array basic) obj) s5-11)) - ) - ) + ) + ) + (else + (dotimes (s5-11 (-> obj length)) + (if (zero? s5-11) + (format #t "~A" (-> (the-as (array basic) obj) s5-11)) + (format #t " ~A" (-> (the-as (array basic) obj) s5-11)) ) ) ) @@ -706,82 +696,67 @@ (format #t "~Tdata[~D]: @ #x~X~%" (-> obj allocated-length) (-> obj data)) (cond ((type-type? (-> obj content-type) integer) - (let ((content-type-sym (-> obj content-type symbol))) - (cond - ((= content-type-sym 'int32) + (case (-> obj content-type symbol) + (('int32) (dotimes (s5-0 (-> obj length)) (format #t "~T [~D] ~D~%" s5-0 (-> (the-as (array int32) obj) s5-0)) ) ) - ((= content-type-sym 'uint32) - (dotimes (s5-1 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-1 (-> (the-as (array uint32) obj) s5-1)) - ) + (('uint32) + (dotimes (s5-1 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-1 (-> (the-as (array uint32) obj) s5-1)) ) - ((= content-type-sym 'int64) - (dotimes (s5-2 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-2 (-> (the-as (array int64) obj) s5-2)) - ) + ) + (('int64) + (dotimes (s5-2 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-2 (-> (the-as (array int64) obj) s5-2)) ) - ((= content-type-sym 'uint64) - (dotimes (s5-3 (-> obj length)) - (format #t "~T [~D] #x~X~%" s5-3 (-> (the-as (array uint64) obj) s5-3)) - ) + ) + (('uint64) + (dotimes (s5-3 (-> obj length)) + (format #t "~T [~D] #x~X~%" s5-3 (-> (the-as (array uint64) obj) s5-3)) ) - ((= content-type-sym 'int8) - (dotimes (s5-4 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-4 (-> (the-as (array int8) obj) s5-4)) - ) + ) + (('int8) + (dotimes (s5-4 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-4 (-> (the-as (array int8) obj) s5-4)) ) - ((= content-type-sym 'uint8) - (dotimes (s5-5 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-5 (-> (the-as (array int8) obj) s5-5)) - ) + ) + (('uint8) + (dotimes (s5-5 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-5 (-> (the-as (array int8) obj) s5-5)) ) - ((= content-type-sym 'int16) - (dotimes (s5-6 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-6 (-> (the-as (array int16) obj) s5-6)) - ) + ) + (('int16) + (dotimes (s5-6 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-6 (-> (the-as (array int16) obj) s5-6)) ) - ((= content-type-sym 'uint16) - (dotimes (s5-7 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-7 (-> (the-as (array uint16) obj) s5-7)) - ) + ) + (('uint16) + (dotimes (s5-7 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-7 (-> (the-as (array uint16) obj) s5-7)) ) - (else - (cond - ((or (= content-type-sym 'int128) (= content-type-sym 'uint128)) - (dotimes (s5-8 (-> obj length)) - (format - #t - "~T [~D] #x~X~%" - s5-8 - (-> (the-as (array uint128) obj) s5-8) - ) - ) - ) - (else - (dotimes (s5-9 (-> obj length)) - (format #t "~T [~D] ~D~%" s5-9 (-> (the-as (array int32) obj) s5-9)) - ) - ) - ) + ) + (('int128 'uint128) + (dotimes (s5-8 (-> obj length)) + (format #t "~T [~D] #x~X~%" s5-8 (-> (the-as (array uint128) obj) s5-8)) + ) + ) + (else + (dotimes (s5-9 (-> obj length)) + (format #t "~T [~D] ~D~%" s5-9 (-> (the-as (array int32) obj) s5-9)) ) ) ) ) + ((= (-> obj content-type) float) + (dotimes (s5-10 (-> obj length)) + (format #t "~T [~D] ~f~%" s5-10 (-> (the-as (array float) obj) s5-10)) + ) + ) (else - (cond - ((= (-> obj content-type) float) - (dotimes (s5-10 (-> obj length)) - (format #t "~T [~D] ~f~%" s5-10 (-> (the-as (array float) obj) s5-10)) - ) - ) - (else - (dotimes (s5-11 (-> obj length)) - (format #t "~T [~D] ~A~%" s5-11 (-> (the-as (array basic) obj) s5-11)) - ) - ) + (dotimes (s5-11 (-> obj length)) + (format #t "~T [~D] ~A~%" s5-11 (-> (the-as (array basic) obj) s5-11)) ) ) ) @@ -1021,96 +996,46 @@ ((and allow-false (not obj)) #t ) - (else + ((= expected-type structure) (cond - ((= expected-type structure) - (cond - ((nonzero? (logand (the-as int obj) 15)) - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" - obj - name - expected-type - ) - ) - #f - ) - ((or (not in-goal-mem) (begin - (let ((v1-10 #x8000)) - (.daddu v1-11 v1-10 s7-0) - ) - (< (the-as uint obj) (the-as uint v1-11)) - ) - ) - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%" - obj - name - expected-type - ) - ) - #f - ) - (else - #t + ((nonzero? (logand (the-as int obj) 15)) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" + obj + name + expected-type ) ) + #f ) - ((= expected-type pair) - (cond - ((!= (logand (the-as int obj) 7) 2) - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" - obj - name - expected-type - ) - ) - #f - ) - ((not in-goal-mem) - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%" - obj - name - expected-type - ) - ) - #f - ) - (else - #t + ((or (not in-goal-mem) (begin + (let ((v1-10 #x8000)) + (.daddu v1-11 v1-10 s7-0) + ) + (< (the-as uint obj) (the-as uint v1-11)) + ) + ) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%" + obj + name + expected-type ) ) + #f ) - ((= expected-type binteger) - (cond - ((zero? (logand (the-as int obj) 7)) - #t - ) - (else - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" - obj - name - expected-type - ) - ) - #f - ) - ) + (else + #t ) - ((!= (logand (the-as int obj) 7) 4) + ) + ) + ((= expected-type pair) + (cond + ((!= (logand (the-as int obj) 7) 2) (if name (format print-dest @@ -1134,96 +1059,135 @@ ) #f ) - ((and (= expected-type type) (!= (rtype-of obj) type)) + (else + #t + ) + ) + ) + ((= expected-type binteger) + (cond + ((zero? (logand (the-as int obj) 7)) + #t + ) + (else (if name (format print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%" + "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" + obj + name + expected-type + ) + ) + #f + ) + ) + ) + ((!= (logand (the-as int obj) 7) 4) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%" + obj + name + expected-type + ) + ) + #f + ) + ((not in-goal-mem) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%" + obj + name + expected-type + ) + ) + #f + ) + ((and (= expected-type type) (!= (rtype-of obj) type)) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%" + obj + name + expected-type + (rtype-of obj) + ) + ) + #f + ) + ((and (!= expected-type type) (not (valid? (rtype-of obj) type #f #t 0))) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%" + obj + name + expected-type + (rtype-of obj) + ) + ) + #f + ) + ((not (type-type? (rtype-of obj) expected-type)) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (is type '~A' instead)~%" + obj + name + expected-type + (rtype-of obj) + ) + ) + #f + ) + ((= expected-type symbol) + (let ((v1-43 #x8000)) + (.daddu v1-44 v1-43 s7-0) + ) + (cond + ((>= (the-as uint obj) (the-as uint v1-44)) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (not in symbol table)~%" obj name expected-type - (rtype-of obj) ) ) #f ) (else - (cond - ((and - (!= expected-type type) - (not (valid? (rtype-of obj) type #f #t 0)) - ) - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%" - obj - name - expected-type - (rtype-of obj) - ) - ) - #f - ) - ((not (type-type? (rtype-of obj) expected-type)) - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (is type '~A' instead)~%" - obj - name - expected-type - (rtype-of obj) - ) - ) - #f - ) - ((= expected-type symbol) - (let ((v1-43 #x8000)) - (.daddu v1-44 v1-43 s7-0) - ) - (cond - ((>= (the-as uint obj) (the-as uint v1-44)) - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (not in symbol table)~%" - obj - name - expected-type - ) - ) - #f - ) - (else - #t - ) - ) - ) - ((begin - (let ((v1-47 #x8000)) - (.daddu v1-48 v1-47 s7-0) - ) - (< (the-as uint obj) (the-as uint v1-48)) - ) - (if name - (format - print-dest - "ERROR: object #x~X ~S is not a valid object of type '~A' (inside symbol table)~%" - obj - name - expected-type - ) - ) - #f - ) - (else - #t - ) - ) + #t ) ) ) + ((begin + (let ((v1-47 #x8000)) + (.daddu v1-48 v1-47 s7-0) + ) + (< (the-as uint obj) (the-as uint v1-48)) + ) + (if name + (format + print-dest + "ERROR: object #x~X ~S is not a valid object of type '~A' (inside symbol table)~%" + obj + name + expected-type + ) + ) + #f + ) + (else + #t + ) ) ) ) diff --git a/test/decompiler/reference/kernel/gkernel_REF.gc b/test/decompiler/reference/kernel/gkernel_REF.gc index cdb2dc810e..5c97fd1cb3 100644 --- a/test/decompiler/reference/kernel/gkernel_REF.gc +++ b/test/decompiler/reference/kernel/gkernel_REF.gc @@ -722,15 +722,15 @@ ) ) ) - (else - (if (-> arg0 next) - (&- - (the-as pointer (-> arg0 next process)) - (the-as uint (&+ (-> obj heap base) 4)) - ) - (&- (-> obj heap top) (the-as uint (-> obj heap base))) + ((-> arg0 next) + (&- + (the-as pointer (-> arg0 next process)) + (the-as uint (&+ (-> obj heap base) 4)) ) ) + (else + (&- (-> obj heap top) (the-as uint (-> obj heap base))) + ) ) ) @@ -1641,11 +1641,11 @@ ((or (not a3-1) (not v1-4)) (return 0) ) + ((= a3-1 a2-1) + (set! (-> a3-1 4) (the-as process-tree (-> arg0 brother))) + ) (else - (if (= a3-1 a2-1) - (set! (-> a3-1 4) (the-as process-tree (-> arg0 brother))) - (set! (-> a3-1 3) (the-as process-tree (-> arg0 brother))) - ) + (set! (-> a3-1 3) (the-as process-tree (-> arg0 brother))) ) ) (cond diff --git a/test/decompiler/reference/kernel/gstring_REF.gc b/test/decompiler/reference/kernel/gstring_REF.gc index 4b7e5a9891..166efc62e0 100644 --- a/test/decompiler/reference/kernel/gstring_REF.gc +++ b/test/decompiler/reference/kernel/gstring_REF.gc @@ -540,25 +540,24 @@ ) ) ) + ((and + (>= (-> next-char-2 0) (the-as uint 97)) + (>= (the-as uint 102) (-> next-char-2 0)) + ) + (set! + result + (the-as + int + (+ (+ (-> next-char-2 0) -87) (the-as uint (* result 16))) + ) + ) + ) (else - (if - (and - (>= (-> next-char-2 0) (the-as uint 97)) - (>= (the-as uint 102) (-> next-char-2 0)) - ) - (set! - result - (the-as - int - (+ (+ (-> next-char-2 0) -87) (the-as uint (* result 16))) - ) - ) - (set! - result - (the-as - int - (+ (+ (-> next-char-2 0) -48) (the-as uint (* result 16))) - ) + (set! + result + (the-as + int + (+ (+ (-> next-char-2 0) -48) (the-as uint (* result 16))) ) ) ) diff --git a/test/decompiler/test_FormExpressionBuildLong.cpp b/test/decompiler/test_FormExpressionBuildLong.cpp index b116a91fdf..e5ee5a82ae 100644 --- a/test/decompiler/test_FormExpressionBuildLong.cpp +++ b/test/decompiler/test_FormExpressionBuildLong.cpp @@ -541,9 +541,8 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) { " (format #t \"#(\")\n" " (cond\n" " ((type-type? (-> arg0 content-type) integer)\n" - " (let ((v1-1 (-> arg0 content-type symbol)))\n" - " (cond\n" - " ((= v1-1 (quote int32))\n" + " (case (-> arg0 content-type symbol) \n" + " (('int32)\n" " (dotimes (s5-0 (-> arg0 length))\n" " (format #t (if (zero? s5-0)\n" " \"~D\"\n" @@ -553,120 +552,111 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) { " )\n" " )\n" " )\n" - " ((= v1-1 (quote uint32))\n" - " (dotimes (s5-1 (-> arg0 length))\n" - " (format #t (if (zero? s5-1)\n" - " \"~D\"\n" - " \" ~D\"\n" - " )\n" - " (-> (the-as (array uint32) arg0) s5-1)\n" - " )\n" + " (('uint32)\n" + " (dotimes (s5-1 (-> arg0 length))\n" + " (format #t (if (zero? s5-1)\n" + " \"~D\"\n" + " \" ~D\"\n" + " )\n" + " (-> (the-as (array uint32) arg0) s5-1)\n" " )\n" " )\n" - " ((= v1-1 (quote int64))\n" - " (dotimes (s5-2 (-> arg0 length))\n" - " (format #t (if (zero? s5-2)\n" - " \"~D\"\n" - " \" ~D\"\n" - " )\n" - " (-> (the-as (array int64) arg0) s5-2)\n" - " )\n" + " )\n" + " (('int64)\n" + " (dotimes (s5-2 (-> arg0 length))\n" + " (format #t (if (zero? s5-2)\n" + " \"~D\"\n" + " \" ~D\"\n" + " )\n" + " (-> (the-as (array int64) arg0) s5-2)\n" " )\n" " )\n" - " ((= v1-1 (quote uint64))\n" - " (dotimes (s5-3 (-> arg0 length))\n" - " (format #t (if (zero? s5-3)\n" - " \"#x~X\"\n" - " \" #x~X\"\n" - " )\n" - " (-> (the-as (array uint64) arg0) s5-3)\n" - " )\n" + " )\n" + " (('uint64)\n" + " (dotimes (s5-3 (-> arg0 length))\n" + " (format #t (if (zero? s5-3)\n" + " \"#x~X\"\n" + " \" #x~X\"\n" + " )\n" + " (-> (the-as (array uint64) arg0) s5-3)\n" " )\n" " )\n" - " ((= v1-1 (quote int8))\n" - " (dotimes (s5-4 (-> arg0 length))\n" - " (format #t (if (zero? s5-4)\n" - " \"~D\"\n" - " \" ~D\"\n" - " )\n" - " (-> (the-as (array int8) arg0) s5-4)\n" - " )\n" + " )\n" + " (('int8)\n" + " (dotimes (s5-4 (-> arg0 length))\n" + " (format #t (if (zero? s5-4)\n" + " \"~D\"\n" + " \" ~D\"\n" + " )\n" + " (-> (the-as (array int8) arg0) s5-4)\n" " )\n" " )\n" - " ((= v1-1 (quote uint8))\n" - " (dotimes (s5-5 (-> arg0 length))\n" - " (format #t (if (zero? s5-5)\n" - " \"~D\"\n" - " \" ~D\"\n" - " )\n" - " (-> (the-as (array uint8) arg0) s5-5)\n" - " )\n" + " )\n" + " (('uint8)\n" + " (dotimes (s5-5 (-> arg0 length))\n" + " (format #t (if (zero? s5-5)\n" + " \"~D\"\n" + " \" ~D\"\n" + " )\n" + " (-> (the-as (array uint8) arg0) s5-5)\n" " )\n" " )\n" - " ((= v1-1 (quote int16))\n" - " (dotimes (s5-6 (-> arg0 length))\n" - " (format #t (if (zero? s5-6)\n" - " \"~D\"\n" - " \" ~D\"\n" - " )\n" - " (-> (the-as (array int16) arg0) s5-6)\n" - " )\n" + " )\n" + " (('int16)\n" + " (dotimes (s5-6 (-> arg0 length))\n" + " (format #t (if (zero? s5-6)\n" + " \"~D\"\n" + " \" ~D\"\n" + " )\n" + " (-> (the-as (array int16) arg0) s5-6)\n" " )\n" " )\n" - " ((= v1-1 (quote uint16))\n" - " (dotimes (s5-7 (-> arg0 length))\n" - " (format #t (if (zero? s5-7)\n" - " \"~D\"\n" - " \" ~D\"\n" - " )\n" - " (-> (the-as (array uint16) arg0) s5-7)\n" - " )\n" + " )\n" + " (('uint16)\n" + " (dotimes (s5-7 (-> arg0 length))\n" + " (format #t (if (zero? s5-7)\n" + " \"~D\"\n" + " \" ~D\"\n" + " )\n" + " (-> (the-as (array uint16) arg0) s5-7)\n" " )\n" " )\n" - " (else\n" - " (cond\n" - " ((or (= v1-1 (quote uint128)) (= v1-1 (quote int128)))\n" - " (dotimes (s5-8 (-> arg0 length))\n" - " (format #t (if (zero? s5-8)\n" - " \"#x~X\"\n" - " \" #x~X\"\n" - " )\n" - " (-> (the-as (array uint128) arg0) s5-8)\n" - " )\n" - " )\n" - " )\n" - " (else\n" - " (dotimes (s5-9 (-> arg0 length))\n" - " (format #t (if (zero? s5-9)\n" - " \"~D\"\n" - " \" ~D\"\n" - " )\n" - " (-> (the-as (array int32) arg0) s5-9)\n" - " )\n" - " )\n" - " )\n" + " )\n" + " (('uint128 'int128)\n" + " (dotimes (s5-8 (-> arg0 length))\n" + " (format #t (if (zero? s5-8)\n" + " \"#x~X\"\n" + " \" #x~X\"\n" + " )\n" + " (-> (the-as (array uint128) arg0) s5-8)\n" + " )\n" + " )\n" + " )\n" + " (else\n" + " (dotimes (s5-9 (-> arg0 length))\n" + " (format #t (if (zero? s5-9)\n" + " \"~D\"\n" + " \" ~D\"\n" + " )\n" + " (-> (the-as (array int32) arg0) s5-9)\n" " )\n" " )\n" " )\n" " )\n" " )\n" - " (else\n" - " (cond\n" - " ((= (-> arg0 content-type) float)\n" - " (dotimes (s5-10 (-> arg0 length))\n" - " (if (zero? s5-10)\n" - " (format #t \"~f\" (-> (the-as (array float) arg0) s5-10))\n" - " (format #t \" ~f\" (-> (the-as (array float) arg0) s5-10))\n" - " )\n" - " )\n" + " ((= (-> arg0 content-type) float)\n" + " (dotimes (s5-10 (-> arg0 length))\n" + " (if (zero? s5-10)\n" + " (format #t \"~f\" (-> (the-as (array float) arg0) s5-10))\n" + " (format #t \" ~f\" (-> (the-as (array float) arg0) s5-10))\n" " )\n" - " (else\n" - " (dotimes (s5-11 (-> arg0 length))\n" - " (if (zero? s5-11)\n" - " (format #t \"~A\" (-> (the-as (array basic) arg0) s5-11))\n" - " (format #t \" ~A\" (-> (the-as (array basic) arg0) s5-11))\n" - " )\n" - " )\n" + " )\n" + " )\n" + " (else\n" + " (dotimes (s5-11 (-> arg0 length))\n" + " (if (zero? s5-11)\n" + " (format #t \"~A\" (-> (the-as (array basic) arg0) s5-11))\n" + " (format #t \" ~A\" (-> (the-as (array basic) arg0) s5-11))\n" " )\n" " )\n" " )\n" @@ -1164,87 +1154,72 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) { " (format #t \"~Tdata[~D]: @ #x~X~%\" (-> arg0 allocated-length) (-> arg0 data))\n" " (cond\n" " ((type-type? (-> arg0 content-type) integer)\n" - " (let ((v1-1 (-> arg0 content-type symbol)))\n" - " (cond\n" - " ((= v1-1 (quote int32))\n" + " (case (-> arg0 content-type symbol) \n" + " (('int32)\n" " (dotimes (s5-0 (-> arg0 length))\n" " (format #t \"~T [~D] ~D~%\" s5-0 (-> (the-as (array int32) arg0) s5-0))\n" " )\n" " )\n" - " ((= v1-1 (quote uint32))\n" - " (dotimes (s5-1 (-> arg0 length))\n" - " (format #t \"~T [~D] ~D~%\" s5-1 (-> (the-as (array uint32) arg0) s5-1))\n" + " (('uint32)\n" + " (dotimes (s5-1 (-> arg0 length))\n" + " (format #t \"~T [~D] ~D~%\" s5-1 (-> (the-as (array uint32) arg0) s5-1))\n" + " )\n" + " )\n" + " (('int64)\n" + " (dotimes (s5-2 (-> arg0 length))\n" + " (format #t \"~T [~D] ~D~%\" s5-2 (-> (the-as (array int64) arg0) s5-2))\n" + " )\n" + " )\n" + " (('uint64)\n" + " (dotimes (s5-3 (-> arg0 length))\n" + " (format #t \"~T [~D] #x~X~%\" s5-3 (-> (the-as (array uint64) arg0) s5-3))\n" + " )\n" + " )\n" + " (('int8)\n" + " (dotimes (s5-4 (-> arg0 length))\n" + " (format #t \"~T [~D] ~D~%\" s5-4 (-> (the-as (array int8) arg0) s5-4))\n" + " )\n" + " )\n" + " (('uint8)\n" + " (dotimes (s5-5 (-> arg0 length))\n" + " (format #t \"~T [~D] ~D~%\" s5-5 (-> (the-as (array int8) arg0) s5-5))\n" + " )\n" + " )\n" + " (('int16)\n" + " (dotimes (s5-6 (-> arg0 length))\n" + " (format #t \"~T [~D] ~D~%\" s5-6 (-> (the-as (array int16) arg0) s5-6))\n" + " )\n" + " )\n" + " (('uint16)\n" + " (dotimes (s5-7 (-> arg0 length))\n" + " (format #t \"~T [~D] ~D~%\" s5-7 (-> (the-as (array uint16) arg0) s5-7))\n" + " )\n" + " )\n" + " (('int128 'uint128)\n" + " (dotimes (s5-8 (-> arg0 length))\n" + " (format\n" + " #t\n" + " \"~T [~D] #x~X~%\"\n" + " s5-8\n" + " (-> (the-as (array uint128) arg0) s5-8)\n" " )\n" " )\n" - " ((= v1-1 (quote int64))\n" - " (dotimes (s5-2 (-> arg0 length))\n" - " (format #t \"~T [~D] ~D~%\" s5-2 (-> (the-as (array int64) arg0) s5-2))\n" - " )\n" - " )\n" - " ((= v1-1 (quote uint64))\n" - " (dotimes (s5-3 (-> arg0 length))\n" - " (format\n" - " #t\n" - " \"~T [~D] #x~X~%\"\n" - " s5-3\n" - " (-> (the-as (array uint64) arg0) s5-3)\n" - " )\n" - " )\n" - " )\n" - " ((= v1-1 (quote int8))\n" - " (dotimes (s5-4 (-> arg0 length))\n" - " (format #t \"~T [~D] ~D~%\" s5-4 (-> (the-as (array int8) arg0) s5-4))\n" - " )\n" - " )\n" - " ((= v1-1 (quote uint8))\n" - " (dotimes (s5-5 (-> arg0 length))\n" - " (format #t \"~T [~D] ~D~%\" s5-5 (-> (the-as (array int8) arg0) s5-5))\n" - " )\n" - " )\n" - " ((= v1-1 (quote int16))\n" - " (dotimes (s5-6 (-> arg0 length))\n" - " (format #t \"~T [~D] ~D~%\" s5-6 (-> (the-as (array int16) arg0) s5-6))\n" - " )\n" - " )\n" - " ((= v1-1 (quote uint16))\n" - " (dotimes (s5-7 (-> arg0 length))\n" - " (format #t \"~T [~D] ~D~%\" s5-7 (-> (the-as (array uint16) arg0) s5-7))\n" - " )\n" - " )\n" - " (else\n" - " (cond\n" - " ((or (= v1-1 (quote int128)) (= v1-1 (quote uint128)))\n" - " (dotimes (s5-8 (-> arg0 length))\n" - " (format\n" - " #t\n" - " \"~T [~D] #x~X~%\"\n" - " s5-8\n" - " (-> (the-as (array uint128) arg0) s5-8)\n" - " )\n" - " )\n" - " )\n" - " (else\n" - " (dotimes (s5-9 (-> arg0 length))\n" - " (format #t \"~T [~D] ~D~%\" s5-9 (-> (the-as (array int32) arg0) s5-9))\n" - " )\n" - " )\n" - " )\n" + " )\n" + " (else\n" + " (dotimes (s5-9 (-> arg0 length))\n" + " (format #t \"~T [~D] ~D~%\" s5-9 (-> (the-as (array int32) arg0) s5-9))\n" " )\n" " )\n" " )\n" " )\n" + " ((= (-> arg0 content-type) float)\n" + " (dotimes (s5-10 (-> arg0 length))\n" + " (format #t \"~T [~D] ~f~%\" s5-10 (-> (the-as (array float) arg0) s5-10))\n" + " )\n" + " )\n" " (else\n" - " (cond\n" - " ((= (-> arg0 content-type) float)\n" - " (dotimes (s5-10 (-> arg0 length))\n" - " (format #t \"~T [~D] ~f~%\" s5-10 (-> (the-as (array float) arg0) s5-10))\n" - " )\n" - " )\n" - " (else\n" - " (dotimes (s5-11 (-> arg0 length))\n" - " (format #t \"~T [~D] ~A~%\" s5-11 (-> (the-as (array basic) arg0) s5-11))\n" - " )\n" - " )\n" + " (dotimes (s5-11 (-> arg0 length))\n" + " (format #t \"~T [~D] ~A~%\" s5-11 (-> (the-as (array basic) arg0) s5-11))\n" " )\n" " )\n" " )\n" @@ -1811,8 +1786,7 @@ TEST_F(FormRegressionTest, ExprValid) { " ((not arg1)\n" " (cond\n" " ((nonzero? (logand (the-as int arg0) 3))\n" - " (if\n" - " arg2\n" + " (if arg2\n" " (format\n" " arg4\n" " \"ERROR: object #x~X ~S is not a valid object (misaligned)~%\"\n" @@ -1823,8 +1797,7 @@ TEST_F(FormRegressionTest, ExprValid) { " #f\n" " )\n" " ((not v1-1)\n" - " (if\n" - " arg2\n" + " (if arg2\n" " (format\n" " arg4\n" " \"ERROR: object #x~X ~S is not a valid object (bad address)~%\"\n" @@ -1834,101 +1807,55 @@ TEST_F(FormRegressionTest, ExprValid) { " )\n" " #f\n" " )\n" - " (else #t)\n" + " (else\n" + " #t\n" + " )\n" " )\n" " )\n" - " ((and arg3 (not arg0)) #t)\n" - " (else\n" + " ((and arg3 (not arg0))\n" + " #t\n" + " )\n" + " ((= arg1 structure)\n" " (cond\n" - " ((= arg1 structure)\n" - " (cond\n" - " ((nonzero? (logand (the-as int arg0) 15))\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " )\n" - " )\n" - " #f\n" - " )\n" - " ((or\n" - " (not v1-1)\n" - " (begin\n" - " (let ((v1-10 #x8000)) (.daddu v1-11 v1-10 s7-0))\n" - " (< (the-as uint arg0) (the-as uint v1-11))\n" - " )\n" - " )\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " )\n" - " )\n" - " #f\n" - " )\n" - " (else #t)\n" - " )\n" - " )\n" - " ((= arg1 pair)\n" - " (cond\n" - " ((!= (logand (the-as int arg0) 7) 2)\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " )\n" - " )\n" - " #f\n" - " )\n" - " ((not v1-1)\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " )\n" - " )\n" - " #f\n" - " )\n" - " (else #t)\n" - " )\n" - " )\n" - " ((= arg1 binteger)\n" - " (cond\n" - " ((zero? (logand (the-as int arg0) 7)) #t)\n" - " (else\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " )\n" - " )\n" - " #f\n" + " ((nonzero? (logand (the-as int arg0) 15))\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" " )\n" " )\n" + " #f\n" " )\n" - " ((!= (logand (the-as int arg0) 7) 4)\n" - " (if\n" - " arg2\n" + " ((or (not v1-1) (begin\n" + " (let ((v1-10 #x8000))\n" + " (.daddu v1-11 v1-10 s7-0)\n" + " )\n" + " (< (the-as uint arg0) (the-as uint v1-11))\n" + " )\n" + " )\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" + " )\n" + " )\n" + " #f\n" + " )\n" + " (else\n" + " #t\n" + " )\n" + " )\n" + " )\n" + " ((= arg1 pair)\n" + " (cond\n" + " ((!= (logand (the-as int arg0) 7) 2)\n" + " (if arg2\n" " (format\n" " arg4\n" " \"ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%\"\n" @@ -1940,8 +1867,7 @@ TEST_F(FormRegressionTest, ExprValid) { " #f\n" " )\n" " ((not v1-1)\n" - " (if\n" - " arg2\n" + " (if arg2\n" " (format\n" " arg4\n" " \"ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%\"\n" @@ -1952,94 +1878,137 @@ TEST_F(FormRegressionTest, ExprValid) { " )\n" " #f\n" " )\n" - " ((and (= arg1 type) (!= (rtype-of arg0) type))\n" - " (if\n" - " arg2\n" + " (else\n" + " #t\n" + " )\n" + " )\n" + " )\n" + " ((= arg1 binteger)\n" + " (cond\n" + " ((zero? (logand (the-as int arg0) 7))\n" + " #t\n" + " )\n" + " (else\n" + " (if arg2\n" " (format\n" " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%\"\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" + " )\n" + " )\n" + " #f\n" + " )\n" + " )\n" + " )\n" + " ((!= (logand (the-as int arg0) 7) 4)\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (misaligned)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" + " )\n" + " )\n" + " #f\n" + " )\n" + " ((not v1-1)\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (bad address)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" + " )\n" + " )\n" + " #f\n" + " )\n" + " ((and (= arg1 type) (!= (rtype-of arg0) type))\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" + " (rtype-of arg0)\n" + " )\n" + " )\n" + " #f\n" + " )\n" + " ((and (!= arg1 type) (not (valid? (rtype-of arg0) type #f #t 0)))\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type #x~X)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" + " (rtype-of arg0)\n" + " )\n" + " )\n" + " #f\n" + " )\n" + " ((not (type-type? (rtype-of arg0) arg1))\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (is type '~A' " + "instead)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" + " (rtype-of arg0)\n" + " )\n" + " )\n" + " #f\n" + " )\n" + " ((= arg1 symbol)\n" + " (let ((v1-43 #x8000))\n" + " (.daddu v1-44 v1-43 s7-0)\n" + " )\n" + " (cond\n" + " ((>= (the-as uint arg0) (the-as uint v1-44))\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (not in symbol " + "table)~%\"\n" " arg0\n" " arg2\n" " arg1\n" - " (rtype-of arg0)\n" " )\n" " )\n" " #f\n" " )\n" " (else\n" - " (cond\n" - " ((and (!= arg1 type) (not (valid? (rtype-of arg0) type #f #t 0)))\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (invalid type " - "#x~X)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " (rtype-of arg0)\n" - " )\n" - " )\n" - " #f\n" - " )\n" - " ((not (type-type? (rtype-of arg0) arg1))\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (is type '~A' " - "instead)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " (rtype-of arg0)\n" - " )\n" - " )\n" - " #f\n" - " )\n" - " ((= arg1 symbol)\n" - " (let ((v1-43 #x8000)) (.daddu v1-44 v1-43 s7-0))\n" - " (cond\n" - " ((>= (the-as uint arg0) (the-as uint v1-44))\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (not in symbol " - "table)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " )\n" - " )\n" - " #f\n" - " )\n" - " (else #t)\n" - " )\n" - " )\n" - " ((begin\n" - " (let ((v1-47 #x8000)) (.daddu v1-48 v1-47 s7-0))\n" - " (< (the-as uint arg0) (the-as uint v1-48))\n" - " )\n" - " (if\n" - " arg2\n" - " (format\n" - " arg4\n" - " \"ERROR: object #x~X ~S is not a valid object of type '~A' (inside symbol " - "table)~%\"\n" - " arg0\n" - " arg2\n" - " arg1\n" - " )\n" - " )\n" - " #f\n" - " )\n" - " (else #t)\n" - " )\n" + " #t\n" " )\n" " )\n" " )\n" + " ((begin\n" + " (let ((v1-47 #x8000))\n" + " (.daddu v1-48 v1-47 s7-0)\n" + " )\n" + " (< (the-as uint arg0) (the-as uint v1-48))\n" + " )\n" + " (if arg2\n" + " (format\n" + " arg4\n" + " \"ERROR: object #x~X ~S is not a valid object of type '~A' (inside symbol table)~%\"\n" + " arg0\n" + " arg2\n" + " arg1\n" + " )\n" + " )\n" + " #f\n" + " )\n" + " (else\n" + " #t\n" + " )\n" " )\n" " )"; test_with_expr( @@ -2377,20 +2346,19 @@ TEST_F(FormRegressionTest, ExprStringToInt) { " (the-as int (+ (+ (-> a0-3 0) -55) (the-as uint (* v0-0 16))))\n" " )\n" " )\n" + " ((and\n" + " (>= (-> a0-3 0) (the-as uint 97))\n" + " (>= (the-as uint 102) (-> a0-3 0))\n" + " )\n" + " (set!\n" + " v0-0\n" + " (the-as int (+ (+ (-> a0-3 0) -87) (the-as uint (* v0-0 16))))\n" + " )\n" + " )\n" " (else\n" - " (if\n" - " (and\n" - " (>= (-> a0-3 0) (the-as uint 97))\n" - " (>= (the-as uint 102) (-> a0-3 0))\n" - " )\n" - " (set!\n" - " v0-0\n" - " (the-as int (+ (+ (-> a0-3 0) -87) (the-as uint (* v0-0 16))))\n" - " )\n" - " (set!\n" - " v0-0\n" - " (the-as int (+ (+ (-> a0-3 0) -48) (the-as uint (* v0-0 16))))\n" - " )\n" + " (set!\n" + " v0-0\n" + " (the-as int (+ (+ (-> a0-3 0) -48) (the-as uint (* v0-0 16))))\n" " )\n" " )\n" " )\n" @@ -2844,16 +2812,14 @@ TEST_F(FormRegressionTest, Method19ResTag) { " )\n" " (cond\n" " ((zero? t6-5)\n" - " (begin\n" - " (set! t4-1 t5-2)\n" - " (goto cfg-32)\n" - " )\n" + " (set! t4-1 t5-2)\n" + " (goto cfg-32)\n" + " )\n" + " ((< (the-as int t6-5) 0)\n" + " (set! t3-1 (+ t5-2 -1))\n" " )\n" " (else\n" - " (if (< (the-as int t6-5) 0)\n" - " (set! t3-1 (+ t5-2 -1))\n" - " (set! t4-0 (+ t5-2 1))\n" - " )\n" + " (set! t4-0 (+ t5-2 1))\n" " )\n" " )\n" " )\n" @@ -2880,12 +2846,10 @@ TEST_F(FormRegressionTest, Method19ResTag) { " )\n" " (+! t4-1 -1)\n" " )\n" - " (if (= arg2 'base)\n" - " (begin\n" - " (set! t0-6 t4-1)\n" - " (set! v1-14 t4-1)\n" - " (goto cfg-73)\n" - " )\n" + " (when (= arg2 'base)\n" + " (set! t0-6 t4-1)\n" + " (set! v1-14 t4-1)\n" + " (goto cfg-73)\n" " )\n" " (let ((t3-13 t4-1)\n" " (t4-4 (&-> (-> arg0 tag) t4-1))\n" @@ -2907,11 +2871,9 @@ TEST_F(FormRegressionTest, Method19ResTag) { " ((!= arg1 (-> t4-4 0 name))\n" " )\n" " ((= (-> t4-4 0 key-frame) arg3)\n" - " (begin\n" - " (set! t0-6 t3-13)\n" - " (set! v1-14 t3-13)\n" - " (goto cfg-73)\n" - " )\n" + " (set! t0-6 t3-13)\n" + " (set! v1-14 t3-13)\n" + " (goto cfg-73)\n" " )\n" " ((and (>= arg3 (-> t4-4 0 key-frame)) (!= arg2 'exact))\n" " (set! t0-6 t3-13)\n" @@ -2921,12 +2883,10 @@ TEST_F(FormRegressionTest, Method19ResTag) { " )\n" " )\n" " ((< arg3 (-> t4-4 0 key-frame))\n" - " (begin\n" - " (if (and (!= t0-6 t1-0) (= arg2 'interp))\n" - " (set! v1-14 t3-13)\n" - " )\n" - " (goto cfg-73)\n" + " (if (and (!= t0-6 t1-0) (= arg2 'interp))\n" + " (set! v1-14 t3-13)\n" " )\n" + " (goto cfg-73)\n" " )\n" " )\n" " (+! t3-13 1)\n" diff --git a/test/decompiler/test_gkernel_decomp.cpp b/test/decompiler/test_gkernel_decomp.cpp index e1a65fa5fd..69141cc049 100644 --- a/test/decompiler/test_gkernel_decomp.cpp +++ b/test/decompiler/test_gkernel_decomp.cpp @@ -1410,15 +1410,15 @@ TEST_F(FormRegressionTest, ExprMethod21DeadPoolHeap) { " )\n" " )\n" " )\n" - " (else\n" - " (if (-> arg1 next)\n" - " (&-\n" - " (the-as pointer (-> arg1 next process))\n" - " (the-as uint (&+ (-> arg0 heap base) 4))\n" - " )\n" - " (&- (-> arg0 heap top) (the-as uint (-> arg0 heap base)))\n" + " ((-> arg1 next)\n" + " (&-\n" + " (the-as pointer (-> arg1 next process))\n" + " (the-as uint (&+ (-> arg0 heap base) 4))\n" " )\n" " )\n" + " (else\n" + " (&- (-> arg0 heap top) (the-as uint (-> arg0 heap base)))\n" + " )\n" " )"; test_with_expr(func, type, expected, false, "", {}, "[\t\t[5, \"v1\", \"pointer\"],\n"