import { Type } from "./type"; import { MultiType } from "./multiType"; import { IType } from "./itype"; import { Maybe } from "../util/maybe"; const INTEGER = new Type("integer", 0); const REAL = new Type("real", 1); const STRING = new Type("text", 2); const BOOLEAN =new Type("boolean", 3); const VOID = new Type("void", 4); const UNDEFINED = new Type("undefined", 5); const ALL = new MultiType([INTEGER, REAL, STRING, BOOLEAN]); interface TypeMap { [key: string]: IType } export const Types = Object.freeze({ INTEGER: INTEGER, REAL: REAL, STRING: STRING, BOOLEAN: BOOLEAN, VOID: VOID, UNDEFINED: UNDEFINED, ALL: ALL }); export function fromOrdToType (ord:number): Maybe { const typeMap = Types as TypeMap; for(let t in typeMap) { if(typeMap[t].ord! === ord){ return Maybe.some(typeMap[t]); } } return Maybe.none(); }