@onda-lang/wasm-compiler 0.5.0 → 0.5.1

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.
@@ -1816,6 +1816,7 @@ class MirCompiler {
1816
1816
  rawIndex,
1817
1817
  () => this.compileBufferParamTotalScalarLen(data.parameter, context),
1818
1818
  data.bounds,
1819
+ true,
1819
1820
  );
1820
1821
  return this.module.i32.add(
1821
1822
  this.loadBufferParamComponent(data.parameter, 0, "i32", context),
@@ -1848,6 +1849,7 @@ class MirCompiler {
1848
1849
  rawIndex,
1849
1850
  () => this.compileBufferTotalScalarLen(data.buffer),
1850
1851
  data.bounds,
1852
+ true,
1851
1853
  );
1852
1854
  const pointer = this.loadBufferTableValue(
1853
1855
  POINTER_GLOBALS.buffers,
@@ -2186,6 +2188,7 @@ class MirCompiler {
2186
2188
  () => this.compileValue(source.data.channel, context),
2187
2189
  channels,
2188
2190
  "clamp",
2191
+ true,
2189
2192
  );
2190
2193
  return [
2191
2194
  this.module.i32.add(
@@ -2218,6 +2221,7 @@ class MirCompiler {
2218
2221
  () => this.compileValue(source.data.channel, context),
2219
2222
  channels,
2220
2223
  "clamp",
2224
+ true,
2221
2225
  );
2222
2226
  return [
2223
2227
  this.module.i32.add(
@@ -2908,16 +2912,14 @@ class MirCompiler {
2908
2912
  this.fail(`unknown bounds mode '${String(bounds)}'`);
2909
2913
  }
2910
2914
 
2911
- compileDynamicBoundedIndex(index, length, bounds) {
2915
+ compileDynamicBoundedIndex(index, length, bounds, clampLengthKnownPositive = false) {
2912
2916
  if (bounds === "unchecked") {
2913
2917
  return index();
2914
2918
  }
2915
2919
  if (bounds === "clamp") {
2916
2920
  const maximum = () =>
2917
2921
  this.module.i32.sub(length(), this.module.i32.const(1));
2918
- return this.module.if(
2919
- this.module.i32.le_s(length(), this.module.i32.const(0)),
2920
- this.module.unreachable(),
2922
+ const clamped = () =>
2921
2923
  this.module.select(
2922
2924
  this.module.i32.lt_s(index(), this.module.i32.const(0)),
2923
2925
  this.module.i32.const(0),
@@ -2926,7 +2928,12 @@ class MirCompiler {
2926
2928
  maximum(),
2927
2929
  index(),
2928
2930
  ),
2929
- ),
2931
+ );
2932
+ if (clampLengthKnownPositive) return clamped();
2933
+ return this.module.if(
2934
+ this.module.i32.le_s(length(), this.module.i32.const(0)),
2935
+ this.module.unreachable(),
2936
+ clamped(),
2930
2937
  );
2931
2938
  }
2932
2939
  if (bounds === "trap") {
package/dist/build.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
- "ondaVersion": "0.5.0",
2
+ "ondaVersion": "0.5.1",
3
3
  "binaryenVersion": "130.0.0",
4
4
  "frontendPackage": "onda_compiler_web",
5
5
  "frontendOptimization": {
6
6
  "tool": "wasm-opt",
7
7
  "binaryenVersion": "130.0.0",
8
8
  "optimizeLevel": 4,
9
- "inputBytes": 6451302,
10
- "outputBytes": 4889523
9
+ "inputBytes": 6453798,
10
+ "outputBytes": 4892395
11
11
  }
12
12
  }
@@ -5,7 +5,7 @@
5
5
  "onda contributors"
6
6
  ],
7
7
  "description": "Browser-safe Onda source-to-MIR compiler",
8
- "version": "0.5.0",
8
+ "version": "0.5.1",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const ONDA_VERSION = "0.5.0";
1
+ export const ONDA_VERSION = "0.5.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onda-lang/wasm-compiler",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "Onda source-to-WebAssembly compiler for browsers and Node.js",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "url": "git+https://github.com/onda-lang/onda.git",
10
10
  "directory": "packages/onda_wasm_compiler"
11
11
  },
12
- "homepage": "https://onda-lang.github.io/onda/",
12
+ "homepage": "https://onda-lang.org/",
13
13
  "bugs": {
14
14
  "url": "https://github.com/onda-lang/onda/issues"
15
15
  },
@@ -59,7 +59,7 @@
59
59
  "prepack": "npm run build"
60
60
  },
61
61
  "dependencies": {
62
- "@onda-lang/processor-abi": "0.5.0",
62
+ "@onda-lang/processor-abi": "0.5.1",
63
63
  "binaryen": "130.0.0"
64
64
  },
65
65
  "publishConfig": {