Ignore:
Timestamp:
Apr 3, 2022, 8:49:42 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
92538ab
Parents:
3eb1653
Message:

Update the String Enum implementation. The declaration now can handles creating the enum decl. But the compilation fails when trying to create reference to the Enum. Need a way to resolve InstTypes?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r3eb1653 r4559b34  
    14701470                        // enumerator initializers should not use the enum type to initialize, since the
    14711471                        // 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
    14751497                }
    14761498                else {
Note: See TracChangeset for help on using the changeset viewer.