~jasper/type_stack_calc

6aca66fb1a7cf1e10f7dd3263f04537c8ff37590 — Jasper den Ouden 9 months ago 0f08de8
Apparently `to_c` can already read ahead one, hopefully its this simple...
2 files changed, 6 insertions(+), 9 deletions(-)

M type_stack_calc/base/component.py
M type_stack_calc/ib/if_block.py
M type_stack_calc/base/component.py => type_stack_calc/base/component.py +4 -3
@@ 8,7 8,7 @@
from type_stack_calc.ib.simple_ib_fun import SimpleInbuildFunction
from type_stack_calc.base.n_args import BaseNArgs

from type_stack_calc.extractor import Extractor
from type_stack_calc.extractor import Extractor, StopMarker
from type_stack_calc.pe.drop import PostExtractDrop

from type_stack_calc.ib.plain_component import PlainComponent


@@ 57,15 57,16 @@ class BaseComponentSet(BaseNArgs):
        wfile, prep = tc[:2]
        var = next(gen)
        assert isinstance(var, BaseComponent), (self, self.component, var, list(gen))

        next_tc = next(gen)
        if var.key == '~r':  # ~ indicates inbuilt "weirdo variable".
            if next_tc is StopMarker: return  # Indicates it is not needed.
            wfile("return ")
        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(f"{var.key} = ")
        tc.new_context(prep, '(').c_1(gen)
        tc.new_context(prep, '(').c_1(gen, next_tc)

    def tp_calc(self, sc, vs, args):
        to, component = args

M type_stack_calc/ib/if_block.py => type_stack_calc/ib/if_block.py +2 -6
@@ 5,7 5,7 @@
#  by the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.

from type_stack_calc.extractor import Extractor
from type_stack_calc.extractor import Extractor, StopMarker

def list_flatten(gen):
    for el in gen:


@@ 16,10 16,6 @@ def list_flatten(gen):

def filter_none(lst): return [el for el in lst if el is not None]

class NEVER:
    """TODO... dunno if i can figure out how to remove this stuff.."""
    c_name="NEVER"

class IfBlock:
    """`if_block.py`: `{..if..} {..else..} (..cond..).if` provider."""
    def __init__(self, cond, yes, no, ret_stack):


@@ 44,7 40,7 @@ class IfBlock:
            if deffer := getattr(tmp, 'deffer', None):
                extractor[1](deffer)
            if getattr(tmp, 'key', "")[:1] == '~':
                extractor[0](NEVER)
                extractor[0](StopMarker)
            else:
                extractor[0](tmp)