Changeset 0b3b2ae for src/SymTab
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.