|
UniSet 2.45.1
|
Открытые члены | |
| __init__ (self, str filename="<stdin>", set[str]|None program_names=None) | |
| None | register_user_fb_type (self, str name) |
| None | register_enum_type (self, str name) |
| None | register_struct_type (self, StructureTypeDeclaration decl) |
| tuple[list[IRVariable], list[IRFBInstance]] | transform_gvl_block (self, GVLBlock gvl) |
| IRProgram | transform_program (self, Program node) |
| IRFunctionBlock | transform_function_block (self, FunctionBlock node) |
Открытые атрибуты | |
| filename = filename | |
Защищенные члены | |
| _parse_init_str (self, str init_str, IECType iec_type) | |
| tuple[list[IRVariable], list[IRFBInstance]] | _transform_var_items_with_fb (self, list items, bool is_local=False) |
| list[IRVariable] | _transform_var_items (self, list items, bool is_input=False, bool is_output=False, bool is_local=False) |
| list[IRVariable] | _transform_array_var (self, item, ArrayTypeInitialization init, bool is_input=False, bool is_output=False, bool is_local=False) |
| object|None | _extract_initial_value (self, value) |
| list[IRStatement] | _transform_statement_list (self, StatementList stmt_list) |
| IRStatement | _transform_statement (self, stmt) |
| IRFBCall | _transform_fb_call (self, FunctionCallStatement stmt) |
| None | _extract_constructor_args (self, list[IRFBInstance] fb_instances, list[IRStatement] body) |
| IRAssignment | _transform_assignment (self, AssignmentStatement stmt) |
| IRIfElse | _transform_if (self, IfStatement stmt) |
| IRCase | _transform_case (self, CaseStatement stmt) |
| IRForLoop | _transform_for (self, ForStatement stmt) |
| IRWhileLoop | _transform_while (self, WhileStatement stmt) |
| IRRepeatLoop | _transform_repeat (self, RepeatStatement stmt) |
| IRExpression | _transform_expression (self, expr) |
| IRFunctionCall | _transform_function_call_expr (self, FunctionCall expr) |
| IRExpression | _transform_multi_element_variable (self, MultiElementVariable expr) |
| IRLiteral | _transform_duration (self, Duration expr) |
Защищенные данные | |
| dict | _struct_types = {} |
| set[str] | _program_names = program_names or set() |
| set[str] | _user_fb_types = set() |
| set[str] | _enum_types = set() |
Walks blark AST nodes and produces IR dataclasses. Handles PROGRAM and FUNCTION_BLOCK declarations, VAR sections (INPUT/OUTPUT/local), FB instance detection, FB call statements, field access (obj.field), assignment, IF/ELSIF/ELSE, CASE, FOR, WHILE, REPEAT, binary/unary expressions, variable references, literals, and Duration (TIME) literals.
|
protected |
Extract constructor arguments from FB calls and store in FB instances. For standard FBs, constructor args (PT for timers, PV for counters) are specified as named parameters in the first FB call. These are extracted from the IRFBCall arguments and stored in the IRFBInstance constructor_args. The constructor args are also removed from the IRFBCall arguments so that only update() params remain.
|
protected |
Extract a Python value from a blark initial value node.
|
protected |
Parse an initial value string into a Python value.
|
protected |
Transform an ARRAY variable declaration.
|
protected |
Transform a blark AssignmentStatement into an IRAssignment.
|
protected |
Transform a blark CaseStatement into an IRCase.
|
protected |
Transform a blark Duration literal into an IRLiteral with millisecond value.
|
protected |
Transform a blark expression node into an IR expression.
|
protected |
Transform a blark FunctionCallStatement into an IRFBCall. Extracts the instance name and named parameters from the call.
|
protected |
Transform a blark ForStatement into an IRForLoop.
|
protected |
Transform a blark FunctionCall (expression) into an IRFunctionCall.
|
protected |
Transform a blark IfStatement into an IRIfElse.
|
protected |
Transform a multi-element variable (e.g. myTimer.Q, arr[i]) into field/array access.
|
protected |
Transform a blark RepeatStatement into an IRRepeatLoop.
|
protected |
Transform a single blark statement into an IR statement.
|
protected |
Transform a blark StatementList into a list of IR statements.
|
protected |
Transform a list of VariableOneInitDeclaration into IRVariables.
|
protected |
Transform VAR items, separating regular variables from FB instances.
Returns:
A tuple of (regular_variables, fb_instances).
|
protected |
Transform a blark WhileStatement into an IRWhileLoop.
| None st2js.transformer.ASTTransformer.register_enum_type | ( | self, | |
| str | name ) |
Register a user-defined ENUM type name.
| None st2js.transformer.ASTTransformer.register_struct_type | ( | self, | |
| StructureTypeDeclaration | decl ) |
Register a STRUCT type declaration for later use in variable resolution.
| None st2js.transformer.ASTTransformer.register_user_fb_type | ( | self, | |
| str | name ) |
Register a user-defined FUNCTION_BLOCK type name.
| IRFunctionBlock st2js.transformer.ASTTransformer.transform_function_block | ( | self, | |
| FunctionBlock | node ) |
Transform a blark FunctionBlock node into an IRFunctionBlock.
| tuple[list[IRVariable], list[IRFBInstance]] st2js.transformer.ASTTransformer.transform_gvl_block | ( | self, | |
| GVLBlock | gvl ) |
Transform a named GVL block into a single STRUCT-like IRVariable.
Each named GVL becomes one variable: `let GVL_Name = { field1: val, ... };`
FB-typed variables within the GVL are emitted as separate FB instances.
| IRProgram st2js.transformer.ASTTransformer.transform_program | ( | self, | |
| Program | node ) |
Transform a blark Program node into an IRProgram.