Changeset 5d125e4 for src/SynTree


Ignore:
Timestamp:
Jul 15, 2016, 10:16:47 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, 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:
873ffb7
Parents:
5ed9061
Message:

start code allowing structures to no fields

Location:
src/SynTree
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AggregateDecl.cc

    r5ed9061 r5d125e4  
    1010// Created On       : Sun May 17 23:56:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:28:00 2016
    13 // Update Count     : 7
     12// Last Modified On : Wed Jul 13 18:03:30 2016
     13// Update Count     : 10
    1414//
    1515
     
    1919
    2020
    21 AggregateDecl::AggregateDecl( const std::string &name ) : Parent( name, DeclarationNode::NoStorageClass, LinkageSpec::Cforall ) {
     21AggregateDecl::AggregateDecl( const std::string &name ) : Parent( name, DeclarationNode::NoStorageClass, LinkageSpec::Cforall ), body( false ) {
    2222}
    2323
     
    2525        cloneAll( other.members, members );
    2626        cloneAll( other.parameters, parameters );
     27        body = other.body;
    2728}
    2829
     
    3738
    3839        os << typeString() << " " << get_name();
     40        os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
     41
    3942        if ( ! parameters.empty() ) {
    4043                os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
     
    5255
    5356        os << typeString() << " " << get_name();
     57        os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
     58
    5459        if ( ! parameters.empty() ) {
    5560                os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
  • src/SynTree/Declaration.h

    r5ed9061 r5d125e4  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 30 21:17:24 2016
    13 // Update Count     : 38
     12// Last Modified On : Tue Jul 12 21:03:17 2016
     13// Update Count     : 39
    1414//
    1515
     
    210210        std::list<TypeDecl*>& get_parameters() { return parameters; }
    211211
     212        bool has_body() const { return body; }
     213        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
     214
    212215        virtual void print( std::ostream &os, int indent = 0 ) const;
    213216        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     
    218221        std::list<Declaration*> members;
    219222        std::list<TypeDecl*> parameters;
     223        bool body;
    220224};
    221225
     
    229233        virtual void accept( Visitor &v ) { v.visit( this ); }
    230234        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    231 
    232235  private:
    233236        virtual std::string typeString() const;
  • src/SynTree/ReferenceToType.cc

    r5ed9061 r5d125e4  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:28:51 2016
    13 // Update Count     : 5
     12// Last Modified On : Wed Jul 13 18:03:30 2016
     13// Update Count     : 9
    1414//
    1515
     
    6969}
    7070
     71void StructInstType::print( std::ostream &os, int indent ) const {
     72        using std::endl;
     73
     74        if ( baseStruct == NULL ) ReferenceToType::print( os, indent );
     75        else {
     76                Type::print( os, indent );
     77                os << "instance of " << typeString() << " " << name << " with body " << baseStruct->has_body() << " ";
     78                if ( ! parameters.empty() ) {
     79                        os << endl << std::string( indent, ' ' ) << "with parameters" << endl;
     80                        printAll( parameters, os, indent+2 );
     81                } // if
     82        } // if
     83}
     84
    7185std::string UnionInstType::typeString() const { return "union"; }
    7286
     
    7993        assert( baseUnion );
    8094        doLookup( baseUnion->get_members(), baseUnion->get_parameters(), parameters, name, foundDecls );
     95}
     96
     97void UnionInstType::print( std::ostream &os, int indent ) const {
     98        using std::endl;
     99
     100        if ( baseUnion == NULL ) ReferenceToType::print( os, indent );
     101        else {
     102                Type::print( os, indent );
     103                os << "instance of " << typeString() << " " << name << " with body " << baseUnion->has_body() << " ";
     104                if ( ! parameters.empty() ) {
     105                        os << endl << std::string( indent, ' ' ) << "with parameters" << endl;
     106                        printAll( parameters, os, indent+2 );
     107                } // if
     108        } // if
    81109}
    82110
  • src/SynTree/Type.h

    r5ed9061 r5d125e4  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:29:08 2016
    13 // Update Count     : 21
     12// Last Modified On : Wed Jul 13 11:46:54 2016
     13// Update Count     : 23
    1414//
    1515
     
    226226        virtual std::string typeString() const = 0;
    227227        std::list< Expression* > parameters;
    228   private:
    229228        std::string name;
     229  private:
    230230};
    231231
     
    249249        virtual void accept( Visitor &v ) { v.visit( this ); }
    250250        virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     251
     252        virtual void print( std::ostream &os, int indent = 0 ) const;
    251253  private:
    252254        virtual std::string typeString() const;
     
    276278        virtual void accept( Visitor &v ) { v.visit( this ); }
    277279        virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     280
     281        virtual void print( std::ostream &os, int indent = 0 ) const;
    278282  private:
    279283        virtual std::string typeString() const;
Note: See TracChangeset for help on using the changeset viewer.