~jasper/type_stack_calc

84f5ae07ac5b8dfc401bde572d7cdc95a5d2e5fe — Jasper den Ouden 6 months ago 267d87d
minor
2 files changed, 4 insertions(+), 3 deletions(-)

M type_stack_calc/base/component.py
M type_stack_calc/call/if_call.py
M type_stack_calc/base/component.py => type_stack_calc/base/component.py +1 -1
@@ 59,7 59,7 @@ class BaseComponentSet(BaseNArgs):
        else:
            if self.initial_set:
                #assert var.val is not None, var  # TODO
                wfile(var.val and var.val.c_name + " " or f"BUG({var}) ")
                wfile((var.val and var.val.c_name or f"Bug({var})") + " ")
            wfile(f"{var.key} = ")
        tc.new_context(prep, '(').c_1(gen)


M type_stack_calc/call/if_call.py => type_stack_calc/call/if_call.py +3 -2
@@ 18,7 18,7 @@ class IfCall:
        assert len(stack) >= 3, \
            f"If needs three blocks, the condition, if-true and if false. Got {stack}"
        then, otherwise, cond = stack[:3]
        wrongs = []
        wrongs = []  # Collect things that might be wrong.
        if not isinstance(cond, list) or cond.tp != '(':
            wrongs.append(f"wrong condition block: {cond}")
        if not isinstance(then, list) or then.tp != '{':


@@ 48,7 48,8 @@ class IfCall:
            tc_t, tc_f = [], []  # Run both sides.
            if_t = sc.tp_calc(then,      vs, [], tc_t.append)
            if_f = sc.tp_calc(otherwise, vs, [], tc_f.append)
            assert len(if_f) == len(if_t)
            assert len(if_f) == len(if_t), \
                "Outputs of `().if` must have same stack size."
            ret_stack = [f.smoosh(t) for f,t in zip(if_t, if_f)]

            return (ret_stack, IfBlock(tc_cond, tc_t, tc_f, ret_stack))