Skip to content

types

Types used in Quokka

AddressSize

Bases: Enum

Address size

Source code in quokka/types.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class AddressSize(enum.Enum):
    """Address size"""

    ADDRESS_64 = enum.auto()
    ADDRESS_32 = enum.auto()
    ADDRESS_16 = enum.auto()
    ADDRESS_UNK = enum.auto()

    @staticmethod
    def from_proto(
        address_size: "quokka.pb.Quokka.AddressSizeValue",
    ) -> "AddressSize":
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.ADDR_32: AddressSize.ADDRESS_32,
            quokka.pb.Quokka.ADDR_64: AddressSize.ADDRESS_64,
        }

        return mapping.get(address_size, AddressSize.ADDRESS_UNK)

from_proto(address_size) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
76
77
78
79
80
81
82
83
84
85
86
@staticmethod
def from_proto(
    address_size: "quokka.pb.Quokka.AddressSizeValue",
) -> "AddressSize":
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.ADDR_32: AddressSize.ADDRESS_32,
        quokka.pb.Quokka.ADDR_64: AddressSize.ADDRESS_64,
    }

    return mapping.get(address_size, AddressSize.ADDRESS_UNK)

BlockType

Bases: Enum

Block Type

Source code in quokka/types.py
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
class BlockType(enum.Enum):
    """Block Type"""

    NORMAL = enum.auto()
    INDJUMP = enum.auto()
    RET = enum.auto()
    NORET = enum.auto()
    CNDRET = enum.auto()
    ENORET = enum.auto()
    EXTERN = enum.auto()
    ERROR = enum.auto()
    FAKE = enum.auto()

    @staticmethod
    def from_proto(
        block_type: "quokka.pb.Quokka.FunctionChunk.Block.BlockTypeValue",
    ) -> BlockType:
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_NORMAL: BlockType.NORMAL,
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_INDJUMP: BlockType.INDJUMP,
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_RET: BlockType.RET,
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_NORET: BlockType.NORET,
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_CNDRET: BlockType.CNDRET,
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_ENORET: BlockType.ENORET,
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_EXTERN: BlockType.EXTERN,
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_ERROR: BlockType.ERROR,
            quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_FAKE: BlockType.FAKE,
        }

        return mapping.get(block_type, BlockType.FAKE)

from_proto(block_type) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
@staticmethod
def from_proto(
    block_type: "quokka.pb.Quokka.FunctionChunk.Block.BlockTypeValue",
) -> BlockType:
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_NORMAL: BlockType.NORMAL,
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_INDJUMP: BlockType.INDJUMP,
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_RET: BlockType.RET,
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_NORET: BlockType.NORET,
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_CNDRET: BlockType.CNDRET,
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_ENORET: BlockType.ENORET,
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_EXTERN: BlockType.EXTERN,
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_ERROR: BlockType.ERROR,
        quokka.pb.Quokka.FunctionChunk.Block.BLOCK_TYPE_FAKE: BlockType.FAKE,
    }

    return mapping.get(block_type, BlockType.FAKE)

DataType

Bases: Enum

Data Type

Source code in quokka/types.py
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
class DataType(enum.Enum):
    """Data Type"""

    UNKNOWN = enum.auto()
    BYTE = enum.auto()
    WORD = enum.auto()
    DOUBLE_WORD = enum.auto()
    QUAD_WORD = enum.auto()
    OCTO_WORD = enum.auto()
    FLOAT = enum.auto()
    DOUBLE = enum.auto()
    ASCII = enum.auto()
    STRUCT = enum.auto()
    ALIGN = enum.auto()
    POINTER = enum.auto()

    @staticmethod
    def from_proto(data_type: "quokka.pb.Quokka.DataTypeValue") -> "DataType":
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.TYPE_B: DataType.BYTE,
            quokka.pb.Quokka.TYPE_W: DataType.WORD,
            quokka.pb.Quokka.TYPE_DW: DataType.DOUBLE_WORD,
            quokka.pb.Quokka.TYPE_QW: DataType.QUAD_WORD,
            quokka.pb.Quokka.TYPE_OW: DataType.QUAD_WORD,
            quokka.pb.Quokka.TYPE_FLOAT: DataType.FLOAT,
            quokka.pb.Quokka.TYPE_DOUBLE: DataType.DOUBLE,
            quokka.pb.Quokka.TYPE_ASCII: DataType.ASCII,
            quokka.pb.Quokka.TYPE_STRUCT: DataType.STRUCT,
            quokka.pb.Quokka.TYPE_ALIGN: DataType.ALIGN,
            quokka.pb.Quokka.TYPE_POINTER: DataType.POINTER,
        }

        return mapping.get(data_type, DataType.UNKNOWN)

