mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Organize source files
This commit is contained in:
@ -1,11 +1,22 @@
|
||||
import ast
|
||||
from llvmlite import ir
|
||||
|
||||
def parser(source_code, filename):
|
||||
tree = ast.parse(source_code, filename)
|
||||
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.FunctionDef):
|
||||
print("Function:", node.name)
|
||||
for dec in node.decorator_list:
|
||||
print(" Decorator AST:", ast.dump(dec))
|
||||
|
||||
def compile_to_ir(filename: str, output: str):
|
||||
with open(filename) as f:
|
||||
ast.parse(f.read(), filename)
|
||||
parser(f.read(), filename)
|
||||
module = ir.Module(name=filename)
|
||||
module.data_layout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
|
||||
module.triple = "bpf"
|
||||
|
||||
module = ir.Module(name="pythonbpf")
|
||||
func_ty = ir.FunctionType(ir.IntType(64), [], False)
|
||||
func = ir.Function(module, func_ty, name="trace_execve")
|
||||
|
||||
|
||||
@ -4,11 +4,8 @@ def tracepoint(name: str):
|
||||
return fn
|
||||
return wrapper
|
||||
|
||||
def license(name: str):
|
||||
def wrapper(fn):
|
||||
fn._license = name
|
||||
return fn
|
||||
return wrapper
|
||||
def license(license_type: str):
|
||||
return license_type
|
||||
|
||||
def trace_printk(msg: str):
|
||||
# placeholder — real version lowers to IR later
|
||||
|
||||
Reference in New Issue
Block a user