/**** **** Defintions for typechk.c. ****/ #ifndef __TYPE__ #define __TYPE__ #include "type.h" typedef struct dimnodetype { nodep simpletype; struct dimnodetype* next; }dimnodetype; #define typeIncluded /* * Some handy macros for the basic type structs. */ #define IntType LookupString("integer")->Type #define RealType LookupString("real")->Type #define CharType LookupString("char")->Type #define StringObj LookupString("string")->Type #define BoolType LookupString("boolean")->Type #define isInt(t) (streq(t->components.atom.val.text, "integer")) #define isReal(t) (streq(t->components.atom.val.text, "real")) #define isChar(t) (streq(t->components.atom.val.text, "char")) #define isString(t) (streq(t->components.atom.val.text, "string")) #define isBool(t) ((streq(t->components.atom.val.text, "boolean")) || \ (streq(t->components.atom.val.text, "true")) || \ (streq(t->components.atom.val.text, "false"))) #define isNil(t) ((streq(t->components.atom.val.text, "nil")) || \ (streq(t->components.atom.val.text, "empty")) || \ (streq(t->components.atom.val.text, "none"))) /* * The representation of a type is a parse tree. See lecture notes for * discussion of this choice of type representation. */ /* typedef nodep TypeStruct; */ /* * Visible type checking functions. */ /*-*********************************************************************** Function: typechk() Purpose: typechecker. Arguments: t - ptr to the chunk of parse tree to type check s - ptr to an additional temporary symbol table. May be null. Returns: The type of the tree passed in (if successful), NULL (if not). ***********************************************************************-*/ TypeStruct typechk(nodep t, Symtab *s); TypeStruct chkAssmnt(); TypeStruct chkArithOp(); TypeStruct chkBoolOp(); TypeStruct chkRelOp(); TypeStruct chkEqOp(); TypeStruct chkAlmostEqOp(); TypeStruct chkProcCall(); TypeStruct chkSetOp(TypeStruct t1, TypeStruct t2); TypeStruct chkIndexOp(); TypeStruct chkUnopBoolOp(TypeStruct t1); TypeStruct chkArithSetOp(TypeStruct t1, TypeStruct t2); bool compat(); bool compat1(); void chkObjPartsDecl(nodep, SymtabEntry*); bool isConstAtom(nodep t); char* qidToString(nodep qid); void chkOpPartsDecl(nodep, SymtabEntry*, unsigned int); TypeStruct BuildOpaqueType(); TypeStruct BuildNameTypePairType(nodep t); TypeStruct BuildLiteralType(nodep t); #endif