Update some docs

This commit is contained in:
Thomas Weber committed 2020-11-21 18:27:33 -06:00
1 parent 9533895ede
commit 5ecd40e703
2 files changed
+59

No files matched your search

+53
View File
@@ -1,31 +1,84 @@
/**
* @fileoverview Common intermediates shared amongst parts of the compiler.
*/
/**
* An IntermediateScript describes a single script.
* A script is anything with a hat -- "when green flag starts", a procedure definition, etc.
*/
class IntermediateScript {
constructor () {
/**
* List of nodes that make up this script.
* @type {Array|null}
*/
this.stack = null;
/**
* Whether this script is a procedure.
* @type {boolean}
*/
this.isProcedure = false;
/**
* The name of this procedure, if any.
* @type {string}
*/
this.procedureCode = '';
/**
* List of arguments accepted by this function, if it is a procedure.
* @type {string[]}
*/
this.arguments = [];
/**
* Whether this script should be run in warp mode.
* @type {boolean}
*/
this.isWarp = false;
/**
* Whether this script can `yield`
* If false, this script will be compiled as a regular JavaScript function (function)
* If true, this script will be compiled as a generator function (function*)
* @type {boolean}
*/
this.yields = false;
/**
* Whether this script should use the "warp timer"
* @type {boolean}
*/
this.warpTimer = false;
/**
* List of procedure IDs that this script needs.
* @readonly
*/
this.dependedProcedures = [];
/**
* Cached result of compiling this script.
* @type {Function|null}
*/
this.cachedCompileResult = null;
}
}
/**
* An IntermediateRepresentation contains scripts.
*/
class IntermediateRepresentation {
constructor () {
/**
* The entry point of this IR.
* @type {IntermediateScript}
*/
this.entry = null;
/**
* Maps procedure IDs to their intermediate script.
* @type {Object.<string, IntermediateScript>}
*/
this.procedures = {};
+6
View File
@@ -3,6 +3,7 @@ const Cast = require('../util/cast');
const VariablePool = require('./variable-pool');
const execute = require('./execute');
const {disableToString} = require('./util');
const {IntermediateScript, IntermediateRepresentation} = require('./intermediate');
const environment = require('./environment');
/**
@@ -292,6 +293,11 @@ const isSafeConstantForEqualsOptimization = input => {
};
class JSGenerator {
/**
* @param {IntermediateScript} script
* @param {IntermediateRepresentation} ir
* @param {Target} target
*/
constructor (script, ir, target) {
this.script = script;
this.ir = ir;