Resolved more circular dependencies. Installed acorn-walk and imported it in RamCalculations using ES6 modules. Fixed bugs in stock market rework

This commit is contained in:
danielyxie
2019-05-06 18:01:06 -07:00
parent 8a5b6f6cbc
commit cdb5dfec62
34 changed files with 7246 additions and 305 deletions
+7 -10
View File
@@ -35,13 +35,13 @@ export class Script {
server: string = "";
constructor(fn: string = "", code: string = "", server: string = "") {
constructor(fn: string="", code: string="", server: string="", otherScripts: Script[]=[]) {
this.filename = fn;
this.code = code;
this.ramUsage = 0;
this.server = server; // IP of server this script is on
this.module = "";
if (this.code !== "") {this.updateRamUsage();}
if (this.code !== "") { this.updateRamUsage(otherScripts); }
};
download(): void {
@@ -64,7 +64,7 @@ export class Script {
}
// Save a script FROM THE SCRIPT EDITOR
saveScript(code: string, currServ: string): void {
saveScript(code: string, serverIp: string, otherScripts: Script[]): void {
if (routing.isOn(Page.ScriptEditor)) {
//Update code and filename
this.code = code.replace(/^\s+|\s+$/g, '');
@@ -77,21 +77,18 @@ export class Script {
this.filename = filenameElem!.value;
// Server
this.server = currServ;
this.server = serverIp;
//Calculate/update ram usage, execution time, etc.
this.updateRamUsage();
this.updateRamUsage(otherScripts);
this.module = "";
}
}
// Updates the script's RAM usage based on its code
async updateRamUsage() {
// TODO Commented this out because I think its unnecessary
// DOuble check/Test
// var codeCopy = this.code.repeat(1);
var res = await calculateRamUsage(this.code);
async updateRamUsage(otherScripts: Script[]) {
var res = await calculateRamUsage(this.code, otherScripts);
if (res !== -1) {
this.ramUsage = roundToTwo(res);
}