source:
src/ResolvExpr/PolyCost.cpp
@
c015e2d
Last change on this file since c015e2d was 5f225f5, checked in by , 3 months ago | |
---|---|
|
|
File size: 1.5 KB |
Rev | Line | |
---|---|---|
[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 | // | |
[5f225f5] | 7 | // PolyCost.cpp -- |
[a32b204] | 8 | // |
9 | // Author : Richard C. Bilson | |
10 | // Created On : Sun May 17 09:50:12 2015 | |
[5aa4656] | 11 | // Last Modified By : Andrew Beach |
12 | // Last Modified On : Wed Jun 19 10:45:00 2019 | |
13 | // Update Count : 4 | |
[a32b204] | 14 | // |
[51b7345] | 15 | |
[9d5089e] | 16 | #include "AST/SymbolTable.hpp" |
[bccd70a] | 17 | #include "AST/Pass.hpp" |
[9d5089e] | 18 | #include "AST/Type.hpp" |
19 | #include "AST/TypeEnvironment.hpp" | |
[51b7345] | 20 | |
21 | namespace ResolvExpr { | |
22 | ||
[2908f08] | 23 | namespace { |
24 | ||
[0bd3faf] | 25 | class PolyCost { |
[5aa4656] | 26 | const ast::SymbolTable &symtab; |
[9ea38de] | 27 | public: |
28 | int result; | |
[5aa4656] | 29 | const ast::TypeEnvironment &env_; |
30 | ||
[ba97ebf] | 31 | PolyCost( const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ) |
[9ea38de] | 32 | : symtab( symtab ), result( 0 ), env_( env ) {} |
[5aa4656] | 33 | |
34 | void previsit( const ast::TypeInstType * type ) { | |
[ba97ebf] | 35 | if ( const ast::EqvClass * eqv = env_.lookup( *type ) ; eqv && eqv->bound ) { |
[5aa4656] | 36 | if ( const ast::TypeInstType * otherType = eqv->bound.as< ast::TypeInstType >() ) { |
37 | if ( symtab.lookupType( otherType->name ) ) { | |
38 | // Bound to opaque type. | |
[ba97ebf] | 39 | result = 1; |
[5aa4656] | 40 | } |
41 | } else { | |
42 | // Bound to concrete type. | |
[ba97ebf] | 43 | result = 1; |
[5aa4656] | 44 | } |
45 | } | |
[9d5089e] | 46 | } |
[5aa4656] | 47 | }; |
48 | ||
[2908f08] | 49 | } // namespace |
50 | ||
[5aa4656] | 51 | int polyCost( |
52 | const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env | |
53 | ) { | |
[ba97ebf] | 54 | return ast::Pass<PolyCost>::read( type, symtab, env ); |
[5aa4656] | 55 | } |
[9d5089e] | 56 | |
[51b7345] | 57 | } // namespace ResolvExpr |
[a32b204] | 58 | |
59 | // Local Variables: // | |
60 | // tab-width: 4 // | |
61 | // mode: c++ // | |
62 | // compile-command: "make install" // | |
63 | // End: // |
Note: See TracBrowser
for help on using the repository browser.