Changeset 0c327ce for src/Validate


Ignore:
Timestamp:
Jul 12, 2024, 3:30:06 PM (5 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
76b507d
Parents:
9c447e2
Message:
  1. Add bound check to Serial function: now compiler generates the unchecked functions in ImplementEnumFunc?, and enum.hfa implements the bound check on top. Todo: Wrapped the checked version into a trait; 2. countof is now works on any type that implement Countof(). Because Countof() is implemented in enum.hfa for all CfaEnum?, we can call countof on { T | CfaEnum?(T) }
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/ImplementEnumFunc.cpp

    r9c447e2 r0c327ce  
    228228ast::FunctionDecl* EnumAttrFuncGenerator::genFromIntProto() const {
    229229        return genProto(
    230                 "fromInt",
     230                "fromInt_unsafe",
    231231                {new ast::ObjectDecl(getLocation(), "_i", new ast::BasicType(ast::BasicKind::UnsignedInt))},
    232232                {new ast::ObjectDecl(getLocation(), "_ret", new ast::EnumInstType(decl))}
     
    313313                genFromIntProto(),
    314314                genFromInstanceProto(),
    315                 genInstToInstFuncProto("succ"),
    316                 genInstToInstFuncProto("pred")
     315                genInstToInstFuncProto("succ_unsafe"),
     316                genInstToInstFuncProto("pred_unsafe")
    317317        };
    318318        for (auto& proto: protos) produceForwardDecl(proto);
Note: See TracChangeset for help on using the changeset viewer.