- Timestamp:
- Apr 3, 2022, 8:49:42 PM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 92538ab
- Parents:
- 3eb1653
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r3eb1653 r4559b34 1468 1468 return strict_dynamic_cast< ast::Decl * >( node ); 1469 1469 } 1470 1470 1471 1471 ConverterOldToNew() = default; 1472 1472 ConverterOldToNew(const ConverterOldToNew &) = delete; … … 2771 2771 ast::EnumInstType * ty; 2772 2772 if ( old->baseEnum ) { 2773 ty = new ast::EnumInstType{ 2773 ty = new ast::EnumInstType{ // Probably here: missing the specification of the base 2774 2774 GET_ACCEPT_1( baseEnum, EnumDecl ), 2775 2775 cv( old ), -
src/AST/Decl.hpp
r3eb1653 r4559b34 317 317 const char * typeString() const override { return aggrString( Enum ); } 318 318 319 bool isTyped() {return base && base.get();} 320 319 321 private: 320 322 EnumDecl * clone() const override { return new EnumDecl{ *this }; } -
src/AST/Print.cpp
r3eb1653 r4559b34 210 210 } 211 211 212 auto ptrToEnum = dynamic_cast<const ast::EnumDecl *>(node); 213 if ( ! short_mode && ptrToEnum && ptrToEnum->base ) { 214 os << endl << indent << ".. with (enum) base" << endl; 215 ++indent; 216 ptrToEnum->base->accept( *this ); 217 --indent; 218 } 219 212 220 os << endl; 213 221 } -
src/Common/PassVisitor.impl.h
r3eb1653 r4559b34 754 754 755 755 // unlike structs, traits, and unions, enums inject their members into the global scope 756 if ( node->base ) maybeAccept_impl( node->base, *this ); // Need this? Maybe not?756 // if ( node->base ) maybeAccept_impl( node->base, *this ); // Need this? Maybe not? 757 757 maybeAccept_impl( node->parameters, *this ); 758 758 maybeAccept_impl( node->members , *this ); -
src/ResolvExpr/Resolver.cc
r3eb1653 r4559b34 1470 1470 // enumerator initializers should not use the enum type to initialize, since the 1471 1471 // enum type is still incomplete at this point. Use `int` instead. 1472 objectDecl = fixObjectType(objectDecl, symtab); 1473 currentObject = ast::CurrentObject{ 1474 objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } }; 1472 1473 if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) { // const ast::PointerType & 1474 const ast::Type * enumBase = (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get()); 1475 const ast::PointerType * enumBaseAsPtr = dynamic_cast<const ast::PointerType *>(enumBase); 1476 1477 if ( enumBaseAsPtr ) { 1478 const ast::Type * pointerBase = enumBaseAsPtr->base.get(); 1479 if ( dynamic_cast<const ast::BasicType *>(pointerBase) ) { 1480 objectDecl = fixObjectType(objectDecl, symtab); 1481 if (dynamic_cast<const ast::BasicType *>(pointerBase)->kind == ast::BasicType::Char) 1482 currentObject = ast::CurrentObject{ 1483 objectDecl->location, new ast::PointerType{ 1484 new ast::BasicType{ ast::BasicType::Char } 1485 } }; 1486 } else { 1487 objectDecl = fixObjectType(objectDecl, symtab); 1488 currentObject = ast::CurrentObject{objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } }; 1489 } 1490 } 1491 } else { 1492 objectDecl = fixObjectType(objectDecl, symtab); 1493 currentObject = ast::CurrentObject{ 1494 objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } }; 1495 } 1496 1475 1497 } 1476 1498 else { -
src/SymTab/Validate.cc
r3eb1653 r4559b34 939 939 // need to resolve enumerator initializers early so that other passes that determine if an expression is constexpr have the appropriate information. 940 940 SingleInit * init = strict_dynamic_cast<SingleInit *>( field->init ); 941 ResolvExpr::findSingleExpression( init->value, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), indexer ); 941 if ( !enumDecl->base || dynamic_cast<BasicType *>(enumDecl->base)) 942 ResolvExpr::findSingleExpression( init->value, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), indexer ); 943 else { 944 if (dynamic_cast<PointerType *>(enumDecl->base)) { 945 auto typePtr = dynamic_cast<PointerType *>(enumDecl->base); 946 ResolvExpr::findSingleExpression( init->value, 947 new PointerType( Type::Qualifiers(), typePtr->base ), indexer ); 948 } else { 949 ResolvExpr::findSingleExpression( init->value, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), indexer ); 950 } 951 } 952 942 953 } 943 954 } 955 944 956 } // if 945 957 } -
src/SynTree/AggregateDecl.cc
r3eb1653 r4559b34 59 59 } // if 60 60 os << " with body " << has_body(); 61 62 61 if ( ! parameters.empty() ) { 63 62 os << endl << indent << "... with parameters" << endl; … … 106 105 const char * EnumDecl::typeString() const { return aggrString( Enum ); } 107 106 107 void EnumDecl::print( std::ostream & os, Indenter indent ) const { 108 AggregateDecl::print(os, indent); 109 os << " with base? " << (base? "True" : "False") << std::endl; 110 if ( base ) { 111 os << "Base Type of Enum:" << std::endl; 112 base->print(os, indent); 113 } 114 os << std::endl << "End of EnumDecl::print" << std::endl; 115 } 116 108 117 const char * TraitDecl::typeString() const { return aggrString( Trait ); } 109 118 -
src/SynTree/Declaration.h
r3eb1653 r4559b34 290 290 AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; } 291 291 292 virtual void print( std::ostream & os, Indenter indent = {} ) const override final;292 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 293 293 virtual void printShort( std::ostream & os, Indenter indent = {} ) const override; 294 294 protected: … … 352 352 Type * base; 353 353 std::unordered_map< std::string, long long int > enumValues; 354 virtual void print( std::ostream & os, Indenter indent = {} ) const override final; 354 355 private: 355 356 // std::unordered_map< std::string, long long int > enumValues;
Note: See TracChangeset
for help on using the changeset viewer.