| [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 | // | 
|---|
| [db4ecc5] | 7 | // Resolver.h -- | 
|---|
| [a32b204] | 8 | // | 
|---|
|  | 9 | // Author           : Richard C. Bilson | 
|---|
|  | 10 | // Created On       : Sun May 17 12:18:34 2015 | 
|---|
| [39d8950] | 11 | // Last Modified By : Andrew Beach | 
|---|
|  | 12 | // Last Modified On : Wed Mar 16 11:32:00 2022 | 
|---|
|  | 13 | // Update Count     : 5 | 
|---|
| [a32b204] | 14 | // | 
|---|
|  | 15 |  | 
|---|
| [6b0b624] | 16 | #pragma once | 
|---|
| [51b73452] | 17 |  | 
|---|
| [d76c588] | 18 | #include <list>          // for list | 
|---|
| [4b7cce6] | 19 |  | 
|---|
|  | 20 | #include "AST/Node.hpp"  // for ptr | 
|---|
| [ea6332d] | 21 |  | 
|---|
|  | 22 | class ConstructorInit; | 
|---|
|  | 23 | class Declaration; | 
|---|
|  | 24 | class Expression; | 
|---|
| [39d8950] | 25 | class DeletedExpr; | 
|---|
| [ea6332d] | 26 | class StmtExpr; | 
|---|
| [39d8950] | 27 | class Type; | 
|---|
| [ea6332d] | 28 | namespace SymTab { | 
|---|
| [d76c588] | 29 | class Indexer; | 
|---|
|  | 30 | } // namespace SymTab | 
|---|
|  | 31 |  | 
|---|
|  | 32 | namespace ast { | 
|---|
| [234b1cb] | 33 | class ConstructorInit; | 
|---|
| [d76c588] | 34 | class Decl; | 
|---|
| [d57e349] | 35 | class DeletedExpr; | 
|---|
| [234b1cb] | 36 | class Init; | 
|---|
| [17a0ede2] | 37 | class StmtExpr; | 
|---|
| [4b7cce6] | 38 | class SymbolTable; | 
|---|
| [39d8950] | 39 | class TranslationGlobal; | 
|---|
| [1f7dc61] | 40 | class TranslationUnit; | 
|---|
| [18e683b] | 41 | class Type; | 
|---|
| [4b7cce6] | 42 | class TypeEnvironment; | 
|---|
| [d76c588] | 43 | } // namespace ast | 
|---|
| [51b73452] | 44 |  | 
|---|
|  | 45 | namespace ResolvExpr { | 
|---|
| [82dd287] | 46 | /// Checks types and binds syntactic constructs to typed representations | 
|---|
| [a32b204] | 47 | void resolve( std::list< Declaration * > translationUnit ); | 
|---|
| [5170d95] | 48 | void resolveDecl( Declaration *, const SymTab::Indexer & indexer ); | 
|---|
|  | 49 | Expression *resolveInVoidContext( Expression * expr, const SymTab::Indexer & indexer ); | 
|---|
|  | 50 | void findVoidExpression( Expression *& untyped, const SymTab::Indexer & indexer ); | 
|---|
|  | 51 | void findSingleExpression( Expression *& untyped, const SymTab::Indexer & indexer ); | 
|---|
|  | 52 | void findSingleExpression( Expression *& untyped, Type * type, const SymTab::Indexer & indexer ); | 
|---|
| [1d2b64f] | 53 | void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer ); | 
|---|
|  | 54 | void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer ); | 
|---|
| [630bcb5] | 55 | /// Searches expr and returns the first DeletedExpr found, otherwise nullptr | 
|---|
|  | 56 | DeletedExpr * findDeletedExpr( Expression * expr ); | 
|---|
| [2a6292d] | 57 | /// Resolves with-stmts and with-clauses on functions | 
|---|
|  | 58 | void resolveWithExprs( std::list< Declaration * > & translationUnit ); | 
|---|
| [d76c588] | 59 |  | 
|---|
| [39d8950] | 60 | /// Helper Type: Passes around information between various sub-calls. | 
|---|
|  | 61 | struct ResolveContext { | 
|---|
|  | 62 | const ast::SymbolTable & symtab; | 
|---|
|  | 63 | const ast::TranslationGlobal & global; | 
|---|
|  | 64 | }; | 
|---|
|  | 65 |  | 
|---|
| [d76c588] | 66 | /// Checks types and binds syntactic constructs to typed representations | 
|---|
| [293dc1c] | 67 | void resolve( ast::TranslationUnit& translationUnit ); | 
|---|
| [d57e349] | 68 | /// Searches expr and returns the first DeletedExpr found, otherwise nullptr | 
|---|
|  | 69 | const ast::DeletedExpr * findDeletedExpr( const ast::Expr * expr ); | 
|---|
| [4b7cce6] | 70 | /// Find the expression candidate that is the unique best match for `untyped` in a `void` | 
|---|
|  | 71 | /// context. | 
|---|
|  | 72 | ast::ptr< ast::Expr > resolveInVoidContext( | 
|---|
| [39d8950] | 73 | const ast::Expr * expr, const ResolveContext &, ast::TypeEnvironment & env ); | 
|---|
| [b2e0df3] | 74 | /// Resolve `untyped` to the single expression whose candidate is the best match for the | 
|---|
| [18e683b] | 75 | /// given type. | 
|---|
|  | 76 | ast::ptr< ast::Expr > findSingleExpression( | 
|---|
| [39d8950] | 77 | const ast::Expr * untyped, const ast::Type * type, const ResolveContext & ); | 
|---|
| [490fb92e] | 78 | ast::ptr< ast::Expr > findVoidExpression( | 
|---|
| [39d8950] | 79 | const ast::Expr * untyped, const ResolveContext & ); | 
|---|
| [234b1cb] | 80 | /// Resolves a constructor init expression | 
|---|
| [293dc1c] | 81 | ast::ptr< ast::Init > resolveCtorInit( | 
|---|
| [39d8950] | 82 | const ast::ConstructorInit * ctorInit, const ResolveContext & context ); | 
|---|
| [1f7dc61] | 83 | /// Resolves a statement expression | 
|---|
| [302ef2a] | 84 | const ast::Expr * resolveStmtExpr( | 
|---|
| [39d8950] | 85 | const ast::StmtExpr * stmtExpr, const ResolveContext & context ); | 
|---|
| [51b73452] | 86 | } // namespace ResolvExpr | 
|---|
|  | 87 |  | 
|---|
| [a32b204] | 88 | // Local Variables: // | 
|---|
|  | 89 | // tab-width: 4 // | 
|---|
|  | 90 | // mode: c++ // | 
|---|
|  | 91 | // compile-command: "make install" // | 
|---|
|  | 92 | // End: // | 
|---|