properly merge ids commit
This commit is contained in:
parent
7389692993
commit
81d8e32a04
@ -1,15 +1,16 @@
|
||||
import * as ast from "../ast/mod.ts";
|
||||
import { Ctx, File } from "../ctx.ts";
|
||||
import { Span } from "../diagnostics.ts";
|
||||
import { AstId, IdMap } from "../ids.ts";
|
||||
import { Resols } from "../resolve/resolver.ts";
|
||||
import { tyToString } from "../ty/to_string.ts";
|
||||
import { Ty } from "../ty/ty.ts";
|
||||
import { exhausted, Res, todo } from "../util.ts";
|
||||
|
||||
export class Checker {
|
||||
private itemTys = new Map<number, Ty>();
|
||||
private exprTys = new Map<number, Ty>();
|
||||
private tyTys = new Map<number, Ty>();
|
||||
private itemTys = new IdMap<AstId, Ty>();
|
||||
private exprTys = new IdMap<AstId, Ty>();
|
||||
private tyTys = new IdMap<AstId, Ty>();
|
||||
|
||||
private currentFile: File;
|
||||
|
||||
|
@ -6,7 +6,8 @@ import {
|
||||
Report,
|
||||
Span,
|
||||
} from "./diagnostics.ts";
|
||||
import { File, IdentId, IdMap, Ids } from "./ids.ts";
|
||||
import { DefId, File, IdentId, IdMap, Ids } from "./ids.ts";
|
||||
export { type File } from "./ids.ts";
|
||||
|
||||
export class Ctx {
|
||||
private fileIds = new Ids<File>();
|
||||
@ -105,10 +106,6 @@ export class Ctx {
|
||||
|
||||
//
|
||||
|
||||
private defIds = new Ids<DefId>();
|
||||
|
||||
//
|
||||
|
||||
public report(rep: Report) {
|
||||
this.reports.push(rep);
|
||||
this.reportImmediately(rep);
|
||||
|
@ -1,8 +1,7 @@
|
||||
import * as path from "jsr:@std/path";
|
||||
import { Parser } from "./parse/parser.ts";
|
||||
import * as ast from "./ast/mod.ts";
|
||||
import { Ctx } from "./ctx.ts";
|
||||
import { File } from "./ctx.ts";
|
||||
import { Ctx, File } from "./ctx.ts";
|
||||
import { Resolver } from "./resolve/resolver.ts";
|
||||
import { Checker } from "./check/checker.ts";
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Ctx, File } from "../ctx.ts";
|
||||
import { Ctx } from "../ctx.ts";
|
||||
import { Pos, Span } from "../diagnostics.ts";
|
||||
import { File } from "../ids.ts";
|
||||
import { ControlFlow, range } from "../util.ts";
|
||||
import { Token, TokenIter } from "./token.ts";
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IdentId } from "../ctx.ts";
|
||||
import { Span } from "../diagnostics.ts";
|
||||
import { IdentId } from "../ids.ts";
|
||||
|
||||
export type Token = {
|
||||
type: string;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as ast from "../ast/mod.ts";
|
||||
import { IdentId, idKey, Key } from "../ctx.ts";
|
||||
import { IdentId, IdMap } from "../ids.ts";
|
||||
import { Res } from "../util.ts";
|
||||
|
||||
export interface Syms {
|
||||
@ -30,17 +30,17 @@ export type Redef = {
|
||||
};
|
||||
|
||||
export class SymsOneNsTab {
|
||||
private defs = new Map<Key<IdentId>, Resolve>();
|
||||
private defs = new IdMap<IdentId, Resolve>();
|
||||
|
||||
public get(ident: ast.Ident): Resolve | undefined {
|
||||
return this.defs.get(idKey(ident.id))!;
|
||||
return this.defs.get(ident.id)!;
|
||||
}
|
||||
|
||||
public def(ident: ast.Ident, kind: ResolveKind): Res<void, Redef> {
|
||||
if (this.defs.has(idKey(ident.id))) {
|
||||
return Res.Err({ ident: this.defs.get(idKey(ident.id))!.ident });
|
||||
if (this.defs.has(ident.id)) {
|
||||
return Res.Err({ ident: this.defs.get(ident.id)!.ident });
|
||||
}
|
||||
this.defs.set(idKey(ident.id), { ident, kind });
|
||||
this.defs.set(ident.id, { ident, kind });
|
||||
return Res.Ok(undefined);
|
||||
}
|
||||
}
|
||||
@ -127,4 +127,3 @@ export class LocalSyms implements Syms {
|
||||
return this.syms.defTy(ident, kind);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import * as ast from "../ast/mod.ts";
|
||||
import { Ctx, File } from "../ctx.ts";
|
||||
import { AstId, IdMap } from "../ids.ts";
|
||||
import { exhausted, todo } from "../util.ts";
|
||||
import {
|
||||
FnSyms,
|
||||
@ -12,10 +13,10 @@ import {
|
||||
|
||||
export class Resols {
|
||||
public constructor(
|
||||
private exprResols: Map<number, Resolve>,
|
||||
private exprResols: IdMap<AstId, Resolve>,
|
||||
) {}
|
||||
|
||||
public exprRes(id: number): Resolve {
|
||||
public exprRes(id: AstId): Resolve {
|
||||
if (!this.exprResols.has(id)) {
|
||||
throw new Error();
|
||||
}
|
||||
@ -28,7 +29,7 @@ export class Resolver implements ast.Visitor {
|
||||
private rootSyms = new RootSyms();
|
||||
private syms: Syms = this.rootSyms;
|
||||
|
||||
private exprResols = new Map<number, Resolve>();
|
||||
private exprResols = new IdMap<AstId, Resolve>();
|
||||
|
||||
public constructor(
|
||||
private ctx: Ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user