Changeset 9e2c1f0 for src/SynTree


Ignore:
Timestamp:
May 6, 2016, 4:28:50 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
ec79847
Parents:
99ee64d (diff), 03e5d14 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'global-init' into ctor and add global destroy function to call destructors on global objects

Conflicts:

src/CodeGen/CodeGenerator.cc
src/InitTweak/module.mk
src/Makefile.in
src/SynTree/Declaration.h
src/SynTree/FunctionDecl.cc
src/main.cc

Location:
src/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    r99ee64d r9e2c1f0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 11 16:55:12 2016
    13 // Update Count     : 36
     12// Last Modified On : Fri May 06 16:26:12 2016
     13// Update Count     : 33
    1414//
    1515
     
    115115        typedef DeclarationWithType Parent;
    116116  public:
    117         FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn );
     117        // temporary - merge this into general GCC attributes
     118        struct Attribute {
     119                enum Type {
     120                        NoAttribute, Constructor, Destructor,
     121                } type;
     122                enum Priority {
     123                        // priorities 0-100 are reserved by gcc, so it's okay to use 100 an exceptional case
     124                        Default = 100, High,
     125                } priority;
     126                Attribute(Type t = NoAttribute, Priority p = Default) : type(t), priority(p) {};
     127        };
     128
     129        FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = Attribute() );
    118130        FunctionDecl( const FunctionDecl &other );
    119131        virtual ~FunctionDecl();
     
    128140        std::list< std::string >& get_oldIdents() { return oldIdents; }
    129141        std::list< Declaration* >& get_oldDecls() { return oldDecls; }
     142        Attribute get_attribute() const { return attribute; }
     143        void set_attribute( Attribute newValue ) { attribute = newValue; }
    130144
    131145        virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
     
    139153        std::list< std::string > oldIdents;
    140154        std::list< Declaration* > oldDecls;
     155        Attribute attribute;
    141156};
    142157
  • src/SynTree/FunctionDecl.cc

    r99ee64d r9e2c1f0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue May 03 15:37:43 2016
     12// Last Modified On : Fri May 06 15:59:48 2016
    1313// Update Count     : 19
    1414//
     
    2121#include "Common/utility.h"
    2222
    23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )
    24                 : Parent( name, sc, linkage ), type( type ), statements( statements ) {
     23FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute )
     24                : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute( attribute ) {
    2525        set_isInline( isInline );
    2626        set_isNoreturn( isNoreturn );
     
    3232
    3333FunctionDecl::FunctionDecl( const FunctionDecl &other )
    34         : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
     34        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) {
    3535}
    3636
     
    6565                os << "_Noreturn ";
    6666        } // if
     67        switch ( attribute.type ) {
     68                case Attribute::Constructor:
     69                        os << "Global Constructor ";
     70                        break;
     71                case Attribute::Destructor:
     72                        os << "Global Destructor ";
     73                        break;
     74                default:
     75                        break;
     76        }
     77        if ( attribute.priority != Attribute::Default ) {
     78                os << "with priority " << attribute.priority << " ";
     79        }
    6780        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    6881                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     
    105118                os << "_Noreturn ";
    106119        } // if
     120        switch ( attribute.type ) {
     121                case Attribute::Constructor:
     122                        os << " Global Constructor ";
     123                        break;
     124                case Attribute::Destructor:
     125                        os << " Global Destructor ";
     126                        break;
     127                default:
     128                        break;
     129        }
     130        if ( attribute.priority != Attribute::Default ) {
     131                os << "with priority " << attribute.priority << " ";
     132        }
    107133        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    108134                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
Note: See TracChangeset for help on using the changeset viewer.