|
1 | 1 | from llvmlite import ir |
2 | 2 |
|
3 | 3 | # TODO: THIS IS NOT SUPPOSED TO MATCH STRINGS :skull: |
| 4 | +mapping = { |
| 5 | + "c_int8": ir.IntType(8), |
| 6 | + "c_uint8": ir.IntType(8), |
| 7 | + "c_int16": ir.IntType(16), |
| 8 | + "c_uint16": ir.IntType(16), |
| 9 | + "c_int32": ir.IntType(32), |
| 10 | + "c_uint32": ir.IntType(32), |
| 11 | + "c_int64": ir.IntType(64), |
| 12 | + "c_uint64": ir.IntType(64), |
| 13 | + "c_float": ir.FloatType(), |
| 14 | + "c_double": ir.DoubleType(), |
| 15 | + "c_void_p": ir.IntType(64), |
| 16 | + # Not so sure about this one |
| 17 | + "str": ir.PointerType(ir.IntType(8)), |
| 18 | +} |
4 | 19 |
|
5 | 20 |
|
6 | 21 | def ctypes_to_ir(ctype: str): |
7 | | - mapping = { |
8 | | - "c_int8": ir.IntType(8), |
9 | | - "c_uint8": ir.IntType(8), |
10 | | - "c_int16": ir.IntType(16), |
11 | | - "c_uint16": ir.IntType(16), |
12 | | - "c_int32": ir.IntType(32), |
13 | | - "c_uint32": ir.IntType(32), |
14 | | - "c_int64": ir.IntType(64), |
15 | | - "c_uint64": ir.IntType(64), |
16 | | - "c_float": ir.FloatType(), |
17 | | - "c_double": ir.DoubleType(), |
18 | | - "c_void_p": ir.IntType(64), |
19 | | - # Not so sure about this one |
20 | | - "str": ir.PointerType(ir.IntType(8)), |
21 | | - } |
22 | 22 | if ctype in mapping: |
23 | 23 | return mapping[ctype] |
24 | 24 | raise NotImplementedError(f"No mapping for {ctype}") |
| 25 | + |
| 26 | + |
| 27 | +def is_ctypes(ctype: str) -> bool: |
| 28 | + return ctype in mapping |
0 commit comments