make web start runtime
This commit is contained in:
parent
c9e4a419af
commit
7c83c7296d
@ -432,10 +432,6 @@ export class Lowerer {
|
|||||||
this.locals = new LocalLeaf(this.locals);
|
this.locals = new LocalLeaf(this.locals);
|
||||||
this.scoutFnHeaders(expr.kind.stmts);
|
this.scoutFnHeaders(expr.kind.stmts);
|
||||||
for (const stmt of expr.kind.stmts) {
|
for (const stmt of expr.kind.stmts) {
|
||||||
console.log(`sm for stmt ${stmt.kind.type} ${stmt.pos.line}`);
|
|
||||||
if (stmt.kind.type === "assign") {
|
|
||||||
console.log(` - ${stmtToString(stmt)}`);
|
|
||||||
}
|
|
||||||
this.addSourceMap(stmt.pos);
|
this.addSourceMap(stmt.pos);
|
||||||
this.lowerStmt(stmt);
|
this.lowerStmt(stmt);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ all: build_dir $(OUT)
|
|||||||
|
|
||||||
$(OUT): $(CXX_OBJECTS)
|
$(OUT): $(CXX_OBJECTS)
|
||||||
$(CXX) -o $@ $(CXX_FLAGS) $^
|
$(CXX) -o $@ $(CXX_FLAGS) $^
|
||||||
|
git rev-parse HEAD > build/rev
|
||||||
|
|
||||||
build_dir:
|
build_dir:
|
||||||
mkdir -p build/
|
mkdir -p build/
|
||||||
|
@ -17,6 +17,7 @@ const filepath = flags._[0] as string;
|
|||||||
const text = await Deno.readTextFile(filepath);
|
const text = await Deno.readTextFile(filepath);
|
||||||
|
|
||||||
const runtime = new Runtime(13370);
|
const runtime = new Runtime(13370);
|
||||||
|
await runtime.start();
|
||||||
|
|
||||||
async function compileProgram(filepath: string) {
|
async function compileProgram(filepath: string) {
|
||||||
const result = await compiler.compileWithDebug(filepath);
|
const result = await compiler.compileWithDebug(filepath);
|
||||||
|
@ -1,12 +1,49 @@
|
|||||||
export class Runtime {
|
export class Runtime {
|
||||||
|
private runtimeProcess?: Deno.ChildProcess;
|
||||||
|
|
||||||
constructor(private port: number) {}
|
constructor(private port: number) {}
|
||||||
|
|
||||||
|
async checkRuntimeRev() {
|
||||||
|
const currentRev = new TextDecoder().decode(
|
||||||
|
await new Deno.Command("git", { args: ["rev-parse", "HEAD"] })
|
||||||
|
.output()
|
||||||
|
.then((output) => output.stdout),
|
||||||
|
).trim();
|
||||||
|
const runtimeRev = (await Deno.readTextFile("../runtime/build/rev"))
|
||||||
|
.trim();
|
||||||
|
if (runtimeRev !== currentRev) {
|
||||||
|
console.error(
|
||||||
|
"runtime out-of-date; run 'make' inside runtime/ folder",
|
||||||
|
);
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async start() {
|
||||||
|
await this.checkRuntimeRev();
|
||||||
|
this.runtimeProcess = new Deno.Command("../runtime/build/sliger", {
|
||||||
|
args: [],
|
||||||
|
stdout: "piped",
|
||||||
|
}).spawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
this.runtimeProcess?.kill();
|
||||||
|
this.runtimeProcess = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
async connect(): Promise<RuntimeConnection> {
|
async connect(): Promise<RuntimeConnection> {
|
||||||
return new RuntimeConnection(
|
return await new Promise((resolve) => {
|
||||||
await Deno.connect({
|
setTimeout(async () => {
|
||||||
port: this.port,
|
resolve(
|
||||||
}),
|
new RuntimeConnection(
|
||||||
);
|
await Deno.connect({
|
||||||
|
port: this.port,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user