XFRP type checking and type environments.
Types
XfrpFuncType = tuple[argTypes: seq[XfrpType], retType: XfrpType]
- A function type. Source Edit
XfrpTypeEnv = object fenv: XfrpFuncTypeEnv venv: XfrpVarTypeEnv openv: XfrpOpTypeEnv
- A type environment. Source Edit
Procs
proc initXfrpTypeEnv(): XfrpTypeEnv {...}{.raises: [], tags: [].}
- Construct new type environment. Source Edit
proc addFunc(typeEnv: var XfrpTypeEnv; id: XfrpFuncId; argTypes: seq[XfrpType]; retType: XfrpType) {...}{.raises: [], tags: [].}
- Add a function type into the environment. Source Edit
proc addVar(typeEnv: var XfrpTypeEnv; id: XfrpId; ty: XfrpType) {...}{.raises: [], tags: [].}
- Add a variable type into the environment. Source Edit
proc addVar(typeEnv: var XfrpTypeEnv; idAndTy: XfrpIdAndType) {...}{.raises: [], tags: [].}
- Add a variable type into the environment. Source Edit
proc addOp(typeEnv: var XfrpTypeEnv; id: XfrpOpId; argTypes: seq[XfrpType]; retType: XfrpType) {...}{.raises: [], tags: [].}
- Add an operator type into the environment. Note: operators can be overloaded. Source Edit
proc getFuncType(typeEnv: XfrpTypeEnv; id: XfrpId; definedIn: XfrpModuleId; materialTbl: XfrpMaterials): XfrpFuncType {...}{. raises: [KeyError, XfrpReferenceError], tags: [].}
- Get a function type by ID and materials. Source Edit
proc getFuncType(typeEnv: XfrpTypeEnv; id: XfrpFuncId): XfrpFuncType {...}{. raises: [KeyError], tags: [].}
- Get a function type by function ID. Source Edit
proc getVarType(typeEnv: XfrpTypeEnv; id: XfrpId): XfrpType {...}{. raises: [KeyError], tags: [].}
- Get a variable type by ID. Source Edit
proc getOpType(typeEnv: XfrpTypeEnv; op: XfrpOperator; argTypes: seq[XfrpType]; definedIn: XfrpModuleId; materialTbl: XfrpMaterials): XfrpType {...}{. raises: [KeyError, XfrpReferenceError], tags: [].}
- Get an operator type by an operator, argument types and materials. Source Edit
proc `$`(typeEnv: XfrpTypeEnv): string {...}{.raises: [], tags: [].}
- Source Edit
proc xfrpTypeOf(env: XfrpTypeEnv; lit: WithCodeInfo[XfrpLiteral]): XfrpType {...}{. raises: [], tags: [].}
- Source Edit
proc xfrpTypeOf(env: XfrpTypeEnv; exp: WithCodeInfo[XfrpExpr]; definedIn: XfrpModuleId; materialTbl: XfrpMaterials): XfrpType {...}{. raises: [XfrpTypeError, KeyError, KeyError, XfrpReferenceError], tags: [].}
- Get a type of given expression. Source Edit
proc makeTypeEnvironment(materialTbl: XfrpMaterials; opEnv: XfrpOpEnv; funcEnv: XfrpFuncEnv; nodeEnv: XfrpNodeEnv): XfrpTypeEnv {...}{. raises: [KeyError, XfrpTypeError, XfrpReferenceError], tags: [].}
- Construct new type environment. Source Edit