mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Fix missing dependency in asc, see #157; Downgrade ts-node to v6
This commit is contained in:
parent
5ca5df3dc7
commit
c4ebc8c291
25
cli/asc.js
25
cli/asc.js
@ -24,17 +24,25 @@ const EOL = process.platform === "win32" ? "\r\n" : "\n";
|
||||
// Use distribution files if present, otherwise run the sources directly
|
||||
var assemblyscript, isDev = false;
|
||||
(() => {
|
||||
try {
|
||||
try { // `asc` on the command line
|
||||
assemblyscript = require("../dist/assemblyscript.js");
|
||||
} catch (e) {
|
||||
try {
|
||||
try { // `asc` on the command line without dist files
|
||||
require("ts-node").register({ project: path.join(__dirname, "..", "src", "tsconfig.json") });
|
||||
require("../src/glue/js");
|
||||
assemblyscript = require("../src");
|
||||
isDev = true;
|
||||
} catch (e) {
|
||||
// last resort: same directory CommonJS
|
||||
assemblyscript = eval("require('./assemblyscript')");
|
||||
} catch (e_ts) {
|
||||
try { // `require("dist/asc.js")` in explicit browser tests
|
||||
assemblyscript = eval("require('./assemblyscript')");
|
||||
} catch (e) {
|
||||
// combine both errors that lead us here
|
||||
e.stack = e_ts.stack + "\n---\n" + e.stack;
|
||||
// Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional
|
||||
// useless code fragment on top of the actual error. suppress this:
|
||||
if (process.removeAllListeners) process.removeAllListeners("uncaughtException");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
@ -408,9 +416,8 @@ exports.main = function main(argv, options, callback) {
|
||||
assemblyscript.setGlobalAlias(compilerOptions, "abort", "~lib/env/abort"); // to disable: --use abort=
|
||||
|
||||
// Add or override aliases if specified
|
||||
var aliases = args.use;
|
||||
if (aliases != null) {
|
||||
if (typeof aliases === "string") aliases = aliases.split(",");
|
||||
if (args.use) {
|
||||
let aliases = args.use;
|
||||
for (let i = 0, k = aliases.length; i < k; ++i) {
|
||||
let part = aliases[i];
|
||||
let p = part.indexOf("=");
|
||||
@ -709,7 +716,7 @@ exports.main = function main(argv, options, callback) {
|
||||
var files;
|
||||
try {
|
||||
stats.readTime += measure(() => {
|
||||
files = require("glob").sync("!(*.d).ts", { cwd: dirname });
|
||||
files = fs.readdirSync(dirname).filter(file => /^(?!.*\.d\.ts$).*\.ts$/.test(file));
|
||||
});
|
||||
return files;
|
||||
} catch (e) {
|
||||
|
@ -133,7 +133,7 @@
|
||||
"Aliases a global object under another name, e.g., to switch",
|
||||
"the default 'Math' implementation used: --use Math=JSMath"
|
||||
],
|
||||
"type": "s",
|
||||
"type": "S",
|
||||
"alias": "u"
|
||||
},
|
||||
"trapMode": {
|
||||
|
@ -30,13 +30,15 @@ function parse(argv, config) {
|
||||
for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {
|
||||
let arg = argv[i];
|
||||
if (arg == "--") { ++i; break; }
|
||||
let match = /^(?:(\-\w)|(\-\-\w{2,})(?:=(.*))?)$/.exec(arg), option, key;
|
||||
let match = /^(?:(\-\w)(?:=(.*))?|(\-\-\w{2,})(?:=(.*))?)$/.exec(arg), option, key;
|
||||
if (match) {
|
||||
if (config[arg]) option = config[key = arg]; // exact
|
||||
else if (match[1] != null) option = config[key = aliases[match[1].substring(1)]]; // alias
|
||||
else if (match[2] != null) {
|
||||
option = config[key = match[2].substring(2)]; // full
|
||||
if (option && match[3] != null) argv[i--] = match[3];
|
||||
else if (match[1] != null) { // alias
|
||||
option = config[key = aliases[match[1].substring(1)]];
|
||||
if (option && match[2] != null) argv[i--] = match[2];
|
||||
} else if (match[3] != null) { // full
|
||||
option = config[key = match[3].substring(2)];
|
||||
if (option && match[4] != null) argv[i--] = match[4];
|
||||
}
|
||||
} else {
|
||||
if (arg.charCodeAt(0) == 45) option = config[key = arg]; // exact
|
||||
|
2
dist/asc.js
vendored
2
dist/asc.js
vendored
File diff suppressed because one or more lines are too long
2
dist/asc.js.map
vendored
2
dist/asc.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js
vendored
2
dist/assemblyscript.js
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js.map
vendored
2
dist/assemblyscript.js.map
vendored
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
6
package-lock.json
generated
@ -4269,9 +4269,9 @@
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.0.tgz",
|
||||
"integrity": "sha512-klJsfswHP0FuOLsvBZ/zzCfUvakOSSxds78mVeK7I+qP76YWtxf16hEZsp3U+b0kIo82R5UatGFeblYMqabb2Q==",
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.2.0.tgz",
|
||||
"integrity": "sha512-ZNT+OEGfUNVMGkpIaDJJ44Zq3Yr0bkU/ugN1PHbU+/01Z7UV1fsELRiTx1KuQNvQ1A3pGh3y25iYF6jXgxV21A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arrify": "^1.0.0",
|
||||
|
@ -21,7 +21,7 @@
|
||||
"diff": "^3.5.0",
|
||||
"glob": "^7.1.2",
|
||||
"ts-loader": "^4.4.2",
|
||||
"ts-node": "^7.0.0",
|
||||
"ts-node": "^6.2.0",
|
||||
"tslint": "^5.10.0",
|
||||
"typedoc": "^0.11.1",
|
||||
"typedoc-plugin-external-module-name": "^1.1.1",
|
||||
|
@ -5894,8 +5894,7 @@ export class Compiler extends DiagnosticEmitter {
|
||||
// otherwise resolve
|
||||
var target = this.program.resolveIdentifier( // reports
|
||||
expression,
|
||||
currentFunction,
|
||||
this.currentEnum
|
||||
this.currentEnum || currentFunction
|
||||
);
|
||||
if (!target) return module.createUnreachable();
|
||||
|
||||
|
@ -4,9 +4,6 @@
|
||||
* @preferred
|
||||
*//***/
|
||||
|
||||
/// <reference path="./binaryen.d.ts" />
|
||||
/// <reference path="./float.d.ts" />
|
||||
/// <reference path="./i64.d.ts" />
|
||||
/// <reference path="./node.d.ts" />
|
||||
|
||||
import "../../../std/portable/index";
|
||||
|
@ -326,13 +326,11 @@ export class Program extends DiagnosticEmitter {
|
||||
|
||||
/** Array prototype reference. */
|
||||
arrayPrototype: ClassPrototype | null = null;
|
||||
/** ArrayBufferView prototype reference. */
|
||||
arrayBufferViewPrototype: InterfacePrototype | null = null;
|
||||
/** String instance reference. */
|
||||
stringInstance: Class | null = null;
|
||||
/** Start function reference. */
|
||||
startFunction: FunctionPrototype;
|
||||
/** Main function reference. */
|
||||
/** Main function reference, if present. */
|
||||
mainFunction: FunctionPrototype | null = null;
|
||||
|
||||
/** Target expression of the previously resolved property or element access. */
|
||||
@ -593,13 +591,6 @@ export class Program extends DiagnosticEmitter {
|
||||
this.arrayPrototype = <ClassPrototype>arrayPrototype;
|
||||
}
|
||||
|
||||
// register 'ArrayBufferView'
|
||||
var arrayBufferViewPrototype = this.elementsLookup.get("ArrayBufferView");
|
||||
if (arrayBufferViewPrototype) {
|
||||
assert(arrayBufferViewPrototype.kind == ElementKind.INTERFACE_PROTOTYPE);
|
||||
this.arrayBufferViewPrototype = <InterfacePrototype>arrayBufferViewPrototype;
|
||||
}
|
||||
|
||||
// register 'String'
|
||||
var stringPrototype = this.elementsLookup.get("String");
|
||||
if (stringPrototype) {
|
||||
@ -2097,58 +2088,46 @@ export class Program extends DiagnosticEmitter {
|
||||
/** Resolves an identifier to the element it refers to. */
|
||||
resolveIdentifier(
|
||||
identifier: IdentifierExpression,
|
||||
contextualFunction: Function | null,
|
||||
contextualEnum: Enum | null = null
|
||||
context: Element | null
|
||||
): Element | null {
|
||||
var name = identifier.text;
|
||||
|
||||
var element: Element | null;
|
||||
var namespace: Element | null;
|
||||
|
||||
// check siblings
|
||||
if (contextualEnum) {
|
||||
if (context) {
|
||||
let parent: Element | null;
|
||||
|
||||
if (
|
||||
contextualEnum.members &&
|
||||
(element = contextualEnum.members.get(name)) &&
|
||||
element.kind == ElementKind.ENUMVALUE
|
||||
) {
|
||||
this.resolvedThisExpression = null;
|
||||
this.resolvedElementExpression = null;
|
||||
return element; // ENUMVALUE
|
||||
}
|
||||
|
||||
} else if (contextualFunction) {
|
||||
|
||||
// check locals
|
||||
if (element = contextualFunction.flow.getScopedLocal(name)) {
|
||||
this.resolvedThisExpression = null;
|
||||
this.resolvedElementExpression = null;
|
||||
return element; // LOCAL
|
||||
}
|
||||
|
||||
// check outer scope locals
|
||||
// let outerScope = contextualFunction.outerScope;
|
||||
// while (outerScope) {
|
||||
// if (element = outerScope.getScopedLocal(name)) {
|
||||
// let scopedLocal = <Local>element;
|
||||
// let scopedGlobal = scopedLocal.scopedGlobal;
|
||||
// if (!scopedGlobal) scopedGlobal = outerScope.addScopedGlobal(scopedLocal);
|
||||
// if (!resolvedElement) resolvedElement = new ResolvedElement();
|
||||
// return resolvedElement.set(scopedGlobal);
|
||||
// }
|
||||
// outerScope = outerScope.currentFunction.outerScope;
|
||||
// }
|
||||
|
||||
// search contextual parent namespaces if applicable
|
||||
if (namespace = contextualFunction.prototype.parent) {
|
||||
do {
|
||||
if (element = this.elementsLookup.get(namespace.internalName + STATIC_DELIMITER + name)) {
|
||||
switch (context.kind) {
|
||||
case ElementKind.FUNCTION: { // search locals
|
||||
element = (<Function>context).flow.getScopedLocal(name);
|
||||
if (element) {
|
||||
this.resolvedThisExpression = null;
|
||||
this.resolvedElementExpression = null;
|
||||
return element; // LOCAL
|
||||
return element;
|
||||
}
|
||||
} while (namespace = namespace.parent);
|
||||
parent = (<Function>context).prototype.parent;
|
||||
break;
|
||||
}
|
||||
case ElementKind.CLASS: {
|
||||
parent = (<Class>context).prototype.parent;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
parent = context;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// search parent
|
||||
while (parent) {
|
||||
let members = parent.members;
|
||||
if (members) {
|
||||
if (element = members.get(name)) {
|
||||
this.resolvedThisExpression = null;
|
||||
this.resolvedElementExpression = null;
|
||||
return element;
|
||||
}
|
||||
}
|
||||
parent = parent.parent;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
"module": "commonjs",
|
||||
"noLib": true,
|
||||
"allowJs": false,
|
||||
"typeRoots": [ "." ],
|
||||
"types": [ "assembly/" ]
|
||||
"typeRoots": [ "types" ],
|
||||
"types": [ "assembly" ]
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
"allowJs": true,
|
||||
"downlevelIteration": true,
|
||||
"preserveConstEnums": true,
|
||||
"typeRoots": [ "." ],
|
||||
"types": [ "portable/" ]
|
||||
"typeRoots": [ "types" ],
|
||||
"types": [ "portable" ]
|
||||
}
|
||||
}
|
||||
|
1
std/types/assembly/index.d.ts
vendored
Normal file
1
std/types/assembly/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import "../../assembly/index";
|
3
std/types/assembly/package.json
Normal file
3
std/types/assembly/package.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"types": "index.d.ts"
|
||||
}
|
1
std/types/portable/index.d.ts
vendored
Normal file
1
std/types/portable/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import "../../portable/index";
|
3
std/types/portable/package.json
Normal file
3
std/types/portable/package.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"types": "index.d.ts"
|
||||
}
|
@ -49,11 +49,7 @@ if (argv.length) {
|
||||
}
|
||||
}
|
||||
|
||||
require("ts-node").register({
|
||||
project: path.join(__dirname, "..", "src", "tsconfig.json"),
|
||||
cache: false // FIXME: for some reason, if both asc and the parser tests use caching, the one
|
||||
// invoked later cannot find some definition files.
|
||||
});
|
||||
require("ts-node").register({ project: path.join(__dirname, "..", "src", "tsconfig.json") });
|
||||
require("../src/glue/js");
|
||||
|
||||
var Parser = require("../src/parser").Parser;
|
||||
|
Loading…
x
Reference in New Issue
Block a user