Changeset 6dba8755 for src/Virtual
- Timestamp:
- Jul 31, 2020, 11:06:44 AM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 95789be
- Parents:
- 0c760db
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Virtual/ExpandCasts.cc
r0c760db r6dba8755 10 10 // Created On : Mon Jul 24 13:59:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jul 22 10:04:00 202013 // Update Count : 312 // Last Modified On : Fri Jul 31 10:29:00 2020 13 // Update Count : 4 14 14 // 15 15 … … 18 18 #include <cassert> // for assert, assertf 19 19 #include <iterator> // for back_inserter, inserter 20 #include <map> // for map, _Rb_tree_iterator, map<>::ite...21 20 #include <string> // for string, allocator, operator==, ope... 22 #include <utility> // for pair23 21 24 22 #include "Common/PassVisitor.h" // for PassVisitor 23 #include "Common/ScopedMap.h" // for ScopedMap 25 24 #include "Common/SemanticError.h" // for SemanticError 26 25 #include "SymTab/Mangler.h" // for mangleType … … 37 36 /// Maps virtual table types the instance for that type. 38 37 class VirtualTableMap final { 39 std::unordered_map<std::string, ObjectDecl *> vtable_instances;38 ScopedMap<std::string, ObjectDecl *> vtable_instances; 40 39 public: 40 void enterScope() { 41 vtable_instances.beginScope(); 42 } 43 void leaveScope() { 44 vtable_instances.endScope(); 45 } 46 41 47 ObjectDecl * insert( ObjectDecl * vtableDecl ) { 42 48 std::string const & mangledName = SymTab::Mangler::mangleType( vtableDecl->type ); … … 93 99 94 100 class VirtualCastCore { 95 VirtualTableMap vtable_instances;96 FunctionDecl *vcast_decl;97 StructDecl *pvt_decl;98 99 101 Type * pointer_to_pvt(int level_of_indirection) { 100 102 Type * type = new StructInstType( … … 108 110 public: 109 111 VirtualCastCore() : 110 vtable_instances(), vcast_decl( nullptr ), pvt_decl( nullptr )112 indexer(), vcast_decl( nullptr ), pvt_decl( nullptr ) 111 113 {} 112 114 … … 116 118 117 119 Expression * postmutate( VirtualCastExpr * castExpr ); 120 121 VirtualTableMap indexer; 122 private: 123 FunctionDecl *vcast_decl; 124 StructDecl *pvt_decl; 118 125 }; 119 126 … … 135 142 void VirtualCastCore::premutate( ObjectDecl * objectDecl ) { 136 143 if ( is_vtable_inst_name( objectDecl->get_name() ) ) { 137 if ( ObjectDecl * existing = vtable_instances.insert( objectDecl ) ) {144 if ( ObjectDecl * existing = indexer.insert( objectDecl ) ) { 138 145 std::string msg = "Repeated instance of virtual table, original found at: "; 139 146 msg += existing->location.filename; … … 222 229 223 230 const Type * vtable_type = getVirtualTableType( castExpr ); 224 ObjectDecl * table = vtable_instances.lookup( vtable_type );231 ObjectDecl * table = indexer.lookup( vtable_type ); 225 232 if ( nullptr == table ) { 226 233 SemanticError( castLocation( castExpr ),
Note: See TracChangeset
for help on using the changeset viewer.