Changeset dd020c0 for src/SynTree


Ignore:
Timestamp:
Mar 3, 2017, 10:12:02 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
8191203
Parents:
f37147b
Message:

first attempt to create function specifiers

Location:
src/SynTree
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/SynTree/Declaration.cc

    rf37147b rdd020c0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  9 14:28:05 2017
    13 // Update Count     : 16
     12// Last Modified On : Wed Mar  1 20:11:57 2017
     13// Update Count     : 17
    1414//
    1515
     
    2828
    2929Declaration::Declaration( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage )
    30                 : name( name ), storageClass( sc ), linkage( linkage ), isInline( false ), isNoreturn( false ), uniqueId( 0 ) {
     30                : name( name ), storageClass( sc ), linkage( linkage ), uniqueId( 0 ) {
    3131}
    3232
    3333Declaration::Declaration( const Declaration &other )
    34         : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), isInline( other.isInline ), isNoreturn( other.isNoreturn ), uniqueId( other.uniqueId ) {
     34        : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), uniqueId( other.uniqueId ) {
    3535}
    3636
  • TabularUnified src/SynTree/Declaration.h

    rf37147b rdd020c0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 14:53:35 2017
    13 // Update Count     : 57
     12// Last Modified On : Fri Mar  3 20:59:27 2017
     13// Update Count     : 96
    1414//
    1515
     
    3838        LinkageSpec::Spec get_linkage() const { return linkage; }
    3939        void set_linkage( LinkageSpec::Spec newValue ) { linkage = newValue; }
    40         bool get_isInline() const { return isInline; }
    41         void set_isInline( bool newValue ) { isInline = newValue; }
    42         bool get_isNoreturn() const { return isNoreturn; }
    43         void set_isNoreturn( bool newValue ) { isNoreturn = newValue; }
    4440        UniqueId get_uniqueId() const { return uniqueId; }
    4541        bool get_extension() const { return extension; }
     
    5955        DeclarationNode::StorageClass storageClass;
    6056        LinkageSpec::Spec linkage;
    61         bool isInline, isNoreturn;
    6257        UniqueId uniqueId;
    6358        bool extension = false;
     
    6661class DeclarationWithType : public Declaration {
    6762  public:
    68         DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes );
     63        DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpec fs = DeclarationNode::FuncSpec() );
    6964        DeclarationWithType( const DeclarationWithType &other );
    7065        virtual ~DeclarationWithType();
     
    8378        std::list< Attribute * >& get_attributes() { return attributes; }
    8479        const std::list< Attribute * >& get_attributes() const { return attributes; }
     80
     81        DeclarationNode::FuncSpec get_funcSpec() const { return fs; }
     82        void set_functionSpecifiers( DeclarationNode::FuncSpec newValue ) { fs = newValue; }
    8583
    8684        virtual DeclarationWithType *clone() const = 0;
     
    9795        ConstantExpr *asmName;
    9896        std::list< Attribute * > attributes;
     97        DeclarationNode::FuncSpec fs;
    9998};
    10099
     
    102101        typedef DeclarationWithType Parent;
    103102  public:
    104         ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes = std::list< Attribute * >(), bool isInline = false, bool isNoreturn = false );
     103        ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
     104                                const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpec fs = DeclarationNode::FuncSpec() );
    105105        ObjectDecl( const ObjectDecl &other );
    106106        virtual ~ObjectDecl();
     
    129129        typedef DeclarationWithType Parent;
    130130  public:
    131         FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, const std::list< Attribute * > attributes = std::list< Attribute * >() );
     131        FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
     132                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpec fs = DeclarationNode::FuncSpec() );
    132133        FunctionDecl( const FunctionDecl &other );
    133134        virtual ~FunctionDecl();
  • TabularUnified src/SynTree/DeclarationWithType.cc

    rf37147b rdd020c0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 13 14:49:43 2016
    13 // Update Count     : 7
     12// Last Modified On : Fri Mar  3 20:59:28 2017
     13// Update Count     : 19
    1414//
    1515
     
    1919#include "Common/utility.h"
    2020
    21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes )
    22         : Declaration( name, sc, linkage ), asmName( nullptr ), attributes( attributes ) {
     21DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpec fs )
     22        : Declaration( name, sc, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) {
    2323}
    2424
    2525DeclarationWithType::DeclarationWithType( const DeclarationWithType &other )
    26                 : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) {
     26        : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ), fs( other.fs ) {
    2727        cloneAll( other.attributes, attributes );
    2828        asmName = maybeClone( other.asmName );
  • TabularUnified src/SynTree/FunctionDecl.cc

    rf37147b rdd020c0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 15:01:52 2017
    13 // Update Count     : 23
     12// Last Modified On : Fri Mar  3 21:29:41 2017
     13// Update Count     : 55
    1414//
    1515
     
    2626extern bool translation_unit_nomain;
    2727
    28 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, std::list< Attribute * > attributes )
    29                 : Parent( name, sc, linkage, attributes ), type( type ), statements( statements ) {
    30         set_isInline( isInline );
    31         set_isNoreturn( isNoreturn );
    32         // this is a brazen hack to force the function "main" to have Cforall linkage
    33         // because we want to replace the main even if it is inside an extern
     28FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, DeclarationNode::FuncSpec fs )
     29                : Parent( name, sc, linkage, attributes, fs ), type( type ), statements( statements ) {
     30        set_functionSpecifiers( fs );
     31
     32        // hack forcing the function "main" to have Cforall linkage to replace main even if it is inside an extern
    3433        if ( name == "main" ) {
    3534                set_linkage( CodeGen::FixMain::mainLinkage() );
     
    6564                os << LinkageSpec::linkageName( get_linkage() ) << " ";
    6665        } // if
    67         if ( get_isInline() ) {
    68                 os << "inline ";
    69         } // if
    70         if ( get_isNoreturn() ) {
    71                 os << "_Noreturn ";
    72         } // if
    7366
    7467        printAll( get_attributes(), os, indent );
    7568
    7669        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    77                 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     70                os << DeclarationNode::storageClassNames[ get_storageClass() ] << ' ';
    7871        } // if
     72        DeclarationNode::print_FuncSpec( os, get_funcSpec() );
     73
    7974        if ( get_type() ) {
    8075                get_type()->print( os, indent );
     
    9792                os << get_name() << ": ";
    9893        } // if
    99         if ( get_isInline() ) {
    100                 os << "inline ";
    101         } // if
    102         if ( get_isNoreturn() ) {
    103                 os << "_Noreturn ";
    104         } // if
    10594
    10695        // xxx - should printShort print attributes?
    10796
    10897        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    109                 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     98                os << DeclarationNode::storageClassNames[ get_storageClass() ] << ' ';
    11099        } // if
     100        DeclarationNode::print_FuncSpec( os, get_funcSpec() );
     101
    111102        if ( get_type() ) {
    112103                get_type()->print( os, indent );
  • TabularUnified src/SynTree/NamedTypeDecl.cc

    rf37147b rdd020c0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 13 08:13:55 2015
    13 // Update Count     : 3
     12// Last Modified On : Tue Feb 28 16:13:24 2017
     13// Update Count     : 4
    1414//
    1515
     
    4040        } // if
    4141        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    42                 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     42                os << DeclarationNode::storageClassNames[ get_storageClass() ] << ' ';
    4343        } // if
    4444        os << typeString();
     
    6464        } // if
    6565        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    66                 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     66                os << DeclarationNode::storageClassNames[ get_storageClass() ] << ' ';
    6767        } // if
    6868        os << typeString();
  • TabularUnified src/SynTree/ObjectDecl.cc

    rf37147b rdd020c0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Oct  1 23:05:56 2016
    13 // Update Count     : 32
     12// Last Modified On : Fri Mar  3 20:59:27 2017
     13// Update Count     : 45
    1414//
    1515
     
    2222#include "Statement.h"
    2323
    24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, bool isInline, bool isNoreturn )
    25         : Parent( name, sc, linkage, attributes ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
    26         set_isInline( isInline );
    27         set_isNoreturn( isNoreturn );
     24ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpec fs )
     25        : Parent( name, sc, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
     26        set_functionSpecifiers( fs );
    2827}
    2928
     
    5049
    5150        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    52                 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     51                os << DeclarationNode::storageClassNames[ get_storageClass() ] << ' ';
    5352        } // if
    5453
     
    8685
    8786        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    88                 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     87                os << DeclarationNode::storageClassNames[ get_storageClass() ] << ' ';
    8988        } // if
    9089
  • TabularUnified src/SynTree/Type.h

    rf37147b rdd020c0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 23 16:38:53 2017
    13 // Update Count     : 34
     12// Last Modified On : Wed Mar  1 09:11:45 2017
     13// Update Count     : 41
    1414//
    1515
     
    2121#include "SynTree.h"
    2222#include "Visitor.h"
    23 #include "Common/utility.h"
    2423
    2524class Type : public BaseSyntaxNode {
     
    213212        bool get_isVarArgs() const { return isVarArgs; }
    214213        void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
    215 
    216214        bool isTtype() const;
    217215
Note: See TracChangeset for help on using the changeset viewer.