Changeset 5eb3f65


Ignore:
Timestamp:
Jun 24, 2024, 11:06:35 PM (4 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
089b39e1, 6803ff1
Parents:
253d0b4
Message:

change enumeration function names labelE, valueE, posE to label, value, posn

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.cfa

    r253d0b4 r5eb3f65  
    66forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V))
    77ostype & ?|?(ostype& os, E e) {
    8     return os | type_name(e) | "." | labelE(e);
     8    return os | type_name(e) | "." | label(e);
    99}
    1010
    1111forall(ostype & | basic_ostream(ostype), E| CfaEnum(E, quasi_void))
    1212ostype & ?|?(ostype& os, E e) {
    13     return os | type_name(e) | "." | labelE(e);
     13    return os | type_name(e) | "." | label(e);
    1414}
    1515
    1616forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V)) {
    17     int ?==?(E l, E r) { return posE(l) == posE(r); }
    18     int ?<=?(E l, E r) { return posE(l) <= posE(r); }
    19     int ?>=?(E l, E r) { return posE(l) >= posE(r); }
    20     int ?<?(E l, E r) { return posE(l) < posE(r); }
    21     int ?>?(E l, E r) { return posE(l) > posE(r); }
     17    int ?==?(E l, E r) { return posn(l) == posn(r); }
     18    int ?<=?(E l, E r) { return posn(l) <= posn(r); }
     19    int ?>=?(E l, E r) { return posn(l) >= posn(r); }
     20    int ?<?(E l, E r) { return posn(l) < posn(r); }
     21    int ?>?(E l, E r) { return posn(l) > posn(r); }
    2222}
  • libcfa/src/enum.hfa

    r253d0b4 r5eb3f65  
    1717// Design one
    1818forall(E, V | Serial(E)) trait CfaEnum {
    19     char* labelE(E e);
    20     unsigned int posE(E e);
    21     V valueE(E e);
    22     char* type_name(E e);
     19    char * label(E e);
     20    unsigned int posn(E e);
     21    V value(E e);
     22    char * type_name(E e);
    2323};
    2424
    25 forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V))
     25forall(ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V))
    2626ostype & ?|?(ostype&, E);
    2727
     
    3131// Design two <- should go for this if we have change the cost model
    3232// forall(E | Serial(E)) trait CfaEnum {
    33 //     char* labelE(E e);
    34 //     unsigned int posE(E e);
     33//     char * label(E e);
     34//     unsigned int posn(E e);
    3535// };
    3636
    3737// forall(E, V| CfaEnum(E)) trait TypedEnum {
    38 //     V valueE(E e);
     38//     V value(E e);
    3939// };
    4040
  • src/ResolvExpr/CandidateFinder.cpp

    r253d0b4 r5eb3f65  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed Jun 5 14:30:00 2019
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Mar 16 11:58:00 2022
    13 // Update Count     : 3
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jun 22 08:07:26 2024
     13// Update Count     : 4
    1414//
    1515
     
    909909                        auto location = expr->location;
    910910                        auto callExpr = new ast::UntypedExpr(
    911                                 location, new ast::NameExpr( location, "valueE" ), {expr}
     911                                location, new ast::NameExpr( location, "value" ), {expr}
    912912                        );
    913913                        finder.find( callExpr );
    914914                        CandidateList winners = findMinCost( finder.candidates );
    915915                        if (winners.size() != 1) {
    916                                 SemanticError( callExpr, "Ambiguous expression in valueE..." );
     916                                SemanticError( callExpr, "Ambiguous expression in value..." );
    917917                        }
    918918                        CandidateRef & choice = winners.front();
  • src/Validate/ImplementEnumFunc.cpp

    r253d0b4 r5eb3f65  
    175175ast::FunctionDecl* EnumAttrFuncGenerator::genPosnProto() const {
    176176    return genProto(
    177         "posE",
     177        "posn",
    178178        {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
    179179        {new ast::ObjectDecl(getLocation(), "_ret",
     
    183183ast::FunctionDecl* EnumAttrFuncGenerator::genLabelProto() const {
    184184        return genProto(
    185                 "labelE",
     185                "label",
    186186                {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
    187187                {new ast::ObjectDecl(
     
    193193        if (decl->base)
    194194                return genProto(
    195                         "valueE",
     195                        "value",
    196196                        {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
    197197                        {new ast::ObjectDecl(getLocation(), "_ret",
     
    203203ast::FunctionDecl* EnumAttrFuncGenerator::genQuasiValueProto() const {
    204204        return genProto(
    205                 "valueE",
     205                "value",
    206206                {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
    207207                {new ast::ObjectDecl(getLocation(), "_ret",
     
    254254        auto param = params.front();
    255255        ast::UntypedExpr* untyped = ast::UntypedExpr::createCall(
    256                 func->location, "posE", { new ast::VariableExpr(func->location, param) });
     256                func->location, "posn", { new ast::VariableExpr(func->location, param) });
    257257        func->stmts = new ast::CompoundStmt(
    258258                func->location, {new ast::ReturnStmt(func->location, untyped)}
  • tests/enum_tests/enumInlineValue.cfa

    r253d0b4 r5eb3f65  
    3838// Note: variable name (cat in this case) cannot be overloaded with those declared in enum,
    3939// Probably for the same reason as const overloading problem
    40 // i.e. int identity_t(enum ACD a) would not work as the valueE(a) is ambigious currently
     40// i.e. int identity_t(enum ACD a) would not work as the value(a) is ambigious currently
    4141int identity_t(enum ACD cat) {
    42     return valueE(cat);
     42    return value(cat);
    4343}
    4444
     
    4747    // Because Inline introduce ambiguity on symbols
    4848    sout | "Symbols (enumerator) should have the same values:" |nl;
    49     sout | "Symbol a: (10) " | valueE(A.a) | "," | valueE(AB.a) | "," | valueE(ACD.a) | nl;
    50     sout | "Symbol b: (20) " | valueE(B.b) | "," | valueE(AB.b) | nl;
    51     sout | "Symbol ab: (30) " | valueE(AB.ab) | nl;
    52     sout | "Symbol c: (40) " | valueE(C.c) | "," | valueE(CD.c) | "," | valueE(ACD.c) | nl;
    53     sout | "Symbol d: (50) " | valueE(D.d) | "," | valueE(CD.d) | "," | valueE(ACD.d) | nl;
    54     sout | "Symbol cd: (60) " | valueE(CD.cd) | "," | valueE(ACD.cd) | nl;
    55     sout | "Symbol acd: (70) " | valueE(ACD.acd) | nl;
     49    sout | "Symbol a: (10) " | value(A.a) | "," | value(AB.a) | "," | value(ACD.a) | nl;
     50    sout | "Symbol b: (20) " | value(B.b) | "," | value(AB.b) | nl;
     51    sout | "Symbol ab: (30) " | value(AB.ab) | nl;
     52    sout | "Symbol c: (40) " | value(C.c) | "," | value(CD.c) | "," | value(ACD.c) | nl;
     53    sout | "Symbol d: (50) " | value(D.d) | "," | value(CD.d) | "," | value(ACD.d) | nl;
     54    sout | "Symbol cd: (60) " | value(CD.cd) | "," | value(ACD.cd) | nl;
     55    sout | "Symbol acd: (70) " | value(ACD.acd) | nl;
    5656
    5757    sout | "Casting/Upcasting:" | nl;
    58     sout | "Symbol a: (10) " | valueE((A)A.a) | "," | valueE((AB)A.a) | "," | valueE((ACD)A.a) | nl;
    59     sout | "Symbol b: (20) " | valueE((B)B.b) | "," | valueE((AB)B.b) | nl;
    60     sout | "Symbol ab: (30) " | valueE((AB)AB.ab) | nl;
    61     sout | "Symbol c: (40) " | valueE((C)C.c) | "," | valueE((CD)C.c) | "," | valueE((ACD)C.c) | "," | valueE((CD)CD.c)| "," | valueE((ACD)CD.c) | nl;
    62     sout | "Symbol d: (50) " | valueE((D)D.d) | "," | valueE((CD)D.d) | "," | valueE((ACD)D.d) | "," | valueE((ACD)CD.d) | nl;
    63     sout | "Symbol cd: (60) " | valueE((CD)CD.cd) | "," | valueE((ACD)CD.cd) | nl;
    64     sout | "Symbol acd: (70) " | valueE((ACD)ACD.acd) | nl;
     58    sout | "Symbol a: (10) " | value((A)A.a) | "," | value((AB)A.a) | "," | value((ACD)A.a) | nl;
     59    sout | "Symbol b: (20) " | value((B)B.b) | "," | value((AB)B.b) | nl;
     60    sout | "Symbol ab: (30) " | value((AB)AB.ab) | nl;
     61    sout | "Symbol c: (40) " | value((C)C.c) | "," | value((CD)C.c) | "," | value((ACD)C.c) | "," | value((CD)CD.c)| "," | value((ACD)CD.c) | nl;
     62    sout | "Symbol d: (50) " | value((D)D.d) | "," | value((CD)D.d) | "," | value((ACD)D.d) | "," | value((ACD)CD.d) | nl;
     63    sout | "Symbol cd: (60) " | value((CD)CD.cd) | "," | value((ACD)CD.cd) | nl;
     64    sout | "Symbol acd: (70) " | value((ACD)ACD.acd) | nl;
    6565
    6666    sout | "Function Call:" | nl;
  • tests/enum_tests/position.cfa

    r253d0b4 r5eb3f65  
    1717    Colour c2 = fishy;
    1818
    19     sout | "Compile Time: blue value: " | valueE(Colour.Blue) | ", position: " | posE(Colour.Blue) | ", label: " | labelE(Colour.Blue) | ", default return value: " | Colour.Blue;
    20     sout | "Runtime: fishy value: " | valueE(fishy) | ", position: " | posE(fishy) | ", label: " | labelE(fishy) | ", default return value: " | fishy;
    21     sout | "Runtime: C2 value: " | valueE(c2) | ", position: " | posE(c2) | ", label: " | labelE(c2) | ", default return value: " | c2;
     19    sout | "Compile Time: blue value: " | value(Colour.Blue) | ", position: " | posn(Colour.Blue) | ", label: " | label(Colour.Blue) | ", default return value: " | Colour.Blue;
     20    sout | "Runtime: fishy value: " | value(fishy) | ", position: " | posn(fishy) | ", label: " | label(fishy) | ", default return value: " | fishy;
     21    sout | "Runtime: C2 value: " | value(c2) | ", position: " | posn(c2) | ", label: " | label(c2) | ", default return value: " | c2;
    2222    Colour.Red;
    2323    char * ao = Colour.Red;
  • tests/enum_tests/voidEnum.cfa

    r253d0b4 r5eb3f65  
    2828    sout | b;
    2929   
    30     sout | labelE(v_1);
    31     sout | labelE(v_2);
    32 
     30    sout | label(v_1);
     31    sout | label(v_2);
    3332}
Note: See TracChangeset for help on using the changeset viewer.