Ignore:
Timestamp:
Jul 13, 2024, 3:29:22 PM (5 weeks ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
2e6b2a0
Parents:
76b507d
Message:

Remove automatic conversion from Enum type name to its len; change With() semantic for enum to avoid type ambiguity (not fully implemented)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/SymbolTable.cpp

    r76b507d r8315947  
    419419void SymbolTable::addWith( const std::vector< ptr<Expr> > & withExprs, const Decl * withStmt ) {
    420420        for ( const Expr * expr : withExprs ) {
    421                 if ( ! expr->result ) continue;
    422                 const Type * resTy = expr->result->stripReferences();
    423                 auto aggrType = dynamic_cast< const BaseInstType * >( resTy );
    424                 assertf( aggrType, "WithStmt expr has non-aggregate type: %s",
    425                         toString( expr->result ).c_str() );
    426                 const AggregateDecl * aggr = aggrType->aggr();
    427                 assertf( aggr, "WithStmt has null aggregate from type: %s",
    428                         toString( expr->result ).c_str() );
    429 
    430                 addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
     421                if ( expr->result ) {
     422                        const Type * resTy = expr->result->stripReferences();
     423                        auto aggrType = dynamic_cast< const BaseInstType * >( resTy );
     424                        assertf( aggrType, "WithStmt expr has non-aggregate type: %s",
     425                                toString( expr->result ).c_str() );
     426                        const AggregateDecl * aggr = aggrType->aggr();
     427                        assertf( aggr, "WithStmt has null aggregate from type: %s",
     428                                toString( expr->result ).c_str() );
     429
     430                        addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
     431                } else {
     432                        auto typeExpr = dynamic_cast< const ast::TypeExpr *>( expr );
     433                        if ( !typeExpr ) continue;
     434                        auto declEnumInst = typeExpr->type.as<ast::EnumInstType>();
     435                        // assertf( declEnumInst,  "WithStmt expr unsupprot type expression: %s",
     436                        //      toString( typeExpr->type ).c_str());
     437                        if ( !declEnumInst ) continue;
     438                       
     439                        const EnumDecl * aggr = declEnumInst->aggr();
     440                        // assertf( aggr, "WithStmt has null aggregate from type: %s",
     441                        //      toString( typeExpr ).c_str() );
     442                        // addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
     443                        if ( !aggr ) {
     444                                aggr = lookupEnum( declEnumInst->name );
     445                                assert( aggr );
     446                        }
     447                        addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
     448                }
    431449        }
    432450}
     
    800818                if ( auto rty = dynamic_cast<const BaseInstType *>( t ) ) {
    801819                        if ( ! dynamic_cast<const StructInstType *>(rty)
    802                                 && ! dynamic_cast<const UnionInstType *>(rty) ) continue;
     820                                && ! dynamic_cast<const UnionInstType *>(rty)
     821                                && ! dynamic_cast<const EnumInstType *>(rty) ) continue;
    803822                        ResolvExpr::Cost cost = ResolvExpr::Cost::zero;
    804823                        ast::ptr<ast::TypeSubstitution> tmp = expr->env;
Note: See TracChangeset for help on using the changeset viewer.