Skip to content

Commit

Permalink
Update binaryen definitions
Browse files Browse the repository at this point in the history
Update dists
  • Loading branch information
willemneal authored Sep 21, 2019
2 parents 328416b + 7eb6f32 commit d15b1c1
Show file tree
Hide file tree
Showing 82 changed files with 23,305 additions and 11,235 deletions.
2 changes: 1 addition & 1 deletion bindings/dist/transformerBundle.js

Large diffs are not rendered by default.

309 changes: 107 additions & 202 deletions cli/asc.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/asc.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/asc.js.map

Large diffs are not rendered by default.

384 changes: 227 additions & 157 deletions dist/assemblyscript.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/assemblyscript.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/assemblyscript.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions lib/loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function postInstantiate(baseModule, instance) {
? U32[arr + ARRAY_LENGTH_OFFSET >>> 2]
: U32[buf + SIZE_OFFSET >>> 2] >>> align;
return getView(align, info & VAL_SIGNED, info & VAL_FLOAT)
.slice(buf >>>= align, buf + length);
.subarray(buf >>>= align, buf + length);
}

baseModule.__getArrayView = __getArrayView;
Expand Down Expand Up @@ -221,8 +221,7 @@ function postInstantiate(baseModule, instance) {
const buffer = memory.buffer;
const U32 = new Uint32Array(buffer);
const bufPtr = U32[ptr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2];
const length = U32[bufPtr + SIZE_OFFSET >>> 2];
return new Type(buffer).slice(bufPtr >>> alignLog2, bufPtr + length >>> alignLog2);
return new Type(buffer, bufPtr, U32[bufPtr + SIZE_OFFSET >>> 2] >>> alignLog2);
}

/** Gets a view on the values of a known-to-be Int8Array in the module's memory. */
Expand Down
8 changes: 8 additions & 0 deletions lib/loader/tests/assembly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ export const INT32ARRAY_ID = idof<Int32Array>();
export const UINT32ARRAY_ID = idof<Uint32Array>();
export const FLOAT32ARRAY_ID = idof<Float32Array>();
export const ARRAYI32_ID = idof<Array<i32>>();

export function newFloat32Array(size: i32): Float32Array {
return new Float32Array(size);
}

export function modifyFloat32Array(array: Float32Array, index: i32, value: f32): void {
array[index] = value;
}
Binary file modified lib/loader/tests/build/untouched.wasm
Binary file not shown.
22 changes: 22 additions & 0 deletions lib/loader/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,25 @@ module.__release(car); // uses Car.prototype.valueOf to obtain `thisPtr`

// should be able to use trace
module.dotrace(42);

// should be able to mutate an array in place using getArrayView
{
let ptr = module.__retain(module.__allocArray(module.FLOAT32ARRAY_ID, [ 1, 2, 3]));
let view = module.__getArrayView(ptr);
assert.deepEqual(view, new Float32Array([1, 2, 3]));
module.modifyFloat32Array(ptr, 0, 4);
assert.deepEqual(view, new Float32Array([4, 2, 3]));
module.__release(ptr);
}

