| 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 | // Alternative.h -- | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Richard C. Bilson | 
|---|
| 10 | // Created On       : Sat May 16 23:45:43 2015 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr | 
|---|
| 12 | // Last Modified On : Sat Jul 22 09:36:36 2017 | 
|---|
| 13 | // Update Count     : 3 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #pragma once | 
|---|
| 17 |  | 
|---|
| 18 | #include <iosfwd>             // for ostream | 
|---|
| 19 | #include <vector>             // for vector | 
|---|
| 20 |  | 
|---|
| 21 | #include "Cost.h"             // for Cost | 
|---|
| 22 | #include "TypeEnvironment.h"  // for TypeEnvironment | 
|---|
| 23 |  | 
|---|
| 24 | class Expression; | 
|---|
| 25 |  | 
|---|
| 26 | namespace ResolvExpr { | 
|---|
| 27 | struct Alternative { | 
|---|
| 28 | Alternative(); | 
|---|
| 29 | Alternative( Expression *expr, const TypeEnvironment &env, const Cost &cost ); | 
|---|
| 30 | Alternative( Expression *expr, const TypeEnvironment &env, const Cost &cost, const Cost &cvtCost ); | 
|---|
| 31 | Alternative( const Alternative &other ); | 
|---|
| 32 | Alternative &operator=( const Alternative &other ); | 
|---|
| 33 | Alternative( Alternative && other ); | 
|---|
| 34 | Alternative &operator=( Alternative && other ); | 
|---|
| 35 | ~Alternative(); | 
|---|
| 36 |  | 
|---|
| 37 | void print( std::ostream &os, Indenter indent = {} ) const; | 
|---|
| 38 |  | 
|---|
| 39 | /// Returns the stored expression, but released from management of this Alternative | 
|---|
| 40 | Expression* release_expr() { | 
|---|
| 41 | Expression* tmp = expr; | 
|---|
| 42 | expr = nullptr; | 
|---|
| 43 | return tmp; | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 | Cost cost; | 
|---|
| 47 | Cost cvtCost; | 
|---|
| 48 | Expression *expr; | 
|---|
| 49 | TypeEnvironment env; | 
|---|
| 50 | }; | 
|---|
| 51 |  | 
|---|
| 52 | typedef std::vector< Alternative > AltList; | 
|---|
| 53 |  | 
|---|
| 54 | /// Moves all elements from src to the end of dst | 
|---|
| 55 | void splice( AltList& dst, AltList& src ); | 
|---|
| 56 |  | 
|---|
| 57 | /// Moves all elements from src to the beginning of dst | 
|---|
| 58 | void spliceBegin( AltList& dst, AltList& src ); | 
|---|
| 59 |  | 
|---|
| 60 | static inline std::ostream & operator<<(std::ostream & os, const ResolvExpr::Alternative & alt) { | 
|---|
| 61 | alt.print( os ); | 
|---|
| 62 | return os; | 
|---|
| 63 | } | 
|---|
| 64 | } // namespace ResolvExpr | 
|---|
| 65 |  | 
|---|
| 66 | // Local Variables: // | 
|---|
| 67 | // tab-width: 4 // | 
|---|
| 68 | // mode: c++ // | 
|---|
| 69 | // compile-command: "make install" // | 
|---|
| 70 | // End: // | 
|---|