Changeset c194661
- Timestamp:
- Jun 20, 2018, 11:23:42 AM (6 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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 0b3b2ae
- Parents:
- 9a7a3b6
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/GenType.cc
r9a7a3b6 rc194661 48 48 void postvisit( ZeroType * zeroType ); 49 49 void postvisit( OneType * oneType ); 50 void postvisit( GlobalScopeType * globalType ); 50 51 void postvisit( TraitInstType * inst ); 51 52 void postvisit( TypeofType * typeof ); 53 void postvisit( QualifiedType * qualType ); 52 54 53 55 private: … … 291 293 } 292 294 295 void GenType::postvisit( GlobalScopeType * globalType ) { 296 assertf( ! genC, "Global scope type should not reach code generation." ); 297 handleQualifiers( globalType ); 298 } 299 293 300 void GenType::postvisit( TraitInstType * inst ) { 294 301 assertf( ! genC, "Trait types should not reach code generation." ); … … 307 314 } 308 315 316 void GenType::postvisit( QualifiedType * qualType ) { 317 assertf( ! genC, "Qualified types should not reach code generation." ); 318 std::ostringstream os; 319 os << genType( qualType->parent, "", pretty, genC, lineMarks ) << "." << genType( qualType->child, "", pretty, genC, lineMarks ); 320 typeString = os.str(); 321 handleQualifiers( qualType ); 322 } 323 309 324 void GenType::handleQualifiers( Type * type ) { 310 325 if ( type->get_const() ) { -
src/Common/PassVisitor.impl.h
r9a7a3b6 rc194661 2268 2268 2269 2269 maybeAccept_impl( node->forall, *this ); 2270 maybeAccept_impl( node->types, *this ); 2270 maybeAccept_impl( node->parent, *this ); 2271 maybeAccept_impl( node->child, *this ); 2271 2272 2272 2273 VISIT_END( node ); … … 2278 2279 2279 2280 maybeMutate_impl( node->forall, *this ); 2280 maybeMutate_impl( node->types, *this ); 2281 maybeMutate_impl( node->parent, *this ); 2282 maybeMutate_impl( node->child, *this ); 2281 2283 2282 2284 MUTATE_END( Type, node ); -
src/Parser/DeclarationNode.cc
r9a7a3b6 rc194661 261 261 262 262 DeclarationNode * DeclarationNode::newQualifiedType( DeclarationNode * parent, DeclarationNode * child) { 263 return child; 264 // return parent->add_last( child ); 263 DeclarationNode * newnode = new DeclarationNode; 264 newnode->type = new TypeData( TypeData::Qualified ); 265 newnode->type->qualified.parent = parent->type; 266 newnode->type->qualified.child = child->type; 267 parent->type = nullptr; 268 child->type = nullptr; 269 delete parent; 270 delete child; 271 return newnode; 265 272 } 266 273 -
src/Parser/TypeData.cc
r9a7a3b6 rc194661 99 99 case Builtin: 100 100 // builtin = new Builtin_t; 101 case Qualified: 102 qualified.parent = nullptr; 103 qualified.child = nullptr; 101 104 break; 102 105 } // switch … … 167 170 // delete builtin; 168 171 break; 172 case Qualified: 173 delete qualified.parent; 174 delete qualified.child; 169 175 } // switch 170 176 } // TypeData::~TypeData … … 240 246 assert( builtintype == DeclarationNode::Zero || builtintype == DeclarationNode::One ); 241 247 newtype->builtintype = builtintype; 248 break; 249 case Qualified: 250 newtype->qualified.parent = maybeClone( qualified.parent ); 251 newtype->qualified.child = maybeClone( qualified.child ); 242 252 break; 243 253 } // switch … … 468 478 return new EnumInstType( buildQualifiers( td ), "" ); 469 479 case TypeData::SymbolicInst: 470 return buildSymbolicInst( td ); ;480 return buildSymbolicInst( td ); 471 481 case TypeData::Tuple: 472 482 return buildTuple( td ); … … 483 493 return new VarArgsType( buildQualifiers( td ) ); 484 494 } 495 case TypeData::GlobalScope: 496 return new GlobalScopeType(); 497 case TypeData::Qualified: 498 return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) ); 485 499 case TypeData::Symbolic: 486 500 case TypeData::Enum: … … 488 502 assert( false ); 489 503 } // switch 504 490 505 return nullptr; 491 506 } // typebuild -
src/Parser/TypeData.h
r9a7a3b6 rc194661 27 27 struct TypeData { 28 28 enum Kind { Basic, Pointer, Array, Reference, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic, 29 SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Unknown };29 SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Qualified, Unknown }; 30 30 31 31 struct Aggregate_t { … … 75 75 }; 76 76 77 struct Qualified_t { // qualified type S.T 78 TypeData * parent; 79 TypeData * child; 80 }; 81 77 82 CodeLocation location; 78 83 … … 94 99 Function_t function; 95 100 Symbolic_t symbolic; 101 Qualified_t qualified; 96 102 DeclarationNode * tuple; 97 103 ExpressionNode * typeexpr; -
src/SynTree/Type.cc
r9a7a3b6 rc194661 106 106 107 107 108 QualifiedType::QualifiedType( const Type::Qualifiers & tq, const std::list< Type * > & types ) : Type( tq, {} ), types( types) {108 QualifiedType::QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child ) : Type( tq, {} ), parent( parent ), child( child ) { 109 109 } 110 110 111 QualifiedType::QualifiedType( const QualifiedType & other ) : Type( other ) { 112 cloneAll( other.types, types ); 111 QualifiedType::QualifiedType( const QualifiedType & other ) : Type( other ), parent( maybeClone( other.parent ) ), child( maybeClone( other.child ) ) { 113 112 } 114 113 115 114 QualifiedType::~QualifiedType() { 116 deleteAll( types ); 115 delete parent; 116 delete child; 117 117 } 118 118 119 119 void QualifiedType::print( std::ostream & os, Indenter indent ) const { 120 120 os << "Qualified Type: " << endl; 121 printAll( types, os, indent+1 ); 121 os << indent+1; 122 parent->print( os, indent+1 ); 123 os << endl << indent+1; 124 child->print( os, indent+1 ); 125 os << endl; 122 126 Type::print( os, indent+1 ); 123 127 } -
src/SynTree/Type.h
r9a7a3b6 rc194661 317 317 class QualifiedType : public Type { 318 318 public: 319 std::list<Type *> types; 320 321 QualifiedType( const Type::Qualifiers & tq, const std::list< Type * > & types ); 319 Type * parent; 320 Type * child; 321 322 QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child ); 322 323 QualifiedType( const QualifiedType & tq ); 323 324 virtual ~QualifiedType();
Note: See TracChangeset
for help on using the changeset viewer.