| [a32b204] | 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 | // | 
|---|
| [2463d0e] | 7 | // ConversionCost.h -- | 
|---|
| [a32b204] | 8 | // | 
|---|
|  | 9 | // Author           : Richard C. Bilson | 
|---|
|  | 10 | // Created On       : Sun May 17 09:37:28 2015 | 
|---|
|  | 11 | // Last Modified By : Peter A. Buhr | 
|---|
| [6b0b624] | 12 | // Last Modified On : Sat Jul 22 09:38:24 2017 | 
|---|
|  | 13 | // Update Count     : 4 | 
|---|
| [a32b204] | 14 | // | 
|---|
|  | 15 |  | 
|---|
| [6b0b624] | 16 | #pragma once | 
|---|
| [51b73452] | 17 |  | 
|---|
| [0c6596f] | 18 | #include <functional>         // for function | 
|---|
|  | 19 |  | 
|---|
| [ea6332d] | 20 | #include "Cost.h"             // for Cost | 
|---|
| [bd0b6b62] | 21 |  | 
|---|
|  | 22 | #include "Common/PassVisitor.h" | 
|---|
| [ea6332d] | 23 | #include "SynTree/Visitor.h"  // for Visitor | 
|---|
|  | 24 | #include "SynTree/SynTree.h"  // for Visitor Nodes | 
|---|
|  | 25 |  | 
|---|
|  | 26 | namespace SymTab { | 
|---|
| [0c6596f] | 27 | class Indexer; | 
|---|
| [ea6332d] | 28 | }  // namespace SymTab | 
|---|
| [51b73452] | 29 |  | 
|---|
|  | 30 | namespace ResolvExpr { | 
|---|
| [0c6596f] | 31 | class TypeEnvironment; | 
|---|
| [ea6332d] | 32 |  | 
|---|
| [721cd19f] | 33 | typedef std::function<Cost(Type *, Type *, const SymTab::Indexer &, const TypeEnvironment &)> CostFunction; | 
|---|
| [bd0b6b62] | 34 | struct ConversionCost : public WithShortCircuiting { | 
|---|
| [a32b204] | 35 | public: | 
|---|
| [721cd19f] | 36 | ConversionCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction ); | 
|---|
| [2463d0e] | 37 |  | 
|---|
| [a32b204] | 38 | Cost get_cost() const { return cost; } | 
|---|
|  | 39 |  | 
|---|
| [bd0b6b62] | 40 | void previsit( BaseSyntaxNode * ) { visit_children = false; } | 
|---|
|  | 41 |  | 
|---|
|  | 42 | void postvisit( VoidType * voidType ); | 
|---|
|  | 43 | void postvisit( BasicType * basicType ); | 
|---|
|  | 44 | void postvisit( PointerType * pointerType ); | 
|---|
|  | 45 | void postvisit( ArrayType * arrayType ); | 
|---|
|  | 46 | void postvisit( ReferenceType * refType ); | 
|---|
|  | 47 | void postvisit( FunctionType * functionType ); | 
|---|
|  | 48 | void postvisit( StructInstType * aggregateUseType ); | 
|---|
|  | 49 | void postvisit( UnionInstType * aggregateUseType ); | 
|---|
|  | 50 | void postvisit( EnumInstType * aggregateUseType ); | 
|---|
|  | 51 | void postvisit( TraitInstType * aggregateUseType ); | 
|---|
|  | 52 | void postvisit( TypeInstType * aggregateUseType ); | 
|---|
|  | 53 | void postvisit( TupleType * tupleType ); | 
|---|
|  | 54 | void postvisit( VarArgsType * varArgsType ); | 
|---|
|  | 55 | void postvisit( ZeroType * zeroType ); | 
|---|
|  | 56 | void postvisit( OneType * oneType ); | 
|---|
| [a32b204] | 57 | protected: | 
|---|
|  | 58 | Type *dest; | 
|---|
|  | 59 | const SymTab::Indexer &indexer; | 
|---|
|  | 60 | Cost cost; | 
|---|
|  | 61 | const TypeEnvironment &env; | 
|---|
| [721cd19f] | 62 | CostFunction costFunc; | 
|---|
| [a32b204] | 63 | }; | 
|---|
| [2463d0e] | 64 |  | 
|---|
| [721cd19f] | 65 | typedef std::function<int(Type *, Type *, const SymTab::Indexer &, const TypeEnvironment &)> PtrsFunction; | 
|---|
| [0c6596f] | 66 | Cost convertToReferenceCost( Type * src, ReferenceType * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ); | 
|---|
| [51b73452] | 67 | } // namespace ResolvExpr | 
|---|
|  | 68 |  | 
|---|
| [a32b204] | 69 | // Local Variables: // | 
|---|
|  | 70 | // tab-width: 4 // | 
|---|
|  | 71 | // mode: c++ // | 
|---|
|  | 72 | // compile-command: "make install" // | 
|---|
|  | 73 | // End: // | 
|---|