| 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 | // GenInit.h --
|
|---|
| 8 | //
|
|---|
| 9 | // Author : Rodolfo G. Esteves
|
|---|
| 10 | // Created On : Mon May 18 07:44:20 2015
|
|---|
| 11 | // Last Modified By : Andrew Beach
|
|---|
| 12 | // Last Modified On : Fri Mar 18 14:22:00 2022
|
|---|
| 13 | // Update Count : 7
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #pragma once
|
|---|
| 17 |
|
|---|
| 18 | #include <list> // for list
|
|---|
| 19 | #include <string> // for string
|
|---|
| 20 |
|
|---|
| 21 | #include "AST/Fwd.hpp"
|
|---|
| 22 | #include "Common/CodeLocation.h"
|
|---|
| 23 | #include "GenPoly/ScopedSet.h" // for ScopedSet
|
|---|
| 24 | #include "SynTree/SynTree.h" // for Visitor Nodes
|
|---|
| 25 |
|
|---|
| 26 | namespace InitTweak {
|
|---|
| 27 | /// Adds return value temporaries and wraps Initializers in ConstructorInit nodes
|
|---|
| 28 | void genInit( std::list< Declaration * > & translationUnit );
|
|---|
| 29 | void genInit( ast::TranslationUnit & translationUnit );
|
|---|
| 30 |
|
|---|
| 31 | /// Converts return statements into copy constructor calls on the hidden return variable
|
|---|
| 32 | void fixReturnStatements( std::list< Declaration * > & translationUnit );
|
|---|
| 33 | void fixReturnStatements( ast::TranslationUnit & translationUnit );
|
|---|
| 34 |
|
|---|
| 35 | /// generates a single ctor/dtor statement using objDecl as the 'this' parameter and arg as the optional argument
|
|---|
| 36 | ImplicitCtorDtorStmt * genCtorDtor( const std::string & fname, ObjectDecl * objDecl, Expression * arg = nullptr );
|
|---|
| 37 | ast::ptr<ast::Stmt> genCtorDtor (const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * objDecl, const ast::Expr * arg = nullptr);
|
|---|
| 38 |
|
|---|
| 39 | /// creates an appropriate ConstructorInit node which contains a constructor, destructor, and C-initializer
|
|---|
| 40 | ConstructorInit * genCtorInit( ObjectDecl * objDecl );
|
|---|
| 41 | ast::ConstructorInit * genCtorInit( const CodeLocation & loc, const ast::ObjectDecl * objDecl );
|
|---|
| 42 |
|
|---|
| 43 | class ManagedTypes {
|
|---|
| 44 | public:
|
|---|
| 45 | bool isManaged( ObjectDecl * objDecl ) const ; // determine if object is managed
|
|---|
| 46 | bool isManaged( Type * type ) const; // determine if type is managed
|
|---|
| 47 |
|
|---|
| 48 | void handleDWT( DeclarationWithType * dwt ); // add type to managed if ctor/dtor
|
|---|
| 49 | void handleStruct( StructDecl * aggregateDecl ); // add type to managed if child is managed
|
|---|
| 50 |
|
|---|
| 51 | void beginScope();
|
|---|
| 52 | void endScope();
|
|---|
| 53 | private:
|
|---|
| 54 | GenPoly::ScopedSet< std::string > managedTypes;
|
|---|
| 55 | };
|
|---|
| 56 |
|
|---|
| 57 | class ManagedTypes_new {
|
|---|
| 58 | public:
|
|---|
| 59 | bool isManaged( const ast::ObjectDecl * objDecl ) const ; // determine if object is managed
|
|---|
| 60 | bool isManaged( const ast::Type * type ) const; // determine if type is managed
|
|---|
| 61 |
|
|---|
| 62 | void handleDWT( const ast::DeclWithType * dwt ); // add type to managed if ctor/dtor
|
|---|
| 63 | void handleStruct( const ast::StructDecl * aggregateDecl ); // add type to managed if child is managed
|
|---|
| 64 |
|
|---|
| 65 | void beginScope();
|
|---|
| 66 | void endScope();
|
|---|
| 67 | private:
|
|---|
| 68 | GenPoly::ScopedSet< std::string > managedTypes;
|
|---|
| 69 | };
|
|---|
| 70 | } // namespace
|
|---|
| 71 |
|
|---|
| 72 | // Local Variables: //
|
|---|
| 73 | // tab-width: 4 //
|
|---|
| 74 | // mode: c++ //
|
|---|
| 75 | // compile-command: "make install" //
|
|---|
| 76 | // End: //
|
|---|