@tsplc/compiler 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ir.js CHANGED
@@ -90,6 +90,45 @@ var standardBlocks = {
90
90
  inputs: [["signal", "CLK", "BOOL"]],
91
91
  outputs: [["fell", "Q", "BOOL"]]
92
92
  },
93
+ UpCounter: {
94
+ native: "CTU",
95
+ inputs: [
96
+ ["countUp", "CU", "BOOL"],
97
+ ["reset", "RESET", "BOOL"],
98
+ ["preset", "PV", "WORD"]
99
+ ],
100
+ outputs: [
101
+ ["reachedPreset", "Q", "BOOL"],
102
+ ["value", "CV", "WORD"]
103
+ ]
104
+ },
105
+ DownCounter: {
106
+ native: "CTD",
107
+ inputs: [
108
+ ["countDown", "CD", "BOOL"],
109
+ ["load", "LOAD", "BOOL"],
110
+ ["preset", "PV", "WORD"]
111
+ ],
112
+ outputs: [
113
+ ["atZero", "Q", "BOOL"],
114
+ ["value", "CV", "WORD"]
115
+ ]
116
+ },
117
+ UpDownCounter: {
118
+ native: "CTUD",
119
+ inputs: [
120
+ ["countUp", "CU", "BOOL"],
121
+ ["countDown", "CD", "BOOL"],
122
+ ["reset", "RESET", "BOOL"],
123
+ ["load", "LOAD", "BOOL"],
124
+ ["preset", "PV", "WORD"]
125
+ ],
126
+ outputs: [
127
+ ["reachedPreset", "QU", "BOOL"],
128
+ ["atZero", "QD", "BOOL"],
129
+ ["value", "CV", "WORD"]
130
+ ]
131
+ },
93
132
  Blinker: {
94
133
  native: "Util.BLINK",
95
134
  inputs: [
@@ -931,7 +970,18 @@ class ModuleDeclarations {
931
970
  if (block.standard) {
932
971
  const expected = Object.hasOwn(standardBlocks, block.standard) ? standardBlocks[block.standard] : undefined;
933
972
  const matches = (variables, schema) => variables.length === schema.length && schema.every(([name, , type]) => variables.some((variable) => variable.name === name && variable.type === type && !variable.mode && !variable.retain));
934
- if (!expected || block.name !== block.standard || block.body.length || block.state.length || block.locals.length || !matches(block.inputs, expected.inputs) || !matches(block.outputs, expected.outputs) || block.outputs.some((output) => output.type === "BOOL" ? output.initial?.kind !== "bool" || output.initial.value !== false : output.initial?.kind !== "duration" || output.initial.nanoseconds !== "0"))
973
+ if (!expected || block.name !== block.standard || block.body.length || block.state.length || block.locals.length || !matches(block.inputs, expected.inputs) || !matches(block.outputs, expected.outputs) || block.outputs.some(({ initial }) => {
974
+ switch (initial?.kind) {
975
+ case "bool":
976
+ return initial.value !== false;
977
+ case "duration":
978
+ return initial.nanoseconds !== "0";
979
+ case "integer":
980
+ return initial.value !== "0";
981
+ default:
982
+ return true;
983
+ }
984
+ }))
935
985
  reject("Invalid canonical standard block definition.", block.span);
936
986
  }
937
987
  }
@@ -1884,5 +1934,5 @@ export {
1884
1934
  wrapsNatively
1885
1935
  };
1886
1936
 
1887
- //# debugId=56F86269D01021CE64756E2164756E21
1937
+ //# debugId=6C2C28B29E0F243F64756E2164756E21
1888
1938
  //# sourceMappingURL=ir.js.map