builtup4/bu4/indexing/constructs/iname.py

23 lines
570 B
Python

# Copyright (c) PARRRATE T&V 2021. All rights reserved.
from bu4.evaluation.av.evtype import evtype
from bu4.evaluation.constructs.evaluable import Evaluable
from bu4.indexing.constructs.indexed import Indexed
from bu4.parsing.codes import CODE_NAME
__all__ = ('IName',)
class IName(Indexed):
def __init__(self, index: int):
self.index = index
def attach(self, ev: evtype) -> Evaluable:
return ev[self.index]
def __str__(self):
return f'[[{self.index}]]'
def __bytes__(self):
return bytes([CODE_NAME, self.index])