Changeset 90152a4 for src/SynTree/ReferenceToType.cc
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (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/SynTree/ReferenceToType.cc
rf9feab8 r90152a4 14 14 // 15 15 16 #include <cassert> // for assert 17 #include <list> // for list, _List_const_iterator, list<>::cons... 18 #include <ostream> // for operator<<, basic_ostream, ostream, endl 19 #include <string> // for string, operator<<, char_traits, operator== 20 21 #include "Common/utility.h" // for printAll, cloneAll, deleteAll 22 #include "Declaration.h" // for StructDecl, UnionDecl, EnumDecl, Declara... 23 #include "Expression.h" // for Expression 24 #include "Type.h" // for TypeInstType, StructInstType, UnionInstType 16 #include <cassert> // for assert 17 #include <list> // for list, _List_const_iterator, list<>::cons... 18 #include <ostream> // for operator<<, basic_ostream, ostream, endl 19 #include <string> // for string, operator<<, char_traits, operator== 20 21 #include "Common/utility.h" // for printAll, cloneAll, deleteAll 22 #include "Declaration.h" // for StructDecl, UnionDecl, EnumDecl, Declara... 23 #include "Expression.h" // for Expression 24 #include "Type.h" // for TypeInstType, StructInstType, UnionInstType 25 #include "TypeSubstitution.h" // for TypeSubstitution 25 26 26 27 class Attribute; … … 49 50 50 51 namespace { 51 void doLookup( const std::list< Declaration * > &members, const std::string &name, std::list< Declaration* > &foundDecls ) {52 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i) {53 if ( (*i)->get_name()== name ) {54 foundDecls.push_back( *i);52 void doLookup( const std::list< Declaration * > & members, const std::string & name, std::list< Declaration* > & foundDecls ) { 53 for ( Declaration * decl : members ) { 54 if ( decl->name == name ) { 55 foundDecls.push_back( decl ); 55 56 } // if 56 57 } // for … … 59 60 60 61 StructInstType::StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes ) : 61 Parent( tq, baseStruct-> get_name(), attributes ), baseStruct( baseStruct ) {}62 Parent( tq, baseStruct->name, attributes ), baseStruct( baseStruct ) {} 62 63 63 64 std::string StructInstType::typeString() const { return "struct"; } 65 66 const std::list<TypeDecl*>* StructInstType::get_baseParameters() const { 67 if ( ! baseStruct ) return nullptr; 68 return &baseStruct->get_parameters(); 69 } 64 70 65 71 std::list<TypeDecl*>* StructInstType::get_baseParameters() { … … 70 76 bool StructInstType::isComplete() const { return baseStruct ? baseStruct->has_body() : false; } 71 77 72 AggregateDecl * StructInstType::getAggr() { return baseStruct; } 78 AggregateDecl * StructInstType::getAggr() const { return baseStruct; } 79 80 TypeSubstitution StructInstType::genericSubstitution() const { 81 return TypeSubstitution( get_baseParameters()->begin(), get_baseParameters()->end(), parameters.begin() ); 82 } 73 83 74 84 void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 75 85 assert( baseStruct ); 76 doLookup( baseStruct-> get_members(), name, foundDecls );86 doLookup( baseStruct->members, name, foundDecls ); 77 87 } 78 88 … … 93 103 94 104 UnionInstType::UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes ) : 95 Parent( tq, baseUnion-> get_name(), attributes ), baseUnion( baseUnion ) {}105 Parent( tq, baseUnion->name, attributes ), baseUnion( baseUnion ) {} 96 106 97 107 std::string UnionInstType::typeString() const { return "union"; } … … 102 112 } 103 113 114 const std::list< TypeDecl * > * UnionInstType::get_baseParameters() const { 115 if ( ! baseUnion ) return nullptr; 116 return &baseUnion->get_parameters(); 117 } 118 104 119 bool UnionInstType::isComplete() const { return baseUnion ? baseUnion->has_body() : false; } 105 120 106 AggregateDecl * UnionInstType::getAggr() { return baseUnion; } 121 AggregateDecl * UnionInstType::getAggr() const { return baseUnion; } 122 123 TypeSubstitution UnionInstType::genericSubstitution() const { 124 return TypeSubstitution( get_baseParameters()->begin(), get_baseParameters()->end(), parameters.begin() ); 125 } 107 126 108 127 void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 109 128 assert( baseUnion ); 110 doLookup( baseUnion-> get_members(), name, foundDecls );129 doLookup( baseUnion->members, name, foundDecls ); 111 130 } 112 131 … … 133 152 bool EnumInstType::isComplete() const { return baseEnum ? baseEnum->has_body() : false; } 134 153 154 AggregateDecl * EnumInstType::getAggr() const { return baseEnum; } 155 135 156 void EnumInstType::print( std::ostream &os, Indenter indent ) const { 136 157 using std::endl;
Note:
See TracChangeset
for help on using the changeset viewer.