from_proto(data_type) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
@staticmethod
def from_proto(data_type: "quokka.pb.Quokka.DataTypeValue") -> "DataType":
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.TYPE_B: DataType.BYTE,
        quokka.pb.Quokka.TYPE_W: DataType.WORD,
        quokka.pb.Quokka.TYPE_DW: DataType.DOUBLE_WORD,
        quokka.pb.Quokka.TYPE_QW: DataType.QUAD_WORD,
        quokka.pb.Quokka.TYPE_OW: DataType.QUAD_WORD,
        quokka.pb.Quokka.TYPE_FLOAT: DataType.FLOAT,
        quokka.pb.Quokka.TYPE_DOUBLE: DataType.DOUBLE,
        quokka.pb.Quokka.TYPE_ASCII: DataType.ASCII,
        quokka.pb.Quokka.TYPE_STRUCT: DataType.STRUCT,
        quokka.pb.Quokka.TYPE_ALIGN: DataType.ALIGN,
        quokka.pb.Quokka.TYPE_POINTER: DataType.POINTER,
    }

    return mapping.get(data_type, DataType.UNKNOWN)

EdgeType

Bases: Enum

Edge Type

Source code in quokka/types.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
class EdgeType(enum.Enum):
    """Edge Type"""

    UNCONDITIONAL = enum.auto()
    TRUE = enum.auto()
    FALSE = enum.auto()
    SWITCH = enum.auto()

    @staticmethod
    def from_proto(
        edge_type: "quokka.pb.Quokka.Edge.EdgeTypeValue",
    ) -> "EdgeType":
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.Edge.TYPE_UNCONDITIONAL: EdgeType.UNCONDITIONAL,
            quokka.pb.Quokka.Edge.TYPE_TRUE: EdgeType.TRUE,
            quokka.pb.Quokka.Edge.TYPE_FALSE: EdgeType.FALSE,
            quokka.pb.Quokka.Edge.TYPE_SWITCH: EdgeType.SWITCH,
        }

        edge = mapping.get(edge_type)
        if edge is not None:
            return edge

        raise ValueError("Unable to decode Edge Type")

from_proto(edge_type) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@staticmethod
def from_proto(
    edge_type: "quokka.pb.Quokka.Edge.EdgeTypeValue",
) -> "EdgeType":
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.Edge.TYPE_UNCONDITIONAL: EdgeType.UNCONDITIONAL,
        quokka.pb.Quokka.Edge.TYPE_TRUE: EdgeType.TRUE,
        quokka.pb.Quokka.Edge.TYPE_FALSE: EdgeType.FALSE,
        quokka.pb.Quokka.Edge.TYPE_SWITCH: EdgeType.SWITCH,
    }

    edge = mapping.get(edge_type)
    if edge is not None:
        return edge

    raise ValueError("Unable to decode Edge Type")

Endianness

Bases: Enum

Endianness of the program

LE: Little endian (least significant bit first) BE: Big endian (most significant bit first)

TODO

See how we can support mixed endianness

Source code in quokka/types.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class Endianness(enum.Enum):
    """Endianness of the program

    LE: Little endian (least significant bit first)
    BE: Big endian (most significant bit first)

    TODO:
        See how we can support mixed endianness
    """

    LITTLE_ENDIAN = enum.auto()
    BIG_ENDIAN = enum.auto()
    UNKNOWN = enum.auto()

    @staticmethod
    def from_proto(
        endianness: "quokka.pb.Quokka.Meta.EndianessValue",
    ) -> Endianness:
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.Meta.END_BE: Endianness.BIG_ENDIAN,
            quokka.pb.Quokka.Meta.END_LE: Endianness.LITTLE_ENDIAN,
        }

        return mapping.get(endianness, Endianness.UNKNOWN)

