|
UniSet 2.45.1
|
Классы | |
| class | ASTTransformer |
Функции | |
| IECType|None | _resolve_type_name (str type_name) |
| IRProgram | transform (ParseResult parse_result, list[str]|None program_filter=None, str main_program="Main") |
| None | resolve_io_by_prefix (IRProgram program) |
| None | _collect_var_refs (list|None stmts, set[str] out) |
| None | _collect_expr_refs (expr, set[str] out) |
Переменные | |
| dict | _TYPE_MAP |
| tuple | _INPUT_PREFIXES = ('MBI_', 'RDI_', 'RAI_') |
| tuple | _OUTPUT_PREFIXES = ('MBO_', 'RDO_', 'RAO_') |
Transform blark AST into st2js IR dataclasses. Walks the blark typed AST (produced by blark.parse_source_code + transform) and produces an IRProgram containing variables, statements, and expressions in the st2js internal representation.
|
protected |
Recursively collect IRVarRef names from an expression.
|
protected |
Recursively collect all IRVarRef.name from a statement list.
|
protected |
Resolve a type name string to an IECType, handling parameterized types. Handles STRING[n], WSTRING[n], etc. by stripping the length suffix.
| None st2js.transformer.resolve_io_by_prefix | ( | IRProgram | program | ) |
Find undeclared variables in program body and classify them as inputs/outputs based on naming convention (MBI_*, RDI_* = inputs, MBO_*, RDO_* = outputs). Mutates program in-place: adds new IRVariable entries to program.inputs and program.outputs.
| IRProgram st2js.transformer.transform | ( | ParseResult | parse_result, |
| list[str] | None | program_filter = None, | ||
| str | main_program = "Main" ) |
Transform a ParseResult (blark AST) into an IRProgram.
Collects all PROGRAM declarations from the source. The main program
(default "Main") becomes the entry point for uniset_on_step().
Other programs are stored in secondary_programs and emitted as
standalone JS functions callable from the main program.
Args:
parse_result: The result from parse_st() containing the blark typed AST.
program_filter: If set, only convert programs whose names are in this list.
If None, all programs are converted.
main_program: Name of the main program (entry point). Case-insensitive.
Returns:
An IRProgram representing the main PROGRAM, with secondary programs
and FUNCTION_BLOCK declarations attached.
Raises:
UnsupportedError: If no matching PROGRAM declaration found.