minigrace
Version:
A compiler for the Grace programming language
1,104 lines • 56.5 kB
JavaScript
let gracecode_compiler_sourceFile = "/Users/black/Development/mg/gracelang/minigrace/compiler.grace";
let gracecode_compiler_sha256 = "b47302cf096b48c9b0fbc65da7df0cdae69a59349bea713262a9a0fc9bf26628";
let gracecode_compiler_minigraceRevision = "b57591d29fc5ee5270d114920bf671367b8c3ecb";
let gracecode_compiler_minigraceGeneration = "5171";
if (typeof gctCache !== "undefined")
gctCache["compiler"] = "dialect:\n standard\nfreshScopes:\nmodules:\n ast\n buildinfo\n errormessages\n genjs\n identifierresolution\n io\n lexer\n mirror\n parser\n standard\n sys\n unicode\n util\n xmodule\npath:\n /Users/black/Development/mg/gracelang/minigrace/compiler.grace\nscope:$100:\n asDebugString String (go) $scope_string\n asString String (go) $scope_string\n astFromLines(1) Unknown (mth) $scope_done\n astFromString(1) Unknown (mth) $scope_done\n basicAsString String (go) $scope_string\n compileInputFile Unknown (mth) $scope_done\n isMe(1) Boolean (go) $scope_boolean\n lexLines(1) Unknown (mth) $scope_done\n lexString(1) Unknown (mth) $scope_done\n myIdentityHash Number (go) $scope_number\n parseLines(1) Unknown (mth) $scope_done\n parseString(1) Unknown (mth) $scope_done\nself:\n $100\ntypes:\n";
if (typeof originalSourceLines !== "undefined") {
originalSourceLines["compiler"] = [
"dialect \"standard\"",
"import \"ast\" as ast",
"import \"buildinfo\" as buildinfo",
"import \"genjs\" as genjs",
"import \"identifierresolution\" as identifierresolution",
"import \"errormessages\" as errormessages",
"import \"io\" as io",
"import \"lexer\" as lexer",
"import \"parser\" as parser",
"import \"sys\" as sys",
"import \"unicode\" as unicode",
"import \"util\" as util",
"import \"xmodule\" as xmodule",
"import \"mirror\" as mirror",
"",
"if (mirror.initialModuleName == \"compiler\") then { compileInputFile }",
"",
"method compileInputFile {",
" util.parseargs(buildinfo)",
"",
" util.log_verbose \"starting compilation\"",
"",
" try {",
" var tokens := lexer.lexfile(util.infile)",
" if (util.target == \"lex\") then {",
" // Print the lexed tokens and quit.",
" for (tokens) do { v ->",
" def val = if (\"\\n\" == v.value) then { \"\\\\n\" } else { v.value }",
" if (util.verbosity > 30) then {",
" util.outprint \"{v.kind}: {val} [pos: {v.line}:{v.column} size: {v.size} indent: {v.indent}]\"",
" } else {",
" util.outprint \"{v.kind}: {val}\"",
" }",
" }",
" util.outfile.close",
" sys.exit(0)",
" }",
"",
" var moduleObject := parser.parse(tokens)",
" tokens := false // release the memory",
" var values := moduleObject.value",
"",
" if (util.target == \"parse\") then {",
" // Parse mode pretty-prints the parse tree and quits.",
" // util.log 60 verbose \"target = parse, outfile = {util.outfile}.\"",
" util.outprint(moduleObject.pretty(0))",
" // util.log 60 verbose \"done writing {util.outfile}.\"",
" util.outfile.close",
" sys.exit(0)",
" }",
" if (util.target == \"grace\") then {",
" for (values) do { v ->",
" util.outprint(v.toGrace(0))",
" }",
" util.outfile.close",
" sys.exit(0)",
" }",
"",
" if (util.target == \"imports\") then {",
" def imps = set.empty",
" def vis = object {",
" inherit ast.baseVisitor",
" method visitImport(o) -> Boolean {",
" imps.add(o.path)",
" false",
" }",
" }",
" moduleObject.accept(vis)",
"",
" list.withAll(imps).sort.do { im ->",
" util.outprint(im)",
" }",
" util.outfile.close",
" sys.exit(0)",
" }",
"",
" moduleObject := identifierresolution.resolve(moduleObject)",
"",
" // Perform the actual compilation",
" match(util.target)",
" case { == \"js\" ->",
" genjs.compile(moduleObject, util.outfile, util.buildtype, util.gracelibPath)",
" } else {",
" io.error.write(\"minigrace: no such target '\" ++ util.target ++ \"'\\n\")",
" sys.exit(1)",
" }",
" } catch { se:errormessages.SyntaxError ->",
" util.generalError(\"Syntax error: {se.message}\", se.data.line, se.data.column, se.data.arrow, se.data.sugg)",
" } catch { se:errormessages.ReuseError ->",
" util.generalError(\"Reuse error: {se.message}\", se.data.line, se.data.column, se.data.arrow, se.data.sugg)",
" } catch { se:errormessages.CompilationError ->",
" util.generalError(\"Compilation error: {se.message}\", se.data.line, se.data.column, se.data.arrow, se.data.sugg)",
" }",
"}",
"////////////////////////////////////////////////////",
"//",
"// methods used when writing unit tests",
"//",
"////////////////////////////////////////////////////",
"",
"method lexLines(input) {",
" // input is a Collection of Strings, each representing a line",
" // answers a linked list of tokens",
"",
" util.lines.clear",
" util.lines.addAll(input)",
" xmodule.externalModules.clear",
" lexer.lexLines (input)",
"}",
"",
"method lexString(inputString) { lexLines(inputString.split \"\\n\") }",
"",
"method parseLines(input) {",
" // input is a Collection of Strings, each representing a line",
" // answers the moduleNode at the top of the parse tree",
"",
" parser.parse (lexLines (input))",
"}",
"",
"method parseString(inputString) { parseLines(inputString.split \"\\n\") }",
"",
"method astFromLines(input) {",
" // input is a Collection of Strings, each representing a line",
" // answers the moduleNode at the top of the AST",
" identifierresolution.resolve (parseLines(input))",
"}",
"",
"method astFromString(inputString) { astFromLines(inputString.split \"\\n\") }" ];
}
function gracecode_compiler() {
importedModules["compiler"] = this;
const var_$module = this;
this.definitionModule = "compiler";
this.definitionLine = 1;
setLineNumber(1); // compilenode dialect
// Dialect "standard"
const var_$dialect = do_import("standard", gracecode_standard);
this.outer = var_$dialect;
setLineNumber(2); // compilenode import
// Import of "ast" as ast
if (typeof gracecode_ast == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module ast"));
var var_ast = do_import("ast", gracecode_ast);
var func0 = function(argcv) { // accessor method ast, line 2
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("ast", 0, numArgs - 0);
return var_ast;
}; // end of method ast
this.methods["ast"] = func0;
func0.methodName = "ast";
func0.paramCounts = [0];
func0.paramNames = [];
func0.definitionLine = 2;
func0.definitionModule = "compiler";
func0.debug = "import";
func0.confidential = true;
setLineNumber(3); // compilenode import
// Import of "buildinfo" as buildinfo
if (typeof gracecode_buildinfo == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module buildinfo"));
var var_buildinfo = do_import("buildinfo", gracecode_buildinfo);
var func1 = function(argcv) { // accessor method buildinfo, line 3
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("buildinfo", 0, numArgs - 0);
return var_buildinfo;
}; // end of method buildinfo
this.methods["buildinfo"] = func1;
func1.methodName = "buildinfo";
func1.paramCounts = [0];
func1.paramNames = [];
func1.definitionLine = 3;
func1.definitionModule = "compiler";
func1.debug = "import";
func1.confidential = true;
setLineNumber(4); // compilenode import
// Import of "genjs" as genjs
if (typeof gracecode_genjs == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module genjs"));
var var_genjs = do_import("genjs", gracecode_genjs);
var func2 = function(argcv) { // accessor method genjs, line 4
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("genjs", 0, numArgs - 0);
return var_genjs;
}; // end of method genjs
this.methods["genjs"] = func2;
func2.methodName = "genjs";
func2.paramCounts = [0];
func2.paramNames = [];
func2.definitionLine = 4;
func2.definitionModule = "compiler";
func2.debug = "import";
func2.confidential = true;
setLineNumber(5); // compilenode import
// Import of "identifierresolution" as identifierresolution
if (typeof gracecode_identifierresolution == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module identifierresolution"));
var var_identifierresolution = do_import("identifierresolution", gracecode_identifierresolution);
var func3 = function(argcv) { // accessor method identifierresolution, line 5
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("identifierresolution", 0, numArgs - 0);
return var_identifierresolution;
}; // end of method identifierresolution
this.methods["identifierresolution"] = func3;
func3.methodName = "identifierresolution";
func3.paramCounts = [0];
func3.paramNames = [];
func3.definitionLine = 5;
func3.definitionModule = "compiler";
func3.debug = "import";
func3.confidential = true;
setLineNumber(6); // compilenode import
// Import of "errormessages" as errormessages
if (typeof gracecode_errormessages == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module errormessages"));
var var_errormessages = do_import("errormessages", gracecode_errormessages);
var func4 = function(argcv) { // accessor method errormessages, line 6
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("errormessages", 0, numArgs - 0);
return var_errormessages;
}; // end of method errormessages
this.methods["errormessages"] = func4;
func4.methodName = "errormessages";
func4.paramCounts = [0];
func4.paramNames = [];
func4.definitionLine = 6;
func4.definitionModule = "compiler";
func4.debug = "import";
func4.confidential = true;
setLineNumber(7); // compilenode import
// Import of "io" as io
if (typeof gracecode_io == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module io"));
var var_io = do_import("io", gracecode_io);
var func5 = function(argcv) { // accessor method io, line 7
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("io", 0, numArgs - 0);
return var_io;
}; // end of method io
this.methods["io"] = func5;
func5.methodName = "io";
func5.paramCounts = [0];
func5.paramNames = [];
func5.definitionLine = 7;
func5.definitionModule = "compiler";
func5.debug = "import";
func5.confidential = true;
setLineNumber(8); // compilenode import
// Import of "lexer" as lexer
if (typeof gracecode_lexer == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module lexer"));
var var_lexer = do_import("lexer", gracecode_lexer);
var func6 = function(argcv) { // accessor method lexer, line 8
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("lexer", 0, numArgs - 0);
return var_lexer;
}; // end of method lexer
this.methods["lexer"] = func6;
func6.methodName = "lexer";
func6.paramCounts = [0];
func6.paramNames = [];
func6.definitionLine = 8;
func6.definitionModule = "compiler";
func6.debug = "import";
func6.confidential = true;
setLineNumber(9); // compilenode import
// Import of "parser" as parser
if (typeof gracecode_parser == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module parser"));
var var_parser = do_import("parser", gracecode_parser);
var func7 = function(argcv) { // accessor method parser, line 9
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("parser", 0, numArgs - 0);
return var_parser;
}; // end of method parser
this.methods["parser"] = func7;
func7.methodName = "parser";
func7.paramCounts = [0];
func7.paramNames = [];
func7.definitionLine = 9;
func7.definitionModule = "compiler";
func7.debug = "import";
func7.confidential = true;
setLineNumber(10); // compilenode import
// Import of "sys" as sys
if (typeof gracecode_sys == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module sys"));
var var_sys = do_import("sys", gracecode_sys);
var func8 = function(argcv) { // accessor method sys, line 10
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("sys", 0, numArgs - 0);
return var_sys;
}; // end of method sys
this.methods["sys"] = func8;
func8.methodName = "sys";
func8.paramCounts = [0];
func8.paramNames = [];
func8.definitionLine = 10;
func8.definitionModule = "compiler";
func8.debug = "import";
func8.confidential = true;
setLineNumber(11); // compilenode import
// Import of "unicode" as unicode
if (typeof gracecode_unicode == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module unicode"));
var var_unicode = do_import("unicode", gracecode_unicode);
var func9 = function(argcv) { // accessor method unicode, line 11
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("unicode", 0, numArgs - 0);
return var_unicode;
}; // end of method unicode
this.methods["unicode"] = func9;
func9.methodName = "unicode";
func9.paramCounts = [0];
func9.paramNames = [];
func9.definitionLine = 11;
func9.definitionModule = "compiler";
func9.debug = "import";
func9.confidential = true;
setLineNumber(12); // compilenode import
// Import of "util" as util
if (typeof gracecode_util == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module util"));
var var_util = do_import("util", gracecode_util);
var func10 = function(argcv) { // accessor method util, line 12
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("util", 0, numArgs - 0);
return var_util;
}; // end of method util
this.methods["util"] = func10;
func10.methodName = "util";
func10.paramCounts = [0];
func10.paramNames = [];
func10.definitionLine = 12;
func10.definitionModule = "compiler";
func10.debug = "import";
func10.confidential = true;
setLineNumber(13); // compilenode import
// Import of "xmodule" as xmodule
if (typeof gracecode_xmodule == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module xmodule"));
var var_xmodule = do_import("xmodule", gracecode_xmodule);
var func11 = function(argcv) { // accessor method xmodule, line 13
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("xmodule", 0, numArgs - 0);
return var_xmodule;
}; // end of method xmodule
this.methods["xmodule"] = func11;
func11.methodName = "xmodule";
func11.paramCounts = [0];
func11.paramNames = [];
func11.definitionLine = 13;
func11.definitionModule = "compiler";
func11.debug = "import";
func11.confidential = true;
setLineNumber(14); // compilenode import
// Import of "mirror" as mirror
if (typeof gracecode_mirror == "undefined")
throw new GraceExceptionPacket(EnvironmentExceptionObject,
new GraceString("could not find module mirror"));
var var_mirror = do_import("mirror", gracecode_mirror);
var func12 = function(argcv) { // accessor method mirror, line 14
const numArgs = arguments.length - 1;
if (numArgs > 0) raiseTypeArgError("mirror", 0, numArgs - 0);
return var_mirror;
}; // end of method mirror
this.methods["mirror"] = func12;
func12.methodName = "mirror";
func12.paramCounts = [0];
func12.paramNames = [];
func12.definitionLine = 14;
func12.definitionModule = "compiler";
func12.debug = "import";
func12.confidential = true;
this.closureKeys = this.closureKeys || [];
this.closureKeys.push("outer_compiler_1");
this.outer_compiler_1 = var_$dialect;
var func13 = function(argcv) { // method compileInputFile, line 18
var returnTarget = invocationCount;
invocationCount++;
const numArgs = arguments.length - 1;
if ((numArgs > 0) && (numArgs !== 0)) {
raiseTypeArgError("compileInputFile", 0, numArgs - 0);
}
setLineNumber(19); // compilenode call
// call case 4: other requests
var call14 = request(var_util, "parseargs(1)", [1], var_buildinfo);
setLineNumber(21); // compilenode string
var string16 = new GraceString("starting compilation");
// call case 4: other requests
var call15 = request(var_util, "log_verbose(1)", [1], string16);
setLineNumber(23); // compilenode block
var block18 = new GraceBlock(this, 23, 0);
block18.guard = jsTrue;
block18.real = function block18() {
setLineNumber(24); // compilenode member
// call case 4: other requests
var call20 = request(var_util, "infile", [0]);
// call case 4: other requests
var call19 = request(var_lexer, "lexfile(1)", [1], call20);
var var_tokens = call19;
var if21 = GraceDone;
setLineNumber(25); // compilenode string
var string23 = new GraceString("lex");
// call case 4: other requests
// call case 4: other requests
var call24 = request(var_util, "target", [0]);
var term22 = request(call24, "==(1)", [1], string23);
if (Grace_isTrue(term22)) {
setLineNumber(27); // compilenode call
if (var_tokens === undefined) raiseUninitializedVariable("tokens");
var block26 = new GraceBlock(this, 27, 1);
block26.guard = jsTrue;
block26.real = function block26(var_v) {
var if27 = GraceDone;
setLineNumber(28); // compilenode member
// call case 4: other requests
var call29 = request(var_v, "value", [0]);
// call case 4: other requests
var string30 = new GraceString("\n");
var term28 = request(string30, "==(1)", [1], call29);
if (Grace_isTrue(term28)) {
var string31 = new GraceString("\\n");
if27 = string31;
} else {
// call case 4: other requests
var call32 = request(var_v, "value", [0]);
if27 = call32;
}
var var_val = if27;
var if33 = GraceDone;
setLineNumber(29); // compilenode num
// call case 4: other requests
// call case 4: other requests
var call35 = request(var_util, "verbosity", [0]);
var term34 = request(call35, ">(1)", [1], new GraceNum(30));
if (Grace_isTrue(term34)) {
setLineNumber(30); // compilenode string
var string38 = new GraceString("]");
// call case 4: other requests
// call case 4: other requests
var call40 = request(var_v, "indent", [0]);
// call case 4: other requests
var string42 = new GraceString(" indent: ");
// call case 4: other requests
// call case 4: other requests
var call44 = request(var_v, "size", [0]);
// call case 4: other requests
var string46 = new GraceString(" size: ");
// call case 4: other requests
// call case 4: other requests
var call48 = request(var_v, "column", [0]);
// call case 4: other requests
var string50 = new GraceString(":");
// call case 4: other requests
// call case 4: other requests
var call52 = request(var_v, "line", [0]);
// call case 4: other requests
var string54 = new GraceString(" [pos: ");
// call case 4: other requests
if (var_val === undefined) raiseUninitializedVariable("val");
// call case 4: other requests
var string57 = new GraceString(": ");
// call case 4: other requests
// call case 4: other requests
var call59 = request(var_v, "kind", [0]);
// call case 4: other requests
var concat58 = request(GraceEmptyString, "++(1)", [1], call59);
var concat56 = request(concat58, "++(1)", [1], string57);
var concat55 = request(concat56, "++(1)", [1], var_val);
var concat53 = request(concat55, "++(1)", [1], string54);
var concat51 = request(concat53, "++(1)", [1], call52);
var concat49 = request(concat51, "++(1)", [1], string50);
var concat47 = request(concat49, "++(1)", [1], call48);
var concat45 = request(concat47, "++(1)", [1], string46);
var concat43 = request(concat45, "++(1)", [1], call44);
var concat41 = request(concat43, "++(1)", [1], string42);
var concat39 = request(concat41, "++(1)", [1], call40);
var concat37 = request(concat39, "++(1)", [1], string38);
// call case 4: other requests
var call36 = request(var_util, "outprint(1)", [1], concat37);
if33 = call36;
} else {
setLineNumber(32); // compilenode string
// call case 4: other requests
if (var_val === undefined) raiseUninitializedVariable("val");
// call case 4: other requests
var string64 = new GraceString(": ");
// call case 4: other requests
// call case 4: other requests
var call66 = request(var_v, "kind", [0]);
// call case 4: other requests
var concat65 = request(GraceEmptyString, "++(1)", [1], call66);
var concat63 = request(concat65, "++(1)", [1], string64);
var concat62 = request(concat63, "++(1)", [1], var_val);
var concat61 = request(concat62, "++(1)", [1], GraceEmptyString);
// call case 4: other requests
var call60 = request(var_util, "outprint(1)", [1], concat61);
if33 = call60;
}
return if33;
};
let applyMeth26 = function apply_1 (argcv, ...args) {
if (this.guard.apply(this.receiver, args))
return this.real.apply(this.receiver, args);
badBlockArgs.apply(this, args);
};
applyMeth26.methodName = "apply(1)";
applyMeth26.paramCounts = [1];
applyMeth26.paramNames = ["v"];
applyMeth26.definitionLine = 27;
applyMeth26.definitionModule = "compiler";
block26.methods["apply(1)"] = applyMeth26;
let matchesMeth26 = function matches_1 (argcv, ...args) {
return this.guard.apply(this.receiver, args) ? GraceTrue : GraceFalse;
};
matchesMeth26.methodName = "matches(1)";
matchesMeth26.paramCounts = [1];
matchesMeth26.paramNames = ["v"];
matchesMeth26.definitionLine = 27;
matchesMeth26.definitionModule = "compiler";
block26.methods["matches(1)"] = matchesMeth26;
var call25 = selfRequest(var_$dialect, "for(1)do(1)", [1, 1], var_tokens, block26);
setLineNumber(35); // compilenode member
// call case 4: other requests
// call case 4: other requests
var call68 = request(var_util, "outfile", [0]);
var call67 = request(call68, "close", [0]);
setLineNumber(36); // compilenode num
// call case 4: other requests
var call69 = request(var_sys, "exit(1)", [1], new GraceNum(0));
if21 = call69;
}
setLineNumber(39); // compilenode call
// call case 4: other requests
var call70 = request(var_parser, "parse(1)", [1], var_tokens);
var var_moduleObject = call70;
setLineNumber(40); // compilenode member
var_tokens = GraceFalse;
setLineNumber(41); // compilenode member
// call case 4: other requests
var call72 = request(var_moduleObject, "value", [0]);
var var_values = call72;
var if73 = GraceDone;
setLineNumber(43); // compilenode string
var string75 = new GraceString("parse");
// call case 4: other requests
// call case 4: other requests
var call76 = request(var_util, "target", [0]);
var term74 = request(call76, "==(1)", [1], string75);
if (Grace_isTrue(term74)) {
setLineNumber(46); // compilenode num
// call case 4: other requests
if (var_moduleObject === undefined) raiseUninitializedVariable("moduleObject");
var call78 = request(var_moduleObject, "pretty(1)", [1], new GraceNum(0));
// call case 4: other requests
var call77 = request(var_util, "outprint(1)", [1], call78);
setLineNumber(48); // compilenode member
// call case 4: other requests
// call case 4: other requests
var call80 = request(var_util, "outfile", [0]);
var call79 = request(call80, "close", [0]);
setLineNumber(49); // compilenode num
// call case 4: other requests
var call81 = request(var_sys, "exit(1)", [1], new GraceNum(0));
if73 = call81;
}
var if82 = GraceDone;
setLineNumber(51); // compilenode string
var string84 = new GraceString("grace");
// call case 4: other requests
// call case 4: other requests
var call85 = request(var_util, "target", [0]);
var term83 = request(call85, "==(1)", [1], string84);
if (Grace_isTrue(term83)) {
setLineNumber(52); // compilenode call
if (var_values === undefined) raiseUninitializedVariable("values");
var block87 = new GraceBlock(this, 52, 1);
block87.guard = jsTrue;
block87.real = function block87(var_v) {
setLineNumber(53); // compilenode num
// call case 4: other requests
var call89 = request(var_v, "toGrace(1)", [1], new GraceNum(0));
// call case 4: other requests
var call88 = request(var_util, "outprint(1)", [1], call89);
return call88;
};
let applyMeth87 = function apply_1 (argcv, ...args) {
if (this.guard.apply(this.receiver, args))
return this.real.apply(this.receiver, args);
badBlockArgs.apply(this, args);
};
applyMeth87.methodName = "apply(1)";
applyMeth87.paramCounts = [1];
applyMeth87.paramNames = ["v"];
applyMeth87.definitionLine = 52;
applyMeth87.definitionModule = "compiler";
block87.methods["apply(1)"] = applyMeth87;
let matchesMeth87 = function matches_1 (argcv, ...args) {
return this.guard.apply(this.receiver, args) ? GraceTrue : GraceFalse;
};
matchesMeth87.methodName = "matches(1)";
matchesMeth87.paramCounts = [1];
matchesMeth87.paramNames = ["v"];
matchesMeth87.definitionLine = 52;
matchesMeth87.definitionModule = "compiler";
block87.methods["matches(1)"] = matchesMeth87;
var call86 = selfRequest(var_$dialect, "for(1)do(1)", [1, 1], var_values, block87);
setLineNumber(55); // compilenode member
// call case 4: other requests
// call case 4: other requests
var call91 = request(var_util, "outfile", [0]);
var call90 = request(call91, "close", [0]);
setLineNumber(56); // compilenode num
// call case 4: other requests
var call92 = request(var_sys, "exit(1)", [1], new GraceNum(0));
if82 = call92;
}
var if93 = GraceDone;
setLineNumber(59); // compilenode string
var string95 = new GraceString("imports");
// call case 4: other requests
// call case 4: other requests
var call96 = request(var_util, "target", [0]);
var term94 = request(call96, "==(1)", [1], string95);
if (Grace_isTrue(term94)) {
setLineNumber(60); // compilenode member
// call case 4: other requests
var call98 = selfRequest(var_$dialect, "set", [0]);
var call97 = request(call98, "empty", [0]);
var var_imps = call97;
setLineNumber(61); // compilenode object
var obj99_build = function(ignore, outerObj, aliases, exclusions) {
this.closureKeys = this.closureKeys || [];
this.closureKeys.push("outer_compiler_61");
this.outer_compiler_61 = outerObj;
const inheritedExclusions = { };
for (var eix = 0, eLen = exclusions.length; eix < eLen; eix ++) {
const exMeth = exclusions[eix];
inheritedExclusions[exMeth] = this.methods[exMeth]; };
setLineNumber(62); // reuse call
var initFun100 = request(var_ast, "baseVisitor$build(3)", [null], this, [], []); // compileReuseCall
var func101 = function(argcv, var_o) { // method visitImport(_), line 63
var returnTarget = invocationCount;
invocationCount++;
const numArgs = arguments.length - 1;
if ((numArgs > 1) && (numArgs !== 1)) {
raiseTypeArgError("visitImport(_)", 0, numArgs - 1);
}
setLineNumber(64); // compilenode member
// call case 4: other requests
var call103 = request(var_o, "path", [0]);
// call case 4: other requests
if (var_imps === undefined) raiseUninitializedVariable("imps");
var call102 = request(var_imps, "add(1)", [1], call103);
setLineNumber(63); // compilenode member
var call105 = selfRequest(var_$dialect, "Boolean", [0]);
setLineNumber(65); // typecheck
assertTypeOrMsg(GraceFalse, call105, "result of method visitImport(_)", "Boolean");
return GraceFalse;
}; // end of method visitImport(_)
setLineNumber(63); // compilenode member
var call106 = selfRequest(var_$dialect, "Boolean", [0]);
func101.returnType = call106;
this.methods["visitImport(1)"] = func101;
func101.methodName = "visitImport(1)";
func101.paramCounts = [1];
func101.paramNames = ["o"];
func101.definitionLine = 63;
func101.definitionModule = "compiler";
const overridenByAliases = { };
for (let aix = 0, aLen = aliases.length; aix < aLen; aix ++) {
const a = aliases[aix];
const newNm = a.newName;
const oldNm = a.oldName;
overridenByAliases[newNm] = this.methods[newNm];
const m = confidentialVersion(overridenByAliases[oldNm] || this.methods[oldNm], newNm);
m.definitionLine = 61;
m.definitionModule = "compiler";
this.methods[newNm] = m;
}
for (let exName in inheritedExclusions) {
if (inheritedExclusions.hasOwnProperty(exName)) {
if (inheritedExclusions[exName]) {
this.methods[exName] = inheritedExclusions[exName];
} else {
delete this.methods[exName];
}
}
}
var obj99_init = function() { // init of object on line 61
initFun100.call(this);
};
return obj99_init; // from compileBuildAndInitFunctions(_)inMethod(_)
};
var obj99 = emptyGraceObject("vis", "compiler", 61);
var obj99_init = obj99_build.call(obj99, null, this, [], []);
obj99_init.call(obj99); // end of compileobject
var var_vis = obj99;
setLineNumber(68); // compilenode call
if (var_vis === undefined) raiseUninitializedVariable("vis");
// call case 4: other requests
if (var_moduleObject === undefined) raiseUninitializedVariable("moduleObject");
var call107 = request(var_moduleObject, "accept(1)", [1], var_vis);
setLineNumber(70); // compilenode block
var block109 = new GraceBlock(this, 70, 1);
block109.guard = jsTrue;
block109.real = function block109(var_im) {
setLineNumber(71); // compilenode call
// call case 4: other requests
var call110 = request(var_util, "outprint(1)", [1], var_im);
return call110;
};
let applyMeth109 = function apply_1 (argcv, ...args) {
if (this.guard.apply(this.receiver, args))
return this.real.apply(this.receiver, args);
badBlockArgs.apply(this, args);
};
applyMeth109.methodName = "apply(1)";
applyMeth109.paramCounts = [1];
applyMeth109.paramNames = ["im"];
applyMeth109.definitionLine = 70;
applyMeth109.definitionModule = "compiler";
block109.methods["apply(1)"] = applyMeth109;
let matchesMeth109 = function matches_1 (argcv, ...args) {
return this.guard.apply(this.receiver, args) ? GraceTrue : GraceFalse;
};
matchesMeth109.methodName = "matches(1)";
matchesMeth109.paramCounts = [1];
matchesMeth109.paramNames = ["im"];
matchesMeth109.definitionLine = 70;
matchesMeth109.definitionModule = "compiler";
block109.methods["matches(1)"] = matchesMeth109;
// call case 4: other requests
setLineNumber(70); // compilenode member
// call case 4: other requests
if (var_imps === undefined) raiseUninitializedVariable("imps");
// call case 4: other requests
var call113 = selfRequest(var_$dialect, "list", [0]);
var call112 = request(call113, "withAll(1)", [1], var_imps);
var call111 = request(call112, "sort", [0]);
var call108 = request(call111, "do(1)", [1], block109);
setLineNumber(73); // compilenode member
// call case 4: other requests
// call case 4: other requests
var call115 = request(var_util, "outfile", [0]);
var call114 = request(call115, "close", [0]);
setLineNumber(74); // compilenode num
// call case 4: other requests
var call116 = request(var_sys, "exit(1)", [1], new GraceNum(0));
if93 = call116;
}
setLineNumber(77); // compilenode call
// call case 4: other requests
var call117 = request(var_identifierresolution, "resolve(1)", [1], var_moduleObject);
var_moduleObject = call117;
setLineNumber(80); // compilenode member
// call case 4: other requests
var call119 = request(var_util, "target", [0]);
var cases118 = [];
setLineNumber(81); // compilenode block
var block120 = new GraceBlock(this, 81, 1);
// call case 4: other requests
var string122 = new GraceString("js");
var call121 = request(string122, "prefix==", [0]);
block120.paramTypes = [call121];
var matches123 = function(var___95____95__1) {
// call case 4: other requests
var string125 = new GraceString("js");
var call124 = request(string125, "prefix==", [0]);
if (!Grace_isTrue(request(call124, "matches(1)", [1], var___95____95__1)))
return false;
return true;
};
block120.guard = matches123;
block120.real = function block120(var___95____95__1) {
setLineNumber(82); // compilenode call
if (var_moduleObject === undefined) raiseUninitializedVariable("moduleObject");
// call case 4: other requests
var call127 = request(var_util, "outfile", [0]);
// call case 4: other requests
var call128 = request(var_util, "buildtype", [0]);
// call case 4: other requests
var call129 = request(var_util, "gracelibPath", [0]);
// call case 4: other requests
var call126 = request(var_genjs, "compile(4)", [4], var_moduleObject, call127, call128, call129);
return call126;
};
let applyMeth120 = function apply_1 (argcv, ...args) {
if (this.guard.apply(this.receiver, args))
return this.real.apply(this.receiver, args);
badBlockArgs.apply(this, args);
};
applyMeth120.methodName = "apply(1)";
applyMeth120.paramCounts = [1];
applyMeth120.paramNames = ["__1"];
applyMeth120.definitionLine = 81;
applyMeth120.definitionModule = "compiler";
block120.methods["apply(1)"] = applyMeth120;
let matchesMeth120 = function matches_1 (argcv, ...args) {
return this.guard.apply(this.receiver, args) ? GraceTrue : GraceFalse;
};
matchesMeth120.methodName = "matches(1)";
matchesMeth120.paramCounts = [1];
matchesMeth120.paramNames = ["__1"];
matchesMeth120.definitionLine = 81;
matchesMeth120.definitionModule = "compiler";
block120.methods["matches(1)"] = matchesMeth120;
cases118.push(block120);
setLineNumber(83); // compilenode block
var block130 = new GraceBlock(this, 83, 0);
block130.guard = jsTrue;
block130.real = function block130() {
setLineNumber(84); // compilenode string
var string133 = new GraceString("'\n");
// call case 4: other requests
// call case 4: other requests
var call135 = request(var_util, "target", [0]);
// call case 4: other requests
var string136 = new GraceString("minigrace: no such target '");
var concat134 = request(string136, "++(1)", [1], call135);
var concat132 = request(concat134, "++(1)", [1], string133);
// call case 4: other requests
// call case 4: other requests
var call137 = request(var_io, "error", [0]);
var call131 = request(call137, "write(1)", [1], concat132);
setLineNumber(85); // compilenode num
// call case 4: other requests
var call138 = request(var_sys, "exit(1)", [1], new GraceNum(1));
return call138;
};
let applyMeth130 = function apply (argcv) {
return this.real.apply(this.receiver);
};
applyMeth130.methodName = "apply";
applyMeth130.paramCounts = [0];
applyMeth130.paramNames = [];
applyMeth130.definitionLine = 83;
applyMeth130.definitionModule = "compiler";
block130.methods["apply"] = applyMeth130;
setLineNumber(80); // compilematchcase
var matchres118 = matchCase(call119,cases118,block130);
return matchres118;
};
let applyMeth18 = function apply (argcv) {
return this.real.apply(this.receiver);
};
applyMeth18.methodName = "apply";
applyMeth18.paramCounts = [0];
applyMeth18.paramNames = [];
applyMeth18.definitionLine = 23;
applyMeth18.definitionModule = "compiler";
block18.methods["apply"] = applyMeth18;
var cases17 = [];
setLineNumber(87); // compilenode block
var block139 = new GraceBlock(this, 87, 1);
// call case 4: other requests
var call140 = request(var_errormessages, "SyntaxError", [0]);
block139.paramTypes = [call140];
var matches141 = function(var_se) {
// call case 4: other requests
var call142 = request(var_errormessages, "SyntaxError", [0]);
if (!Grace_isTrue(request(call142, "matches(1)", [1], var_se)))
return false;
return true;
};
block139.guard = matches141;
block139.real = function block139(var_se) {
setLineNumber(88); // compilenode string
// call case 4: other requests
// call case 4: other requests
var call146 = request(var_se, "message", [0]);
// call case 4: other requests
var string147 = new GraceString("Syntax error: ");
var concat145 = request(string147, "++(1)", [1], call146);
var concat144 = request(concat145, "++(1)", [1], GraceEmptyString);
// call case 4: other requests
// call case 4: other requests
var call149 = request(var_se, "data", [0]);
var call148 = request(call149, "line", [0]);
// call case 4: other requests
// call case 4: other requests
var call151 = request(var_se, "data", [0]);
var call150 = request(call151, "column", [0]);
// call case 4: other requests
// call case 4: other requests
var call153 = request(var_se, "data", [0]);
var call152 = request(call153, "arrow", [0]);
// call case 4: other requests
// call case 4: other requests
var call155 = request(var_se, "data", [0]);
var call154 = request(call155, "sugg", [0]);
// call case 4: other requests
var call143 = request(var_util, "generalError(5)", [5], concat144, call148, call150, call152, call154);
return call143;
};
let applyMeth139 = function apply_1 (argcv, ...args) {
if (this.guard.apply(this.receiver, args))
return this.real.apply(this.receiver, args);
badBlockArgs.apply(this, args);
};
applyMeth139.methodName = "apply(1)";
applyMeth139.paramCounts = [1];
applyMeth139.paramNames = ["se"];
applyMeth139.definitionLine = 87;
applyMeth139.definitionModule = "compiler";
block139.methods["apply(1)"] = applyMeth139;
let matchesMeth139 = function matches_1 (argcv, ...args) {
return this.guard.apply(this.receiver, args) ? GraceTrue : GraceFalse;
};
matchesMeth139.methodName = "matches(1)";
matchesMeth139.paramCounts = [1];
matchesMeth139.paramNames = ["se"];
matchesMeth139.definitionLine = 87;
matchesMeth139.definitionModule = "compiler";
block139.methods["matches(1)"] = matchesMeth139;
cases17.push(block139);
setLineNumber(89); // compilenode block
var block156 = new GraceBlock(this, 89, 1);
// call case 4: other requests
var call157 = request(var_errormessages, "ReuseError", [0]);
block156.paramTypes = [call157];
var matches158 = function(var_se) {
// call case 4: other requests
var call159 = request(var_errormessages, "ReuseError", [0]);
if (!Grace_isTrue(request(call159, "matches(1)", [1], var_se)))
return false;
return true;
};
block156.guard = matches158;
block156.real = function block156(var_se) {
setLineNumber(90); // compilenode string
// call case 4: other requests
// call case 4: other requests
var call163 = request(var_se, "message", [0]);
// call case 4: other requests
var string164 = new GraceString("Reuse error: ");
var concat162 = request(string164, "++(1)", [1], call163);
var concat161 = request(concat162, "++(1)", [1], GraceEmptyString);
// call case 4: other requests
// call case 4: other requests
var call166 = request(var_se, "data", [0]);
var call165 = request(call166, "line", [0]);
// call case 4: other requests
// call case 4: other requests
var call168 = request(var_se, "data", [0]);
var call167 = request(call168, "column", [0]);
// call case 4: other requests
// call case 4: other requests
var call170 = request(var_se, "data", [0]);
var call169 = request(call170, "arrow", [0]);
// call case 4: other requests
// call case 4: other requests
var call172 = request(var_se, "data", [0]);
var call171 = request(call172, "sugg", [0]);
// call case 4: other requests
var call160 = request(var_util, "generalError(5)", [5], concat161, call165, call167, call169, call171);
return call160;
};
let applyMeth156 = function apply_1 (argcv, ...args) {
if (this.guard.apply(this.receiver, args))
return this.real.apply(this.receiver, args);
badBlockArgs.apply(this, args);
};
applyMeth156.methodName = "apply(1)";
applyMeth156.paramCounts = [1];
applyMeth156.paramNames = ["se"];
applyMeth156.definitionLine = 89;
applyMeth156.definitionModule = "compiler";
block156.methods["apply(1)"] = applyMeth156;
let matchesMeth156 = function matches_1 (argcv, ...args) {
return this.guard.apply(this.receiver, args) ? GraceTrue : GraceFalse;
};
matchesMeth156.methodName = "matches(1)";
matchesMeth156.paramCounts = [1];
matchesMeth156.paramNames = ["se"];
matchesMeth156.definitionLine = 89;
matchesMeth156.definitionModule = "compiler";
block156.methods["matches(1)"] = matchesMeth156;
cases17.push(block156);
setLineNumber(91); // compilenode block
var block173 = new GraceBlock(this, 91, 1);
// call case 4: other requests
var call174 = request(var_errormessages, "CompilationError", [0]);
block173.paramTypes = [call174];
var matches175 = function(var_se) {
// call case 4: other requests
var call176 = request(var_errormessages, "CompilationError", [0]);
if (!Grace_isTrue(request(call176, "matches(1)", [1], var_se)))
return false;
return true;
};
block173.guard = matches175;
block173.real = function block173(var_se) {
setLineNumber(92); // compilenode string
// call case 4: other requests
// call case 4: other requests
var call180 = request(var_se, "message", [0]);
// call case 4: other requests
var string181 = new GraceString("Compilation error: ");
var concat179 = request(string181, "++(1)", [1], call180);
var concat178 = request(concat179, "++(1)", [1], GraceEmptyString);
// call case 4: other requests
// call case 4: other requests
var call183 = request(var_se, "data", [0]);
var call182 = request(call183, "line", [0]);
// call case 4: other requests
// call case 4: other requests
var call185 = request(var_se, "data", [0]);
var call184 = request(call185, "column", [0]);
// call case 4: other requests
// call case 4: other requests
var call187 = request(var_se, "data", [0]);
var call186 = request(call187, "arrow", [0]);
// call case 4: other requests
// call case 4: other requests
var call189 = request(var_se, "data", [0]);
var call188 = request(call189, "sugg", [0]);
// call case 4: other requests
var call177 = request(var_util, "generalError(5)", [5], concat178, call182, call184, call186, call188);
return call177;
};
let applyMeth173 = function apply_1 (argcv, ...args) {
if (this.guard.apply(this.receiver, args))
return this.real.apply(this.receiver, args);
badBlockArgs.apply(this, args);
};
applyMeth173.methodName = "apply(1)";
applyMeth173.paramCounts = [1];
applyMeth173.paramNames = ["se"];
applyMeth173.definitionLine = 91;
applyMeth173.definitionModule = "compiler";
block173.methods["apply(1)"] = applyMeth173;
let matchesMeth173 = function matches_1 (argcv, ...args) {
return this.guard.apply(this.receiver, args) ? GraceTrue : GraceFalse;
};
matchesMeth173.methodName = "matches(1)";
matchesMeth173.paramCounts = [1];
matchesMeth173.paramNames = ["se"];
matchesMeth173.definitionLine = 91;
matchesMeth173.definitionModule = "compiler";
block173.methods["matches(1)"] = matchesMeth173;
cases17.push(block173);
setLineNumber(23); // compiletrycatch
var catchres17 = tryCatch(block18,cases17,false);
return catchres17;
}; // end of method compileInputFile
this.methods["compileInputFile"] = func13;
func13.methodName = "compileInputFile";
func13.paramCounts = [0];
func13.paramNames = [];
func13.definitionLine = 18;
func13.definitionModule = "compiler";
var func190 = function(argcv, var_input) { // method lexLines(_), line 101
var returnTarget = invocationCount;
invocationCount++;
const numArgs = arguments.length - 1;
if ((numArgs > 1) && (numArgs !== 1)) {
raiseTypeArgError("lexLines(_)", 0, numArgs - 1);
}
setLineNumber(105); // compilenode member
// call case 4: other requests
// call case 4: other requests
var call192 = request(var_util, "lines", [0]);
var call191 = request(call192, "clear", [0]);
setLineNumber(106); // compilenode call
// call case 4: other requests
// call case 4: other requests
var call194 = request(var_util, "lines", [0]);
var call193 = request(call194, "addAll(1)", [1], var_input);
setLineNumber(107); // compilenode member
// call case 4: other requests
// call case 4: other requests
var call196 = request(var_xmodule, "externalModules", [0]);
var call195 = request(call196, "clear", [0]);
setLineNumber(108); // compilenode call
// call case 4: other requests
var call197 = request(var_lexer, "lexLines(1)", [1], var_input);
return call197;
}; // end of method lexLines(_)
this.methods["lexLines(1)"] = func190;
func190.methodName = "lexLines(1)";
func190.paramCounts = [1];
func190.paramNames = ["input"];
func190.defi