mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 23:12:19 +00:00
Process backlog once more after Transform#afterParse, see #356
This commit is contained in:
parent
6ed45bee98
commit
aedc821c09
60
cli/asc.js
60
cli/asc.js
@ -285,33 +285,10 @@ exports.main = function main(argv, options, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include entry files
|
// Parses the backlog of imported files after including entry files
|
||||||
for (let i = 0, k = argv.length; i < k; ++i) {
|
function parseBacklog() {
|
||||||
const filename = argv[i];
|
var sourcePath, sourceText;
|
||||||
|
|
||||||
let sourcePath = String(filename).replace(/\\/g, "/").replace(/(\.ts|\/)$/, "");
|
|
||||||
|
|
||||||
// Try entryPath.ts, then entryPath/index.ts
|
|
||||||
let sourceText = readFile(path.join(baseDir, sourcePath) + ".ts");
|
|
||||||
if (sourceText === null) {
|
|
||||||
sourceText = readFile(path.join(baseDir, sourcePath, "index.ts"));
|
|
||||||
if (sourceText === null) {
|
|
||||||
return callback(Error("Entry file '" + sourcePath + ".ts' not found."));
|
|
||||||
} else {
|
|
||||||
sourcePath += "/index.ts";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sourcePath += ".ts";
|
|
||||||
}
|
|
||||||
|
|
||||||
stats.parseCount++;
|
|
||||||
stats.parseTime += measure(() => {
|
|
||||||
parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Process backlog
|
|
||||||
while ((sourcePath = parser.nextFile()) != null) {
|
while ((sourcePath = parser.nextFile()) != null) {
|
||||||
let found = false;
|
|
||||||
|
|
||||||
// Load library file if explicitly requested
|
// Load library file if explicitly requested
|
||||||
if (sourcePath.startsWith(exports.libraryPrefix)) {
|
if (sourcePath.startsWith(exports.libraryPrefix)) {
|
||||||
@ -390,7 +367,38 @@ exports.main = function main(argv, options, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Include entry files
|
||||||
|
for (let i = 0, k = argv.length; i < k; ++i) {
|
||||||
|
const filename = argv[i];
|
||||||
|
|
||||||
|
let sourcePath = String(filename).replace(/\\/g, "/").replace(/(\.ts|\/)$/, "");
|
||||||
|
|
||||||
|
// Try entryPath.ts, then entryPath/index.ts
|
||||||
|
let sourceText = readFile(path.join(baseDir, sourcePath) + ".ts");
|
||||||
|
if (sourceText === null) {
|
||||||
|
sourceText = readFile(path.join(baseDir, sourcePath, "index.ts"));
|
||||||
|
if (sourceText === null) {
|
||||||
|
return callback(Error("Entry file '" + sourcePath + ".ts' not found."));
|
||||||
|
} else {
|
||||||
|
sourcePath += "/index.ts";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sourcePath += ".ts";
|
||||||
|
}
|
||||||
|
|
||||||
|
stats.parseCount++;
|
||||||
|
stats.parseTime += measure(() => {
|
||||||
|
parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);
|
||||||
|
});
|
||||||
|
let code = parseBacklog();
|
||||||
|
if (code) return code;
|
||||||
|
}
|
||||||
|
|
||||||
applyTransform("afterParse", parser);
|
applyTransform("afterParse", parser);
|
||||||
|
{
|
||||||
|
let code = parseBacklog();
|
||||||
|
if (code) return code;
|
||||||
|
}
|
||||||
|
|
||||||
// Finish parsing
|
// Finish parsing
|
||||||
const program = assemblyscript.finishParsing(parser);
|
const program = assemblyscript.finishParsing(parser);
|
||||||
|
@ -16,8 +16,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
Options,
|
Options,
|
||||||
Feature,
|
Feature
|
||||||
Compiler
|
|
||||||
} from "./compiler";
|
} from "./compiler";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user