Changeset 236f133 for src/Validate


Ignore:
Timestamp:
Jul 11, 2024, 3:04:34 PM (8 days ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
9c447e2
Parents:
9d5eacb
Message:

Remove quasi_void for enums. The idea of quasi_void from Mike was to get around some resolution problem that enum pick function defines for Bounded over CfaEnum/TypedEnum?. But it is not clear that how often this can happen, and cfa might change the cast function scheme in the future. (change cost comparison scheme) Deprecate quasi_void for now so that enum traits looks cleaner without the dummy type for opaque enums

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/ImplementEnumFunc.cpp

    r9d5eacb r236f133  
    2525                : decl(decl),
    2626                  functionNesting{functionNesting},
    27                   quasi_void_decl(new ast::StructDecl(decl->location,
    28                         "quasi_void", ast::AggregateDecl::Struct,
    29                         {}, ast::Linkage::AutoGen)),
     27                //   quasi_void_decl(new ast::StructDecl(decl->location,
     28                //      "quasi_void", ast::AggregateDecl::Struct,
     29                //      {}, ast::Linkage::AutoGen)),
    3030                  proto_linkage{ast::Linkage::Cforall} {}
    3131
     
    208208
    209209ast::FunctionDecl* EnumAttrFuncGenerator::genValueProto() const {
    210         if (decl->isTyped())
    211                 return genProto(
    212                         "value",
    213                         {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
    214                         {new ast::ObjectDecl(getLocation(), "_ret",
    215                                                                 ast::deepCopy(decl->base))});
    216         else
    217                 return genQuasiValueProto();
    218 }
    219 
    220 ast::FunctionDecl* EnumAttrFuncGenerator::genQuasiValueProto() const {
     210        assert (decl->isTyped());
    221211        return genProto(
    222212                "value",
    223213                {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
    224214                {new ast::ObjectDecl(getLocation(), "_ret",
    225                                                 new ast::StructInstType(quasi_void_decl))});
    226 }
     215                                                        ast::deepCopy(decl->base))});
     216        // else
     217        //      return genQuasiValueProto();
     218}
     219
     220// ast::FunctionDecl* EnumAttrFuncGenerator::genQuasiValueProto() const {
     221//      return genProto(
     222//              "value",
     223//              {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
     224//              {new ast::ObjectDecl(getLocation(), "_ret",
     225//                                              new ast::StructInstType(quasi_void_decl))});
     226// }
    227227
    228228ast::FunctionDecl* EnumAttrFuncGenerator::genFromIntProto() const {
     
    390390}
    391391
    392 void EnumAttrFuncGenerator::genQuasiValueBody(ast::FunctionDecl* func) const {
    393         auto location = func->location;
    394         const ast::ObjectDecl * objDecl = new ast::ObjectDecl(
    395                 location, "_out", new ast::StructInstType( quasi_void_decl ));
    396         const ast::DeclStmt * declStmt = new ast::DeclStmt(location, objDecl);
    397         const ast::VariableExpr * varExpr = new ast::VariableExpr(location, objDecl);
    398         const ast::ReturnStmt * retStmt = new ast::ReturnStmt(location, varExpr);
    399 
    400         func->stmts = new ast::CompoundStmt(
    401                 location, {declStmt, retStmt}
    402         );
    403 }
     392// void EnumAttrFuncGenerator::genQuasiValueBody(ast::FunctionDecl* func) const {
     393//      auto location = func->location;
     394//      const ast::ObjectDecl * objDecl = new ast::ObjectDecl(
     395//              location, "_out", new ast::StructInstType( quasi_void_decl ));
     396//      const ast::DeclStmt * declStmt = new ast::DeclStmt(location, objDecl);
     397//      const ast::VariableExpr * varExpr = new ast::VariableExpr(location, objDecl);
     398//      const ast::ReturnStmt * retStmt = new ast::ReturnStmt(location, varExpr);
     399
     400//      func->stmts = new ast::CompoundStmt(
     401//              location, {declStmt, retStmt}
     402//      );
     403// }
    404404
    405405void EnumAttrFuncGenerator::genPosnBody(ast::FunctionDecl* func) const {
     
    433433                        genValueOrLabelBody(funcProto, arrayProto);
    434434                        produceDecl(funcProto);
    435                 }  else {
    436                         ast::FunctionDecl* funcProto = genQuasiValueProto();
    437                         produceForwardDecl(funcProto);
    438                         genQuasiValueBody(funcProto);
    439                         produceDecl(funcProto);
    440                 }
     435                } 
     436                // else {
     437                //      ast::FunctionDecl* funcProto = genQuasiValueProto();
     438                //      produceForwardDecl(funcProto);
     439                //      // genQuasiValueBody(funcProto);
     440                //      produceDecl(funcProto);
     441                // }
    441442        } else if (attr == ast::EnumAttribute::Label) {
    442443                std::vector<ast::ptr<ast::Init>> inits = genLabelInit();
Note: See TracChangeset for help on using the changeset viewer.