Changeset acb33f15 for src/Validate


Ignore:
Timestamp:
May 13, 2024, 10:26:52 AM (8 weeks ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
31f4837
Parents:
41c8312
Message:

Change enum conversion steps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/ImplementEnumFunc.cpp

    r41c8312 racb33f15  
    7272                ast::DeclWithType* decl = declPtr.get_and_mutate();
    7373                decl->attributes.push_back(new ast::Attribute("unused"));
    74         }
    75 
    76         ast::ObjectDecl* dstParam() const {
    77                 return new ast::ObjectDecl(getLocation(), "_dst",
    78                                            new ast::ReferenceType(new ast::EnumAttrType(
    79                                                ast::deepCopy(instType))));
    80         }
    81 
    82         ast::ObjectDecl* srcParam() const {
    83                 return new ast::ObjectDecl(
    84                         getLocation(), "_src",
    85                         new ast::EnumAttrType(ast::deepCopy(instType)));
    8674        }
    8775
     
    329317}
    330318
    331 inline ast::EnumAttrType * getPosnType( const ast::EnumDecl * decl ) {
    332         return new ast::EnumAttrType(new ast::EnumInstType(decl), ast::EnumAttribute::Posn);
    333 }
    334 
    335319ast::ObjectDecl* EnumAttrFuncGenerator::genAttrArrayProto(
    336320        const ast::EnumAttribute attr, const CodeLocation& location,
     
    360344                        func->location,
    361345                        new ast::VariableExpr( func->location, func->params.front() ),
    362                         new ast::EnumAttrType( new ast::EnumInstType(decl),
    363                                 ast::EnumAttribute::Posn))});
     346                        new ast::BasicType( ast::BasicKind::UnsignedInt ),
     347                        ast::GeneratedFlag::ExplicitCast
     348                )});
    364349        func->stmts = new ast::CompoundStmt(
    365350                func->location, {new ast::ReturnStmt(func->location, untyped)});
     
    370355                func->location,
    371356                new ast::VariableExpr(func->location, func->params.front()),
    372                 new ast::EnumAttrType(new ast::EnumInstType(decl),
    373                                                           ast::EnumAttribute::Posn));
     357                new ast::BasicType( ast::BasicKind::UnsignedInt ),
     358                        ast::GeneratedFlag::ExplicitCast);
    374359        func->stmts = new ast::CompoundStmt(
    375360                func->location, {new ast::ReturnStmt(func->location, castExpr)});
Note: See TracChangeset for help on using the changeset viewer.