source: src/GenPoly/GenPoly.h @ adc6781

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

Remove unnecessarily duplicated name-mangling passes in Box

  • Property mode set to 100644
File size: 4.1 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#include <utility>
23
24#include "SymTab/Mangler.h"
25
26#include "SynTree/Declaration.h"
27#include "SynTree/Type.h"
28#include "SynTree/TypeSubstitution.h"
29
30namespace GenPoly {
31        typedef std::map< std::string, TypeDecl::Kind > TyVarMap;
32
33        /// A function needs an adapter if it returns a polymorphic value or if any of its
34        /// parameters have polymorphic type
35        bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVarr );
36
37        /// true iff function has polymorphic return type
38        ReferenceToType *isPolyRet( FunctionType *function );
39
40        /// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided
41        Type *isPolyType( Type *type, const TypeSubstitution *env = 0 );
42       
43        /// returns polymorphic type if is polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
44        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
45
46        /// returns polymorphic type if is pointer to polymorphic type, NULL otherwise; will look up substitution in env if provided
47        Type *isPolyPtr( Type *type, const TypeSubstitution *env = 0 );
48       
49        /// returns polymorphic type if is pointer to polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
50        Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
51
52        /// if the base type (after dereferencing N >= 0 pointers) is a polymorphic type, returns the base type, NULL otherwise;
53        /// N will be stored in levels, if provided, will look up substitution in env if provided
54        Type *hasPolyBase( Type *type, int *levels = 0, const TypeSubstitution *env = 0 );
55
56        /// if the base type (after dereferencing N >= 0 pointers) is a polymorphic type in tyVars, returns the base type, NULL otherwise;
57        /// N will be stored in levels, if provided, will look up substitution in env if provided
58        Type *hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels = 0, const TypeSubstitution *env = 0 );
59
60        /// Returns a pointer to the base FunctionType if ty is the type of a function (or pointer to one), NULL otherwise
61        FunctionType *getFunctionType( Type *ty );
62
63        /// If expr (after dereferencing N >= 0 pointers) is a variable expression, returns the variable expression, NULL otherwise;
64        /// N will be stored in levels, if provided
65        VariableExpr *getBaseVar( Expression *expr, int *levels = 0 );
66
67        /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
68        void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
69       
70        /// Prints type variable map
71        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
72
73        /// Gets the mangled name of this type; alias for SymTab::Mangler::mangleType().
74        inline std::string mangleType( Type *ty ) { return SymTab::Mangler::mangleType( ty ); }
75       
76        /// Gets the name of the sizeof parameter for the type, given its mangled name
77        inline std::string sizeofName( const std::string &name ) { return std::string( "_sizeof_" ) + name; }
78
79        /// Gets the name of the alignof parameter for the type, given its mangled name
80        inline std::string alignofName( const std::string &name ) { return std::string( "_alignof_" ) + name; }
81
82        /// Gets the name of the offsetof parameter for the type, given its mangled name
83        inline std::string offsetofName( const std::string &name ) { return std::string( "_offsetof_" ) + name; }
84
85        /// Gets the name of the layout function for a given aggregate type, given its declaration
86        inline std::string layoutofName( AggregateDecl *decl ) { return std::string( "_layoutof_" ) + decl->get_name(); }
87       
88} // namespace GenPoly
89
90#endif // GENPOLY_H
91
92// Local Variables: //
93// tab-width: 4 //
94// mode: c++ //
95// compile-command: "make install" //
96// End: //
Note: See TracBrowser for help on using the repository browser.