mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Update bpf examples and remove function pass code
This commit is contained in:
@ -1,32 +1,5 @@
|
||||
from llvmlite import ir
|
||||
import ast
|
||||
|
||||
def emit_function(module: ir.Module, license_str: str):
|
||||
license_bytes = license_str.encode("utf8") + b"\x00"
|
||||
elems = [ir.Constant(ir.IntType(8), b) for b in license_bytes]
|
||||
ty = ir.ArrayType(ir.IntType(8), len(elems))
|
||||
|
||||
gvar = ir.GlobalVariable(module, ty, name="LICENSE")
|
||||
|
||||
gvar.initializer = ir.Constant(ty, elems) # type: ignore
|
||||
|
||||
gvar.align = 1 # type: ignore
|
||||
gvar.linkage = "dso_local" # type: ignore
|
||||
gvar.global_constant = False
|
||||
gvar.section = "license" # type: ignore
|
||||
|
||||
return gvar
|
||||
|
||||
def functions_processing(tree, module):
|
||||
bpf_functions = []
|
||||
helper_functions = []
|
||||
for node in tree.body:
|
||||
section_name = ""
|
||||
if isinstance(node, ast.FunctionDef):
|
||||
if len(node.decorator_list) == 1:
|
||||
bpf_functions.append(node)
|
||||
else:
|
||||
if 'helper_functions' not in locals():
|
||||
helper_functions.append(node)
|
||||
|
||||
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user