22from llvmlite import ir
33from .type_deducer import ctypes_to_ir
44from . import dwarf_constants as dc
5+ from enum import Enum
56
67map_sym_tab = {}
78
@@ -22,6 +23,11 @@ def is_map(func_node):
2223 )
2324
2425
26+ class BPFMapType (Enum ):
27+ HASH = 1
28+ PERF_EVENT_ARRAY = 4
29+
30+
2531BPF_MAP_MAPPINGS = {
2632 "HASH" : 1 , # BPF_MAP_TYPE_HASH
2733 "PERF_EVENT_ARRAY" : 4 , # BPF_MAP_TYPE_PERF_EVENT_ARRAY
@@ -186,7 +192,7 @@ def create_map_debug_info(module, map_global, map_name, map_params):
186192
187193def process_hash_map (map_name , rval , module ):
188194 print (f"Creating HashMap map: { map_name } " )
189- map_params : dict [ str , object ] = {"type" : " HASH" }
195+ map_params : = {"type" : BPFMapType . HASH }
190196
191197 # Assuming order: key_type, value_type, max_entries
192198 if len (rval .args ) >= 1 and isinstance (rval .args [0 ], ast .Name ):
@@ -214,7 +220,7 @@ def process_hash_map(map_name, rval, module):
214220
215221def process_perf_event_map (map_name , rval , module ):
216222 print (f"Creating PerfEventArray map: { map_name } " )
217- map_params = {"type" : " PERF_EVENT_ARRAY" }
223+ map_params = {"type" : BPFMapType . PERF_EVENT_ARRAY }
218224
219225 if len (rval .args ) >= 1 and isinstance (rval .args [0 ], ast .Name ):
220226 map_params ["key_size" ] = rval .args [0 ].id
0 commit comments