@onda-lang/processor-abi 0.7.4 → 0.7.5
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/package.json +1 -1
- package/src/index.d.ts +9 -4
- package/src/index.js +34 -2
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const PROCESSOR_ARTIFACT_FORMAT: "onda-processor";
|
|
2
2
|
// Synchronized from format-versions.json; do not edit these copies directly.
|
|
3
|
-
export const PROCESSOR_ARTIFACT_FORMAT_VERSION:
|
|
4
|
-
export const PROCESSOR_ABI_VERSION:
|
|
3
|
+
export const PROCESSOR_ARTIFACT_FORMAT_VERSION: 4;
|
|
4
|
+
export const PROCESSOR_ABI_VERSION: 4;
|
|
5
5
|
export const PROCESSOR_EXECUTION_OK: 0;
|
|
6
6
|
export const PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE: 1;
|
|
7
7
|
export const PROCESSOR_SNAPSHOT_FORMAT_VERSION: 1;
|
|
@@ -165,13 +165,18 @@ export interface OndaStateMetadata {
|
|
|
165
165
|
packed_snapshot_byte_offset: number;
|
|
166
166
|
physical_state_byte_offset: number;
|
|
167
167
|
byte_size: number;
|
|
168
|
+
integer_range?: {
|
|
169
|
+
min: { type: "i32" | "i64"; value: string };
|
|
170
|
+
max: { type: "i32" | "i64"; value: string };
|
|
171
|
+
mode: "clamp" | "wrap";
|
|
172
|
+
} | null;
|
|
168
173
|
}
|
|
169
174
|
|
|
170
175
|
export interface OndaProcessorMetadata {
|
|
171
176
|
format: "onda-processor";
|
|
172
|
-
format_version:
|
|
177
|
+
format_version: 4;
|
|
173
178
|
artifact_kind: OndaArtifactKind;
|
|
174
|
-
abi_version:
|
|
179
|
+
abi_version: 4;
|
|
175
180
|
backend: string;
|
|
176
181
|
mir_schema_version: number;
|
|
177
182
|
target: OndaTargetInfo;
|
package/src/index.js
CHANGED
|
@@ -4,8 +4,8 @@ const PARAM_CONTROL = globalThis.__ONDA_PARAM_CONTROL_V2__;
|
|
|
4
4
|
|
|
5
5
|
export const PROCESSOR_ARTIFACT_FORMAT = "onda-processor";
|
|
6
6
|
// Synchronized from format-versions.json; do not edit these copies directly.
|
|
7
|
-
export const PROCESSOR_ARTIFACT_FORMAT_VERSION =
|
|
8
|
-
export const PROCESSOR_ABI_VERSION =
|
|
7
|
+
export const PROCESSOR_ARTIFACT_FORMAT_VERSION = 4;
|
|
8
|
+
export const PROCESSOR_ABI_VERSION = 4;
|
|
9
9
|
export const PROCESSOR_EXECUTION_OK = 0;
|
|
10
10
|
export const PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE = 1;
|
|
11
11
|
export const PROCESSOR_SNAPSHOT_FORMAT_VERSION = 1;
|
|
@@ -482,6 +482,38 @@ function validateStateMetadata(value, path) {
|
|
|
482
482
|
);
|
|
483
483
|
requireInteger(value?.byte_size, `${path}.byte_size`, 1);
|
|
484
484
|
requireScalarLayout(value, path);
|
|
485
|
+
const range = value?.integer_range;
|
|
486
|
+
if (range === undefined || range === null) return;
|
|
487
|
+
if (value.scalar !== "i32" && value.scalar !== "i64") {
|
|
488
|
+
throw new OndaArtifactError(`${path}.integer_range requires i32 or i64 state`);
|
|
489
|
+
}
|
|
490
|
+
if (value.array_len !== 1) {
|
|
491
|
+
throw new OndaArtifactError(`${path}.integer_range requires scalar state`);
|
|
492
|
+
}
|
|
493
|
+
if (range.mode !== "clamp" && range.mode !== "wrap") {
|
|
494
|
+
throw new OndaArtifactError(`${path}.integer_range.mode must be 'clamp' or 'wrap'`);
|
|
495
|
+
}
|
|
496
|
+
const parseEndpoint = (endpoint, endpointPath) => {
|
|
497
|
+
if (endpoint?.type !== value.scalar) {
|
|
498
|
+
throw new OndaArtifactError(`${endpointPath}.type must match state scalar '${value.scalar}'`);
|
|
499
|
+
}
|
|
500
|
+
requireString(endpoint?.value, `${endpointPath}.value`);
|
|
501
|
+
if (!/^-?(0|[1-9][0-9]*)$/.test(endpoint.value)) {
|
|
502
|
+
throw new OndaArtifactError(`${endpointPath}.value must be a canonical decimal integer`);
|
|
503
|
+
}
|
|
504
|
+
const parsed = BigInt(endpoint.value);
|
|
505
|
+
const minimum = value.scalar === "i32" ? -(1n << 31n) : -(1n << 63n);
|
|
506
|
+
const maximum = value.scalar === "i32" ? (1n << 31n) - 1n : (1n << 63n) - 1n;
|
|
507
|
+
if (parsed < minimum || parsed > maximum) {
|
|
508
|
+
throw new OndaArtifactError(`${endpointPath}.value exceeds ${value.scalar}`);
|
|
509
|
+
}
|
|
510
|
+
return parsed;
|
|
511
|
+
};
|
|
512
|
+
const minimum = parseEndpoint(range.min, `${path}.integer_range.min`);
|
|
513
|
+
const maximum = parseEndpoint(range.max, `${path}.integer_range.max`);
|
|
514
|
+
if (minimum > maximum) {
|
|
515
|
+
throw new OndaArtifactError(`${path}.integer_range minimum exceeds maximum`);
|
|
516
|
+
}
|
|
485
517
|
}
|
|
486
518
|
|
|
487
519
|
function validateRuntimeLayouts(descriptor) {
|