1586 lines
98 KiB
JavaScript
1586 lines
98 KiB
JavaScript
#!/usr/bin/env node
|
|
import { Runtime } from "./runtime.js";
|
|
const runtime = new Runtime("/home/simone/Workspace/phi-lang/compile.phi");
|
|
// === emitting file /home/simone/Workspace/phi-lang/compile.phi ===
|
|
// === emitting file /home/simone/Workspace/phi-lang/stdlib.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
function _slice37(_list48, _idx49) {
|
|
runtime.pushCall("slice", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
const r_0 = (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 3), ((...args) => runtime.builtinLen(...args))(_list48));
|
|
let _list_len50 = r_0;
|
|
const r_1 = ({ type: "list", values: [] });
|
|
let _elems51 = r_1;
|
|
const r_2 = _idx49;
|
|
let _i52 = r_2;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 7), runtime.opGte(_i52, _list_len50)))) {
|
|
break};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 8), ((...args) => runtime.builtinPush(...args))(_elems51, (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 8), ((...args) => runtime.builtinAt(...args))(_list48, _i52))));
|
|
(_i52 = runtime.opAdd(_i52, ({ type: "int", value: 1 })));
|
|
};
|
|
runtime.popCall();
|
|
return _elems51;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _slice_eq38(_str53, _slice_idx54, _substr55) {
|
|
runtime.pushCall("slice_eq", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
const r_3 = (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 15), ((...args) => runtime.builtinLen(...args))(_str53));
|
|
let _str_len56 = r_3;
|
|
const r_4 = (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 16), ((...args) => runtime.builtinLen(...args))(_substr55));
|
|
let _substr_len57 = r_4;
|
|
const r_5 = ({ type: "int", value: 0 });
|
|
let _i58 = r_5;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 19), runtime.opGte(_i58, _substr_len57)))) {
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: true })};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 21), runtime.opGte((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 21), runtime.opAdd(_slice_idx54, _i58)), _str_len56)))) {
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: false })};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 23), runtime.opNe((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 23), ((...args) => runtime.builtinAt(...args))(_str53, (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 23), runtime.opAdd(_slice_idx54, _i58)))), (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 23), ((...args) => runtime.builtinAt(...args))(_substr55, _i58)))))) {
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: false })};
|
|
(_i58 = runtime.opAdd(_i58, ({ type: "int", value: 1 })));
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: true });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _contains39(_text59, _ch60) {
|
|
runtime.pushCall("contains", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
const r_6 = (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 32), ((...args) => runtime.builtinLen(...args))(_text59));
|
|
let _text_len61 = r_6;
|
|
const r_7 = ({ type: "int", value: 0 });
|
|
let _i62 = r_7;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 35), runtime.opGte(_i62, _text_len61)))) {
|
|
break};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 36), runtime.opEq((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 36), ((...args) => runtime.builtinAt(...args))(_text59, _i62)), _ch60)))) {
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: true });
|
|
};
|
|
(_i62 = runtime.opAdd(_i62, ({ type: "int", value: 1 })));
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: false });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _indent40(_depth63) {
|
|
runtime.pushCall("indent", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
const r_8 = ({ type: "string", value: "" });
|
|
let _space64 = r_8;
|
|
const r_9 = ({ type: "int", value: 0 });
|
|
let _i65 = r_9;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 48), runtime.opGte(_i65, _depth63)))) {
|
|
break};
|
|
(_space64 = runtime.opAdd(_space64, ({ type: "string", value: " " })));
|
|
(_i65 = runtime.opAdd(_i65, ({ type: "int", value: 1 })));
|
|
};
|
|
runtime.popCall();
|
|
return _space64;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _list_push41(_list_66, _value67) {
|
|
runtime.pushCall("list_push", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
const r_10 = (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 56), ((...args) => runtime.builtinLen(...args))(_list_66));
|
|
let _list_len68 = r_10;
|
|
const r_11 = ({ type: "int", value: 0 });
|
|
let _i69 = r_11;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 59), runtime.opGte(_i69, _list_len68)))) {
|
|
break};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 60), runtime.opEq((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 60), ((...args) => runtime.builtinAt(...args))(_list_66, _i69)), ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 61), ((...args) => runtime.builtinSet(...args))(_list_66, _i69, _value67));
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
(_i69 = runtime.opAdd(_i69, ({ type: "int", value: 1 })));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 66), ((...args) => runtime.builtinPush(...args))(_list_66, _value67));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _list_pop42(_list_70) {
|
|
runtime.pushCall("list_pop", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
const r_12 = (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 70), runtime.opSub((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 70), ((...args) => runtime.builtinLen(...args))(_list_70)), ({ type: "int", value: 1 })));
|
|
let _i71 = r_12;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 72), runtime.opLt(_i71, ({ type: "int", value: 0 }))))) {
|
|
break};
|
|
const r_13 = (runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 73), ((...args) => runtime.builtinAt(...args))(_list_70, _i71));
|
|
let _value72 = r_13;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 74), runtime.opNe(_value72, ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 75), ((...args) => runtime.builtinSet(...args))(_list_70, _i71, ({ type: "null" })));
|
|
runtime.popCall();
|
|
return _value72;
|
|
};
|
|
(_i71 = runtime.opSub(_i71, ({ type: "int", value: 1 })));
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "null" });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _list_contains43(_list_73, _value74) {
|
|
runtime.pushCall("list_contains", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
for (const r_14 of _list_73.values) {;
|
|
let _elem75 = r_14;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 85), runtime.opEq(_elem75, _value74)))) {
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: true });
|
|
};
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: false });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _map44() {
|
|
runtime.pushCall("map", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [] });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _map_has45(_map76, _key77) {
|
|
runtime.pushCall("map_has", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
for (const r_15 of _map76.values) {;
|
|
const r_16 = r_15.values[0] ?? { type: "null"};
|
|
let _m_key78 = r_16;
|
|
const r_17 = r_15.values[1] ?? { type: "null"};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 98), runtime.opEq(_m_key78, _key77)))) {
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: true });
|
|
};
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: false });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _map_get46(_map79, _key80) {
|
|
runtime.pushCall("map_get", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
for (const r_18 of _map79.values) {;
|
|
const r_19 = r_18.values[0] ?? { type: "null"};
|
|
let _m_key81 = r_19;
|
|
const r_20 = r_18.values[1] ?? { type: "null"};
|
|
let _value82 = r_20;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 107), runtime.opEq(_m_key81, _key80)))) {
|
|
runtime.popCall();
|
|
return _value82;
|
|
};
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "null" });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _map_set47(_map83, _key84, _value85) {
|
|
runtime.pushCall("map_set", "/home/simone/Workspace/phi-lang/stdlib.phi");
|
|
for (const r_21 of _map83.values) {;
|
|
let _entry86 = r_21;
|
|
const r_22 = _entry86;
|
|
const r_23 = r_22.values[0] ?? { type: "null"};
|
|
let _entry_key87 = r_23;
|
|
const r_24 = r_22.values[1] ?? { type: "null"};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 117), runtime.opEq(_entry_key87, _key84)))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 118), ((...args) => runtime.builtinSet(...args))(_entry86, ({ type: "int", value: 1 }), _value85));
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/stdlib.phi", 122), ((...args) => runtime.builtinPush(...args))(_map83, ({ type: "list", values: [_key84, _value85] })));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
|
|
// === resuming file /home/simone/Workspace/phi-lang/compile.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compile.phi");
|
|
// === emitting file /home/simone/Workspace/phi-lang/compiler/parse.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
;
|
|
// === emitting file /home/simone/Workspace/phi-lang/compiler/counter.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compiler/counter.phi");
|
|
function _Counter126() {
|
|
runtime.pushCall("Counter", "/home/simone/Workspace/phi-lang/compiler/counter.phi");
|
|
const r_25 = ({ type: "int", value: 0 });
|
|
let _counter129 = r_25;
|
|
function _count127() {
|
|
runtime.pushCall("count", "/home/simone/Workspace/phi-lang/compiler/counter.phi");
|
|
runtime.popCall();
|
|
return _counter129;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _increment128() {
|
|
runtime.pushCall("increment", "/home/simone/Workspace/phi-lang/compiler/counter.phi");
|
|
(_counter129 = runtime.opAdd(_counter129, ({ type: "int", value: 1 })));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [_count127, _increment128] });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
|
|
// === resuming file /home/simone/Workspace/phi-lang/compiler/parse.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
function _Parser106(_tokens130) {
|
|
runtime.pushCall("Parser", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
const r_26 = ({ type: "int", value: 0 });
|
|
let _i138 = r_26;
|
|
const r_27 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 6), ((...args) => runtime.builtinAt(...args))(_tokens130, _i138));
|
|
let _tok139 = r_27;
|
|
const r_28 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 8), _Counter126());
|
|
const r_29 = r_28.values[0] ?? { type: "null"};
|
|
let _id_count140 = r_29;
|
|
const r_30 = r_28.values[1] ?? { type: "null"};
|
|
let _increment_id141 = r_30;
|
|
function _next_id131() {
|
|
runtime.pushCall("next_id", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
const r_31 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 10), _id_count140());
|
|
let _id142 = r_31;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 11), _increment_id141());
|
|
runtime.popCall();
|
|
return _id142;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _parse132() {
|
|
runtime.pushCall("parse", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
const r_32 = ({ type: "list", values: [] });
|
|
let _exprs143 = r_32;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 18), _done137()))) {
|
|
break};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 19), ((...args) => runtime.builtinPush(...args))(_exprs143, (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 19), _parse_expr133())));
|
|
};
|
|
runtime.popCall();
|
|
return _exprs143;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _parse_expr133() {
|
|
runtime.pushCall("parse_expr", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
const r_33 = _tok139;
|
|
const r_34 = r_33.values[0] ?? { type: "null"};
|
|
let _ty144 = r_34;
|
|
const r_35 = r_33.values[1] ?? { type: "null"};
|
|
let _line145 = r_35;
|
|
const r_36 = r_33.values[2] ?? { type: "null"};
|
|
let _value146 = r_36;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 26), _eat134(({ type: "string", value: "(" }))))) {
|
|
const r_37 = ({ type: "list", values: [] });
|
|
let _values147 = r_37;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 29), _test136(({ type: "string", value: ")" }))))) {
|
|
break};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 30), ((...args) => runtime.builtinPush(...args))(_values147, (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 30), _parse_expr133())));
|
|
};
|
|
if (runtime.truthy(runtime.opNot((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 32), _eat134(({ type: "string", value: ")" })))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 33), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected ')' on line %" }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 33), ((...args) => runtime.builtinAt(...args))(_tok139, ({ type: "int", value: 1 })))));
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 35), _next_id131()), ({ type: "string", value: "list" }), _line145, _values147] });
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 36), _eat134(({ type: "string", value: "string" }))))) {
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 37), _next_id131()), ({ type: "string", value: "string" }), _line145, _value146] });
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 38), _eat134(({ type: "string", value: "int" }))))) {
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 39), _next_id131()), ({ type: "string", value: "int" }), _line145, (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 39), ((...args) => runtime.builtinStringToInt(...args))(_value146))] });
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 40), _eat134(({ type: "string", value: "ident" }))))) {
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 41), _next_id131()), ({ type: "string", value: "ident" }), _line145, _value146] });
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 43), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected expression, got '%' on line %" }), _ty144, _line145));
|
|
}}}};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _eat134(_pat148) {
|
|
runtime.pushCall("eat", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
if (runtime.truthy(runtime.opNot((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 48), _test136(_pat148))))) {
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: false })};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 49), _step135());
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: true });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _step135() {
|
|
runtime.pushCall("step", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
(_i138 = runtime.opAdd(_i138, ({ type: "int", value: 1 })));
|
|
if (runtime.truthy(runtime.opNot((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 55), _done137())))) {
|
|
const r_38 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 56), ((...args) => runtime.builtinAt(...args))(_tokens130, _i138));
|
|
let _new_tok149 = r_38;
|
|
(_tok139 = _new_tok149);
|
|
};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _test136(_pat150) {
|
|
runtime.pushCall("test", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 62), _done137()))) {
|
|
runtime.popCall();
|
|
return ({ type: "bool", value: false })};
|
|
const r_39 = _tok139;
|
|
const r_40 = r_39.values[0] ?? { type: "null"};
|
|
let _ty151 = r_40;
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 64), runtime.opEq(_pat150, _ty151));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _done137() {
|
|
runtime.pushCall("done", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 68), runtime.opGte(_i138, (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 68), ((...args) => runtime.builtinLen(...args))(_tokens130))));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [_parse132] });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _tokenize107(_text152) {
|
|
runtime.pushCall("tokenize", "/home/simone/Workspace/phi-lang/compiler/parse.phi");
|
|
const r_41 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 75), ((...args) => runtime.builtinLen(...args))(_text152));
|
|
let _text_len153 = r_41;
|
|
const r_42 = ({ type: "list", values: [] });
|
|
let _tokens154 = r_42;
|
|
const r_43 = ({ type: "int", value: 0 });
|
|
let _i155 = r_43;
|
|
const r_44 = ({ type: "int", value: 1 });
|
|
let _line156 = r_44;
|
|
const r_45 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 81), runtime.opAdd(({ type: "string", value: "abcdefghijklmnopqrstuvwxyz" }), ({ type: "string", value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-*/%&|=?!<>'_" })));
|
|
let _ident_chars157 = r_45;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 85), runtime.opGte(_i155, _text_len153)))) {
|
|
break};
|
|
const r_46 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 87), ((...args) => runtime.builtinAt(...args))(_text152, _i155));
|
|
let _ch158 = r_46;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 89), _contains39(({ type: "string", value: " \t\r\n" }), _ch158)))) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 90), runtime.opEq(_ch158, ({ type: "string", value: "\n" }))))) {
|
|
(_line156 = runtime.opAdd(_line156, ({ type: "int", value: 1 })));
|
|
};
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 94), _slice_eq38(_text152, _i155, ({ type: "string", value: "//" }))))) {
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 96), { type: "bool", value: runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 96), runtime.opGte(_i155, _text_len153))) || runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 96), runtime.opEq((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 96), ((...args) => runtime.builtinAt(...args))(_text152, _i155)), ({ type: "string", value: "\n" })))) }))) {
|
|
break;
|
|
};
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
};
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 101), _contains39(({ type: "string", value: "()" }), _ch158)))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 102), ((...args) => runtime.builtinPush(...args))(_tokens154, ({ type: "list", values: [_ch158, _line156] })));
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 104), runtime.opEq(_ch158, ({ type: "string", value: "\"" }))))) {
|
|
const r_47 = ({ type: "string", value: "" });
|
|
let _value159 = r_47;
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
(_ch158 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 107), ((...args) => runtime.builtinAt(...args))(_text152, _i155)));
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 109), { type: "bool", value: runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 109), runtime.opGte(_i155, _text_len153))) || runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 109), runtime.opEq(_ch158, ({ type: "string", value: "\"" })))) }))) {
|
|
break;
|
|
};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 112), runtime.opEq(_ch158, ({ type: "string", value: "\\" }))))) {
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 114), runtime.opGte(_i155, _text_len153)))) {
|
|
break;
|
|
};
|
|
(_ch158 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 117), ((...args) => runtime.builtinAt(...args))(_text152, _i155)));
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 118), runtime.opEq(_ch158, ({ type: "string", value: "t" }))))) {
|
|
(_value159 = runtime.opAdd(_value159, ({ type: "string", value: "\t" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 120), runtime.opEq(_ch158, ({ type: "string", value: "r" }))))) {
|
|
(_value159 = runtime.opAdd(_value159, ({ type: "string", value: "\r" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 122), runtime.opEq(_ch158, ({ type: "string", value: "n" }))))) {
|
|
(_value159 = runtime.opAdd(_value159, ({ type: "string", value: "\n" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 124), runtime.opEq(_ch158, ({ type: "string", value: "0" }))))) {
|
|
(_value159 = runtime.opAdd(_value159, ({ type: "string", value: "\n" })));
|
|
} else {
|
|
(_value159 = runtime.opAdd(_value159, _ch158));
|
|
}}}};
|
|
} else {
|
|
(_value159 = runtime.opAdd(_value159, _ch158));
|
|
};
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
(_ch158 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 133), ((...args) => runtime.builtinAt(...args))(_text152, _i155)));
|
|
};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 135), { type: "bool", value: runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 135), runtime.opGte(_i155, _text_len153))) || runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 135), runtime.opNe(_ch158, ({ type: "string", value: "\"" })))) }))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 136), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected '\"' on line %" }), _line156));
|
|
};
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 139), ((...args) => runtime.builtinPush(...args))(_tokens154, ({ type: "list", values: [({ type: "string", value: "string" }), _line156, _value159] })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 140), _contains39(({ type: "string", value: "0123456789" }), _ch158)))) {
|
|
const r_48 = ({ type: "string", value: "" });
|
|
let _value160 = r_48;
|
|
while (true) {
|
|
(_ch158 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 143), ((...args) => runtime.builtinAt(...args))(_text152, _i155)));
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 144), { type: "bool", value: runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 144), runtime.opGte(_i155, _text_len153))) || runtime.truthy(runtime.opNot((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 144), _contains39(({ type: "string", value: "0123456789" }), _ch158)))) }))) {
|
|
break;
|
|
};
|
|
(_value160 = runtime.opAdd(_value160, _ch158));
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 150), ((...args) => runtime.builtinPush(...args))(_tokens154, ({ type: "list", values: [({ type: "string", value: "int" }), _line156, _value160] })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 151), _contains39(_ident_chars157, _ch158)))) {
|
|
const r_49 = ({ type: "string", value: "" });
|
|
let _value161 = r_49;
|
|
while (true) {
|
|
(_ch158 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 154), ((...args) => runtime.builtinAt(...args))(_text152, _i155)));
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 155), { type: "bool", value: runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 155), runtime.opGte(_i155, _text_len153))) || runtime.truthy(runtime.opNot((runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 155), _contains39(_ident_chars157, _ch158)))) }))) {
|
|
break;
|
|
};
|
|
(_value161 = runtime.opAdd(_value161, _ch158));
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 161), ((...args) => runtime.builtinPush(...args))(_tokens154, ({ type: "list", values: [({ type: "string", value: "ident" }), _line156, _value161] })));
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/parse.phi", 163), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "illegal char '%'" }), _ch158));
|
|
(_i155 = runtime.opAdd(_i155, ({ type: "int", value: 1 })));
|
|
}}}}}};
|
|
};
|
|
runtime.popCall();
|
|
return _tokens154;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
|
|
// === resuming file /home/simone/Workspace/phi-lang/compile.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compile.phi");
|
|
// === emitting file /home/simone/Workspace/phi-lang/compiler/emit_js.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
;
|
|
;
|
|
// === emitting file /home/simone/Workspace/phi-lang/compiler/syms.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
;
|
|
function _Syms200() {
|
|
runtime.pushCall("Syms", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
const r_50 = ({ type: "list", values: [({ type: "null" }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 4), _map44())] });
|
|
let _syms209 = r_50;
|
|
function _enter_scope201() {
|
|
runtime.pushCall("enter_scope", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
(_syms209 = ({ type: "list", values: [_syms209, (runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 7), _map44())] }));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _leave_scope202() {
|
|
runtime.pushCall("leave_scope", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
const r_51 = _syms209;
|
|
const r_52 = r_51.values[0] ?? { type: "null"};
|
|
let _parent210 = r_52;
|
|
const r_53 = r_51.values[1] ?? { type: "null"};
|
|
(_syms209 = _parent210);
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _define_sym203(_ident211, _sym212) {
|
|
runtime.pushCall("define_sym", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
const r_54 = _syms209;
|
|
const r_55 = r_54.values[0] ?? { type: "null"};
|
|
const r_56 = r_54.values[1] ?? { type: "null"};
|
|
let _map213 = r_56;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 17), _map_set47(_map213, _ident211, _sym212));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _find_sym204(_syms214, _ident215) {
|
|
runtime.pushCall("find_sym", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
const r_57 = _syms214;
|
|
const r_58 = r_57.values[0] ?? { type: "null"};
|
|
let _parent216 = r_58;
|
|
const r_59 = r_57.values[1] ?? { type: "null"};
|
|
let _map217 = r_59;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 22), _map_has45(_map217, _ident215)))) {
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 23), _map_get46(_map217, _ident215));
|
|
};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 25), runtime.opNe(_parent216, ({ type: "null" }))))) {
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 26), _find_sym204(_parent216, _ident215));
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "null" });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _get_sym205(_ident218) {
|
|
runtime.pushCall("get_sym", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 32), _find_sym204(_syms209, _ident218));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _get_current_map206() {
|
|
runtime.pushCall("get_current_map", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
const r_60 = _syms209;
|
|
const r_61 = r_60.values[0] ?? { type: "null"};
|
|
const r_62 = r_60.values[1] ?? { type: "null"};
|
|
let _map219 = r_62;
|
|
runtime.popCall();
|
|
return _map219;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _print_syms_node207(_syms220, _depth221) {
|
|
runtime.pushCall("print_syms_node", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
const r_63 = _syms220;
|
|
const r_64 = r_63.values[0] ?? { type: "null"};
|
|
let _parent222 = r_64;
|
|
const r_65 = r_63.values[1] ?? { type: "null"};
|
|
let _map223 = r_65;
|
|
for (const r_66 of _map223.values) {;
|
|
const r_67 = r_66.values[0] ?? { type: "null"};
|
|
let _ident224 = r_67;
|
|
const r_68 = r_66.values[1] ?? { type: "null"};
|
|
let _sym225 = r_68;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 43), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%- %: %" }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 43), _indent40(_depth221)), _ident224, _sym225));
|
|
};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 45), runtime.opNe(_parent222, ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 46), _print_syms_node207(_parent222, (runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 46), runtime.opAdd(_depth221, ({ type: "int", value: 1 })))));
|
|
};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _print_syms208() {
|
|
runtime.pushCall("print_syms", "/home/simone/Workspace/phi-lang/compiler/syms.phi");
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/syms.phi", 51), _print_syms_node207(_syms209, ({ type: "int", value: 0 })));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [_enter_scope201, _leave_scope202, _define_sym203, _get_sym205, _get_current_map206, _print_syms208] });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
|
|
// === resuming file /home/simone/Workspace/phi-lang/compiler/emit_js.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
;
|
|
function _JsEmitter180(_ast226, _initial_filename227) {
|
|
runtime.pushCall("JsEmitter", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_69 = ({ type: "list", values: [] });
|
|
let _output249 = r_69;
|
|
const r_70 = _initial_filename227;
|
|
let _filename250 = r_70;
|
|
const r_71 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 20), _Syms200());
|
|
let _syms251 = r_71;
|
|
const r_72 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 22), _Counter126());
|
|
const r_73 = r_72.values[0] ?? { type: "null"};
|
|
let _sym_id_count252 = r_73;
|
|
const r_74 = r_72.values[1] ?? { type: "null"};
|
|
let _sym_id_increment253 = r_74;
|
|
const r_75 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 23), _Counter126());
|
|
const r_76 = r_75.values[0] ?? { type: "null"};
|
|
let _let_node_reg_count254 = r_76;
|
|
const r_77 = r_75.values[1] ?? { type: "null"};
|
|
let _let_node_reg_increment255 = r_77;
|
|
const r_78 = ({ type: "list", values: [_filename250] });
|
|
let _import_stack256 = r_78;
|
|
const r_79 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 26), _map44());
|
|
let _imported_files257 = r_79;
|
|
const r_80 = ({ type: "list", values: [({ type: "list", values: [({ type: "string", value: "format" }), ({ type: "string", value: "builtinFormat" })] }), ({ type: "list", values: [({ type: "string", value: "print" }), ({ type: "string", value: "builtinPrint" })] }), ({ type: "list", values: [({ type: "string", value: "println" }), ({ type: "string", value: "builtinPrintln" })] }), ({ type: "list", values: [({ type: "string", value: "panic" }), ({ type: "string", value: "builtinPanic" })] }), ({ type: "list", values: [({ type: "string", value: "read_text_file" }), ({ type: "string", value: "builtinReadTextFile" })] }), ({ type: "list", values: [({ type: "string", value: "write_text_file" }), ({ type: "string", value: "builtinWriteTextFile" })] }), ({ type: "list", values: [({ type: "string", value: "push" }), ({ type: "string", value: "builtinPush" })] }), ({ type: "list", values: [({ type: "string", value: "at" }), ({ type: "string", value: "builtinAt" })] }), ({ type: "list", values: [({ type: "string", value: "set" }), ({ type: "string", value: "builtinSet" })] }), ({ type: "list", values: [({ type: "string", value: "len" }), ({ type: "string", value: "builtinLen" })] }), ({ type: "list", values: [({ type: "string", value: "string_to_int" }), ({ type: "string", value: "builtinStringToInt" })] }), ({ type: "list", values: [({ type: "string", value: "char_code" }), ({ type: "string", value: "builtinCharCode" })] }), ({ type: "list", values: [({ type: "string", value: "strings_join" }), ({ type: "string", value: "builtinStringsJoin" })] }), ({ type: "list", values: [({ type: "string", value: "get_args" }), ({ type: "string", value: "builtinGetArgs" })] }), ({ type: "list", values: [({ type: "string", value: "fs_basename" }), ({ type: "string", value: "builtinFsBasename" })] }), ({ type: "list", values: [({ type: "string", value: "fs_dirname" }), ({ type: "string", value: "builtinFsDirname" })] }), ({ type: "list", values: [({ type: "string", value: "fs_cwd" }), ({ type: "string", value: "builtinFsCwd" })] }), ({ type: "list", values: [({ type: "string", value: "fs_resolve" }), ({ type: "string", value: "builtinFsResolve" })] })] });
|
|
let _builtin_syms258 = r_80;
|
|
function _generate228() {
|
|
runtime.pushCall("generate", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 50), _emit238(({ type: "string", value: "#!/usr/bin/env node\n" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 51), _emit238(({ type: "string", value: "import { Runtime } from \"./runtime.js\";\n" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 52), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 52), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "const runtime = new Runtime(\"%\");\n" }), _filename250))));
|
|
for (const r_81 of _builtin_syms258.values) {;
|
|
const r_82 = r_81.values[0] ?? { type: "null"};
|
|
let _ident259 = r_82;
|
|
const r_83 = r_81.values[1] ?? { type: "null"};
|
|
let _builtin_id260 = r_83;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 55), _define_builtin239(_ident259, _builtin_id260));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 58), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 58), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "// === emitting file % ===\n" }), _filename250))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 59), _enter_scope243());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 60), _discover_syms230(_ast226));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 61), _emit_exprs229(_ast226));
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 62), ((...args) => runtime.builtinStringsJoin(...args))(_output249));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _emit_exprs229(_exprs261) {
|
|
runtime.pushCall("emit_exprs", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
for (const r_84 of _exprs261.values) {;
|
|
let _expr262 = r_84;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 67), _emit_expr231(_expr262));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 68), _emit238(({ type: "string", value: ";\n" })));
|
|
};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _discover_syms230(_exprs263) {
|
|
runtime.pushCall("discover_syms", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
for (const r_85 of _exprs263.values) {;
|
|
let _expr264 = r_85;
|
|
const r_86 = _expr264;
|
|
const r_87 = r_86.values[0] ?? { type: "null"};
|
|
const r_88 = r_86.values[1] ?? { type: "null"};
|
|
let _ty265 = r_88;
|
|
const r_89 = r_86.values[2] ?? { type: "null"};
|
|
let _line266 = r_89;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 75), runtime.opNe(_ty265, ({ type: "string", value: "list" }))))) {
|
|
runtime.popCall();
|
|
return { type: "null" }};
|
|
const r_90 = _expr264;
|
|
const r_91 = r_90.values[0] ?? { type: "null"};
|
|
const r_92 = r_90.values[1] ?? { type: "null"};
|
|
const r_93 = r_90.values[2] ?? { type: "null"};
|
|
const r_94 = r_90.values[3] ?? { type: "null"};
|
|
let _s267 = r_94;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 77), runtime.opEq((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 77), ((...args) => runtime.builtinLen(...args))(_s267)), ({ type: "int", value: 0 }))))) {
|
|
runtime.popCall();
|
|
return { type: "null" }};
|
|
const r_95 = _s267;
|
|
const r_96 = r_95.values[0] ?? { type: "null"};
|
|
const r_97 = r_96.values[0] ?? { type: "null"};
|
|
const r_98 = r_96.values[1] ?? { type: "null"};
|
|
const r_99 = r_96.values[2] ?? { type: "null"};
|
|
const r_100 = r_96.values[3] ?? { type: "null"};
|
|
let _id268 = r_100;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 79), runtime.opEq(_id268, ({ type: "string", value: "fn" }))))) {
|
|
const r_101 = _s267;
|
|
const r_102 = r_101.values[0] ?? { type: "null"};
|
|
const r_103 = r_101.values[1] ?? { type: "null"};
|
|
const r_104 = r_103.values[0] ?? { type: "null"};
|
|
const r_105 = r_103.values[1] ?? { type: "null"};
|
|
const r_106 = r_103.values[2] ?? { type: "null"};
|
|
const r_107 = r_103.values[3] ?? { type: "null"};
|
|
let _ident269 = r_107;
|
|
const r_108 = r_101.values[2] ?? { type: "null"};
|
|
const r_109 = r_108.values[0] ?? { type: "null"};
|
|
const r_110 = r_108.values[1] ?? { type: "null"};
|
|
const r_111 = r_108.values[2] ?? { type: "null"};
|
|
const r_112 = r_108.values[3] ?? { type: "null"};
|
|
let _params270 = r_112;
|
|
const r_113 = r_101.values[3] ?? { type: "null"};
|
|
let _body271 = r_113;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 81), _define_fn240(_ident269, _line266));
|
|
};
|
|
};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _emit_expr231(_expr272) {
|
|
runtime.pushCall("emit_expr", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_114 = _expr272;
|
|
const r_115 = r_114.values[0] ?? { type: "null"};
|
|
const r_116 = r_114.values[1] ?? { type: "null"};
|
|
let _ty273 = r_116;
|
|
const r_117 = r_114.values[2] ?? { type: "null"};
|
|
let _line274 = r_117;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 88), runtime.opEq(_ty273, ({ type: "string", value: "list" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 89), _emit_list232(_expr272));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 90), runtime.opEq(_ty273, ({ type: "string", value: "int" }))))) {
|
|
const r_118 = _expr272;
|
|
const r_119 = r_118.values[0] ?? { type: "null"};
|
|
const r_120 = r_118.values[1] ?? { type: "null"};
|
|
const r_121 = r_118.values[2] ?? { type: "null"};
|
|
const r_122 = r_118.values[3] ?? { type: "null"};
|
|
let _value275 = r_122;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 92), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 92), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "({ type: \"int\", value: % })" }), _value275))));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 93), runtime.opEq(_ty273, ({ type: "string", value: "string" }))))) {
|
|
const r_123 = _expr272;
|
|
const r_124 = r_123.values[0] ?? { type: "null"};
|
|
const r_125 = r_123.values[1] ?? { type: "null"};
|
|
const r_126 = r_123.values[2] ?? { type: "null"};
|
|
const r_127 = r_123.values[3] ?? { type: "null"};
|
|
let _value276 = r_127;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 95), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 95), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "({ type: \"string\", value: \"%\" })" }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 95), _string_escape181(_value276))))));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 96), runtime.opEq(_ty273, ({ type: "string", value: "ident" }))))) {
|
|
const r_128 = _expr272;
|
|
const r_129 = r_128.values[0] ?? { type: "null"};
|
|
const r_130 = r_128.values[1] ?? { type: "null"};
|
|
const r_131 = r_128.values[2] ?? { type: "null"};
|
|
const r_132 = r_128.values[3] ?? { type: "null"};
|
|
let _value277 = r_132;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 99), runtime.opEq(_value277, ({ type: "string", value: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 100), _emit238(({ type: "string", value: "({ type: \"null\" })" })));
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 102), runtime.opEq(_value277, ({ type: "string", value: "false" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 103), _emit238(({ type: "string", value: "({ type: \"bool\", value: false })" })));
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 105), runtime.opEq(_value277, ({ type: "string", value: "true" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 106), _emit238(({ type: "string", value: "({ type: \"bool\", value: true })" })));
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
}}};
|
|
const r_133 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 110), _get_sym246(_value277));
|
|
let _sym278 = r_133;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 111), runtime.opEq(_sym278, ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 112), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "undefined symbol '%' on line %" }), _value277, _line274));
|
|
};
|
|
const r_134 = _sym278;
|
|
const r_135 = r_134.values[0] ?? { type: "null"};
|
|
let _sym_id279 = r_135;
|
|
const r_136 = r_134.values[1] ?? { type: "null"};
|
|
let _sym_ty280 = r_136;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 116), runtime.opEq(_sym_ty280, ({ type: "string", value: "builtin" }))))) {
|
|
const r_137 = _sym278;
|
|
const r_138 = r_137.values[0] ?? { type: "null"};
|
|
const r_139 = r_137.values[1] ?? { type: "null"};
|
|
const r_140 = r_137.values[2] ?? { type: "null"};
|
|
let _id281 = r_140;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 118), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 118), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "((...args) => runtime.%(...args))" }), _id281))));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 119), runtime.opEq(_sym_ty280, ({ type: "string", value: "fn" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 120), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 120), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value277, _sym_id279))));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 121), runtime.opEq(_sym_ty280, ({ type: "string", value: "param" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 122), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 122), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value277, _sym_id279))));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 123), runtime.opEq(_sym_ty280, ({ type: "string", value: "let" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 124), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 124), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value277, _sym_id279))));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 125), runtime.opEq(_sym_ty280, ({ type: "string", value: "imported" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 130), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 130), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value277, _sym_id279))));
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 132), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented '%'" }), _sym_ty280));
|
|
}}}}};
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 135), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "unknown expr type '%' on line %" }), _ty273, _line274));
|
|
}}}};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _emit_list232(_expr282) {
|
|
runtime.pushCall("emit_list", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_141 = _expr282;
|
|
const r_142 = r_141.values[0] ?? { type: "null"};
|
|
const r_143 = r_141.values[1] ?? { type: "null"};
|
|
let _ty283 = r_143;
|
|
const r_144 = r_141.values[2] ?? { type: "null"};
|
|
let _line284 = r_144;
|
|
const r_145 = r_141.values[3] ?? { type: "null"};
|
|
let _s285 = r_145;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 141), runtime.opEq((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 141), ((...args) => runtime.builtinLen(...args))(_s285)), ({ type: "int", value: 0 }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 142), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "illegal function on line %" }), _line284));
|
|
};
|
|
const r_146 = _s285;
|
|
const r_147 = r_146.values[0] ?? { type: "null"};
|
|
const r_148 = r_147.values[0] ?? { type: "null"};
|
|
const r_149 = r_147.values[1] ?? { type: "null"};
|
|
let _id_ty286 = r_149;
|
|
const r_150 = r_147.values[2] ?? { type: "null"};
|
|
const r_151 = r_147.values[3] ?? { type: "null"};
|
|
let _id287 = r_151;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 145), runtime.opNe(_id_ty286, ({ type: "string", value: "ident" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 146), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "illegal function on line %" }), _line284));
|
|
};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 148), runtime.opEq(_id287, ({ type: "string", value: "import" }))))) {
|
|
const r_152 = _s285;
|
|
const r_153 = r_152.values[0] ?? { type: "null"};
|
|
const r_154 = r_152.values[1] ?? { type: "null"};
|
|
const r_155 = r_154.values[0] ?? { type: "null"};
|
|
const r_156 = r_154.values[1] ?? { type: "null"};
|
|
const r_157 = r_154.values[2] ?? { type: "null"};
|
|
const r_158 = r_154.values[3] ?? { type: "null"};
|
|
let _inner_filename_rel288 = r_158;
|
|
const r_159 = r_152.values[2] ?? { type: "null"};
|
|
const r_160 = r_159.values[0] ?? { type: "null"};
|
|
const r_161 = r_159.values[1] ?? { type: "null"};
|
|
const r_162 = r_159.values[2] ?? { type: "null"};
|
|
const r_163 = r_159.values[3] ?? { type: "null"};
|
|
let _idents289 = r_163;
|
|
const r_164 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 151), ((...args) => runtime.builtinFsResolve(...args))((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 151), ((...args) => runtime.builtinFsDirname(...args))(_filename250)), _inner_filename_rel288));
|
|
let _inner_filename290 = r_164;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 153), _list_contains43(_import_stack256, _inner_filename290)))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 154), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "circular dependendy: '%' imports '%'" }), _filename250, _inner_filename290));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 156), _list_push41(_import_stack256, _inner_filename290));
|
|
const r_165 = ({ type: "null" });
|
|
let _sym_map291 = r_165;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 160), _map_has45(_imported_files257, _inner_filename290)))) {
|
|
(_sym_map291 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 161), _map_get46(_imported_files257, _inner_filename290)));
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 163), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "compiling '%'" }), _inner_filename290));
|
|
const r_166 = _filename250;
|
|
let _outer_filename292 = r_166;
|
|
(_filename250 = _inner_filename290);
|
|
const r_167 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 167), ((...args) => runtime.builtinReadTextFile(...args))(_filename250));
|
|
let _text293 = r_167;
|
|
const r_168 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 168), _tokenize107(_text293));
|
|
let _tokens294 = r_168;
|
|
const r_169 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 169), _Parser106(_tokens294));
|
|
let _parser295 = r_169;
|
|
const r_170 = _parser295;
|
|
const r_171 = r_170.values[0] ?? { type: "null"};
|
|
let _parse296 = r_171;
|
|
const r_172 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 171), _parse296());
|
|
let _ast297 = r_172;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 173), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 173), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "// === emitting file % ===\n" }), _filename250))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 174), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 174), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.setFile(\"%\");\n" }), _filename250))));
|
|
const r_173 = _syms251;
|
|
let _outer_syms298 = r_173;
|
|
(_syms251 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 177), _Syms200()));
|
|
for (const r_174 of _builtin_syms258.values) {;
|
|
const r_175 = r_174.values[0] ?? { type: "null"};
|
|
let _ident299 = r_175;
|
|
const r_176 = r_174.values[1] ?? { type: "null"};
|
|
let _builtin_id300 = r_176;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 179), _define_builtin239(_ident299, _builtin_id300));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 182), _enter_scope243());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 183), _discover_syms230(_ast297));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 184), _emit_exprs229(_ast297));
|
|
(_sym_map291 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 185), _get_current_map247()));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 186), _map_set47(_imported_files257, _filename250, _sym_map291));
|
|
(_syms251 = _outer_syms298);
|
|
(_filename250 = _outer_filename292);
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 191), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 191), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "\n// === resuming file % ===\n" }), _outer_filename292))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 192), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 192), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.setFile(\"%\")" }), _outer_filename292))));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 194), _list_pop42(_import_stack256));
|
|
for (const r_177 of _idents289.values) {;
|
|
const r_178 = r_177.values[0] ?? { type: "null"};
|
|
const r_179 = r_177.values[1] ?? { type: "null"};
|
|
const r_180 = r_177.values[2] ?? { type: "null"};
|
|
const r_181 = r_177.values[3] ?? { type: "null"};
|
|
let _ident301 = r_181;
|
|
const r_182 = ({ type: "null" });
|
|
let _sym302 = r_182;
|
|
for (const r_183 of _sym_map291.values) {;
|
|
const r_184 = r_183.values[0] ?? { type: "null"};
|
|
let _sym_ident303 = r_184;
|
|
const r_185 = r_183.values[1] ?? { type: "null"};
|
|
let _found_sym304 = r_185;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 199), runtime.opEq(_sym_ident303, _ident301)))) {
|
|
(_sym302 = _found_sym304);
|
|
break;
|
|
};
|
|
};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 204), runtime.opEq(_sym302, ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 205), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "no symbol '%' from imported '%'" }), _ident301, _inner_filename290));
|
|
};
|
|
const r_186 = _sym302;
|
|
const r_187 = r_186.values[0] ?? { type: "null"};
|
|
const r_188 = r_186.values[1] ?? { type: "null"};
|
|
let _sym_type305 = r_188;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 208), runtime.opEq(_sym_type305, ({ type: "string", value: "imported" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 209), _define_sym245(_ident301, _sym302));
|
|
} else {
|
|
const r_189 = _sym302;
|
|
const r_190 = r_189.values[0] ?? { type: "null"};
|
|
let _sym_id306 = r_190;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 212), _define_sym245(_ident301, ({ type: "list", values: [_sym_id306, ({ type: "string", value: "imported" }), _sym302] })));
|
|
};
|
|
};
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 215), runtime.opEq(_id287, ({ type: "string", value: "fn" }))))) {
|
|
const r_191 = _s285;
|
|
const r_192 = r_191.values[0] ?? { type: "null"};
|
|
const r_193 = r_191.values[1] ?? { type: "null"};
|
|
const r_194 = r_193.values[0] ?? { type: "null"};
|
|
const r_195 = r_193.values[1] ?? { type: "null"};
|
|
const r_196 = r_193.values[2] ?? { type: "null"};
|
|
const r_197 = r_193.values[3] ?? { type: "null"};
|
|
let _ident307 = r_197;
|
|
const r_198 = r_191.values[2] ?? { type: "null"};
|
|
const r_199 = r_198.values[0] ?? { type: "null"};
|
|
const r_200 = r_198.values[1] ?? { type: "null"};
|
|
const r_201 = r_198.values[2] ?? { type: "null"};
|
|
const r_202 = r_198.values[3] ?? { type: "null"};
|
|
let _params308 = r_202;
|
|
const r_203 = r_191.values[3] ?? { type: "null"};
|
|
let _body309 = r_203;
|
|
const r_204 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 218), _get_sym246(_ident307));
|
|
let _sym310 = r_204;
|
|
const r_205 = _sym310;
|
|
const r_206 = r_205.values[0] ?? { type: "null"};
|
|
let _sym_id311 = r_206;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 221), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 221), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "function _%%(" }), _ident307, _sym_id311))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 223), _enter_scope243());
|
|
const r_207 = ({ type: "bool", value: true });
|
|
let _first312 = r_207;
|
|
for (const r_208 of _params308.values) {;
|
|
const r_209 = r_208.values[0] ?? { type: "null"};
|
|
const r_210 = r_208.values[1] ?? { type: "null"};
|
|
const r_211 = r_208.values[2] ?? { type: "null"};
|
|
const r_212 = r_208.values[3] ?? { type: "null"};
|
|
let _ident313 = r_212;
|
|
if (runtime.truthy(runtime.opNot(_first312))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 228), _emit238(({ type: "string", value: ", " })));
|
|
};
|
|
(_first312 = ({ type: "bool", value: false }));
|
|
const r_213 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 232), _define_param241(_ident313, _line284));
|
|
let _sym_id314 = r_213;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 233), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 233), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _ident313, _sym_id314))));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 237), _emit238(({ type: "string", value: ") {\n" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 238), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 238), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.pushCall(\"%\", \"%\");\n" }), _ident307, _filename250))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 240), _emit_expr231(_body309));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 241), _emit238(({ type: "string", value: ";\nruntime.popCall();\nreturn { type: \"null\" };\n}" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 243), _leave_scope244());
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 244), runtime.opEq(_id287, ({ type: "string", value: "let" }))))) {
|
|
const r_214 = _s285;
|
|
const r_215 = r_214.values[0] ?? { type: "null"};
|
|
const r_216 = r_214.values[1] ?? { type: "null"};
|
|
let _pat315 = r_216;
|
|
const r_217 = r_214.values[2] ?? { type: "null"};
|
|
let _expr316 = r_217;
|
|
const r_218 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 246), _let_node_reg_count254());
|
|
let _reg317 = r_218;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 247), _let_node_reg_increment255());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 248), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 248), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "const r_% = " }), _reg317))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 249), _emit_expr231(_expr316));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 250), _emit_let_node234(_pat315, _reg317));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 251), runtime.opEq(_id287, ({ type: "string", value: "do" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 252), _enter_scope243());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 253), _discover_syms230((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 253), _slice37(_s285, ({ type: "int", value: 1 })))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 254), _emit_exprs229((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 254), _slice37(_s285, ({ type: "int", value: 1 })))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 255), _leave_scope244());
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 256), runtime.opEq(_id287, ({ type: "string", value: "for" }))))) {
|
|
const r_219 = _s285;
|
|
const r_220 = r_219.values[0] ?? { type: "null"};
|
|
const r_221 = r_219.values[1] ?? { type: "null"};
|
|
let _pat318 = r_221;
|
|
const r_222 = r_219.values[2] ?? { type: "null"};
|
|
let _expr319 = r_222;
|
|
const r_223 = r_219.values[3] ?? { type: "null"};
|
|
let _body320 = r_223;
|
|
const r_224 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 259), _let_node_reg_count254());
|
|
let _reg321 = r_224;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 260), _let_node_reg_increment255());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 261), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 261), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "for (const r_% of " }), _reg321))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 262), _emit_expr231(_expr319));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 263), _emit238(({ type: "string", value: ".values) {" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 265), _enter_scope243());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 266), _emit_let_node234(_pat318, _reg321));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 267), _enter_scope243());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 269), _emit238(({ type: "string", value: ";\n" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 270), _emit_expr231(_body320));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 271), _emit238(({ type: "string", value: "}" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 273), _leave_scope244());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 274), _leave_scope244());
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 275), runtime.opEq(_id287, ({ type: "string", value: "loop" }))))) {
|
|
const r_225 = _s285;
|
|
const r_226 = r_225.values[0] ?? { type: "null"};
|
|
const r_227 = r_225.values[1] ?? { type: "null"};
|
|
let _body322 = r_227;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 277), _emit238(({ type: "string", value: "while (true) {\n" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 278), _emit_expr231(_body322));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 279), _emit238(({ type: "string", value: "}" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 280), runtime.opEq(_id287, ({ type: "string", value: "if" }))))) {
|
|
const r_228 = _s285;
|
|
const r_229 = r_228.values[0] ?? { type: "null"};
|
|
const r_230 = r_228.values[1] ?? { type: "null"};
|
|
let _cond323 = r_230;
|
|
const r_231 = r_228.values[2] ?? { type: "null"};
|
|
let _truthy324 = r_231;
|
|
const r_232 = r_228.values[3] ?? { type: "null"};
|
|
let _falsy325 = r_232;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 282), _emit238(({ type: "string", value: "if (runtime.truthy(" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 283), _emit_expr231(_cond323));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 284), _emit238(({ type: "string", value: ")) {\n" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 285), _emit_expr231(_truthy324));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 286), _emit238(({ type: "string", value: "}" })));
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 287), runtime.opNe(_falsy325, ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 288), _emit238(({ type: "string", value: " else {\n" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 289), _emit_expr231(_falsy325));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 290), _emit238(({ type: "string", value: "}" })));
|
|
};
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 292), runtime.opEq(_id287, ({ type: "string", value: "return" }))))) {
|
|
const r_233 = _s285;
|
|
const r_234 = r_233.values[0] ?? { type: "null"};
|
|
const r_235 = r_233.values[1] ?? { type: "null"};
|
|
let _value326 = r_235;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 294), _emit238(({ type: "string", value: "runtime.popCall();\n" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 295), _emit238(({ type: "string", value: "return " })));
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 296), runtime.opNe(_value326, ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 297), _emit_expr231(_value326));
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 299), _emit238(({ type: "string", value: "{ type: \"null\" }" })));
|
|
};
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 301), runtime.opEq(_id287, ({ type: "string", value: "break" }))))) {
|
|
const r_236 = _s285;
|
|
const r_237 = r_236.values[0] ?? { type: "null"};
|
|
const r_238 = r_236.values[1] ?? { type: "null"};
|
|
let _value327 = r_238;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 303), _emit238(({ type: "string", value: "break" })));
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 304), runtime.opNe(_value327, ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 305), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented" })));
|
|
};
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 307), runtime.opEq(_id287, ({ type: "string", value: "call" }))))) {
|
|
const r_239 = _s285;
|
|
const r_240 = r_239.values[0] ?? { type: "null"};
|
|
const r_241 = r_239.values[1] ?? { type: "null"};
|
|
let _callee328 = r_241;
|
|
const r_242 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 309), _slice37(_s285, ({ type: "int", value: 2 })));
|
|
let _args329 = r_242;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 310), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 310), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(%, " }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 310), _rt_info236(_line284))))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 311), _emit_expr231(_callee328));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 312), _emit238(({ type: "string", value: "(" })));
|
|
const r_243 = ({ type: "bool", value: true });
|
|
let _first330 = r_243;
|
|
for (const r_244 of _args329.values) {;
|
|
let _arg331 = r_244;
|
|
if (runtime.truthy(runtime.opNot(_first330))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 317), _emit238(({ type: "string", value: ", " })));
|
|
};
|
|
(_first330 = ({ type: "bool", value: false }));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 321), _emit_expr231(_arg331));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 324), _emit238(({ type: "string", value: "))" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 325), runtime.opEq(_id287, ({ type: "string", value: "list" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 326), _emit_list_literal233((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 326), _slice37(_s285, ({ type: "int", value: 1 })))));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 327), runtime.opEq(_id287, ({ type: "string", value: "=" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 328), _emit_assign_expr237(_s285, _line284, ({ type: "string", value: "=" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 329), runtime.opEq(_id287, ({ type: "string", value: "+=" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 330), _emit_assign_expr237(_s285, _line284, ({ type: "string", value: "+" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 331), runtime.opEq(_id287, ({ type: "string", value: "-=" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 332), _emit_assign_expr237(_s285, _line284, ({ type: "string", value: "-" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 333), runtime.opEq(_id287, ({ type: "string", value: "or" }))))) {
|
|
const r_245 = _s285;
|
|
const r_246 = r_245.values[0] ?? { type: "null"};
|
|
const r_247 = r_245.values[1] ?? { type: "null"};
|
|
let _left332 = r_247;
|
|
const r_248 = r_245.values[2] ?? { type: "null"};
|
|
let _right333 = r_248;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 335), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 335), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(%" }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 335), _rt_info236(_line284)), _line284))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 336), _emit238(({ type: "string", value: ", { type: \"bool\", value: runtime.truthy(" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 337), _emit_expr231(_left332));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 338), _emit238(({ type: "string", value: ") || runtime.truthy(" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 339), _emit_expr231(_right333));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 340), _emit238(({ type: "string", value: ") })" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 341), runtime.opEq(_id287, ({ type: "string", value: "and" }))))) {
|
|
const r_249 = _s285;
|
|
const r_250 = r_249.values[0] ?? { type: "null"};
|
|
const r_251 = r_249.values[1] ?? { type: "null"};
|
|
let _left334 = r_251;
|
|
const r_252 = r_249.values[2] ?? { type: "null"};
|
|
let _right335 = r_252;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 343), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 343), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(%" }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 343), _rt_info236(_line284)), _line284))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 344), _emit238(({ type: "string", value: ", { type: \"bool\", value: runtime.truthy(" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 345), _emit_expr231(_left334));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 346), _emit238(({ type: "string", value: ") && runtime.truthy(" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 347), _emit_expr231(_right335));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 348), _emit238(({ type: "string", value: ") })" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 349), runtime.opEq(_id287, ({ type: "string", value: "==" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 350), _emit_binary_op235(_s285, ({ type: "string", value: "opEq" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 351), runtime.opEq(_id287, ({ type: "string", value: "!=" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 352), _emit_binary_op235(_s285, ({ type: "string", value: "opNe" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 353), runtime.opEq(_id287, ({ type: "string", value: "<" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 354), _emit_binary_op235(_s285, ({ type: "string", value: "opLt" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 355), runtime.opEq(_id287, ({ type: "string", value: ">" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 356), _emit_binary_op235(_s285, ({ type: "string", value: "opGt" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 357), runtime.opEq(_id287, ({ type: "string", value: "<=" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 358), _emit_binary_op235(_s285, ({ type: "string", value: "opLte" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 359), runtime.opEq(_id287, ({ type: "string", value: ">=" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 360), _emit_binary_op235(_s285, ({ type: "string", value: "opGte" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 361), runtime.opEq(_id287, ({ type: "string", value: "+" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 362), _emit_binary_op235(_s285, ({ type: "string", value: "opAdd" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 363), runtime.opEq(_id287, ({ type: "string", value: "-" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 364), _emit_binary_op235(_s285, ({ type: "string", value: "opSub" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 365), runtime.opEq(_id287, ({ type: "string", value: "not" }))))) {
|
|
const r_253 = _s285;
|
|
const r_254 = r_253.values[0] ?? { type: "null"};
|
|
const r_255 = r_253.values[1] ?? { type: "null"};
|
|
let _expr336 = r_255;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 367), _emit238(({ type: "string", value: "runtime.opNot(" })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 368), _emit_expr231(_expr336));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 369), _emit238(({ type: "string", value: ")" })));
|
|
} else {
|
|
const r_256 = _s285;
|
|
const r_257 = r_256.values[0] ?? { type: "null"};
|
|
let _callee337 = r_257;
|
|
const r_258 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 372), _slice37(_s285, ({ type: "int", value: 1 })));
|
|
let _args338 = r_258;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 373), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 373), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(%, " }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 373), _rt_info236(_line284)), _line284))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 374), _emit_expr231(_callee337));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 375), _emit238(({ type: "string", value: "(" })));
|
|
const r_259 = ({ type: "bool", value: true });
|
|
let _first339 = r_259;
|
|
for (const r_260 of _args338.values) {;
|
|
let _arg340 = r_260;
|
|
if (runtime.truthy(runtime.opNot(_first339))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 380), _emit238(({ type: "string", value: ", " })));
|
|
};
|
|
(_first339 = ({ type: "bool", value: false }));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 384), _emit_expr231(_arg340));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 387), _emit238(({ type: "string", value: "))" })));
|
|
}}}}}}}}}}}}}}}}}}}}}}}}};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _emit_list_literal233(_s341) {
|
|
runtime.pushCall("emit_list_literal", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 392), _emit238(({ type: "string", value: "({ type: \"list\", values: [" })));
|
|
const r_261 = ({ type: "bool", value: true });
|
|
let _first342 = r_261;
|
|
for (const r_262 of _s341.values) {;
|
|
let _e343 = r_262;
|
|
if (runtime.truthy(runtime.opNot(_first342))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 396), _emit238(({ type: "string", value: ", " })));
|
|
};
|
|
(_first342 = ({ type: "bool", value: false }));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 400), _emit_expr231(_e343));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 402), _emit238(({ type: "string", value: "] })" })));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _emit_let_node234(_pat344, _base_reg345) {
|
|
runtime.pushCall("emit_let_node", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_263 = _pat344;
|
|
const r_264 = r_263.values[0] ?? { type: "null"};
|
|
const r_265 = r_263.values[1] ?? { type: "null"};
|
|
let _pat_ty346 = r_265;
|
|
const r_266 = r_263.values[2] ?? { type: "null"};
|
|
let _line347 = r_266;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 407), runtime.opEq(_pat_ty346, ({ type: "string", value: "ident" }))))) {
|
|
const r_267 = _pat344;
|
|
const r_268 = r_267.values[0] ?? { type: "null"};
|
|
const r_269 = r_267.values[1] ?? { type: "null"};
|
|
const r_270 = r_267.values[2] ?? { type: "null"};
|
|
const r_271 = r_267.values[3] ?? { type: "null"};
|
|
let _ident348 = r_271;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 410), runtime.opEq(_ident348, ({ type: "string", value: "_" }))))) {
|
|
runtime.popCall();
|
|
return { type: "null" }};
|
|
const r_272 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 412), _define_let242(_ident348, _line347));
|
|
let _sym_id349 = r_272;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 413), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 413), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: ";\nlet _%% = r_%" }), _ident348, _sym_id349, _base_reg345))));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 414), runtime.opEq(_pat_ty346, ({ type: "string", value: "list" }))))) {
|
|
const r_273 = _pat344;
|
|
const r_274 = r_273.values[0] ?? { type: "null"};
|
|
const r_275 = r_273.values[1] ?? { type: "null"};
|
|
const r_276 = r_273.values[2] ?? { type: "null"};
|
|
const r_277 = r_273.values[3] ?? { type: "null"};
|
|
let _pats350 = r_277;
|
|
const r_278 = ({ type: "int", value: 0 });
|
|
let _i351 = r_278;
|
|
for (const r_279 of _pats350.values) {;
|
|
let _pat352 = r_279;
|
|
const r_280 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 419), _let_node_reg_count254());
|
|
let _reg353 = r_280;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 420), _let_node_reg_increment255());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 421), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 421), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: ";\nconst r_% = r_%.values[%] ?? { type: \"null\"}" }), _reg353, _base_reg345, _i351))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 425), _emit_let_node234(_pat352, _reg353));
|
|
(_i351 = runtime.opAdd(_i351, ({ type: "int", value: 1 })));
|
|
};
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 429), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "malformed pattern on line %" }), _line347));
|
|
}};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _emit_binary_op235(_s354, _id355) {
|
|
runtime.pushCall("emit_binary_op", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_281 = _s354;
|
|
const r_282 = r_281.values[0] ?? { type: "null"};
|
|
const r_283 = r_282.values[0] ?? { type: "null"};
|
|
const r_284 = r_282.values[1] ?? { type: "null"};
|
|
const r_285 = r_282.values[2] ?? { type: "null"};
|
|
let _line356 = r_285;
|
|
const r_286 = r_282.values[3] ?? { type: "null"};
|
|
const r_287 = r_281.values[1] ?? { type: "null"};
|
|
let _left357 = r_287;
|
|
const r_288 = r_281.values[2] ?? { type: "null"};
|
|
let _right358 = r_288;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 435), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 435), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(%, runtime.%(" }), (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 435), _rt_info236(_line356)), _id355))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 436), _emit_expr231(_left357));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 437), _emit238(({ type: "string", value: ", " })));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 438), _emit_expr231(_right358));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 439), _emit238(({ type: "string", value: "))" })));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _rt_info236(_line359) {
|
|
runtime.pushCall("rt_info", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 443), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.info(\"%\", %)" }), _filename250, _line359));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _emit_assign_expr237(_s360, _line361, _id362) {
|
|
runtime.pushCall("emit_assign_expr", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_289 = _s360;
|
|
const r_290 = r_289.values[0] ?? { type: "null"};
|
|
const r_291 = r_289.values[1] ?? { type: "null"};
|
|
const r_292 = r_291.values[0] ?? { type: "null"};
|
|
const r_293 = r_291.values[1] ?? { type: "null"};
|
|
let _target_type363 = r_293;
|
|
const r_294 = r_289.values[2] ?? { type: "null"};
|
|
let _expr364 = r_294;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 448), runtime.opNe(_target_type363, ({ type: "string", value: "ident" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 449), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "cannot assign to expression on line %" }), _line361));
|
|
};
|
|
const r_295 = _s360;
|
|
const r_296 = r_295.values[0] ?? { type: "null"};
|
|
const r_297 = r_295.values[1] ?? { type: "null"};
|
|
const r_298 = r_297.values[0] ?? { type: "null"};
|
|
const r_299 = r_297.values[1] ?? { type: "null"};
|
|
const r_300 = r_297.values[2] ?? { type: "null"};
|
|
const r_301 = r_297.values[3] ?? { type: "null"};
|
|
let _ident365 = r_301;
|
|
const r_302 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 452), _get_sym246(_ident365));
|
|
let _sym366 = r_302;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 453), runtime.opEq(_sym366, ({ type: "null" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 454), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "could not find symbol '%' on line %" }), _ident365, _line361));
|
|
};
|
|
const r_303 = _sym366;
|
|
const r_304 = r_303.values[0] ?? { type: "null"};
|
|
let _sym_id367 = r_304;
|
|
const r_305 = r_303.values[1] ?? { type: "null"};
|
|
let _sym_type368 = r_305;
|
|
const r_306 = r_303.values[2] ?? { type: "null"};
|
|
let _sym_ident369 = r_306;
|
|
const r_307 = r_303.values[3] ?? { type: "null"};
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 457), runtime.opEq(_sym_type368, ({ type: "string", value: "let" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 458), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 458), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(_%% = " }), _sym_ident369, _sym_id367))));
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 459), runtime.opEq(_id362, ({ type: "string", value: "=" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 460), _emit_expr231(_expr364));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 461), runtime.opEq(_id362, ({ type: "string", value: "+" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 462), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 462), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.opAdd(_%%, " }), _sym_ident369, _sym_id367))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 463), _emit_expr231(_expr364));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 464), _emit238(({ type: "string", value: ")" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 465), runtime.opEq(_id362, ({ type: "string", value: "-" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 466), _emit238((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 466), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.opSub(_%%, " }), _sym_ident369, _sym_id367))));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 467), _emit_expr231(_expr364));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 468), _emit238(({ type: "string", value: ")" })));
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 470), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented" })));
|
|
}}};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 472), _emit238(({ type: "string", value: ")" })));
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 474), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "cannot assign to symbol '%' on line %" }), _sym_ident369, _line361));
|
|
};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _emit238(_str370) {
|
|
runtime.pushCall("emit", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 479), ((...args) => runtime.builtinPush(...args))(_output249, _str370));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _define_builtin239(_ident371, _builtin_id372) {
|
|
runtime.pushCall("define_builtin", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_308 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 483), _sym_id_count252());
|
|
let _sym_id373 = r_308;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 484), _sym_id_increment253());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 486), _define_sym245(_ident371, ({ type: "list", values: [_sym_id373, ({ type: "string", value: "builtin" }), _builtin_id372] })));
|
|
runtime.popCall();
|
|
return _sym_id373;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _define_fn240(_ident374, _line375) {
|
|
runtime.pushCall("define_fn", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_309 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 491), _sym_id_count252());
|
|
let _sym_id376 = r_309;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 492), _sym_id_increment253());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 494), _define_sym245(_ident374, ({ type: "list", values: [_sym_id376, ({ type: "string", value: "fn" }), _ident374, _line375] })));
|
|
runtime.popCall();
|
|
return _sym_id376;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _define_param241(_ident377, _line378) {
|
|
runtime.pushCall("define_param", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_310 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 499), _sym_id_count252());
|
|
let _sym_id379 = r_310;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 500), _sym_id_increment253());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 502), _define_sym245(_ident377, ({ type: "list", values: [_sym_id379, ({ type: "string", value: "param" }), _ident377, _line378] })));
|
|
runtime.popCall();
|
|
return _sym_id379;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _define_let242(_ident380, _line381) {
|
|
runtime.pushCall("define_let", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_311 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 507), _sym_id_count252());
|
|
let _sym_id382 = r_311;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 508), _sym_id_increment253());
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 510), _define_sym245(_ident380, ({ type: "list", values: [_sym_id382, ({ type: "string", value: "let" }), _ident380, _line381] })));
|
|
runtime.popCall();
|
|
return _sym_id382;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _enter_scope243() {
|
|
runtime.pushCall("enter_scope", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_312 = _syms251;
|
|
const r_313 = r_312.values[0] ?? { type: "null"};
|
|
let _enter_scope383 = r_313;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 517), _enter_scope383());
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _leave_scope244() {
|
|
runtime.pushCall("leave_scope", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_314 = _syms251;
|
|
const r_315 = r_314.values[0] ?? { type: "null"};
|
|
const r_316 = r_314.values[1] ?? { type: "null"};
|
|
let _leave_scope384 = r_316;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 521), _leave_scope384());
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _define_sym245(_ident385, _sym386) {
|
|
runtime.pushCall("define_sym", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_317 = _syms251;
|
|
const r_318 = r_317.values[0] ?? { type: "null"};
|
|
const r_319 = r_317.values[1] ?? { type: "null"};
|
|
const r_320 = r_317.values[2] ?? { type: "null"};
|
|
let _define_sym387 = r_320;
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 525), _define_sym387(_ident385, _sym386));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _get_sym246(_ident388) {
|
|
runtime.pushCall("get_sym", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_321 = _syms251;
|
|
const r_322 = r_321.values[0] ?? { type: "null"};
|
|
const r_323 = r_321.values[1] ?? { type: "null"};
|
|
const r_324 = r_321.values[2] ?? { type: "null"};
|
|
const r_325 = r_321.values[3] ?? { type: "null"};
|
|
let _get_sym389 = r_325;
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 529), _get_sym389(_ident388));
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _get_current_map247() {
|
|
runtime.pushCall("get_current_map", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_326 = _syms251;
|
|
const r_327 = r_326.values[0] ?? { type: "null"};
|
|
const r_328 = r_326.values[1] ?? { type: "null"};
|
|
const r_329 = r_326.values[2] ?? { type: "null"};
|
|
const r_330 = r_326.values[3] ?? { type: "null"};
|
|
const r_331 = r_326.values[4] ?? { type: "null"};
|
|
let _get_current_map390 = r_331;
|
|
runtime.popCall();
|
|
return (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 533), _get_current_map390());
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _print_syms248() {
|
|
runtime.pushCall("print_syms", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_332 = _syms251;
|
|
const r_333 = r_332.values[0] ?? { type: "null"};
|
|
const r_334 = r_332.values[1] ?? { type: "null"};
|
|
const r_335 = r_332.values[2] ?? { type: "null"};
|
|
const r_336 = r_332.values[3] ?? { type: "null"};
|
|
const r_337 = r_332.values[4] ?? { type: "null"};
|
|
const r_338 = r_332.values[5] ?? { type: "null"};
|
|
let _print_syms391 = r_338;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 537), _print_syms391());
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
runtime.popCall();
|
|
return ({ type: "list", values: [_generate228] });
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
function _string_escape181(_str392) {
|
|
runtime.pushCall("string_escape", "/home/simone/Workspace/phi-lang/compiler/emit_js.phi");
|
|
const r_339 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 544), ((...args) => runtime.builtinLen(...args))(_str392));
|
|
let _str_len393 = r_339;
|
|
const r_340 = ({ type: "int", value: 0 });
|
|
let _i394 = r_340;
|
|
const r_341 = ({ type: "string", value: "" });
|
|
let _result395 = r_341;
|
|
while (true) {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 548), runtime.opGte(_i394, _str_len393)))) {
|
|
break};
|
|
const r_342 = (runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 549), ((...args) => runtime.builtinAt(...args))(_str392, _i394));
|
|
let _ch396 = r_342;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 550), runtime.opEq(_ch396, ({ type: "string", value: "\\" }))))) {
|
|
(_result395 = runtime.opAdd(_result395, ({ type: "string", value: "\\\\" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 552), runtime.opEq(_ch396, ({ type: "string", value: "\"" }))))) {
|
|
(_result395 = runtime.opAdd(_result395, ({ type: "string", value: "\\\"" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 554), runtime.opEq(_ch396, ({ type: "string", value: "\t" }))))) {
|
|
(_result395 = runtime.opAdd(_result395, ({ type: "string", value: "\\t" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 556), runtime.opEq(_ch396, ({ type: "string", value: "\r" }))))) {
|
|
(_result395 = runtime.opAdd(_result395, ({ type: "string", value: "\\r" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 558), runtime.opEq(_ch396, ({ type: "string", value: "\n" }))))) {
|
|
(_result395 = runtime.opAdd(_result395, ({ type: "string", value: "\\n" })));
|
|
} else {
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compiler/emit_js.phi", 560), runtime.opEq(_ch396, ({ type: "string", value: "\n" }))))) {
|
|
(_result395 = runtime.opAdd(_result395, ({ type: "string", value: "\\0" })));
|
|
} else {
|
|
(_result395 = runtime.opAdd(_result395, _ch396));
|
|
}}}}}};
|
|
(_i394 = runtime.opAdd(_i394, ({ type: "int", value: 1 })));
|
|
};
|
|
runtime.popCall();
|
|
return _result395;
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
|
|
// === resuming file /home/simone/Workspace/phi-lang/compile.phi ===
|
|
runtime.setFile("/home/simone/Workspace/phi-lang/compile.phi");
|
|
function _print_expr18(_expr397, _depth398) {
|
|
runtime.pushCall("print_expr", "/home/simone/Workspace/phi-lang/compile.phi");
|
|
const r_343 = _expr397;
|
|
const r_344 = r_343.values[0] ?? { type: "null"};
|
|
let _ty399 = r_344;
|
|
const r_345 = r_343.values[1] ?? { type: "null"};
|
|
let _line400 = r_345;
|
|
const r_346 = r_343.values[2] ?? { type: "null"};
|
|
let _value401 = r_346;
|
|
if (runtime.truthy((runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 7), runtime.opEq(_ty399, ({ type: "string", value: "list" }))))) {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 8), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%(% %" }), (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 8), _indent40(_depth398)), _ty399, _line400));
|
|
for (const r_347 of _value401.values) {;
|
|
let _e402 = r_347;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 10), _print_expr18(_e402, (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 10), runtime.opAdd(_depth398, ({ type: "int", value: 1 })))));
|
|
};
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 12), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%)" }), (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 12), _indent40(_depth398))));
|
|
} else {
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 14), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%%" }), (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 14), _indent40(_depth398)), _expr397));
|
|
};
|
|
;
|
|
runtime.popCall();
|
|
return { type: "null" };
|
|
};
|
|
const r_348 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 18), ((...args) => runtime.builtinGetArgs(...args))());
|
|
const r_349 = r_348.values[0] ?? { type: "null"};
|
|
let _input_filename_rel403 = r_349;
|
|
const r_350 = r_348.values[1] ?? { type: "null"};
|
|
let _output_filename_rel404 = r_350;
|
|
const r_351 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 20), ((...args) => runtime.builtinFsResolve(...args))((runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 20), ((...args) => runtime.builtinFsCwd(...args))()), _input_filename_rel403));
|
|
let _input_filename405 = r_351;
|
|
const r_352 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 21), ((...args) => runtime.builtinFsResolve(...args))((runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 21), ((...args) => runtime.builtinFsCwd(...args))()), _output_filename_rel404));
|
|
let _output_filename406 = r_352;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 23), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "compiling '%'..." }), _input_filename405));
|
|
const r_353 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 24), ((...args) => runtime.builtinReadTextFile(...args))(_input_filename405));
|
|
let _text407 = r_353;
|
|
const r_354 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 26), _tokenize107(_text407));
|
|
let _tokens408 = r_354;
|
|
const r_355 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 27), _Parser106(_tokens408));
|
|
let _parser409 = r_355;
|
|
const r_356 = _parser409;
|
|
const r_357 = r_356.values[0] ?? { type: "null"};
|
|
let _parse410 = r_357;
|
|
const r_358 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 29), _parse410());
|
|
let _ast411 = r_358;
|
|
const r_359 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 30), _JsEmitter180(_ast411, _input_filename405));
|
|
let _emitter412 = r_359;
|
|
const r_360 = _emitter412;
|
|
const r_361 = r_360.values[0] ?? { type: "null"};
|
|
let _emit413 = r_361;
|
|
const r_362 = (runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 32), _emit413());
|
|
let _js_code414 = r_362;
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 37), ((...args) => runtime.builtinWriteTextFile(...args))(_output_filename406, _js_code414));
|
|
(runtime.info("/home/simone/Workspace/phi-lang/compile.phi", 38), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "writing '%'" }), _output_filename406));
|