Changeset 7e23d0a for src/SymTab/Validate.cc
- Timestamp:
- Nov 25, 2015, 2:53:26 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 32d281d, 704c9dd
- Parents:
- 02ec390 (diff), 5189888 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r02ec390 r7e23d0a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Aug 11 16:59:35201513 // Update Count : 19611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Nov 20 16:33:52 2015 13 // Update Count : 201 14 14 // 15 15 … … 54 54 #include "MakeLibCfa.h" 55 55 #include "TypeEquality.h" 56 #include "ResolvExpr/typeops.h" 56 57 57 58 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } … … 125 126 }; 126 127 127 class A ddStructAssignment: public Visitor {128 class AutogenerateRoutines : public Visitor { 128 129 public: 129 130 /// Generates assignment operators for aggregate types as required 130 static void a ddStructAssignment( std::list< Declaration * > &translationUnit );131 static void autogenerateRoutines( std::list< Declaration * > &translationUnit ); 131 132 132 133 std::list< Declaration * > &get_declsToAdd() { return declsToAdd; } … … 151 152 virtual void visit( CatchStmt *catchStmt ); 152 153 153 A ddStructAssignment() : functionNesting( 0 ) {}154 AutogenerateRoutines() : functionNesting( 0 ) {} 154 155 private: 155 156 template< typename StmtClass > void visitStatement( StmtClass *stmt ); … … 195 196 acceptAll( translationUnit, pass1 ); 196 197 acceptAll( translationUnit, pass2 ); 197 // need to collect all of the assignment operators prior to 198 // this point and only generate assignment operators if one doesn't exist 199 AddStructAssignment::addStructAssignment( translationUnit ); 198 AutogenerateRoutines::autogenerateRoutines( translationUnit ); 200 199 acceptAll( translationUnit, pass3 ); 201 200 } … … 501 500 static const std::list< std::string > noLabels; 502 501 503 void A ddStructAssignment::addStructAssignment( std::list< Declaration * > &translationUnit ) {504 A ddStructAssignmentvisitor;502 void AutogenerateRoutines::autogenerateRoutines( std::list< Declaration * > &translationUnit ) { 503 AutogenerateRoutines visitor; 505 504 acceptAndAdd( translationUnit, visitor, false ); 506 505 } … … 704 703 } 705 704 706 void A ddStructAssignment::visit( EnumDecl *enumDecl ) {705 void AutogenerateRoutines::visit( EnumDecl *enumDecl ) { 707 706 if ( ! enumDecl->get_members().empty() ) { 708 707 EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() ); … … 713 712 } 714 713 715 void A ddStructAssignment::visit( StructDecl *structDecl ) {714 void AutogenerateRoutines::visit( StructDecl *structDecl ) { 716 715 if ( ! structDecl->get_members().empty() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) { 717 716 StructInstType *structInst = new StructInstType( Type::Qualifiers(), structDecl->get_name() ); … … 722 721 } 723 722 724 void A ddStructAssignment::visit( UnionDecl *unionDecl ) {723 void AutogenerateRoutines::visit( UnionDecl *unionDecl ) { 725 724 if ( ! unionDecl->get_members().empty() ) { 726 725 UnionInstType *unionInst = new UnionInstType( Type::Qualifiers(), unionDecl->get_name() ); … … 730 729 } 731 730 732 void A ddStructAssignment::visit( TypeDecl *typeDecl ) {731 void AutogenerateRoutines::visit( TypeDecl *typeDecl ) { 733 732 CompoundStmt *stmts = 0; 734 733 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); … … 758 757 } 759 758 760 void A ddStructAssignment::visit( FunctionType *) {759 void AutogenerateRoutines::visit( FunctionType *) { 761 760 // ensure that we don't add assignment ops for types defined as part of the function 762 761 } 763 762 764 void A ddStructAssignment::visit( PointerType *) {763 void AutogenerateRoutines::visit( PointerType *) { 765 764 // ensure that we don't add assignment ops for types defined as part of the pointer 766 765 } 767 766 768 void A ddStructAssignment::visit( ContextDecl *) {767 void AutogenerateRoutines::visit( ContextDecl *) { 769 768 // ensure that we don't add assignment ops for types defined as part of the context 770 769 } 771 770 772 771 template< typename StmtClass > 773 inline void A ddStructAssignment::visitStatement( StmtClass *stmt ) {772 inline void AutogenerateRoutines::visitStatement( StmtClass *stmt ) { 774 773 std::set< std::string > oldStructs = structsDone; 775 774 addVisit( stmt, *this ); … … 777 776 } 778 777 779 void A ddStructAssignment::visit( FunctionDecl *functionDecl ) {778 void AutogenerateRoutines::visit( FunctionDecl *functionDecl ) { 780 779 maybeAccept( functionDecl->get_functionType(), *this ); 781 780 acceptAll( functionDecl->get_oldDecls(), *this ); … … 785 784 } 786 785 787 void A ddStructAssignment::visit( CompoundStmt *compoundStmt ) {786 void AutogenerateRoutines::visit( CompoundStmt *compoundStmt ) { 788 787 visitStatement( compoundStmt ); 789 788 } 790 789 791 void A ddStructAssignment::visit( IfStmt *ifStmt ) {790 void AutogenerateRoutines::visit( IfStmt *ifStmt ) { 792 791 visitStatement( ifStmt ); 793 792 } 794 793 795 void A ddStructAssignment::visit( WhileStmt *whileStmt ) {794 void AutogenerateRoutines::visit( WhileStmt *whileStmt ) { 796 795 visitStatement( whileStmt ); 797 796 } 798 797 799 void A ddStructAssignment::visit( ForStmt *forStmt ) {798 void AutogenerateRoutines::visit( ForStmt *forStmt ) { 800 799 visitStatement( forStmt ); 801 800 } 802 801 803 void A ddStructAssignment::visit( SwitchStmt *switchStmt ) {802 void AutogenerateRoutines::visit( SwitchStmt *switchStmt ) { 804 803 visitStatement( switchStmt ); 805 804 } 806 805 807 void A ddStructAssignment::visit( ChooseStmt *switchStmt ) {806 void AutogenerateRoutines::visit( ChooseStmt *switchStmt ) { 808 807 visitStatement( switchStmt ); 809 808 } 810 809 811 void A ddStructAssignment::visit( CaseStmt *caseStmt ) {810 void AutogenerateRoutines::visit( CaseStmt *caseStmt ) { 812 811 visitStatement( caseStmt ); 813 812 } 814 813 815 void A ddStructAssignment::visit( CatchStmt *cathStmt ) {814 void AutogenerateRoutines::visit( CatchStmt *cathStmt ) { 816 815 visitStatement( cathStmt ); 817 816 } … … 857 856 Type * t1 = tyDecl->get_base(); 858 857 Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base(); 859 if ( ! typeEquals( t1, t2, true) ) {858 if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) { 860 859 throw SemanticError( "cannot redefine typedef: " + tyDecl->get_name() ); 861 860 }
Note: See TracChangeset
for help on using the changeset viewer.