Skip to content

Commit d15b1c1

Browse files
authored
Update binaryen definitions
Update dists
2 parents 328416b + 7eb6f32 commit d15b1c1

File tree

82 files changed

+23305
-11235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+23305
-11235
lines changed

bindings/dist/transformerBundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/asc.js

Lines changed: 107 additions & 202 deletions
Large diffs are not rendered by default.

dist/asc.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/asc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assemblyscript.d.ts

Lines changed: 227 additions & 157 deletions
Large diffs are not rendered by default.

dist/assemblyscript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assemblyscript.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/loader/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function postInstantiate(baseModule, instance) {
192192
? U32[arr + ARRAY_LENGTH_OFFSET >>> 2]
193193
: U32[buf + SIZE_OFFSET >>> 2] >>> align;
194194
return getView(align, info & VAL_SIGNED, info & VAL_FLOAT)
195-
.slice(buf >>>= align, buf + length);
195+
.subarray(buf >>>= align, buf + length);
196196
}
197197

198198
baseModule.__getArrayView = __getArrayView;
@@ -221,8 +221,7 @@ function postInstantiate(baseModule, instance) {
221221
const buffer = memory.buffer;
222222
const U32 = new Uint32Array(buffer);
223223
const bufPtr = U32[ptr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2];
224-
const length = U32[bufPtr + SIZE_OFFSET >>> 2];
225-
return new Type(buffer).slice(bufPtr >>> alignLog2, bufPtr + length >>> alignLog2);
224+
return new Type(buffer, bufPtr, U32[bufPtr + SIZE_OFFSET >>> 2] >>> alignLog2);
226225
}
227226

228227
/** Gets a view on the values of a known-to-be Int8Array in the module's memory. */

lib/loader/tests/assembly/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ export const INT32ARRAY_ID = idof<Int32Array>();
7070
export const UINT32ARRAY_ID = idof<Uint32Array>();
7171
export const FLOAT32ARRAY_ID = idof<Float32Array>();
7272
export const ARRAYI32_ID = idof<Array<i32>>();
73+
74+
export function newFloat32Array(size: i32): Float32Array {
75+
return new Float32Array(size);
76+
}
77+
78+
export function modifyFloat32Array(array: Float32Array, index: i32, value: f32): void {
79+
array[index] = value;
80+
}

lib/loader/tests/build/untouched.wasm

454 Bytes
Binary file not shown.

lib/loader/tests/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,25 @@ module.__release(car); // uses Car.prototype.valueOf to obtain `thisPtr`
151151

152152
// should be able to use trace
153153
module.dotrace(42);
154+
155+
// should be able to mutate an array in place using getArrayView
156+
{
157+
let ptr = module.__retain(module.__allocArray(module.FLOAT32ARRAY_ID, [ 1, 2, 3]));
158+
let view = module.__getArrayView(ptr);
159+
assert.deepEqual(view, new Float32Array([1, 2, 3]));
160+
module.modifyFloat32Array(ptr, 0, 4);
161+
assert.deepEqual(view, new Float32Array([4, 2, 3]));
162+
module.__release(ptr);
163+
}
164+
165+
// should be able to mutate an array in place using getFloat32Array
166+
{
167+
let ptr = module.newFloat32Array(3); // returns are pre-retained
168+
let view = module.__getFloat32Array(ptr);
169+
assert.deepEqual(view, new Float32Array([0, 0, 0]));
170+
module.modifyFloat32Array(ptr, 0, 3);
171+
module.modifyFloat32Array(ptr, 1, 2);
172+
module.modifyFloat32Array(ptr, 2, 1);
173+
assert.deepEqual(view, new Float32Array([3, 2, 1]));
174+
module.__release(ptr);
175+
}

package-lock.json

Lines changed: 13 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,24 @@
1212
},
1313
"dependencies": {
1414
"@protobufjs/utf8": "^1.1.0",
15-
"binaryen": "89.0.0-nightly.20190914",
15+
"binaryen": "89.0.0-nightly.20190918",
1616
"glob": "^7.1.4",
1717
"long": "^4.0.0",
1818
"opencollective-postinstall": "^2.0.0",
1919
"source-map-support": "^0.5.13"
2020
},
2121
"devDependencies": {
22-
"@types/node": "^12.7.4",
23-
"assemblyscript-json": "github:nearprotocol/assemblyscript-json",
24-
"bignum": "github:WebAssemblyOS/bignum.wasm#ef043261e06ca36c86a2d330f8b0742211a884a5",
22+
"@types/node": "^12.7.5",
2523
"browser-process-hrtime": "^1.0.0",
2624
"diff": "^4.0.1",
25+
"ts-loader": "^6.1.1",
2726
"near-runtime-ts": "github:nearprotocol/near-runtime-ts",
28-
"ts-loader": "^6.1.0",
2927
"ts-node": "^6.2.0",
3028
"tslint": "^5.20.0",
3129
"typedoc-plugin-external-module-name": "^2.1.0",
32-
"typescript": "^3.6.2",
33-
"webpack": "^4.39.3",
34-
"webpack-cli": "^3.3.8"
30+
"typescript": "^3.6.3",
31+
"webpack": "^4.40.2",
32+
"webpack-cli": "^3.3.9"
3533
},
3634
"main": "index.js",
3735
"types": "index.d.ts",

