@@ -38,7 +38,10 @@ def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, func,
3838 """
3939 Emit LLVM IR for bpf_map_lookup_elem helper function call.
4040 """
41- key_ptr = get_key_ptr (call , builder , local_sym_tab )
41+ if not call .args or len (call .args ) != 1 :
42+ raise ValueError ("Map lookup expects exactly one argument (key), got "
43+ f"{ len (call .args )} " )
44+ key_ptr = get_key_ptr (call .args [0 ], builder , local_sym_tab )
4245 map_void_ptr = builder .bitcast (map_ptr , ir .PointerType ())
4346
4447 fn_type = ir .FunctionType (
@@ -239,25 +242,7 @@ def bpf_map_update_elem_emitter(call, map_ptr, module, builder, func,
239242 value_arg = call .args [1 ]
240243 flags_arg = call .args [2 ] if len (call .args ) > 2 else None
241244
242- # Handle key
243- if isinstance (key_arg , ast .Name ):
244- key_name = key_arg .id
245- if local_sym_tab and key_name in local_sym_tab :
246- key_ptr = local_sym_tab [key_name ][0 ]
247- else :
248- raise ValueError (
249- f"Key variable { key_name } not found in local symbol table." )
250- elif isinstance (key_arg , ast .Constant ) and isinstance (key_arg .value , int ):
251- # Handle constant integer keys
252- key_val = key_arg .value
253- key_type = ir .IntType (64 )
254- key_ptr = builder .alloca (key_type )
255- key_ptr .align = key_type .width // 8
256- builder .store (ir .Constant (key_type , key_val ), key_ptr )
257- else :
258- raise NotImplementedError (
259- "Only simple variable names and integer constants are supported as keys in map update." )
260-
245+ key_ptr = get_key_ptr (key_arg , builder , local_sym_tab )
261246 # Handle value
262247 if isinstance (value_arg , ast .Name ):
263248 value_name = value_arg .id
@@ -331,7 +316,10 @@ def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, func,
331316 Emit LLVM IR for bpf_map_delete_elem helper function call.
332317 Expected call signature: map.delete(key)
333318 """
334- key_ptr = get_key_ptr (call , builder , local_sym_tab )
319+ if not call .args or len (call .args ) != 1 :
320+ raise ValueError ("Map delete expects exactly one argument (key), got "
321+ f"{ len (call .args )} " )
322+ key_ptr = get_key_ptr (call .args [0 ], builder , local_sym_tab )
335323 map_void_ptr = builder .bitcast (map_ptr , ir .PointerType ())
336324
337325 # Define function type for bpf_map_delete_elem
0 commit comments