Building with Codegen
Variable Assignments
Codegen’s enables manipulation of variable assignments via the following classes:
- AssignmentStatement - A statement containing one or more assignments
- Assignment - A single assignment within an AssignmentStatement
Simple Value Changes
Consider the following source code:
In Codegen, you can access assignments with the get_local_var_assignment method.
You can then manipulate the assignment with the set_value method.
Assignments inherit both HasName and HasValue behaviors. See Inheritable Behaviors for more details.
Type Annotations
Similarly, you can set type annotations with the set_type_annotation method.
For example, consider the following source code:
You can manipulate the assignments as follows:
Tracking Usages and Dependencies
Like other symbols, Assignments support usages and dependencies.
See Dependencies and Usages for more details.
Was this page helpful?