Converted everything to use acorn npm package. Updated acorn packages to latest version. Updated acorn parsing to use ES9

This commit is contained in:
danielyxie 2019-07-13 22:36:12 -07:00
parent 06cd584f10
commit 096f984d6b
9 changed files with 19 additions and 3667 deletions

29
package-lock.json generated

@ -689,24 +689,9 @@
} }
}, },
"acorn": { "acorn": {
"version": "5.7.3", "version": "6.2.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.0.tgz",
"integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" "integrity": "sha512-8oe72N3WPMjA+2zVG71Ia0nXZ8DpQH+QyyHO+p06jT8eg8FGG3FbcUIi8KziHlAfheJQZeoqbvq1mQSQHXKYLw=="
},
"acorn-dynamic-import": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-2.0.2.tgz",
"integrity": "sha1-x1K9IQvvZ5UBtsbLf8hPj0cVjMQ=",
"requires": {
"acorn": "4.0.13"
},
"dependencies": {
"acorn": {
"version": "4.0.13",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz",
"integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c="
}
}
}, },
"acorn-globals": { "acorn-globals": {
"version": "4.3.2", "version": "4.3.2",
@ -715,7 +700,7 @@
"dev": true, "dev": true,
"requires": { "requires": {
"acorn": "6.1.1", "acorn": "6.1.1",
"acorn-walk": "6.1.1" "acorn-walk": "6.2.0"
}, },
"dependencies": { "dependencies": {
"acorn": { "acorn": {
@ -744,9 +729,9 @@
} }
}, },
"acorn-walk": { "acorn-walk": {
"version": "6.1.1", "version": "6.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.1.tgz", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.2.0.tgz",
"integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==" "integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA=="
}, },
"ajv": { "ajv": {
"version": "5.5.2", "version": "5.5.2",

@ -9,9 +9,8 @@
"@types/numeral": "0.0.25", "@types/numeral": "0.0.25",
"@types/react": "^16.8.6", "@types/react": "^16.8.6",
"@types/react-dom": "^16.8.2", "@types/react-dom": "^16.8.2",
"acorn": "^5.7.3", "acorn": "^6.2.0",
"acorn-dynamic-import": "^2.0.0", "acorn-walk": "^6.2.0",
"acorn-walk": "^6.1.1",
"ajv": "^5.1.5", "ajv": "^5.1.5",
"ajv-keywords": "^2.0.0", "ajv-keywords": "^2.0.0",
"async": "^2.6.1", "async": "^2.6.1",

@ -1,6 +1,6 @@
import { FconfSettings } from "./FconfSettings"; import { FconfSettings } from "./FconfSettings";
import { parse, Node } from "../../utils/acorn"; import { parse, Node } from "acorn";
import { dialogBoxCreate } from "../../utils/DialogBox"; import { dialogBoxCreate } from "../../utils/DialogBox";
var FconfComments = { var FconfComments = {

@ -1,4 +1,4 @@
import * as acorn from "../utils/acorn"; import * as acorn from "acorn";
/** /**
* @license * @license
* JavaScript Interpreter * JavaScript Interpreter

@ -1,5 +1,4 @@
import { setTimeoutRef } from "./utils/SetTimeoutRef"; import { setTimeoutRef } from "./utils/SetTimeoutRef";
import { parse, Node } from "../utils/acorn";
import { isValidIPAddress } from "../utils/helpers/isValidIPAddress"; import { isValidIPAddress } from "../utils/helpers/isValidIPAddress";
import { isString } from "../utils/helpers/isString"; import { isString } from "../utils/helpers/isString";

@ -30,14 +30,14 @@ import { setTimeoutRef } from "./utils/SetTimeoutRef";
import { generate } from "escodegen"; import { generate } from "escodegen";
import { parse, Node } from "../utils/acorn";
import { dialogBoxCreate } from "../utils/DialogBox"; import { dialogBoxCreate } from "../utils/DialogBox";
import { compareArrays } from "../utils/helpers/compareArrays"; import { compareArrays } from "../utils/helpers/compareArrays";
import { arrayToString } from "../utils/helpers/arrayToString"; import { arrayToString } from "../utils/helpers/arrayToString";
import { roundToTwo } from "../utils/helpers/roundToTwo"; import { roundToTwo } from "../utils/helpers/roundToTwo";
import { isString } from "../utils/StringHelperFunctions"; import { isString } from "../utils/StringHelperFunctions";
const walk = require("acorn/dist/walk"); import { parse, Node } from "acorn";
const walk = require("acorn-walk");
// Netscript Ports are instantiated here // Netscript Ports are instantiated here
export const NetscriptPorts = []; export const NetscriptPorts = [];
@ -288,7 +288,7 @@ function startNetscript1Script(workerScript) {
*/ */
function processNetscript1Imports(code, workerScript) { function processNetscript1Imports(code, workerScript) {
//allowReserved prevents 'import' from throwing error in ES5 //allowReserved prevents 'import' from throwing error in ES5
const ast = parse(code, { ecmaVersion: 6, allowReserved: true, sourceType: "module" }); const ast = parse(code, { ecmaVersion: 9, allowReserved: true, sourceType: "module" });
var server = workerScript.getServer(); var server = workerScript.getServer();
if (server == null) { if (server == null) {
@ -319,7 +319,7 @@ function processNetscript1Imports(code, workerScript) {
if (script == null) { if (script == null) {
throw new Error("'Import' failed due to invalid script: " + scriptName); throw new Error("'Import' failed due to invalid script: " + scriptName);
} }
let scriptAst = parse(script.code, {ecmaVersion:5, allowReserved:true, sourceType:"module"}); let scriptAst = parse(script.code, { ecmaVersion:9, allowReserved:true, sourceType:"module" });
if (node.specifiers.length === 1 && node.specifiers[0].type === "ImportNamespaceSpecifier") { if (node.specifiers.length === 1 && node.specifiers[0].type === "ImportNamespaceSpecifier") {
// import * as namespace from script // import * as namespace from script
@ -535,7 +535,7 @@ export function createAndAddWorkerScript(runningScriptObj, server) {
// already stopped somewhere else (maybe by something like exit()). This prevents // already stopped somewhere else (maybe by something like exit()). This prevents
// the script from being cleaned up twice // the script from being cleaned up twice
if (!w.running) { return; } if (!w.running) { return; }
console.log("Stopping script " + w.name + " because it finished running naturally"); console.log("Stopping script " + w.name + " because it finished running naturally");
killWorkerScript(s); killWorkerScript(s);
w.log("Script finished running"); w.log("Script finished running");

@ -6,11 +6,11 @@
* the way * the way
*/ */
import * as walk from "acorn-walk"; import * as walk from "acorn-walk";
import { parse, Node } from "acorn";
import { RamCalculationErrorCode } from "./RamCalculationErrorCodes"; import { RamCalculationErrorCode } from "./RamCalculationErrorCodes";
import { RamCosts, RamCostConstants } from "../Netscript/RamCostGenerator"; import { RamCosts, RamCostConstants } from "../Netscript/RamCostGenerator";
import { parse, Node } from "../../utils/acorn";
// These special strings are used to reference the presence of a given logical // These special strings are used to reference the presence of a given logical
// construct within a user script. // construct within a user script.
@ -215,7 +215,7 @@ async function parseOnlyRamCalculate(otherScripts, code, workerScript) {
* that need to be parsed (i.e. are 'import'ed scripts). * that need to be parsed (i.e. are 'import'ed scripts).
*/ */
function parseOnlyCalculateDeps(code, currentModule) { function parseOnlyCalculateDeps(code, currentModule) {
const ast = parse(code, {sourceType:"module", ecmaVersion: 8}); const ast = parse(code, {sourceType:"module", ecmaVersion: 9});
// Everything from the global scope goes in ".". Everything else goes in ".function", where only // Everything from the global scope goes in ".". Everything else goes in ".function", where only
// the outermost layer of functions counts. // the outermost layer of functions counts.

@ -37,7 +37,7 @@
if (!options.indent) // JSHint error.character actually is a column index, this fixes underlining on lines using tabs for indentation if (!options.indent) // JSHint error.character actually is a column index, this fixes underlining on lines using tabs for indentation
options.indent = 1; // JSHint default value is 4 options.indent = 1; // JSHint default value is 4
options.esversion = 6; options.esversion = 9;
JSHINT(sanitizedText, options, options.globals); JSHINT(sanitizedText, options, options.globals);
var errors = JSHINT.data().errors, result = []; var errors = JSHINT.data().errors, result = [];

File diff suppressed because it is too large Load Diff