source: src/GenPoly/GenPoly.h@ 70a06f6

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 70a06f6 was bfae637, checked in by Aaron Moss <a3moss@…>, 9 years ago

Initial compiling build with TyVarMap as ErasableScopedMap

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