- Timestamp:
- Jun 22, 2018, 3:43:19 PM (6 years ago)
- 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)
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rc194661 r0b3b2ae 164 164 previsit( (BaseSyntaxNode *)node ); 165 165 GuardAction( [this, node](){ 166 if ( printExprTypes ) {166 if ( printExprTypes && node->result ) { 167 167 output << " /* " << genType( node->result, "", pretty, genC ) << " */ "; 168 168 } … … 224 224 225 225 void CodeGenerator::handleAggregate( AggregateDecl * aggDecl, const std::string & kind ) { 226 if( ! aggDecl-> get_parameters().empty() && ! genC ) {226 if( ! aggDecl->parameters.empty() && ! genC ) { 227 227 // assertf( ! genC, "Aggregate type parameters should not reach code generation." ); 228 228 output << "forall("; 229 genCommaList( aggDecl-> get_parameters().begin(), aggDecl->get_parameters().end() );229 genCommaList( aggDecl->parameters.begin(), aggDecl->parameters.end() ); 230 230 output << ")" << endl; 231 231 output << indent; … … 233 233 234 234 output << kind; 235 genAttributes( aggDecl-> get_attributes());236 output << aggDecl-> get_name();235 genAttributes( aggDecl->attributes ); 236 output << aggDecl->name; 237 237 238 238 if ( aggDecl->has_body() ) { 239 std::list< Declaration * > & memb = aggDecl-> get_members();239 std::list< Declaration * > & memb = aggDecl->members; 240 240 output << " {" << endl; 241 241 -
src/SymTab/Validate.cc
rc194661 r0b3b2ae 379 379 void EnumAndPointerDecay::previsit( EnumDecl *enumDecl ) { 380 380 // 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 ) { 382 382 ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i ); 383 383 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 ) ); 385 385 } // for 386 386 } … … 539 539 SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name ); 540 540 } // if 541 if ( traitDecl-> get_parameters().size() != traitInst->get_parameters().size() ) {541 if ( traitDecl->parameters.size() != traitInst->parameters.size() ) { 542 542 SemanticError( traitInst, "incorrect number of trait parameters: " ); 543 543 } // if … … 715 715 if ( eliminator.pass.typedefNames.count( "size_t" ) ) { 716 716 // 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(); 718 718 } else { 719 719 // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong … … 727 727 // instances of typedef types will come here. If it is an instance 728 728 // 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 ); 730 730 if ( def != typedefNames.end() ) { 731 731 Type *ret = def->second.first->base->clone(); … … 744 744 SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name ); 745 745 } 746 rtt-> get_parameters().clear();746 rtt->parameters.clear(); 747 747 cloneAll( typeInst->parameters, rtt->parameters ); 748 748 mutateAll( rtt->parameters, *visitor ); // recursively fix typedefs on parameters … … 751 751 return ret; 752 752 } else { 753 TypeDeclMap::const_iterator base = typedeclNames.find( typeInst-> get_name());753 TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->name ); 754 754 assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->name.c_str() ); 755 755 typeInst->set_baseType( base->second ); … … 773 773 774 774 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 ) { 776 776 // typedef to the same name from the same scope 777 777 // must be from the same type 778 778 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; 781 781 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 782 782 SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name ); … … 790 790 } 791 791 } else { 792 typedefNames[ tyDecl-> get_name()] = std::make_pair( TypedefDeclPtr( tyDecl ), scopeLevel );792 typedefNames[ tyDecl->name ] = std::make_pair( TypedefDeclPtr( tyDecl ), scopeLevel ); 793 793 } // if 794 794 … … 802 802 // Note, qualifiers on the typedef are superfluous for the forward declaration. 803 803 804 Type *designatorType = tyDecl-> get_base()->stripDeclarator();804 Type *designatorType = tyDecl->base->stripDeclarator(); 805 805 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 ); 807 807 } 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 ); 809 809 } 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 ); 811 811 } else { 812 812 return tyDecl->clone(); … … 815 815 816 816 void EliminateTypedef::premutate( TypeDecl * typeDecl ) { 817 TypedefMap::iterator i = typedefNames.find( typeDecl-> get_name());817 TypedefMap::iterator i = typedefNames.find( typeDecl->name ); 818 818 if ( i != typedefNames.end() ) { 819 819 typedefNames.erase( i ) ; 820 820 } // if 821 821 822 typedeclNames[ typeDecl-> get_name()] = typeDecl;822 typedeclNames[ typeDecl->name ] = typeDecl; 823 823 } 824 824 … … 832 832 833 833 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? 835 835 // 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(); 838 838 objDecl->set_type( nullptr ); 839 839 delete objDecl; … … 857 857 filter( compoundStmt->kids, [](Statement * stmt) { 858 858 if ( DeclStmt *declStmt = dynamic_cast< DeclStmt * >( stmt ) ) { 859 if ( dynamic_cast< TypedefDecl * >( declStmt-> get_decl()) ) {859 if ( dynamic_cast< TypedefDecl * >( declStmt->decl ) ) { 860 860 return true; 861 861 } // if … … 1051 1051 1052 1052 void ArrayLength::previsit( ObjectDecl * objDecl ) { 1053 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl-> get_type()) ) {1053 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) { 1054 1054 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() ) ) ); 1057 1057 } 1058 1058 } -
src/SynTree/ReferenceToType.cc
rc194661 r0b3b2ae 76 76 bool StructInstType::isComplete() const { return baseStruct ? baseStruct->has_body() : false; } 77 77 78 AggregateDecl * StructInstType::getAggr() { return baseStruct; }78 AggregateDecl * StructInstType::getAggr() const { return baseStruct; } 79 79 80 80 TypeSubstitution StructInstType::genericSubstitution() const { … … 119 119 bool UnionInstType::isComplete() const { return baseUnion ? baseUnion->has_body() : false; } 120 120 121 AggregateDecl * UnionInstType::getAggr() { return baseUnion; }121 AggregateDecl * UnionInstType::getAggr() const { return baseUnion; } 122 122 123 123 TypeSubstitution UnionInstType::genericSubstitution() const { … … 152 152 bool EnumInstType::isComplete() const { return baseEnum ? baseEnum->has_body() : false; } 153 153 154 AggregateDecl * EnumInstType::getAggr() const { return baseEnum; } 155 154 156 void EnumInstType::print( std::ostream &os, Indenter indent ) const { 155 157 using std::endl; -
src/SynTree/Type.cc
rc194661 r0b3b2ae 129 129 GlobalScopeType::GlobalScopeType() : Type( Type::Qualifiers(), {} ) {} 130 130 131 void GlobalScopeType::print( std::ostream & os, Indenter indent) const {131 void GlobalScopeType::print( std::ostream & os, Indenter ) const { 132 132 os << "Global Scope Type" << endl; 133 133 } -
src/SynTree/Type.h
rc194661 r0b3b2ae 178 178 virtual bool isComplete() const { return true; } 179 179 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 ) ); } 181 181 182 182 virtual TypeSubstitution genericSubstitution() const; … … 431 431 virtual bool isComplete() const override; 432 432 433 virtual AggregateDecl * getAggr() override;433 virtual AggregateDecl * getAggr() const override; 434 434 435 435 virtual TypeSubstitution genericSubstitution() const override; … … 468 468 virtual bool isComplete() const override; 469 469 470 virtual AggregateDecl * getAggr() override;470 virtual AggregateDecl * getAggr() const override; 471 471 472 472 virtual TypeSubstitution genericSubstitution() const override; … … 500 500 501 501 virtual bool isComplete() const override; 502 503 virtual AggregateDecl * getAggr() const; 502 504 503 505 virtual EnumInstType *clone() const override { return new EnumInstType( *this ); }
Note: See TracChangeset
for help on using the changeset viewer.