source: src/ResolvExpr/ConversionCost.h @ 721cd19f

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 721cd19f was 721cd19f, checked in by Rob Schluntz <rschlunt@…>, 6 years ago

Refactor ConversionCost? and CastCost? to remove explicit recursive accept calls

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[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
[51b7345]17
[0c6596f]18#include <functional>         // for function
19
[ea6332d]20#include "Cost.h"             // for Cost
21#include "SynTree/Visitor.h"  // for Visitor
22#include "SynTree/SynTree.h"  // for Visitor Nodes
23
24namespace SymTab {
[0c6596f]25        class Indexer;
[ea6332d]26}  // namespace SymTab
[51b7345]27
28namespace ResolvExpr {
[0c6596f]29        class TypeEnvironment;
[ea6332d]30
[721cd19f]31        typedef std::function<Cost(Type *, Type *, const SymTab::Indexer &, const TypeEnvironment &)> CostFunction;
[a32b204]32        class ConversionCost : public Visitor {
33          public:
[721cd19f]34                ConversionCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction );
[2463d0e]35
[a32b204]36                Cost get_cost() const { return cost; }
37
38                virtual void visit(VoidType *voidType);
39                virtual void visit(BasicType *basicType);
40                virtual void visit(PointerType *pointerType);
41                virtual void visit(ArrayType *arrayType);
[2463d0e]42                virtual void visit(ReferenceType *refType);
[a32b204]43                virtual void visit(FunctionType *functionType);
44                virtual void visit(StructInstType *aggregateUseType);
45                virtual void visit(UnionInstType *aggregateUseType);
46                virtual void visit(EnumInstType *aggregateUseType);
[4040425]47                virtual void visit(TraitInstType *aggregateUseType);
[a32b204]48                virtual void visit(TypeInstType *aggregateUseType);
49                virtual void visit(TupleType *tupleType);
[44b7088]50                virtual void visit(VarArgsType *varArgsType);
[89e6ffc]51                virtual void visit(ZeroType *zeroType);
52                virtual void visit(OneType *oneType);
[a32b204]53          protected:
54                Type *dest;
55                const SymTab::Indexer &indexer;
56                Cost cost;
57                const TypeEnvironment &env;
[721cd19f]58                CostFunction costFunc;
[a32b204]59        };
[2463d0e]60
[721cd19f]61        typedef std::function<int(Type *, Type *, const SymTab::Indexer &, const TypeEnvironment &)> PtrsFunction;
[0c6596f]62        Cost convertToReferenceCost( Type * src, ReferenceType * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func );
[51b7345]63} // namespace ResolvExpr
64
[a32b204]65// Local Variables: //
66// tab-width: 4 //
67// mode: c++ //
68// compile-command: "make install" //
69// End: //
Note: See TracBrowser for help on using the repository browser.