Esempio n. 1
0
def _code_extract(code: Atom, ndx: int) -> Union[Token, Tuple[Atom]]:
    if isinstance(code, CodeBlock) and code.size() == 0:
        return Token.revert
    if not isinstance(code, CodeBlock):
        return code,
    ndx = abs(ndx % code.size())
    return code.code_at_point(ndx),
Esempio n. 2
0
File: code.py Progetto: erp12/Pysh
def _code_extract(code: Atom, ndx: int) -> Union[Token, Tuple[Atom]]:
    if isinstance(code, CodeBlock) and code.size() == 0:
        return Token.revert
    if not isinstance(code, CodeBlock):
        return code,
    ndx = abs(ndx % code.size())
    return code.code_at_point(ndx),
Esempio n. 3
0
def _code_combine(a: Atom, b: Atom) -> Tuple[CodeBlock]:
    if isinstance(a, CodeBlock) and isinstance(b, CodeBlock):
        return CodeBlock(b + a),
    elif isinstance(b, CodeBlock):
        return b.append(a),
    elif isinstance(a, CodeBlock):
        return a.append(b),
    else:
        return CodeBlock([a, b]),
Esempio n. 4
0
File: code.py Progetto: erp12/Pysh
def _code_combine(a: Atom, b: Atom) -> Tuple[CodeBlock]:
    if isinstance(a, CodeBlock) and isinstance(b, CodeBlock):
        return CodeBlock.from_list(list(b.copy()) + list(a.copy())),
    elif isinstance(b, CodeBlock):
        result = b.copy()
        result.append(a)
        return result,
    elif isinstance(a, CodeBlock):
        result = a.copy()
        result.append(b)
        return result,
    else:
        return CodeBlock(a, b),
Esempio n. 5
0
def _code_combine(a: Atom, b: Atom) -> Tuple[CodeBlock]:
    if isinstance(a, CodeBlock) and isinstance(b, CodeBlock):
        return CodeBlock.from_list(list(b.copy()) + list(a.copy())),
    elif isinstance(b, CodeBlock):
        result = b.copy()
        result.append(a)
        return result,
    elif isinstance(a, CodeBlock):
        result = a.copy()
        result.append(b)
        return result,
    else:
        return CodeBlock(a, b),
Esempio n. 6
0
def _code_size(code: Atom) -> Tuple[int]:
    if not isinstance(code, CodeBlock):
        return 1,
    return code.size(),
Esempio n. 7
0
File: code.py Progetto: erp12/Pysh
def _code_size(code: Atom) -> Tuple[int]:
    if not isinstance(code, CodeBlock):
        return 1,
    return code.size(),