generate more code

This commit is contained in:
nora 2023-07-26 20:50:48 +02:00
parent ccd8008731
commit 42bc96dbce
7 changed files with 306 additions and 51 deletions

View file

@ -155,8 +155,8 @@ const BINARY_KIND_PREC_CLASS = new Map<BinaryKind, number>([
export function binaryExprPrecedenceClass(k: BinaryKind): number {
const cls = BINARY_KIND_PREC_CLASS.get(k);
if (!cls) {
throw new Error(`Invalid binary kind: ${k}`);
if (cls === undefined) {
throw new Error(`Invalid binary kind: '${k}'`);
}
return cls;
}
@ -209,15 +209,27 @@ export type Resolution =
}
| {
kind: "builtin";
name: string;
name: BuiltinName;
};
export const BUILTINS = [
"print",
"String",
"Int",
"Bool",
"true",
"false",
] as const;
export type BuiltinName = (typeof BUILTINS)[number];
export type TyString = {
kind: "string";
};
export type TyInt = {
kind: "int";
signed: boolean;
};
export type TyBool = {
@ -259,7 +271,7 @@ export function tyIsUnit(ty: Ty): ty is TyUnit {
export const TY_UNIT: Ty = { kind: "tuple", elems: [] };
export const TY_STRING: Ty = { kind: "string" };
export const TY_BOOL: Ty = { kind: "bool" };
export const TY_INT: Ty = { kind: "int" };
export const TY_INT: Ty = { kind: "int", signed: false };
// folders