Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.h

    rc6b4432 rfed6a0f  
    2222#include "AST/Fwd.hpp"
    2323#include "AST/Pass.hpp"       // for WithShortCircuiting
     24#include "Common/PassVisitor.h"
     25#include "SynTree/Visitor.h"  // for Visitor
     26#include "SynTree/SynTree.h"  // for Visitor Nodes
    2427
    2528namespace SymTab {
     
    2932namespace ResolvExpr {
    3033        class TypeEnvironment;
     34
     35        Cost conversionCost(
     36                const Type * src, const Type * dest, bool srcIsLvalue,
     37                const SymTab::Indexer & indexer, const TypeEnvironment & env );
     38
     39        typedef std::function<Cost(const Type *, const Type *, bool,
     40                const SymTab::Indexer &, const TypeEnvironment &)> CostFunction;
     41
     42        struct ConversionCost : public WithShortCircuiting {
     43          public:
     44                ConversionCost( const Type * dest, bool srcIsLvalue,
     45                        const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction );
     46
     47                Cost get_cost() const { return cost; }
     48
     49                void previsit( const BaseSyntaxNode * ) { visit_children = false; }
     50
     51                void postvisit( const VoidType * voidType );
     52                void postvisit( const BasicType * basicType );
     53                void postvisit( const PointerType * pointerType );
     54                void postvisit( const ArrayType * arrayType );
     55                void postvisit( const ReferenceType * refType );
     56                void postvisit( const FunctionType * functionType );
     57                void postvisit( const EnumInstType * aggregateUseType );
     58                void postvisit( const TraitInstType * aggregateUseType );
     59                void postvisit( const TypeInstType * aggregateUseType );
     60                void postvisit( const TupleType * tupleType );
     61                void postvisit( const VarArgsType * varArgsType );
     62                void postvisit( const ZeroType * zeroType );
     63                void postvisit( const OneType * oneType );
     64          protected:
     65                const Type * dest;
     66                bool srcIsLvalue;
     67                const SymTab::Indexer &indexer;
     68                Cost cost;
     69                const TypeEnvironment &env;
     70                CostFunction costFunc;
     71          private:
     72                // refactor for code resue
     73                void conversionCostFromBasicToBasic( const BasicType * src, const BasicType* dest );
     74        };
     75
     76        typedef std::function<int(const Type *, const Type *, const SymTab::Indexer &, const TypeEnvironment &)> PtrsFunction;
     77        Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, bool srcIsLvalue,
     78                const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func );
    3179
    3280// Some function pointer types, differ in return type.
Note: See TracChangeset for help on using the changeset viewer.