- File:
-
- 1 edited
-
src/ResolvExpr/ConversionCost.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ConversionCost.h
r7d01cf44 rbd0b6b62 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 09:37:28 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thu Aug 8 16:13:00 201913 // Update Count : 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:38:24 2017 13 // Update Count : 4 14 14 // 15 15 … … 20 20 #include "Cost.h" // for Cost 21 21 22 #include "AST/Fwd.hpp"23 #include "AST/Pass.hpp" // for WithShortCircuiting24 22 #include "Common/PassVisitor.h" 25 23 #include "SynTree/Visitor.h" // for Visitor … … 33 31 class TypeEnvironment; 34 32 35 typedef std::function<Cost(const Type *, const Type *, bool, 36 const SymTab::Indexer &, const TypeEnvironment &)> CostFunction; 37 33 typedef std::function<Cost(Type *, Type *, const SymTab::Indexer &, const TypeEnvironment &)> CostFunction; 38 34 struct ConversionCost : public WithShortCircuiting { 39 35 public: 40 ConversionCost( const Type * dest, bool srcIsLvalue, 41 const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction ); 36 ConversionCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction ); 42 37 43 38 Cost get_cost() const { return cost; } 44 39 45 void previsit( constBaseSyntaxNode * ) { visit_children = false; }40 void previsit( BaseSyntaxNode * ) { visit_children = false; } 46 41 47 void postvisit( constVoidType * voidType );48 void postvisit( constBasicType * basicType );49 void postvisit( constPointerType * pointerType );50 void postvisit( constArrayType * arrayType );51 void postvisit( constReferenceType * refType );52 void postvisit( constFunctionType * functionType );53 void postvisit( constStructInstType * aggregateUseType );54 void postvisit( constUnionInstType * aggregateUseType );55 void postvisit( constEnumInstType * aggregateUseType );56 void postvisit( constTraitInstType * aggregateUseType );57 void postvisit( constTypeInstType * aggregateUseType );58 void postvisit( constTupleType * tupleType );59 void postvisit( constVarArgsType * varArgsType );60 void postvisit( constZeroType * zeroType );61 void postvisit( constOneType * oneType );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 ); 62 57 protected: 63 const Type * dest; 64 bool srcIsLvalue; 58 Type *dest; 65 59 const SymTab::Indexer &indexer; 66 60 Cost cost; … … 69 63 }; 70 64 71 typedef std::function<int(const Type *, const Type *, const SymTab::Indexer &, const TypeEnvironment &)> PtrsFunction; 72 Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, bool srcIsLvalue, 73 const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ); 74 75 // Some function pointer types, differ in return type. 76 using CostCalculation = std::function<Cost(const ast::Type *, const ast::Type *, 77 const ast::SymbolTable &, const ast::TypeEnvironment &)>; 78 using NumCostCalculation = std::function<int(const ast::Type *, const ast::Type *, 79 const ast::SymbolTable &, const ast::TypeEnvironment &)>; 80 81 #warning when the old ConversionCost is removed, get ride of the _new suffix. 82 class ConversionCost_new : public ast::WithShortCircuiting { 83 protected: 84 const ast::Type * dst; 85 const ast::SymbolTable & symtab; 86 const ast::TypeEnvironment & env; 87 CostCalculation costCalc; 88 public: 89 Cost cost; 90 91 ConversionCost_new( const ast::Type * dst, const ast::SymbolTable & symtab, 92 const ast::TypeEnvironment & env, CostCalculation costCalc ) : 93 dst( dst ), symtab( symtab ), env( env ), costCalc( costCalc ), cost( Cost::infinity ) 94 {} 95 96 void previsit( const ast::Node * ) { visit_children = false; } 97 98 void postvisit( const ast::VoidType * voidType ); 99 void postvisit( const ast::BasicType * basicType ); 100 void postvisit( const ast::PointerType * pointerType ); 101 void postvisit( const ast::ArrayType * arrayType ); 102 void postvisit( const ast::ReferenceType * refType ); 103 void postvisit( const ast::FunctionType * functionType ); 104 void postvisit( const ast::StructInstType * structInstType ); 105 void postvisit( const ast::UnionInstType * unionInstType ); 106 void postvisit( const ast::EnumInstType * enumInstType ); 107 void postvisit( const ast::TraitInstType * traitInstType ); 108 void postvisit( const ast::TypeInstType * typeInstType ); 109 void postvisit( const ast::TupleType * tupleType ); 110 void postvisit( const ast::VarArgsType * varArgsType ); 111 void postvisit( const ast::ZeroType * zeroType ); 112 void postvisit( const ast::OneType * oneType ); 113 }; 114 115 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dest, 116 const ast::SymbolTable & indexer, const ast::TypeEnvironment & env, NumCostCalculation func ); 117 65 typedef std::function<int(Type *, Type *, const SymTab::Indexer &, const TypeEnvironment &)> PtrsFunction; 66 Cost convertToReferenceCost( Type * src, ReferenceType * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ); 118 67 } // namespace ResolvExpr 119 68
Note:
See TracChangeset
for help on using the changeset viewer.