| 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 : Peter A. Buhr
 | 
|---|
| 12 | // Last Modified On : Sat Jul 22 09:31:19 2017
 | 
|---|
| 13 | // Update Count     : 4
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #pragma once
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #include <list>                // for list
 | 
|---|
| 19 | #include <string>              // for string
 | 
|---|
| 20 | 
 | 
|---|
| 21 | #include "SynTree/SynTree.h"   // for Visitor Nodes
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #include "GenPoly/ScopedSet.h" // for ScopedSet
 | 
|---|
| 24 | 
 | 
|---|
| 25 | namespace InitTweak {
 | 
|---|
| 26 |         /// Adds return value temporaries and wraps Initializers in ConstructorInit nodes
 | 
|---|
| 27 |         void genInit( std::list< Declaration * > & translationUnit );
 | 
|---|
| 28 | 
 | 
|---|
| 29 |         /// Converts return statements into copy constructor calls on the hidden return variable
 | 
|---|
| 30 |         void fixReturnStatements( std::list< Declaration * > & translationUnit );
 | 
|---|
| 31 | 
 | 
|---|
| 32 |         /// generates a single ctor/dtor statement using objDecl as the 'this' parameter and arg as the optional argument
 | 
|---|
| 33 |         ImplicitCtorDtorStmt * genCtorDtor( const std::string & fname, ObjectDecl * objDecl, Expression * arg = nullptr );
 | 
|---|
| 34 | 
 | 
|---|
| 35 |         /// creates an appropriate ConstructorInit node which contains a constructor, destructor, and C-initializer
 | 
|---|
| 36 |         ConstructorInit * genCtorInit( ObjectDecl * objDecl );
 | 
|---|
| 37 | 
 | 
|---|
| 38 |         class ManagedTypes {
 | 
|---|
| 39 |         public:
 | 
|---|
| 40 |                 bool isManaged( ObjectDecl * objDecl ) const ; // determine if object is managed
 | 
|---|
| 41 |                 bool isManaged( Type * type ) const; // determine if type is managed
 | 
|---|
| 42 | 
 | 
|---|
| 43 |                 void handleDWT( DeclarationWithType * dwt ); // add type to managed if ctor/dtor
 | 
|---|
| 44 |                 void handleStruct( StructDecl * aggregateDecl ); // add type to managed if child is managed
 | 
|---|
| 45 | 
 | 
|---|
| 46 |                 void beginScope();
 | 
|---|
| 47 |                 void endScope();
 | 
|---|
| 48 |         private:
 | 
|---|
| 49 |                 GenPoly::ScopedSet< std::string > managedTypes;
 | 
|---|
| 50 |         };
 | 
|---|
| 51 | } // namespace
 | 
|---|
| 52 | 
 | 
|---|
| 53 | // Local Variables: //
 | 
|---|
| 54 | // tab-width: 4 //
 | 
|---|
| 55 | // mode: c++ //
 | 
|---|
| 56 | // compile-command: "make install" //
 | 
|---|
| 57 | // End: //
 | 
|---|