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
|
// Use distribution files if present, otherwise run the sources directly
|
||||||
var assemblyscript, isDev = false;
|
var assemblyscript, isDev = false;
|
||||||
(() => {
|
(() => {
|
||||||
try {
|
try { // `asc` on the command line
|
||||||
assemblyscript = require("../dist/assemblyscript.js");
|
assemblyscript = require("../dist/assemblyscript.js");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
try { // `asc` on the command line without dist files
|
||||||
require("ts-node").register({ project: path.join(__dirname, "..", "src", "tsconfig.json") });
|
require("ts-node").register({ project: path.join(__dirname, "..", "src", "tsconfig.json") });
|
||||||
require("../src/glue/js");
|
require("../src/glue/js");
|
||||||
assemblyscript = require("../src");
|
assemblyscript = require("../src");
|
||||||
isDev = true;
|
isDev = true;
|
||||||
} catch (e) {
|
} catch (e_ts) {
|
||||||
// last resort: same directory CommonJS
|
try { // `require("dist/asc.js")` in explicit browser tests
|
||||||
assemblyscript = eval("require('./assemblyscript')");
|
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=
|
assemblyscript.setGlobalAlias(compilerOptions, "abort", "~lib/env/abort"); // to disable: --use abort=
|
||||||
|
|
||||||
// Add or override aliases if specified
|
// Add or override aliases if specified
|
||||||
var aliases = args.use;
|
if (args.use) {
|
||||||
if (aliases != null) {
|
let aliases = args.use;
|
||||||
if (typeof aliases === "string") aliases = aliases.split(",");
|
|
||||||
for (let i = 0, k = aliases.length; i < k; ++i) {
|
for (let i = 0, k = aliases.length; i < k; ++i) {
|
||||||
let part = aliases[i];
|
let part = aliases[i];
|
||||||
let p = part.indexOf("=");
|
let p = part.indexOf("=");
|
||||||
@ -709,7 +716,7 @@ exports.main = function main(argv, options, callback) {
|
|||||||
var files;
|
var files;
|
||||||
try {
|
try {
|
||||||
stats.readTime += measure(() => {
|
stats.readTime += measure(() => {
|
||||||
files = require("glob").sync("!(*.d).ts", { cwd: dirname });
|
files = fs.readdirSync(dirname).filter(file => /^(?!.*\.d\.ts$).*\.ts$/.test(file));
|
||||||
});
|
});
|
||||||
return files;
|
return files;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -133,7 +133,7 @@
|
|||||||
"Aliases a global object under another name, e.g., to switch",
|
"Aliases a global object under another name, e.g., to switch",
|
||||||
"the default 'Math' implementation used: --use Math=JSMath"
|
"the default 'Math' implementation used: --use Math=JSMath"
|
||||||
],
|
],
|
||||||
"type": "s",
|
"type": "S",
|
||||||
"alias": "u"
|
"alias": "u"
|
||||||
},
|
},
|
||||||
"trapMode": {
|
"trapMode": {
|
||||||
|
@ -30,13 +30,15 @@ function parse(argv, config) {
|
|||||||
for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {
|
for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {
|
||||||
let arg = argv[i];
|
let arg = argv[i];
|
||||||
if (arg == "--") { ++i; break; }
|
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 (match) {
|
||||||
if (config[arg]) option = config[key = arg]; // exact
|
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[1] != null) { // alias
|
||||||
else if (match[2] != null) {
|
option = config[key = aliases[match[1].substring(1)]];
|
||||||
option = config[key = match[2].substring(2)]; // full
|
if (option && match[2] != null) argv[i--] = match[2];
|
||||||
if (option && match[3] != null) argv[i--] = match[3];
|
} else if (match[3] != null) { // full
|
||||||
|
option = config[key = match[3].substring(2)];
|
||||||
|
if (option && match[4] != null) argv[i--] = match[4];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (arg.charCodeAt(0) == 45) option = config[key = arg]; // exact
|
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": {
|
"ts-node": {
|
||||||
"version": "7.0.0",
|
"version": "6.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.2.0.tgz",
|
||||||
"integrity": "sha512-klJsfswHP0FuOLsvBZ/zzCfUvakOSSxds78mVeK7I+qP76YWtxf16hEZsp3U+b0kIo82R5UatGFeblYMqabb2Q==",
|
"integrity": "sha512-ZNT+OEGfUNVMGkpIaDJJ44Zq3Yr0bkU/ugN1PHbU+/01Z7UV1fsELRiTx1KuQNvQ1A3pGh3y25iYF6jXgxV21A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"arrify": "^1.0.0",
|
"arrify": "^1.0.0",
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
"diff": "^3.5.0",
|
"diff": "^3.5.0",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"ts-loader": "^4.4.2",
|
"ts-loader": "^4.4.2",
|
||||||
"ts-node": "^7.0.0",
|
"ts-node": "^6.2.0",
|
||||||
"tslint": "^5.10.0",
|
"tslint": "^5.10.0",
|
||||||
"typedoc": "^0.11.1",
|
"typedoc": "^0.11.1",
|
||||||
"typedoc-plugin-external-module-name": "^1.1.1",
|
"typedoc-plugin-external-module-name": "^1.1.1",
|
||||||
|
@ -5894,8 +5894,7 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
// otherwise resolve
|
// otherwise resolve
|
||||||
var target = this.program.resolveIdentifier( // reports
|
var target = this.program.resolveIdentifier( // reports
|
||||||
expression,
|
expression,
|
||||||
currentFunction,
|
this.currentEnum || currentFunction
|
||||||
this.currentEnum
|
|
||||||
);
|
);
|
||||||
if (!target) return module.createUnreachable();
|
if (!target) return module.createUnreachable();
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
* @preferred
|
* @preferred
|
||||||
*//***/
|
*//***/
|
||||||
|
|
||||||
/// <reference path="./binaryen.d.ts" />
|
|
||||||
/// <reference path="./float.d.ts" />
|
|
||||||
/// <reference path="./i64.d.ts" />
|
|
||||||
/// <reference path="./node.d.ts" />
|
/// <reference path="./node.d.ts" />
|
||||||
|
|
||||||
import "../../../std/portable/index";
|
import "../../../std/portable/index";
|
||||||
|
@ -326,13 +326,11 @@ export class Program extends DiagnosticEmitter {
|
|||||||
|
|
||||||
/** Array prototype reference. */
|
/** Array prototype reference. */
|
||||||
arrayPrototype: ClassPrototype | null = null;
|
arrayPrototype: ClassPrototype | null = null;
|
||||||
/** ArrayBufferView prototype reference. */
|
|
||||||
arrayBufferViewPrototype: InterfacePrototype | null = null;
|
|
||||||
/** String instance reference. */
|
/** String instance reference. */
|
||||||
stringInstance: Class | null = null;
|
stringInstance: Class | null = null;
|
||||||
/** Start function reference. */
|
/** Start function reference. */
|
||||||
startFunction: FunctionPrototype;
|
startFunction: FunctionPrototype;
|
||||||
/** Main function reference. */
|
/** Main function reference, if present. */
|
||||||
mainFunction: FunctionPrototype | null = null;
|
mainFunction: FunctionPrototype | null = null;
|
||||||
|
|
||||||
/** Target expression of the previously resolved property or element access. */
|
/** Target expression of the previously resolved property or element access. */
|
||||||
@ -593,13 +591,6 @@ export class Program extends DiagnosticEmitter {
|
|||||||
this.arrayPrototype = <ClassPrototype>arrayPrototype;
|
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'
|
// register 'String'
|
||||||
var stringPrototype = this.elementsLookup.get("String");
|
var stringPrototype = this.elementsLookup.get("String");
|
||||||
if (stringPrototype) {
|
if (stringPrototype) {
|
||||||
@ -2097,58 +2088,46 @@ export class Program extends DiagnosticEmitter {
|
|||||||
/** Resolves an identifier to the element it refers to. */
|
/** Resolves an identifier to the element it refers to. */
|
||||||
resolveIdentifier(
|
resolveIdentifier(
|
||||||
identifier: IdentifierExpression,
|
identifier: IdentifierExpression,
|
||||||
contextualFunction: Function | null,
|
context: Element | null
|
||||||
contextualEnum: Enum | null = null
|
|
||||||
): Element | null {
|
): Element | null {
|
||||||
var name = identifier.text;
|
var name = identifier.text;
|
||||||
|
|
||||||
var element: Element | null;
|
var element: Element | null;
|
||||||
var namespace: Element | null;
|
|
||||||
|
|
||||||
// check siblings
|
if (context) {
|
||||||
if (contextualEnum) {
|
let parent: Element | null;
|
||||||
|
|
||||||
if (
|
switch (context.kind) {
|
||||||
contextualEnum.members &&
|
case ElementKind.FUNCTION: { // search locals
|
||||||
(element = contextualEnum.members.get(name)) &&
|
element = (<Function>context).flow.getScopedLocal(name);
|
||||||
element.kind == ElementKind.ENUMVALUE
|
if (element) {
|
||||||
) {
|
|
||||||
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)) {
|
|
||||||
this.resolvedThisExpression = null;
|
this.resolvedThisExpression = null;
|
||||||
this.resolvedElementExpression = 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",
|
"module": "commonjs",
|
||||||
"noLib": true,
|
"noLib": true,
|
||||||
"allowJs": false,
|
"allowJs": false,
|
||||||
"typeRoots": [ "." ],
|
"typeRoots": [ "types" ],
|
||||||
"types": [ "assembly/" ]
|
"types": [ "assembly" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"downlevelIteration": true,
|
"downlevelIteration": true,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"typeRoots": [ "." ],
|
"typeRoots": [ "types" ],
|
||||||
"types": [ "portable/" ]
|
"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({
|
require("ts-node").register({ project: path.join(__dirname, "..", "src", "tsconfig.json") });
|
||||||
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("../src/glue/js");
|
require("../src/glue/js");
|
||||||
|
|
||||||
var Parser = require("../src/parser").Parser;
|
var Parser = require("../src/parser").Parser;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user