Exemplo n.º 1
0
 def add_symbol(self, vname: str, vtype: Optional["BCTyp"],
                altname: Optional[str], parameter: Optional[int],
                globaladdress: Optional[int]) -> None:
     id = self.new_id()
     varinfo = AST.ASTVarInfo(id, vname, vtype, altname, parameter,
                              globaladdress)
     index = (vname, altname) if altname else (vname, "__none__")
     self._symboltable[index] = varinfo
Exemplo n.º 2
0
if TYPE_CHECKING:
    from chb.bctypes.BCFieldInfo import BCFieldInfo
    from chb.bctypes.BCFunArgs import BCFunArg
    from chb.bctypes.BCFunctionDefinition import BCFunctionDefinition
    from chb.bctypes.BCTyp import BCTyp, BCTypFun, BCTypComp, BCTypArray
    from chb.bctypes.BCVarInfo import BCVarInfo

ASTSpanRecord = NewType(
    "ASTSpanRecord", Dict[str, Union[int, List[Dict[str, Union[str, int]]]]])
"""fname -> registers/stack -> name/offset -> [span/altname -> (low, high), name]."""
VariableNamesRec = NewType(
    "VariableNamesRec",
    Dict[str, Dict[str, Dict[str, List[Dict[str, Union[Tuple[str, str],
                                                       str]]]]]])

ignoredvariable = AST.ASTVarInfo(-1, "ignored", None, None, None, None)
nooffset = AST.ASTNoOffset(-1)


class VariableNames:
    def __init__(self, namerecords: VariableNamesRec) -> None:
        self._namerecords = namerecords

    @property
    def namerecords(self) -> VariableNamesRec:
        return self._namerecords

    def has_register_variable(self, fname: str, v: str) -> bool:
        return (fname in self.namerecords
                and "registers" in self.namerecords[fname]
                and v in self.namerecords[fname]["registers"])