src/ast.ts

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -683,19 +683,12 @@ export abstract class Node {
683683
if (path) {
684684
let normalizedPath = normalizePath(path.value);
685685
if (path.value.startsWith(".")) { // relative
686-
stmt.normalizedPath = resolvePath(
687-
normalizedPath,
688-
range.source.normalizedPath
689-
);
686+
normalizedPath = resolvePath(normalizedPath, range.source.internalPath);
690687
} else { // absolute
691-
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
692-
normalizedPath = LIBRARY_PREFIX + normalizedPath;
693-
}
694-
stmt.normalizedPath = normalizedPath;
688+
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath;
695689
}
696-
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
690+
stmt.internalPath = mangleInternalPath(normalizedPath);
697691
} else {
698-
stmt.normalizedPath = null;
699692
stmt.internalPath = null;
700693
}
701694
stmt.isDeclare = isDeclare;
@@ -772,17 +765,11 @@ export abstract class Node {
772765
stmt.path = path;
773766
var normalizedPath = normalizePath(path.value);
774767
if (path.value.startsWith(".")) { // relative in project
775-
stmt.normalizedPath = resolvePath(
776-
normalizedPath,
777-
range.source.normalizedPath
778-
);
768+
normalizedPath = resolvePath(normalizedPath, range.source.internalPath);
779769
} else { // absolute in library
780-
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
781-
normalizedPath = LIBRARY_PREFIX + normalizedPath;
782-
}
783-
stmt.normalizedPath = normalizedPath;
770+
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath;
784771
}
785-
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
772+
stmt.internalPath = mangleInternalPath(normalizedPath);
786773
return stmt;
787774
}
788775

@@ -798,17 +785,11 @@ export abstract class Node {
798785
stmt.path = path;
799786
var normalizedPath = normalizePath(path.value);
800787
if (path.value.startsWith(".")) {
801-
stmt.normalizedPath = resolvePath(
802-
normalizedPath,
803-
range.source.normalizedPath
804-
);
788+
normalizedPath = resolvePath(normalizedPath, range.source.internalPath);
805789
} else {
806-
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
807-
normalizedPath = LIBRARY_PREFIX + normalizedPath;
808-
}
809-
stmt.normalizedPath = normalizedPath;
790+
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath;
810791
}
811-
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
792+
stmt.internalPath = mangleInternalPath(normalizedPath);
812793
return stmt;
813794
}
814795

@@ -1636,7 +1617,7 @@ export class Source extends Node {
16361617

16371618
/** Source kind. */
16381619
sourceKind: SourceKind;
1639-
/** Normalized path. */
1620+
/** Normalized path with file extension. */
16401621
normalizedPath: string;
16411622
/** Path used internally. */
16421623
internalPath: string;
@@ -1812,9 +1793,7 @@ export class ExportStatement extends Statement {
18121793
members: ExportMember[] | null;
18131794
/** Path being exported from, if applicable. */
18141795
path: StringLiteralExpression | null;
1815-
/** Normalized path, if `path` is set. */
1816-
normalizedPath: string | null;
1817-
/** Mangled internal path being referenced, if `path` is set. */
1796+
/** Internal path being referenced, if `path` is set. */
18181797
internalPath: string | null;
18191798
/** Whether this is a declared export. */
18201799
isDeclare: bool;
@@ -1934,9 +1913,7 @@ export class ImportStatement extends Statement {
19341913
namespaceName: IdentifierExpression | null;
19351914
/** Path being imported from. */
19361915
path: StringLiteralExpression;
1937-
/** Normalized path. */
1938-
normalizedPath: string;
1939-
/** Mangled internal path being referenced. */
1916+
/** Internal path being referenced. */
19401917
internalPath: string;
19411918
}
19421919

0 commit comments

Comments
 (0)