Changeset b726084 for src/ResolvExpr
- Timestamp:
- Nov 9, 2016, 2:51:42 PM (8 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 30b65d8, d073e3c
- Parents:
- 141b786 (diff), 84118d8 (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. - Location:
- src/ResolvExpr
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/AlternativeFinder.h ¶
r141b786 rb726084 95 95 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ); 96 96 97 void resolveObject( const SymTab::Indexer & indexer, ObjectDecl * objectDecl );98 99 97 template< typename InputIterator, typename OutputIterator > 100 98 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { -
TabularUnified src/ResolvExpr/AlternativePrinter.h ¶
r141b786 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AlternativePrinter.h -- 7 // AlternativePrinter.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 23 23 24 24 namespace ResolvExpr { 25 class AlternativePrinter : public SymTab::Indexer {25 class AlternativePrinter final : public SymTab::Indexer { 26 26 public: 27 27 AlternativePrinter( std::ostream &os ); 28 virtual void visit( ExprStmt *exprStmt ); 28 29 using SymTab::Indexer::visit; 30 virtual void visit( ExprStmt *exprStmt ) override; 29 31 private: 30 32 std::ostream &os; -
TabularUnified src/ResolvExpr/Resolver.cc ¶
r141b786 rb726084 33 33 34 34 namespace ResolvExpr { 35 class Resolver : public SymTab::Indexer {35 class Resolver final : public SymTab::Indexer { 36 36 public: 37 37 Resolver() : SymTab::Indexer( false ) {} 38 Resolver( const SymTab::Indexer & indexer ) : SymTab::Indexer( indexer ) {} 39 40 virtual void visit( FunctionDecl *functionDecl ) ;41 virtual void visit( ObjectDecl * objectDecl );42 virtual void visit( TypeDecl *typeDecl ) ;43 virtual void visit( EnumDecl * enumDecl ) ;44 45 virtual void visit( ArrayType * at ) ;46 virtual void visit( PointerType * at ) ;47 48 virtual void visit( ExprStmt *exprStmt ) ;49 virtual void visit( AsmExpr *asmExpr ) ;50 virtual void visit( AsmStmt *asmStmt ) ;51 virtual void visit( IfStmt *ifStmt ) ;52 virtual void visit( WhileStmt *whileStmt ) ;53 virtual void visit( ForStmt *forStmt ) ;54 virtual void visit( SwitchStmt *switchStmt ) ;55 virtual void visit( CaseStmt *caseStmt ) ;56 virtual void visit( BranchStmt *branchStmt ) ;57 virtual void visit( ReturnStmt *returnStmt ) ;58 59 virtual void visit( SingleInit *singleInit ) ;60 virtual void visit( ListInit *listInit ) ;61 virtual void visit( ConstructorInit *ctorInit ) ;38 39 using SymTab::Indexer::visit; 40 virtual void visit( FunctionDecl *functionDecl ) override; 41 virtual void visit( ObjectDecl *functionDecl ) override; 42 virtual void visit( TypeDecl *typeDecl ) override; 43 virtual void visit( EnumDecl * enumDecl ) override; 44 45 virtual void visit( ArrayType * at ) override; 46 virtual void visit( PointerType * at ) override; 47 48 virtual void visit( ExprStmt *exprStmt ) override; 49 virtual void visit( AsmExpr *asmExpr ) override; 50 virtual void visit( AsmStmt *asmStmt ) override; 51 virtual void visit( IfStmt *ifStmt ) override; 52 virtual void visit( WhileStmt *whileStmt ) override; 53 virtual void visit( ForStmt *forStmt ) override; 54 virtual void visit( SwitchStmt *switchStmt ) override; 55 virtual void visit( CaseStmt *caseStmt ) override; 56 virtual void visit( BranchStmt *branchStmt ) override; 57 virtual void visit( ReturnStmt *returnStmt ) override; 58 59 virtual void visit( SingleInit *singleInit ) override; 60 virtual void visit( ListInit *listInit ) override; 61 virtual void visit( ConstructorInit *ctorInit ) override; 62 62 private: 63 63 typedef std::list< Initializer * >::iterator InitIterator; … … 69 69 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 70 70 void fallbackInit( ConstructorInit * ctorInit ); 71 71 72 Type * functionReturn = nullptr; 72 73 Type *initContext = nullptr; … … 533 534 } 534 535 535 void resolveObject( const SymTab::Indexer & indexer, ObjectDecl * objectDecl ) {536 Resolver resolver( indexer );537 objectDecl->accept( resolver );538 }539 540 536 void Resolver::visit( ConstructorInit *ctorInit ) { 541 537 // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit -
TabularUnified src/ResolvExpr/TypeMap.h ¶
r141b786 rb726084 38 38 typedef typename std::map< std::string, Value* > ValueMap; 39 39 typedef typename ValueMap::iterator ValueMapIterator; 40 40 41 41 Value *voidValue; ///< Value for void type 42 42 Value *basicValue[BasicType::NUMBER_OF_BASIC_TYPES]; ///< Values for basic types … … 54 54 /// One scope of map rollbacks 55 55 typedef std::vector< std::pair< ValueMapIterator, Value* > > MapScope; 56 56 57 57 PointerScope pointers; ///< Value pointers to roll back to their previous state 58 58 MapScope mapNodes; ///< Value map iterators to roll back to their previous state … … 68 68 69 69 std::vector< Rollback > scopes; ///< Scope rollback information 70 70 71 71 struct Lookup : public Visitor { 72 72 Lookup( TypeMap<Value> &typeMap ) : typeMap( typeMap ), found( 0 ), toInsert( 0 ) {} … … 87 87 return found; 88 88 } 89 89 90 90 void findAndReplace( Value *&loc ) { 91 91 found = loc; … … 109 109 } 110 110 } 111 111 112 112 virtual void visit( VoidType *voidType ) { 113 113 findAndReplace( typeMap.voidValue ); 114 114 } 115 115 116 116 virtual void visit( BasicType *basicType ) { 117 117 findAndReplace( typeMap.basicValue[basicType->get_kind()] ); 118 118 } 119 119 120 120 virtual void visit( PointerType *pointerType ) { 121 121 // NOTE This is one of the places where the apporoximation of the resolver is (deliberately) poor; … … 129 129 } 130 130 } 131 131 132 132 virtual void visit( ArrayType *arrayType ) { 133 133 if ( dynamic_cast< FunctionType* >( arrayType->get_base() ) ) { … … 137 137 } 138 138 } 139 139 140 140 virtual void visit( FunctionType *functionType ) { 141 141 findAndReplace( typeMap.functionPointerValue ); 142 142 } 143 143 144 144 virtual void visit( StructInstType *structType ) { 145 145 findAndReplace( typeMap.structValue, structType->get_name() ); 146 146 } 147 147 148 148 virtual void visit( UnionInstType *unionType ) { 149 149 findAndReplace( typeMap.unionValue, unionType->get_name() ); 150 150 } 151 151 152 152 virtual void visit( EnumInstType *enumType ) { 153 153 findAndReplace( typeMap.enumValue, enumType->get_name() ); … … 157 157 Value *found; ///< Value found (NULL if none yet) 158 158 Value *toInsert; ///< Value to insert (NULL if a lookup) 159 }; // classLookup160 friend classLookup;161 159 }; // struct Lookup 160 friend struct Lookup; 161 162 162 public: 163 163 /// Starts a new scope … … 180 180 scopes.pop_back(); 181 181 } 182 182 183 183 TypeMap() : voidValue( 0 ), pointerValue( 0 ), voidPointerValue( 0 ), functionPointerValue( 0 ), structValue(), unionValue(), enumValue(), scopes() { 184 184 beginScope(); … … 199 199 return searcher.find( key ); 200 200 } 201 201 202 202 }; // class TypeMap 203 203 -
TabularUnified src/ResolvExpr/Unify.cc ¶
r141b786 rb726084 73 73 const OpenVarSet &openVars; 74 74 WidenMode widenMode; 75 Type *commonType;76 75 const SymTab::Indexer &indexer; 77 76 };
Note: See TracChangeset
for help on using the changeset viewer.