|
4 | 4 | import importlib |
5 | 5 | import inspect |
6 | 6 |
|
| 7 | +from .assignment_info import AssignmentInfo, AssignmentType |
7 | 8 | from .dependency_handler import DependencyHandler |
8 | 9 | from .ir_gen import IRGenerator |
9 | 10 | from .class_handler import process_vmlinux_class |
@@ -82,7 +83,7 @@ def vmlinux_proc(tree: ast.AST, module): |
82 | 83 | # initialise dependency handler |
83 | 84 | handler = DependencyHandler() |
84 | 85 | # initialise assignment dictionary of name to type |
85 | | - assignments: dict[str, tuple[type, Any]] = {} |
| 86 | + assignments: dict[str, AssignmentInfo] = {} |
86 | 87 |
|
87 | 88 | if not import_statements: |
88 | 89 | logger.info("No vmlinux imports found") |
@@ -132,16 +133,31 @@ def vmlinux_proc(tree: ast.AST, module): |
132 | 133 | return assignments |
133 | 134 |
|
134 | 135 |
|
135 | | -def process_vmlinux_assign(node, module, assignments: dict[str, tuple[type, Any]]): |
136 | | - # Check if this is a simple assignment with a constant value |
| 136 | +def process_vmlinux_assign(node, module, assignments: dict[str, AssignmentInfo]): |
| 137 | + """Process assignments from vmlinux module.""" |
| 138 | + # Only handle single-target assignments |
137 | 139 | if len(node.targets) == 1 and isinstance(node.targets[0], ast.Name): |
138 | 140 | target_name = node.targets[0].id |
| 141 | + |
| 142 | + # Handle constant value assignments |
139 | 143 | if isinstance(node.value, ast.Constant): |
140 | | - assignments[target_name] = (type(node.value.value), node.value.value) |
| 144 | + # Fixed: using proper TypedDict creation syntax with named arguments |
| 145 | + assignments[target_name] = AssignmentInfo( |
| 146 | + value_type=AssignmentType.CONSTANT, |
| 147 | + python_type=type(node.value.value), |
| 148 | + value=node.value.value, |
| 149 | + pointer_level=None, |
| 150 | + signature=None, |
| 151 | + members=None |
| 152 | + ) |
141 | 153 | logger.info( |
142 | 154 | f"Added assignment: {target_name} = {node.value.value!r} of type {type(node.value.value)}" |
143 | 155 | ) |
| 156 | + |
| 157 | + # Handle other assignment types that we may need to support |
144 | 158 | else: |
145 | | - raise ValueError(f"Unsupported assignment type for {target_name}") |
| 159 | + logger.warning( |
| 160 | + f"Unsupported assignment type for {target_name}: {ast.dump(node.value)}" |
| 161 | + ) |
146 | 162 | else: |
147 | 163 | raise ValueError("Not a simple assignment") |
0 commit comments