from_proto(endianness) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
103
104
105
106
107
108
109
110
111
112
113
@staticmethod
def from_proto(
    endianness: "quokka.pb.Quokka.Meta.EndianessValue",
) -> Endianness:
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.Meta.END_BE: Endianness.BIG_ENDIAN,
        quokka.pb.Quokka.Meta.END_LE: Endianness.LITTLE_ENDIAN,
    }

    return mapping.get(endianness, Endianness.UNKNOWN)

ExporterMode

Bases: IntEnum

Mode type

The exporter mode controls the type of exported data.

Source code in quokka/types.py
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
class ExporterMode(enum.IntEnum):
    """Mode type

    The exporter mode controls the type of exported data.
    """

    LIGHT = enum.auto()
    FULL = enum.auto()
    NORMAL = enum.auto()

    @staticmethod
    def from_proto(mode: "quokka.pb.Quokka.ExporterMeta.ModeValue") -> "ExporterMode":
        mapping = {
            quokka.pb.Quokka.ExporterMeta.MODE_LIGHT: ExporterMode.LIGHT,
            quokka.pb.Quokka.ExporterMeta.MODE_FULL: ExporterMode.FULL,
        }

        return mapping.get(mode, ExporterMode.NORMAL)

FunctionType

Bases: Enum

Function Type

Source code in quokka/types.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
class FunctionType(enum.Enum):
    """Function Type"""

    NORMAL = enum.auto()
    IMPORTED = enum.auto()
    LIBRARY = enum.auto()
    THUNK = enum.auto()
    EXTERN = enum.auto()
    INVALID = enum.auto()

    @staticmethod
    def from_proto(
        function_type: "quokka.pb.Quokka.Function.FunctionTypeValue",
    ) -> "FunctionType":
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.Function.TYPE_NORMAL: FunctionType.NORMAL,
            quokka.pb.Quokka.Function.TYPE_IMPORTED: FunctionType.IMPORTED,
            quokka.pb.Quokka.Function.TYPE_LIBRARY: FunctionType.LIBRARY,
            quokka.pb.Quokka.Function.TYPE_THUNK: FunctionType.THUNK,
        }

        return mapping.get(function_type, FunctionType.INVALID)

from_proto(function_type) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
153
154
155
156
157
158
159
160
161
162
163
164
165
@staticmethod
def from_proto(
    function_type: "quokka.pb.Quokka.Function.FunctionTypeValue",
) -> "FunctionType":
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.Function.TYPE_NORMAL: FunctionType.NORMAL,
        quokka.pb.Quokka.Function.TYPE_IMPORTED: FunctionType.IMPORTED,
        quokka.pb.Quokka.Function.TYPE_LIBRARY: FunctionType.LIBRARY,
        quokka.pb.Quokka.Function.TYPE_THUNK: FunctionType.THUNK,
    }

    return mapping.get(function_type, FunctionType.INVALID)

ReferenceType

Bases: Enum

Reference Type

Source code in quokka/types.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
class ReferenceType(enum.Enum):
    """Reference Type"""

    CALL = enum.auto()
    DATA = enum.auto()
    ENUM = enum.auto()
    STRUC = enum.auto()
    UNKNOWN = enum.auto()

    @staticmethod
    def from_proto(
        reference_type: "quokka.pb.Quokka.Reference.ReferenceTypeValue",
    ) -> "ReferenceType":
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.Reference.REF_CALL: ReferenceType.CALL,
            quokka.pb.Quokka.Reference.REF_DATA: ReferenceType.DATA,
            quokka.pb.Quokka.Reference.REF_ENUM: ReferenceType.ENUM,
            quokka.pb.Quokka.Reference.REF_STRUC: ReferenceType.STRUC,
        }

        return mapping.get(reference_type, ReferenceType.UNKNOWN)

from_proto(reference_type) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
210
211
212
213
214
215
216
217
218
219
220
221
222
@staticmethod
def from_proto(
    reference_type: "quokka.pb.Quokka.Reference.ReferenceTypeValue",
) -> "ReferenceType":
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.Reference.REF_CALL: ReferenceType.CALL,
        quokka.pb.Quokka.Reference.REF_DATA: ReferenceType.DATA,
        quokka.pb.Quokka.Reference.REF_ENUM: ReferenceType.ENUM,
        quokka.pb.Quokka.Reference.REF_STRUC: ReferenceType.STRUC,
    }

    return mapping.get(reference_type, ReferenceType.UNKNOWN)

