source: src/InitTweak/GenInit.h @ daf4c89

Last change on this file since daf4c89 was 11df881, checked in by Andrew Beach <ajbeach@…>, 2 years ago

Updated documentation on pre-resolver passes, moving code to headers instead of uses. Note that some comments were just copied over, I don't know if they are accurate.

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