mirror of
https://git.sfja.dk/Mikkel/slige.git
synced 2025-01-18 18:16:31 +00:00
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.scoutFnHeaders(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.lowerStmt(stmt);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ all: build_dir $(OUT)
|
||||
|
||||
$(OUT): $(CXX_OBJECTS)
|
||||
$(CXX) -o $@ $(CXX_FLAGS) $^
|
||||
git rev-parse HEAD > build/rev
|
||||
|
||||
build_dir:
|
||||
mkdir -p build/
|
||||
|
@ -17,6 +17,7 @@ const filepath = flags._[0] as string;
|
||||
const text = await Deno.readTextFile(filepath);
|
||||
|
||||
const runtime = new Runtime(13370);
|
||||
await runtime.start();
|
||||
|
||||
async function compileProgram(filepath: string) {
|
||||
const result = await compiler.compileWithDebug(filepath);
|
||||
|
@ -1,12 +1,49 @@
|
||||
export class Runtime {
|
||||
private runtimeProcess?: Deno.ChildProcess;
|
||||
|
||||
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> {
|
||||
return new RuntimeConnection(
|
||||
await Deno.connect({
|
||||
port: this.port,
|
||||
}),
|
||||
);
|
||||
return await new Promise((resolve) => {
|
||||
setTimeout(async () => {
|
||||
resolve(
|
||||
new RuntimeConnection(
|
||||
await Deno.connect({
|
||||
port: this.port,
|
||||
}),
|
||||
),
|
||||
);
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user