RegAccessMode

Bases: Enum

Register access mode

Source code in quokka/types.py
51
52
53
54
55
56
class RegAccessMode(enum.Enum):
    """Register access mode"""

    READ = enum.auto()
    WRITE = enum.auto()
    ANY = enum.auto()

SegmentType

Bases: Enum

Segment Type

Source code in quokka/types.py
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
class SegmentType(enum.Enum):
    """Segment Type"""

    UNKNOWN = enum.auto()
    CODE = enum.auto()
    DATA = enum.auto()
    BSS = enum.auto()
    NULL = enum.auto()
    EXTERN = enum.auto()
    NORMAL = enum.auto()
    ABSOLUTE_SYMBOLS = enum.auto()

    @staticmethod
    def from_proto(
        segment_type: "quokka.pb.Quokka.Segment.TypeValue",
    ) -> "SegmentType":
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.Segment.SEGMENT_CODE: SegmentType.CODE,
            quokka.pb.Quokka.Segment.SEGMENT_DATA: SegmentType.DATA,
            quokka.pb.Quokka.Segment.SEGMENT_BSS: SegmentType.BSS,
            quokka.pb.Quokka.Segment.SEGMENT_NULL: SegmentType.NULL,
            quokka.pb.Quokka.Segment.SEGMENT_NORMAL: SegmentType.NORMAL,
            quokka.pb.Quokka.Segment.SEGMENT_EXTERN: SegmentType.EXTERN,
            quokka.pb.Quokka.Segment.SEGMENT_ABSOLUTE_SYMBOLS: SegmentType.ABSOLUTE_SYMBOLS,
        }

        return mapping.get(segment_type, SegmentType.UNKNOWN)

from_proto(segment_type) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
@staticmethod
def from_proto(
    segment_type: "quokka.pb.Quokka.Segment.TypeValue",
) -> "SegmentType":
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.Segment.SEGMENT_CODE: SegmentType.CODE,
        quokka.pb.Quokka.Segment.SEGMENT_DATA: SegmentType.DATA,
        quokka.pb.Quokka.Segment.SEGMENT_BSS: SegmentType.BSS,
        quokka.pb.Quokka.Segment.SEGMENT_NULL: SegmentType.NULL,
        quokka.pb.Quokka.Segment.SEGMENT_NORMAL: SegmentType.NORMAL,
        quokka.pb.Quokka.Segment.SEGMENT_EXTERN: SegmentType.EXTERN,
        quokka.pb.Quokka.Segment.SEGMENT_ABSOLUTE_SYMBOLS: SegmentType.ABSOLUTE_SYMBOLS,
    }

    return mapping.get(segment_type, SegmentType.UNKNOWN)

StructureType

Bases: Enum

Structure Type

Source code in quokka/types.py
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
class StructureType(enum.Enum):
    """Structure Type"""

    STRUCT = enum.auto()
    ENUM = enum.auto()
    UNION = enum.auto()
    UNKNOWN = enum.auto()

    @staticmethod
    def from_proto(
        structure_type: "quokka.pb.Quokka.Structure.StructureTypeValue",
    ) -> "StructureType":
        """Convert the protobuf value into this enumeration"""
        mapping = {
            quokka.pb.Quokka.Structure.TYPE_STRUCT: StructureType.STRUCT,
            quokka.pb.Quokka.Structure.TYPE_ENUM: StructureType.ENUM,
            quokka.pb.Quokka.Structure.TYPE_UNION: StructureType.UNION,
        }

        return mapping.get(structure_type, StructureType.UNKNOWN)

from_proto(structure_type) staticmethod

Convert the protobuf value into this enumeration

Source code in quokka/types.py
299
300
301
302
303
304
305
306
307
308
309
310
@staticmethod
def from_proto(
    structure_type: "quokka.pb.Quokka.Structure.StructureTypeValue",
) -> "StructureType":
    """Convert the protobuf value into this enumeration"""
    mapping = {
        quokka.pb.Quokka.Structure.TYPE_STRUCT: StructureType.STRUCT,
        quokka.pb.Quokka.Structure.TYPE_ENUM: StructureType.ENUM,
        quokka.pb.Quokka.Structure.TYPE_UNION: StructureType.UNION,
    }

    return mapping.get(structure_type, StructureType.UNKNOWN)