~jasper/type_stack_calc

ref: 6aca66fb1a7cf1e10f7dd3263f04537c8ff37590 type_stack_calc/type_stack_calc/util/markings_in_stack.py -rw-r--r-- 507 bytes
6aca66fb — Jasper den Ouden Apparently `to_c` can already read ahead one, hopefully its this simple... 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from type_stack_calc.ib.word import InbuildWord

def markings_in_stack(stack):
    """Extracts out all the markings in a stack. These can indicate info about functions, for instance forcing one to be treated as destructive."""
    ret, markings = [], set()
    for v in stack:
        if isinstance(v, InbuildWord):  # TODO marker words?
            assert v not in markings
            markings.add(str(v))
        else:
            assert v is not None
            ret.append(v)
    return ret, markings