Changeset 0b3b2ae


Ignore:
Timestamp:
Jun 22, 2018, 3:43:19 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
ed34540
Parents:
c194661
git-author:
Rob Schluntz <rschlunt@…> (06/22/18 14:48:30)
git-committer:
Rob Schluntz <rschlunt@…> (06/22/18 15:43:19)
Message:

Minor code cleanup

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rc194661 r0b3b2ae  
    164164                previsit( (BaseSyntaxNode *)node );
    165165                GuardAction( [this, node](){
    166                         if ( printExprTypes ) {
     166                        if ( printExprTypes && node->result ) {
    167167                                output << " /* " << genType( node->result, "", pretty, genC ) << " */ ";
    168168                        }
     
    224224
    225225        void CodeGenerator::handleAggregate( AggregateDecl * aggDecl, const std::string & kind ) {
    226                 if( ! aggDecl->get_parameters().empty() && ! genC ) {
     226                if( ! aggDecl->parameters.empty() && ! genC ) {
    227227                        // assertf( ! genC, "Aggregate type parameters should not reach code generation." );
    228228                        output << "forall(";
    229                         genCommaList( aggDecl->get_parameters().begin(), aggDecl->get_parameters().end() );
     229                        genCommaList( aggDecl->parameters.begin(), aggDecl->parameters.end() );
    230230                        output << ")" << endl;
    231231                        output << indent;
     
    233233
    234234                output << kind;
    235                 genAttributes( aggDecl->get_attributes() );
    236                 output << aggDecl->get_name();
     235                genAttributes( aggDecl->attributes );
     236                output << aggDecl->name;
    237237
    238238                if ( aggDecl->has_body() ) {
    239                         std::list< Declaration * > & memb = aggDecl->get_members();
     239                        std::list< Declaration * > & memb = aggDecl->members;
    240240                        output << " {" << endl;
    241241
  • src/SymTab/Validate.cc

    rc194661 r0b3b2ae  
    379379        void EnumAndPointerDecay::previsit( EnumDecl *enumDecl ) {
    380380                // Set the type of each member of the enumeration to be EnumConstant
    381                 for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) {
     381                for ( std::list< Declaration * >::iterator i = enumDecl->members.begin(); i != enumDecl->members.end(); ++i ) {
    382382                        ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i );
    383383                        assert( obj );
    384                         obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->get_name() ) );
     384                        obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->name ) );
    385385                } // for
    386386        }
     
    539539                        SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );
    540540                } // if
    541                 if ( traitDecl->get_parameters().size() != traitInst->get_parameters().size() ) {
     541                if ( traitDecl->parameters.size() != traitInst->parameters.size() ) {
    542542                        SemanticError( traitInst, "incorrect number of trait parameters: " );
    543543                } // if
     
    715715                if ( eliminator.pass.typedefNames.count( "size_t" ) ) {
    716716                        // grab and remember declaration of size_t
    717                         SizeType = eliminator.pass.typedefNames["size_t"].first->get_base()->clone();
     717                        SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();
    718718                } else {
    719719                        // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong
     
    727727                // instances of typedef types will come here. If it is an instance
    728728                // of a typdef type, link the instance to its actual type.
    729                 TypedefMap::const_iterator def = typedefNames.find( typeInst->get_name() );
     729                TypedefMap::const_iterator def = typedefNames.find( typeInst->name );
    730730                if ( def != typedefNames.end() ) {
    731731                        Type *ret = def->second.first->base->clone();
     
    744744                                        SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name );
    745745                                }
    746                                 rtt->get_parameters().clear();
     746                                rtt->parameters.clear();
    747747                                cloneAll( typeInst->parameters, rtt->parameters );
    748748                                mutateAll( rtt->parameters, *visitor );  // recursively fix typedefs on parameters
     
    751751                        return ret;
    752752                } else {
    753                         TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->get_name() );
     753                        TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->name );
    754754                        assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->name.c_str() );
    755755                        typeInst->set_baseType( base->second );
     
    773773
    774774        Declaration *EliminateTypedef::postmutate( TypedefDecl * tyDecl ) {
    775                 if ( typedefNames.count( tyDecl->get_name() ) == 1 && typedefNames[ tyDecl->get_name() ].second == scopeLevel ) {
     775                if ( typedefNames.count( tyDecl->name ) == 1 && typedefNames[ tyDecl->name ].second == scopeLevel ) {
    776776                        // typedef to the same name from the same scope
    777777                        // must be from the same type
    778778
    779                         Type * t1 = tyDecl->get_base();
    780                         Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base();
     779                        Type * t1 = tyDecl->base;
     780                        Type * t2 = typedefNames[ tyDecl->name ].first->base;
    781781                        if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) {
    782782                                SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
     
    790790                        }
    791791                } else {
    792                         typedefNames[ tyDecl->get_name() ] = std::make_pair( TypedefDeclPtr( tyDecl ), scopeLevel );
     792                        typedefNames[ tyDecl->name ] = std::make_pair( TypedefDeclPtr( tyDecl ), scopeLevel );
    793793                } // if
    794794
     
    802802                // Note, qualifiers on the typedef are superfluous for the forward declaration.
    803803
    804                 Type *designatorType = tyDecl->get_base()->stripDeclarator();
     804                Type *designatorType = tyDecl->base->stripDeclarator();
    805805                if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) {
    806                         return new StructDecl( aggDecl->get_name(), DeclarationNode::Struct, noAttributes, tyDecl->get_linkage() );
     806                        return new StructDecl( aggDecl->name, DeclarationNode::Struct, noAttributes, tyDecl->linkage );
    807807                } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) {
    808                         return new UnionDecl( aggDecl->get_name(), noAttributes, tyDecl->get_linkage() );
     808                        return new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage );
    809809                } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( designatorType ) ) {
    810                         return new EnumDecl( enumDecl->get_name(), noAttributes, tyDecl->get_linkage() );
     810                        return new EnumDecl( enumDecl->name, noAttributes, tyDecl->linkage );
    811811                } else {
    812812                        return tyDecl->clone();
     
    815815
    816816        void EliminateTypedef::premutate( TypeDecl * typeDecl ) {
    817                 TypedefMap::iterator i = typedefNames.find( typeDecl->get_name() );
     817                TypedefMap::iterator i = typedefNames.find( typeDecl->name );
    818818                if ( i != typedefNames.end() ) {
    819819                        typedefNames.erase( i ) ;
    820820                } // if
    821821
    822                 typedeclNames[ typeDecl->get_name() ] = typeDecl;
     822                typedeclNames[ typeDecl->name ] = typeDecl;
    823823        }
    824824
     
    832832
    833833        DeclarationWithType *EliminateTypedef::postmutate( ObjectDecl * objDecl ) {
    834                 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( objDecl->get_type() ) ) { // function type?
     834                if ( FunctionType *funtype = dynamic_cast<FunctionType *>( objDecl->type ) ) { // function type?
    835835                        // replace the current object declaration with a function declaration
    836                         FunctionDecl * newDecl = new FunctionDecl( objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() );
    837                         objDecl->get_attributes().clear();
     836                        FunctionDecl * newDecl = new FunctionDecl( objDecl->name, objDecl->get_storageClasses(), objDecl->linkage, funtype, 0, objDecl->attributes, objDecl->get_funcSpec() );
     837                        objDecl->attributes.clear();
    838838                        objDecl->set_type( nullptr );
    839839                        delete objDecl;
     
    857857                filter( compoundStmt->kids, [](Statement * stmt) {
    858858                        if ( DeclStmt *declStmt = dynamic_cast< DeclStmt * >( stmt ) ) {
    859                                 if ( dynamic_cast< TypedefDecl * >( declStmt->get_decl() ) ) {
     859                                if ( dynamic_cast< TypedefDecl * >( declStmt->decl ) ) {
    860860                                        return true;
    861861                                } // if
     
    10511051
    10521052        void ArrayLength::previsit( ObjectDecl * objDecl ) {
    1053                 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) {
     1053                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) {
    10541054                        if ( at->get_dimension() ) return;
    1055                         if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->get_init() ) ) {
    1056                                 at->set_dimension( new ConstantExpr( Constant::from_ulong( init->get_initializers().size() ) ) );
     1055                        if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->init ) ) {
     1056                                at->set_dimension( new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ) );
    10571057                        }
    10581058                }
  • src/SynTree/ReferenceToType.cc

    rc194661 r0b3b2ae  
    7676bool StructInstType::isComplete() const { return baseStruct ? baseStruct->has_body() : false; }
    7777
    78 AggregateDecl * StructInstType::getAggr() { return baseStruct; }
     78AggregateDecl * StructInstType::getAggr() const { return baseStruct; }
    7979
    8080TypeSubstitution StructInstType::genericSubstitution() const {
     
    119119bool UnionInstType::isComplete() const { return baseUnion ? baseUnion->has_body() : false; }
    120120
    121 AggregateDecl * UnionInstType::getAggr() { return baseUnion; }
     121AggregateDecl * UnionInstType::getAggr() const { return baseUnion; }
    122122
    123123TypeSubstitution UnionInstType::genericSubstitution() const {
     
    152152bool EnumInstType::isComplete() const { return baseEnum ? baseEnum->has_body() : false; }
    153153
     154AggregateDecl * EnumInstType::getAggr() const { return baseEnum; }
     155
    154156void EnumInstType::print( std::ostream &os, Indenter indent ) const {
    155157        using std::endl;
  • src/SynTree/Type.cc

    rc194661 r0b3b2ae  
    129129GlobalScopeType::GlobalScopeType() : Type( Type::Qualifiers(), {} ) {}
    130130
    131 void GlobalScopeType::print( std::ostream & os, Indenter indent ) const {
     131void GlobalScopeType::print( std::ostream & os, Indenter ) const {
    132132        os << "Global Scope Type" << endl;
    133133}
  • src/SynTree/Type.h

    rc194661 r0b3b2ae  
    178178        virtual bool isComplete() const { return true; }
    179179
    180         virtual AggregateDecl * getAggr() { assertf( false, "Non-aggregate type: %s", toCString( this ) ); }
     180        virtual AggregateDecl * getAggr() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); }
    181181
    182182        virtual TypeSubstitution genericSubstitution() const;
     
    431431        virtual bool isComplete() const override;
    432432
    433         virtual AggregateDecl * getAggr() override;
     433        virtual AggregateDecl * getAggr() const override;
    434434
    435435        virtual TypeSubstitution genericSubstitution() const override;
     
    468468        virtual bool isComplete() const override;
    469469
    470         virtual AggregateDecl * getAggr() override;
     470        virtual AggregateDecl * getAggr() const override;
    471471
    472472        virtual TypeSubstitution genericSubstitution() const override;
     
    500500
    501501        virtual bool isComplete() const override;
     502
     503        virtual AggregateDecl * getAggr() const;
    502504
    503505        virtual EnumInstType *clone() const override { return new EnumInstType( *this ); }
Note: See TracChangeset for help on using the changeset viewer.