source: src/GenPoly/GenPoly.h @ 05d47278

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 05d47278 was 05d47278, checked in by Aaron Moss <a3moss@…>, 8 years ago

First draft of member expressions by passed offset

  • Property mode set to 100644
File size: 3.3 KB
Line 
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
27namespace 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 polymorphic base type if the base type (after dereferencing any number of pointers) is a polymorphic type, NULL otherwise;
50        /// will look up substitution in env if provided
51        Type *hasPolyBase( Type *type, const TypeSubstitution *env = 0 );
52
53        /// returns polymorphic base type if the base type (after dereferencing any number of pointers) is a polymorphic type in tyVars, NULL otherwise;
54        /// will look up substitution in env if provided
55        Type *hasPolyBase( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
56
57        /// Returns a pointer to the base FunctionType if ty is the type of a function (or pointer to one), NULL otherwise
58        FunctionType *getFunctionType( Type *ty );
59
60        /// Returns the base variable (possibly repeatedly dereferenced) for an expression, NULL if none found
61        VariableExpr *getBaseVar( Expression *expr );
62
63        /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
64        void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
65       
66        /// Prints type variable map
67        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
68
69        /// Gets the name of the sizeof parameter for the type
70        std::string sizeofName( Type *ty );
71
72        /// Gets the name of the alignof parameter for the type
73        std::string alignofName( Type *ty );
74
75        /// Gets the name of the offsetof parameter for the type
76        std::string offsetofName( Type *ty );
77} // namespace GenPoly
78
79#endif // GENPOLY_H
80
81// Local Variables: //
82// tab-width: 4 //
83// mode: c++ //
84// compile-command: "make install" //
85// End: //
Note: See TracBrowser for help on using the repository browser.