Skip to content

Clean up portable memory definitions #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ var assemblyscript, isDev = false;
try { // `require("dist/asc.js")` in explicit browser tests
assemblyscript = eval("require('./assemblyscript')");
} catch (e) {
// combine both errors that lead us here
e.message = e_ts.stack + "\n---\n" + e.stack;
throw e;
throw Error(e_ts.stack + "\n---\n" + e.stack);
}
}
}
Expand Down Expand Up @@ -302,10 +300,13 @@ exports.main = function main(argv, options, callback) {
var sourceText = null; // text reported back to the compiler
var sourcePath = null; // path reported back to the compiler

// Try file.ts, file/index.ts
// Try file.ts, file/index.ts, file.d.ts
if (!internalPath.startsWith(exports.libraryPrefix)) {
if ((sourceText = readFile(sourcePath = internalPath + ".ts", baseDir)) == null) {
sourceText = readFile(sourcePath = internalPath + "/index.ts", baseDir);
if ((sourceText = readFile(sourcePath = internalPath + "/index.ts", baseDir)) == null) {
// portable d.ts: uses the .js file next to it in JS or becomes an import in Wasm
sourceText = readFile(sourcePath = internalPath + ".d.ts", baseDir);
}
}

// Search library in this order: stdlib, custom lib dirs, paths
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/AssemblyScript/assemblyscript/issues"
},
"dependencies": {
"binaryen": "89.0.0-nightly.20191120",
"binaryen": "89.0.0-nightly.20191204",
"long": "^4.0.0",
"source-map-support": "^0.5.16",
"ts-node": "^6.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export class Compiler extends DiagnosticEmitter {
max(options.memoryBase, 8)
);
this.module = Module.create();
var featureFlags: BinaryenFeatureFlags = 0;
var featureFlags: FeatureFlags = 0;
if (this.options.hasFeature(Feature.SIGN_EXTENSION)) featureFlags |= FeatureFlags.SignExt;
if (this.options.hasFeature(Feature.MUTABLE_GLOBALS)) featureFlags |= FeatureFlags.MutableGloabls;
if (this.options.hasFeature(Feature.NONTRAPPING_F2I)) featureFlags |= FeatureFlags.NontrappingFPToInt;
Expand Down
1,515 changes: 764 additions & 751 deletions src/glue/binaryen.d.ts

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/glue/binaryen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const binaryen = global.Binaryen || require("binaryen");

module.exports = binaryen;

const { Module } = require("../module");

Module.prototype.toText = function() {
// NOTE: Conversion to StackIR can yield conversion artifacts like sequences
// of unreachable statements not actually emitted by the compiler. Optimizing
// StackIR removes these again, but may also suppress useless code emitted by
// the compiler that's then no longer visible in tests. Both not ideal.
return binaryen.wrapModule(this.ref).emitStackIR(/* optimize-stack-ir */ true);
};

Module.prototype.toAsmjs = function() {
return binaryen.wrapModule(this.ref).emitAsmjs();
};
12 changes: 0 additions & 12 deletions src/glue/js/binaryen.d.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/glue/js/binaryen.js

This file was deleted.

16 changes: 1 addition & 15 deletions src/glue/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,7 @@
* @preferred
*//***/

import "./binaryen"; // must be first so portable can pick up the memory implementation
import "../../../std/portable/index";
import "../binaryen";
import "./float";
import "./i64";

import { Module } from "../../module";

Module.prototype.toText = function(this: Module) {
// NOTE: Conversion to StackIR can yield conversion artifacts like sequences
// of unreachable statements not actually emitted by the compiler. Optimizing
// StackIR removes these again, but may also suppress useless code emitted by
// the compiler that's then no longer visible in tests. Both not ideal.
return binaryen.wrapModule(this.ref).emitStackIR(/* optimize-stack-ir */ true);
};

Module.prototype.toAsmjs = function(this: Module) {
return binaryen.wrapModule(this.ref).emitAsmjs();
};
Loading