// should be able to mutate an array in place using getFloat32Array
{
let ptr = module.newFloat32Array(3); // returns are pre-retained
let view = module.__getFloat32Array(ptr);
assert.deepEqual(view, new Float32Array([0, 0, 0]));
module.modifyFloat32Array(ptr, 0, 3);
module.modifyFloat32Array(ptr, 1, 2);
module.modifyFloat32Array(ptr, 2, 1);
assert.deepEqual(view, new Float32Array([3, 2, 1]));
module.__release(ptr);
}
32 changes: 13 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,24 @@
},
"dependencies": {
"@protobufjs/utf8": "^1.1.0",
"binaryen": "89.0.0-nightly.20190914",
"binaryen": "89.0.0-nightly.20190918",
"glob": "^7.1.4",
"long": "^4.0.0",
"opencollective-postinstall": "^2.0.0",
"source-map-support": "^0.5.13"
},
"devDependencies": {
"@types/node": "^12.7.4",
"assemblyscript-json": "github:nearprotocol/assemblyscript-json",
"bignum": "github:WebAssemblyOS/bignum.wasm#ef043261e06ca36c86a2d330f8b0742211a884a5",
"@types/node": "^12.7.5",
"browser-process-hrtime": "^1.0.0",
"diff": "^4.0.1",
"ts-loader": "^6.1.1",
"near-runtime-ts": "github:nearprotocol/near-runtime-ts",
"ts-loader": "^6.1.0",
"ts-node": "^6.2.0",
"tslint": "^5.20.0",
"typedoc-plugin-external-module-name": "^2.1.0",
"typescript": "^3.6.2",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.8"
"typescript": "^3.6.3",
"webpack": "^4.40.2",
"webpack-cli": "^3.3.9"
},
"main": "index.js",
"types": "index.d.ts",
Expand Down
47 changes: 12 additions & 35 deletions src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,19 +683,12 @@ export abstract class Node {
if (path) {
let normalizedPath = normalizePath(path.value);
if (path.value.startsWith(".")) { // relative
stmt.normalizedPath = resolvePath(
normalizedPath,
range.source.normalizedPath
);
normalizedPath = resolvePath(normalizedPath, range.source.internalPath);
} else { // absolute
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
normalizedPath = LIBRARY_PREFIX + normalizedPath;
}
stmt.normalizedPath = normalizedPath;
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath;
}
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
stmt.internalPath = mangleInternalPath(normalizedPath);
} else {
stmt.normalizedPath = null;
stmt.internalPath = null;
}
stmt.isDeclare = isDeclare;
Expand Down Expand Up @@ -772,17 +765,11 @@ export abstract class Node {
stmt.path = path;
var normalizedPath = normalizePath(path.value);
if (path.value.startsWith(".")) { // relative in project
stmt.normalizedPath = resolvePath(
normalizedPath,
range.source.normalizedPath
);
normalizedPath = resolvePath(normalizedPath, range.source.internalPath);
} else { // absolute in library
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
normalizedPath = LIBRARY_PREFIX + normalizedPath;
}
stmt.normalizedPath = normalizedPath;
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath;
}
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
stmt.internalPath = mangleInternalPath(normalizedPath);
return stmt;
}

Expand All @@ -798,17 +785,11 @@ export abstract class Node {
stmt.path = path;
var normalizedPath = normalizePath(path.value);
if (path.value.startsWith(".")) {
stmt.normalizedPath = resolvePath(
normalizedPath,
range.source.normalizedPath
);
normalizedPath = resolvePath(normalizedPath, range.source.internalPath);
} else {
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
normalizedPath = LIBRARY_PREFIX + normalizedPath;
}
stmt.normalizedPath = normalizedPath;
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) normalizedPath = LIBRARY_PREFIX + normalizedPath;
}
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
stmt.internalPath = mangleInternalPath(normalizedPath);
return stmt;
}

Expand Down Expand Up @@ -1636,7 +1617,7 @@ export class Source extends Node {

/** Source kind. */
sourceKind: SourceKind;
/** Normalized path. */
/** Normalized path with file extension. */
normalizedPath: string;
/** Path used internally. */
internalPath: string;
Expand Down Expand Up @@ -1812,9 +1793,7 @@ export class ExportStatement extends Statement {
members: ExportMember[] | null;
/** Path being exported from, if applicable. */
path: StringLiteralExpression | null;
/** Normalized path, if `path` is set. */
normalizedPath: string | null;
/** Mangled internal path being referenced, if `path` is set. */
/** Internal path being referenced, if `path` is set. */
internalPath: string | null;
/** Whether this is a declared export. */
isDeclare: bool;
Expand Down Expand Up @@ -1934,9 +1913,7 @@ export class ImportStatement extends Statement {
namespaceName: IdentifierExpression | null;
/** Path being imported from. */
path: StringLiteralExpression;
/** Normalized path. */
normalizedPath: string;
/** Mangled internal path being referenced. */
/** Internal path being referenced. */
internalPath: string;
}

Expand Down
Loading

0 comments on commit d15b1c1

Please sign in to comment.