Changeset 85855b0 for src/Parser


Ignore:
Timestamp:
Jun 10, 2024, 2:43:13 AM (4 weeks ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
42cdd07d
Parents:
d68de59
Message:
  1. Implement enum cast; 2. Change valueE so that opague enum returns quasi_void; 3. change enum hiding interpretation and pass visiting scheme
Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.cpp

    rd68de59 r85855b0  
    14651465        ret->hide = td->aggregate.hiding == EnumHiding::Hide ? ast::EnumDecl::EnumHiding::Hide : ast::EnumDecl::EnumHiding::Visible;
    14661466        for ( const DeclarationNode * cur = td->aggregate.fields ; cur != nullptr ; cur = cur->next, ++members ) {
    1467                 if ( cur->enumInLine ) {
    1468                         // Do Nothing
    1469                 } else if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) {
     1467                if (cur->enumInLine) continue;
     1468                ast::Decl * member = members->get_and_mutate();
     1469                ast::ObjectDecl * object = strict_dynamic_cast<ast::ObjectDecl *>( member );
     1470                object->isHidden = ast::EnumDecl::EnumHiding::Hide == ret->hide;
     1471                if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) {
    14701472                        SemanticError( td->location, "Enumerator of enum(void) cannot have an explicit initializer value." );
    14711473                } else if ( cur->has_enumeratorValue() ) {
    1472                         ast::Decl * member = members->get_and_mutate();
    1473                         ast::ObjectDecl * object = strict_dynamic_cast<ast::ObjectDecl *>( member );
    14741474                        object->init = new ast::SingleInit(
    14751475                                td->location,
     
    14771477                                ast::NoConstruct
    14781478                        );
    1479                 } else if ( !cur->initializer ) {
    1480                         if ( baseType && (!dynamic_cast<ast::BasicType *>(baseType) || !dynamic_cast<ast::BasicType *>(baseType)->isInteger())) {
    1481                                 SemanticError( td->location, "Enumerators of an non-integer typed enum must be explicitly initialized." );
    1482                         }
    1483                 }
     1479                }
    14841480                // else cur is a List Initializer and has been set as init in buildList()
    14851481                // if
  • src/Parser/parser.yy

    rd68de59 r85855b0  
    28272827        | enumerator_list ',' visible_hide_opt identifier_or_type_name enumerator_value_opt
    28282828                { $$ = $1->set_last( DeclarationNode::newEnumValueGeneric( $4, $5 ) ); }
    2829         | enumerator_list ',' INLINE type_name enumerator_value_opt
    2830                 { $$ = $1->set_last( DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ) ); }
     2829        | enumerator_list ',' INLINE type_name
     2830                { $$ = $1->set_last( DeclarationNode::newEnumInLine( $4->symbolic.name ) ); }
    28312831        ;
    28322832
Note: See TracChangeset for help on using the changeset viewer.