From c8aa3e7c1c1c1fba01a03425a1920ce85569dd95 Mon Sep 17 00:00:00 2001 From: sfja Date: Mon, 16 Mar 2026 22:32:29 +0100 Subject: [PATCH] resolmap into syms --- src/front/check.ts | 12 ++++++------ src/front/resolve.ts | 6 +++--- src/main.ts | 6 +++--- src/middle.ts | 6 +++--- tests/array.ethlang | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/front/check.ts b/src/front/check.ts index b0cdb2b..9019811 100644 --- a/src/front/check.ts +++ b/src/front/check.ts @@ -2,17 +2,17 @@ import * as ast from "../ast.ts"; import { FileReporter, Loc } from "../diagnostics.ts"; import { Ty } from "../ty.ts"; import { builtins } from "./builtins.ts"; -import { ResolveMap } from "./resolve.ts"; +import { Syms } from "./resolve.ts"; export class Tys { private nodeTys = new Map(); private checker: Checker; constructor( - private resols: ResolveMap, + private syms: Syms, private reporter: FileReporter, ) { - this.checker = new Checker(this, this.resols, this.reporter); + this.checker = new Checker(this, this.syms, this.reporter); } expr(node: ast.Node): Ty { @@ -28,7 +28,7 @@ export class Tys { class Checker { constructor( private tys: Tys, - private resols: ResolveMap, + private syms: Syms, private reporter: FileReporter, ) {} @@ -40,7 +40,7 @@ class Checker { } if (node.is("Param")) { - const sym = this.resols.get(node); + const sym = this.syms.get(node); if (sym.tag === "Let") { const exprTy = this.tys.expr(sym.stmt.kind.expr); @@ -66,7 +66,7 @@ class Checker { } if (node.is("IdentExpr")) { - const sym = this.resols.get(node); + const sym = this.syms.get(node); if (sym.tag === "Fn") { return this.tys.expr(sym.stmt); } diff --git a/src/front/resolve.ts b/src/front/resolve.ts index e1a2939..dad8c15 100644 --- a/src/front/resolve.ts +++ b/src/front/resolve.ts @@ -2,7 +2,7 @@ import * as ast from "../ast.ts"; import { FileReporter } from "../diagnostics.ts"; import { builtins } from "./builtins.ts"; -export class ResolveMap { +export class Syms { constructor( private resols: Map, ) {} @@ -35,7 +35,7 @@ export type Sym = export function resolve( file: ast.Node, reporter: FileReporter, -): ResolveMap { +): Syms { let syms = ResolverSyms.root(); const resols = new Map(); @@ -88,7 +88,7 @@ export function resolve( }, }); - return new ResolveMap(resols); + return new Syms(resols); } class ResolverSyms { diff --git a/src/main.ts b/src/main.ts index 002bdee..918627a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,8 +12,8 @@ const text = await Deno.readTextFile(filename); const fileRep = reporter.ofFile({ filename, text }); const fileAst = front.parse(text, fileRep); -const resols = front.resolve(fileAst, fileRep); -const tys = new front.Tys(resols, fileRep); +const syms = front.resolve(fileAst, fileRep); +const tys = new front.Tys(syms, fileRep); let mainFn: ast.NodeWithKind<"FnStmt"> | null = null; @@ -36,7 +36,7 @@ if (!mainFn) { Deno.exit(1); } -const m = new middle.MiddleLowerer(resols, tys); +const m = new middle.MiddleLowerer(syms, tys); const mainMiddleFn = m.lowerFn(mainFn); if (!Deno.args.includes("--test")) { diff --git a/src/middle.ts b/src/middle.ts index 0d7034b..ea9dbe2 100644 --- a/src/middle.ts +++ b/src/middle.ts @@ -1,5 +1,5 @@ import * as ast from "./ast.ts"; -import { ResolveMap, Tys } from "./front/mod.ts"; +import { Syms, Tys } from "./front/mod.ts"; import { Ty } from "./ty.ts"; import { BasicBlock, BinaryOp, Fn, Inst, InstKind } from "./mir.ts"; @@ -7,7 +7,7 @@ export class MiddleLowerer { private fns = new Map(); constructor( - private resols: ResolveMap, + private resols: Syms, private tys: Tys, ) {} @@ -28,7 +28,7 @@ class FnLowerer { constructor( private lowerer: MiddleLowerer, - private resols: ResolveMap, + private resols: Syms, private tys: Tys, private stmt: ast.FnStmt, ) {} diff --git a/tests/array.ethlang b/tests/array.ethlang index ad59c4a..9f5c624 100644 --- a/tests/array.ethlang +++ b/tests/array.ethlang @@ -1,12 +1,12 @@ fn main() { - let array: [int; 3] = [1, 2, false]; + let array: [int; 3] = [1, 2, 3]; - // let a = 4; - // let b = a; - // array[0] = a; - // print_int(array[0]); + let a = 4; + let b = a; + array[0] = a; + print_int(array[0]); // let elem: int = array[0]; // // e xpect: 1