|
UniSet 2.45.1
|
Классы | |
| class | GenerateStats |
| class | CodeGenerator |
Функции | |
| str | generate (IRProgram program, SensorMapping mapping, bool debug=False) |
| tuple[str, GenerateStats] | generate_with_stats (IRProgram program, SensorMapping mapping, bool debug=False) |
Переменные | |
| dict | _OPERATOR_MAP |
| dict | _DEFAULT_VALUES |
JavaScript code generator for the st2js converter.
Walks the typed IR and emits JavaScript source code compatible with the
UniSet2 JScript extension. Generates:
- load("uniset2-iec61131.js") import
- uniset_inputs / uniset_outputs sensor arrays
- Local variable declarations
- uniset_on_step() function wrapping the PROGRAM body
Sensor variable substitution:
- VAR_INPUT variables become in_<SensorName>
- VAR_OUTPUT variables become out_<SensorName>
- VAR local variables keep their original names
| str st2js.codegen.generate | ( | IRProgram | program, |
| SensorMapping | mapping, | ||
| bool | debug = False ) |
Generate JavaScript source from a typed IRProgram and sensor mapping.
Args:
program: The typed IRProgram (after type checking).
mapping: The sensor mapping configuration.
debug: If True, emit trace instrumentation and program metadata.
Returns:
A complete JavaScript source string.
| tuple[str, GenerateStats] st2js.codegen.generate_with_stats | ( | IRProgram | program, |
| SensorMapping | mapping, | ||
| bool | debug = False ) |
Generate JavaScript source and collect statistics.
Returns:
Tuple of (JavaScript source string, GenerateStats).
|
protected |
|
protected |