open Support.Pervasive open Support.Error open Prim type param = string * typ and decl = VarD of typ * string * exp (* type, name, initializing expression *) | VarFwdD of typ * string (* type, name *) | FunD of string (* function name *) * param list (* parameters *) * typ (* return type *) * stmt (* body *) | ExternScopeD of string * decl list | FunFwdD of string (* function name *) * param list (* parameters *) * typ (* return type *) | ExternFunFwdD of string (* language: C, C++ *) * string (* function name *) * param list (* parameters *) * typ (* return type *) | ClassFwdD of string | ClassD of string (* class name *) * string list (* base classes *) * class_mem list | MethodD of string (* class name *) * string (* method name *) * param list (* parameters *) * typ (* return type *) * stmt (* body *) | IncludeD of string (* file name *) | LocalD of decl list (* local declarations, hide in unnamed namespace *) and class_mem = Field of string * typ | Constructor of int (* ID number *) * param list (* parameters *) * (string * exp list) list (* member inits *) * stmt (* body *) | Destructor of stmt | Method of string (* name *) * bool (* virtual? *) * param list (* parameters *) * typ (* return type *) * stmt (* body *) | MethodFwd of string (* name *) * bool (* virtual? *) * param list (* parameters *) * typ (* return type *) | Enum of string * string list and stmt = VarS of typ * string * exp (* type, name, initializing expression *) | ExprS of exp | ReturnS of exp option | IfS of exp * stmt * stmt | WhileS of exp * stmt | CompoundS of stmt list | SwitchS of exp * stmt | CaseS of exp * stmt | DefaultS of stmt | BreakS | PureS (* as in pure virtual method *) and exp = NullE (* null pointer *) | IntE of int | FloatE of float | DoubleE of float | BoolE of bool | StringE of string | CharE of char | VarE of string | FunE of param list (* parameters *) * typ (* return type *) * (string * (exp * typ)) list (* inits *) * stmt (* body *) | ApplyE of exp * exp list | ClassE of alloc * string * int * exp list | PlacementClassE of exp * string * int * exp list | IfE of exp * exp * exp | PrimE of primitive | MemE of exp * string (* some primitives that are type dependent *) | NewE of alloc * typ * exp list | PlacementNewE of exp * typ * exp list | NewArrayE of alloc * typ * exp | DestroyE of typ * exp | CastE of typ * exp | AnyCastE of typ * exp | SizeofE of typ | ScopedE of string list | SeqE of exp list and typ = AnyT | AnyRefT | AnyConstRefT | AnyPtrRefT | AnyConstPtrRefT | AnyPtrConstRefT | AnyConstPtrConstRefT | AnyPtrT | AnyConstPtrT | RefT of typ | ConstT of typ | ClassT of string | UnionT of (string * typ) list | IntT | LongT | LongLongT | ShortT | UnsignedT of typ | SignedT of typ | FloatT | DoubleT | LongDoubleT | BoolT | StringT | CharT | WCharT | VoidT | NullT | PtrT of typ | FunT of typ list * typ | ElipsesT let pod (t : typ) : bool = (match t with IntT | FloatT | DoubleT | BoolT | StringT | CharT | WCharT | NullT -> true | PtrT AnyT -> false | PtrT _ -> true | _ -> false)