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