Changeset 62e5546 for src/ResolvExpr
- Timestamp:
- Oct 27, 2016, 4:22:27 PM (9 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:
- 0ebac75
- Parents:
- d93d980
- Location:
- src/ResolvExpr
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativePrinter.h
rd93d980 r62e5546 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; -
src/ResolvExpr/Resolver.cc
rd93d980 r62e5546 32 32 33 33 namespace ResolvExpr { 34 class Resolver : public SymTab::Indexer {34 class Resolver final : public SymTab::Indexer { 35 35 public: 36 Resolver() : SymTab::Indexer( false ), switchType( 0 ) {} 37 38 virtual void visit( FunctionDecl *functionDecl ); 39 virtual void visit( ObjectDecl *functionDecl ); 40 virtual void visit( TypeDecl *typeDecl ); 41 virtual void visit( EnumDecl * enumDecl ); 42 43 virtual void visit( ArrayType * at ); 44 virtual void visit( PointerType * at ); 45 46 virtual void visit( ExprStmt *exprStmt ); 47 virtual void visit( AsmExpr *asmExpr ); 48 virtual void visit( AsmStmt *asmStmt ); 49 virtual void visit( IfStmt *ifStmt ); 50 virtual void visit( WhileStmt *whileStmt ); 51 virtual void visit( ForStmt *forStmt ); 52 virtual void visit( SwitchStmt *switchStmt ); 53 virtual void visit( CaseStmt *caseStmt ); 54 virtual void visit( BranchStmt *branchStmt ); 55 virtual void visit( ReturnStmt *returnStmt ); 56 57 virtual void visit( SingleInit *singleInit ); 58 virtual void visit( ListInit *listInit ); 59 virtual void visit( ConstructorInit *ctorInit ); 36 Resolver() : SymTab::Indexer( false ) {} 37 38 using SymTab::Indexer::visit; 39 virtual void visit( FunctionDecl *functionDecl ) override; 40 virtual void visit( ObjectDecl *functionDecl ) override; 41 virtual void visit( TypeDecl *typeDecl ) override; 42 virtual void visit( EnumDecl * enumDecl ) override; 43 44 virtual void visit( ArrayType * at ) override; 45 virtual void visit( PointerType * at ) override; 46 47 virtual void visit( ExprStmt *exprStmt ) override; 48 virtual void visit( AsmExpr *asmExpr ) override; 49 virtual void visit( AsmStmt *asmStmt ) override; 50 virtual void visit( IfStmt *ifStmt ) override; 51 virtual void visit( WhileStmt *whileStmt ) override; 52 virtual void visit( ForStmt *forStmt ) override; 53 virtual void visit( SwitchStmt *switchStmt ) override; 54 virtual void visit( CaseStmt *caseStmt ) override; 55 virtual void visit( BranchStmt *branchStmt ) override; 56 virtual void visit( ReturnStmt *returnStmt ) override; 57 58 virtual void visit( SingleInit *singleInit ) override; 59 virtual void visit( ListInit *listInit ) override; 60 virtual void visit( ConstructorInit *ctorInit ) override; 60 61 private: 61 62 typedef std::list< Initializer * >::iterator InitIterator; … … 69 70 std::list< Type * > functionReturn; 70 71 Type *initContext; 71 Type *switchType;72 72 bool inEnumDecl = false; 73 73 }; -
src/ResolvExpr/TypeMap.h
rd93d980 r62e5546 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 -
src/ResolvExpr/Unify.cc
rd93d980 r62e5546 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.