source: src/GenPoly/GenPoly.h @ ae7014e

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 ae7014e was 8488c715, checked in by Aaron Moss <a3moss@…>, 8 years ago

Fixed dereferencing in member expressions

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[51587aa]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//
[01aeade]7// GenPoly.h --
[51587aa]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[bdf1954]11// Last Modified By : Rob Schluntz
12// Last Modified On : Tue Nov 24 15:24:38 2015
13// Update Count     : 6
[51587aa]14//
[51b7345]15
[b1a6d6b]16#ifndef GENPOLY_H
17#define GENPOLY_H
18
[51b7345]19#include <map>
20#include <string>
21#include <iostream>
[8488c715]22#include <utility>
[ffad73a]23
[51b7345]24#include "SynTree/Declaration.h"
[aadc9a4]25#include "SynTree/Type.h"
[ffad73a]26#include "SynTree/TypeSubstitution.h"
[51b7345]27
28namespace GenPoly {
[01aeade]29        typedef std::map< std::string, TypeDecl::Kind > TyVarMap;
[51b7345]30
[ffad73a]31        /// A function needs an adapter if it returns a polymorphic value or if any of its
32        /// parameters have polymorphic type
[01aeade]33        bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVarr );
[ffad73a]34
35        /// true iff function has polymorphic return type
[aadc9a4]36        ReferenceToType *isPolyRet( FunctionType *function );
[bdf1954]37
[ffad73a]38        /// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided
[0f889a77]39        Type *isPolyType( Type *type, const TypeSubstitution *env = 0 );
40       
41        /// returns polymorphic type if is polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
[ffad73a]42        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
43
44        /// returns polymorphic type if is pointer to polymorphic type, NULL otherwise; will look up substitution in env if provided
[0f889a77]45        Type *isPolyPtr( Type *type, const TypeSubstitution *env = 0 );
46       
47        /// returns polymorphic type if is pointer to polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
[ffad73a]48        Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
49
[8488c715]50        /// if the base type (after dereferencing N >= 0 pointers) is a polymorphic type, returns the base type, NULL otherwise;
51        /// N will be stored in levels, if provided, will look up substitution in env if provided
52        Type *hasPolyBase( Type *type, int *levels = 0, const TypeSubstitution *env = 0 );
[05d47278]53
[8488c715]54        /// if the base type (after dereferencing N >= 0 pointers) is a polymorphic type in tyVars, returns the base type, NULL otherwise;
55        /// N will be stored in levels, if provided, will look up substitution in env if provided
56        Type *hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels = 0, const TypeSubstitution *env = 0 );
[05d47278]57
[7754cde]58        /// Returns a pointer to the base FunctionType if ty is the type of a function (or pointer to one), NULL otherwise
[05d47278]59        FunctionType *getFunctionType( Type *ty );
60
[8488c715]61        /// If expr (after dereferencing N >= 0 pointers) is a variable expression, returns the variable expression, NULL otherwise;
62        /// N will be stored in levels, if provided
63        VariableExpr *getBaseVar( Expression *expr, int *levels = 0 );
[7754cde]64
[aadc9a4]65        /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
66        void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
67       
[ffad73a]68        /// Prints type variable map
[01aeade]69        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
[ffad73a]70
71        /// Gets the name of the sizeof parameter for the type
72        std::string sizeofName( Type *ty );
73
74        /// Gets the name of the alignof parameter for the type
75        std::string alignofName( Type *ty );
[05d47278]76
77        /// Gets the name of the offsetof parameter for the type
78        std::string offsetofName( Type *ty );
[51b7345]79} // namespace GenPoly
[b1a6d6b]80
[01aeade]81#endif // GENPOLY_H
82
[51587aa]83// Local Variables: //
84// tab-width: 4 //
85// mode: c++ //
86// compile-command: "make install" //
87// End: //
Note: See TracBrowser for help on using the repository browser.