Skip to content

Commit

Permalink
Update gleam to 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
x0k committed Oct 12, 2024
1 parent 636c9b5 commit c15e4a7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Binary file modified packages/gleam-runtime/src/vendor/compiler/gleam_wasm_bg.wasm
Binary file not shown.
5 changes: 3 additions & 2 deletions packages/gleam-runtime/src/vendor/compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "gleam-wasm",
"type": "module",
"collaborators": [
"Louis Pilfold <[email protected]>"
],
"version": "1.5.0",
"version": "1.5.1",
"license": "SEE LICENSE IN LICENCE",
"files": [
"gleam_wasm_bg.wasm",
"gleam_wasm.js",
"gleam_wasm.d.ts"
],
"module": "gleam_wasm.js",
"main": "gleam_wasm.js",
"types": "gleam_wasm.d.ts",
"sideEffects": [
"./snippets/*"
Expand Down
21 changes: 12 additions & 9 deletions packages/gleam-runtime/src/vendor/stdlib/precompiled/gleam.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class List {
return desired === 0;
}

// @internal
countLength() {
let length = 0;
for (let _ of this) length++;
Expand Down Expand Up @@ -169,24 +170,24 @@ export function sizedInt(value, size, isBigEndian) {

// Convert negative number to two's complement representation
if (value < 0) {
value = (2 ** size) + value;
value = 2 ** size + value;
}

if (isBigEndian) {
for (let i = 0; i < byteArray.length; i++) {
const byte = value % 256
for (let i = byteArray.length - 1; i >= 0; i--) {
const byte = value % 256;
byteArray[i] = byte;
value = (value - byte) / 256;
}
} else {
for (let i = byteArray.length - 1; i >= 0; i--) {
const byte = value % 256
for (let i = 0; i < byteArray.length; i++) {
const byte = value % 256;
byteArray[i] = byte;
value = (value - byte) / 256;
}
}

return byteArray.reverse();
return byteArray;
}

// @internal
Expand Down Expand Up @@ -226,9 +227,9 @@ export function byteArrayToFloat(byteArray, start, end, isBigEndian) {
const byteSize = end - start;

if (byteSize === 8) {
return view.getFloat64(start, !isBigEndian)
return view.getFloat64(start, !isBigEndian);
} else if (byteSize === 4) {
return view.getFloat32(start, !isBigEndian)
return view.getFloat32(start, !isBigEndian);
} else {
const msg = `Sized floats must be 32-bit or 64-bit on JavaScript, got size of ${byteSize * 8} bits`;
throw new globalThis.Error(msg);
Expand Down Expand Up @@ -261,7 +262,7 @@ export function sizedFloat(float, size, isBigEndian) {
} else if (size === 32) {
view.setFloat32(0, float, !isBigEndian);
}

return byteArray;
}

Expand Down Expand Up @@ -414,6 +415,8 @@ export function makeError(variant, module, line, fn, message, extra) {
error.gleam_error = variant;
error.module = module;
error.line = line;
error.function = fn;
// TODO: Remove this with Gleam v2.0.0
error.fn = fn;
for (let k in extra) error[k] = extra[k];
return error;
Expand Down

0 comments on commit c15e4a7

Please sign in to comment.