| 1 | //
|
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
|---|
| 3 | //
|
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
|
|---|
| 5 | // file "LICENCE" distributed with Cforall.
|
|---|
| 6 | //
|
|---|
| 7 | // GenPoly.h --
|
|---|
| 8 | //
|
|---|
| 9 | // Author : Richard C. Bilson
|
|---|
| 10 | // Created On : Mon May 18 07:44:20 2015
|
|---|
| 11 | // Last Modified By : Rob Schluntz
|
|---|
| 12 | // Last Modified On : Tue Nov 24 15:24:38 2015
|
|---|
| 13 | // Update Count : 6
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #ifndef GENPOLY_H
|
|---|
| 17 | #define GENPOLY_H
|
|---|
| 18 |
|
|---|
| 19 | #include <map>
|
|---|
| 20 | #include <string>
|
|---|
| 21 | #include <iostream>
|
|---|
| 22 |
|
|---|
| 23 | #include "SynTree/Declaration.h"
|
|---|
| 24 | #include "SynTree/Type.h"
|
|---|
| 25 | #include "SynTree/TypeSubstitution.h"
|
|---|
| 26 |
|
|---|
| 27 | namespace GenPoly {
|
|---|
| 28 | typedef std::map< std::string, TypeDecl::Kind > TyVarMap;
|
|---|
| 29 |
|
|---|
| 30 | /// A function needs an adapter if it returns a polymorphic value or if any of its
|
|---|
| 31 | /// parameters have polymorphic type
|
|---|
| 32 | bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVarr );
|
|---|
| 33 |
|
|---|
| 34 | /// true iff function has polymorphic return type
|
|---|
| 35 | ReferenceToType *isPolyRet( FunctionType *function );
|
|---|
| 36 |
|
|---|
| 37 | /// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided
|
|---|
| 38 | Type *isPolyType( Type *type, const TypeSubstitution *env = 0 );
|
|---|
| 39 |
|
|---|
| 40 | /// returns polymorphic type if is polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
|
|---|
| 41 | Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
|
|---|
| 42 |
|
|---|
| 43 | /// returns polymorphic type if is pointer to polymorphic type, NULL otherwise; will look up substitution in env if provided
|
|---|
| 44 | Type *isPolyPtr( Type *type, const TypeSubstitution *env = 0 );
|
|---|
| 45 |
|
|---|
| 46 | /// returns polymorphic type if is pointer to polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
|
|---|
| 47 | Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
|
|---|
| 48 |
|
|---|
| 49 | /// Returns a pointer to the base FunctionType if ty is the type of a function (or pointer to one), NULL otherwise
|
|---|
| 50 | FunctionType * getFunctionType( Type *ty );
|
|---|
| 51 |
|
|---|
| 52 | /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
|
|---|
| 53 | void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
|
|---|
| 54 |
|
|---|
| 55 | /// Prints type variable map
|
|---|
| 56 | void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
|
|---|
| 57 |
|
|---|
| 58 | /// Gets the name of the sizeof parameter for the type
|
|---|
| 59 | std::string sizeofName( Type *ty );
|
|---|
| 60 |
|
|---|
| 61 | /// Gets the name of the alignof parameter for the type
|
|---|
| 62 | std::string alignofName( Type *ty );
|
|---|
| 63 | } // namespace GenPoly
|
|---|
| 64 |
|
|---|
| 65 | #endif // GENPOLY_H
|
|---|
| 66 |
|
|---|
| 67 | // Local Variables: //
|
|---|
| 68 | // tab-width: 4 //
|
|---|
| 69 | // mode: c++ //
|
|---|
| 70 | // compile-command: "make install" //
|
|---|
| 71 | // End: //
|
|---|