source: src/ResolvExpr/typeops.h @ fd344aa

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since fd344aa was fd344aa, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Remove unused cost functions functions

  • Property mode set to 100644
File size: 4.2 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// typeops.h --
8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 07:28:22 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sun May 17 07:33:11 2015
13// Update Count     : 2
14//
15
16#ifndef TYPEOPS_H
17#define TYPEOPS_H
18
19#include "SynTree/SynTree.h"
20#include "SynTree/Type.h"
21#include "SymTab/Indexer.h"
22#include "Cost.h"
23#include "TypeEnvironment.h"
24
25namespace ResolvExpr {
26        // combos: takes a list of sets and returns a set of lists representing every possible way of forming a list by
27        // picking one element out of each set
28        template< typename InputIterator, typename OutputIterator >
29        void combos( InputIterator begin, InputIterator end, OutputIterator out ) {
30                typedef typename InputIterator::value_type SetType;
31                typedef typename std::list< typename SetType::value_type > ListType;
32
33                if ( begin == end )     {
34                        *out++ = ListType();
35                        return;
36                } // if
37
38                InputIterator current = begin;
39                begin++;
40
41                std::list< ListType > recursiveResult;
42                combos( begin, end, back_inserter( recursiveResult ) );
43
44                for ( typename std::list< ListType >::const_iterator i = recursiveResult.begin(); i != recursiveResult.end(); ++i ) {
45                        for ( typename ListType::const_iterator j = current->begin(); j != current->end(); ++j ) {
46                                ListType result;
47                                std::back_insert_iterator< ListType > inserter = back_inserter( result );
48                                *inserter++ = *j;
49                                std::copy( i->begin(), i->end(), inserter );
50                                *out++ = result;
51                        } // for
52                } // for
53        }
54
55        // in AdjustExprType.cc
56        /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function
57        void adjustExprType( Type *&type, const TypeEnvironment &env, const SymTab::Indexer &indexer );
58
59        template< typename ForwardIterator >
60        void adjustExprTypeList( ForwardIterator begin, ForwardIterator end, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
61                while ( begin != end ) {
62                        adjustExprType( *begin++, env, indexer );
63                } // while
64        }
65
66        // in CastCost.cc
67        Cost castCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
68
69        // in ConversionCost.cc
70        Cost conversionCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
71
72        // in PtrsAssignable.cc
73        int ptrsAssignable( Type *src, Type *dest, const TypeEnvironment &env );
74
75        // in PtrsCastable.cc
76        int ptrsCastable( Type *src, Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer );
77
78        // in Unify.cc
79        bool isFtype( Type *type );
80        bool typesCompatible( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env );
81        bool typesCompatibleIgnoreQualifiers( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env );
82
83        inline bool typesCompatible( Type *t1, Type *t2, const SymTab::Indexer &indexer ) {
84                TypeEnvironment env;
85                return typesCompatible( t1, t2, indexer, env );
86        }
87
88        inline bool typesCompatibleIgnoreQualifiers( Type *t1, Type *t2, const SymTab::Indexer &indexer ) {
89                TypeEnvironment env;
90                return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env );
91        }
92
93        /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value.
94        Type * extractResultType( FunctionType * functionType );
95
96        // in CommonType.cc
97        Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars );
98
99        // in PolyCost.cc
100        int polyCost( Type *type, const TypeEnvironment &env, const SymTab::Indexer &indexer );
101
102        // in Occurs.cc
103        bool occurs( Type *type, std::string varName, const TypeEnvironment &env );
104
105        // flatten tuple type into list of types
106        template< typename OutputIterator >
107        void flatten( Type * type, OutputIterator out ) {
108                if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) {
109                        for ( Type * t : tupleType->get_types() ) {
110                                flatten( t, out );
111                        }
112                } else {
113                        *out++ = type->clone();
114                }
115        }
116} // namespace ResolvExpr
117
118#endif // TYPEOPS_H
119
120// Local Variables: //
121// tab-width: 4 //
122// mode: c++ //
123// compile-command: "make install" //
124// End: //
Note: See TracBrowser for help on using the repository browser.