Beispiel #1
0
    def __init__(self, type_, name=None):
        """ type_ = Internal representation (e.g. TYPE.ubyte)
        """
        assert TYPE.is_valid(type_)
        if not name:
            name = TYPE.to_string(type_)

        super(SymbolBASICTYPE, self).__init__(name, 0)
        self.type_ = type_
Beispiel #2
0
    def TYPE(type_):
        """ Converts a backend type (from api.constants)
        to a SymbolTYPE object (taken from the SYMBOL_TABLE).
        If type_ is already a SymbolTYPE object, nothing
        is done.
        """
        if isinstance(type_, symbols.TYPE):
            return type_

        assert TYPE.is_valid(type_)
        return gl.SYMBOL_TABLE.basic_types[type_]
    def TSUFFIX(type_):
        assert isinstance(type_, symbols.TYPE) or TYPE.is_valid(type_)

        _TSUFFIX = {TYPE.byte_: 'i8', TYPE.ubyte: 'u8',
                    TYPE.integer: 'i16', TYPE.uinteger: 'u16',
                    TYPE.long_: 'i32', TYPE.ulong: 'u32',
                    TYPE.fixed: 'f16', TYPE.float_: 'f',
                    TYPE.string: 'str'
                    }

        if isinstance(type_, symbols.TYPEREF):
            type_ = type_.final
            assert isinstance(type_, symbols.BASICTYPE)

        if isinstance(type_, symbols.BASICTYPE):
            return _TSUFFIX[type_.type_]

        return _TSUFFIX[type_]
Beispiel #4
0
 def btyperef(self, type_):
     assert TYPE.is_valid(type_)
     return symbols.TYPEREF(symbols.BASICTYPE(type_), 0)