Changes in / [1e12f07:d39d8a4]


Ignore:
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.hfa

    r1e12f07 rd39d8a4  
    6666                return l;
    6767        }
    68 
    69         E ?+=? ( E & l, one_t ) {
    70                 l = succ(l);
    71                 return l;
    72         }
    73        
    74         E ?-=? ( E & l, one_t ) {
    75                 l = pred(l);
    76                 return l;
    77         }
    78 
    79         E ?+=? ( E & l, int i ) {
    80                 int pos = posn(l) + i;
    81                 return fromInt(pos);
    82         }
    83 
    84         E ?-=? ( E & l, int i ) {
    85                 int pos = posn(l) - i;
    86                 return fromInt(pos);
    87         }
    8868       
    8969        E ?++( E & l ) {
  • src/ControlStruct/TranslateEnumRange.cpp

    r1e12f07 rd39d8a4  
    55
    66namespace ControlStruct {
     7
     8struct addInitType {
     9    const ast::Stmt * postvisit( const ast::ForStmt * stmt );
     10};
    711
    812struct addInit {
     
    1317    const ast::Stmt * postvisit( const ast::ForStmt * stmt );
    1418};
     19
     20const ast::Stmt* addInitType::postvisit( const ast::ForStmt * stmt ) {
     21    if ( stmt->range_over ) {
     22        auto typeExpr = stmt->range_over.strict_as<ast::TypeExpr>();
     23        auto type = typeExpr->type;
     24
     25        auto objInit = stmt->inits.front();
     26        assert( stmt->inits.size() == 1 );
     27
     28        if (auto declStmt = objInit.as<ast::DeclStmt>()) {
     29            auto decl = declStmt->decl;
     30            if ( auto objDecl = decl.as<ast::ObjectDecl>()) {
     31                if ( !objDecl->type && type ) {
     32                    auto objDeclWithType = ast::mutate_field( objDecl, &ast::ObjectDecl::type, type );
     33                    auto declWithType = ast::mutate_field( declStmt, &ast::DeclStmt::decl, objDeclWithType );
     34                    stmt = ast::mutate_field_index( stmt, &ast::ForStmt::inits, 0, declWithType );
     35                }
     36            }
     37        }
     38    }
     39    return stmt;
     40}
    1541
    1642const ast::Stmt* addInit::postvisit( const ast::ForStmt * stmt ) {
     
    6187    mut = ast::mutate_field(stmt, &ast::ForStmt::inc, assig );
    6288    return mut;
    63 } 
     89}
    6490
    6591void translateEnumRange( ast::TranslationUnit & translationUnit ) {
  • src/ResolvExpr/CandidateFinder.cpp

    r1e12f07 rd39d8a4  
    938938                        addAggMembers( unionInst, aggrExpr, *cand, Cost::unsafe, "" );
    939939                } else if ( auto enumInst = aggrExpr->result.as< ast::EnumInstType >() ) {
    940                         addEnumValueAsCandidate( enumInst, aggrExpr, Cost::implicit );
     940                        addEnumValueAsCandidate(enumInst, aggrExpr, Cost::unsafe);
    941941                }
    942942        }
  • src/ResolvExpr/Cost.hpp

    r1e12f07 rd39d8a4  
    3131                #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
    3232                        // Little-endian => first value is low priority and last is high priority.
     33                        unsigned char padding;                                  ///< unused
    3334                        unsigned char referenceCost;                    ///< reference conversions
    3435                        unsigned char specCost;                                 ///< Polymorphic type specializations (type assertions), negative cost
     
    3738                        unsigned char safeCost;                                 ///< Safe (widening) conversions
    3839                        unsigned char polyCost;                                 ///< Count of parameters and return values bound to some poly type
    39                         unsigned char implicitCost;                             ///< Aggregate implicit cost
    4040                        unsigned char unsafeCost;                               ///< Unsafe (narrowing) conversions
    4141                #else
     
    4646        };
    4747        static const unsigned char correctb = 0xff;             // byte correction for negative spec cost
    48         static const uint64_t correctw = 0x00'00'00'00'00'00'ff'00; //' word correction for negative spec cost
     48        static const uint64_t correctw = 0x00'00'00'00'00'ff'00'00; //' word correction for negative spec cost
    4949  public:
    5050        // Compiler adjusts constants for correct endian.
    5151        enum : uint64_t {
    52                 zero      = 0x00'00'00'00'00'00'ff'00,
    53                 infinity  = 0xff'ff'ff'ff'ff'ff'00'ff,
    54                 unsafe    = 0x01'00'00'00'00'00'ff'00,
    55                 implicit  = 0x00'01'00'00'01'00'ff'00,
    56                 poly      = 0x00'00'01'00'00'00'ff'00,
    57                 safe      = 0x00'00'00'01'00'00'ff'00,
    58                 sign      = 0x00'00'00'00'01'00'ff'00,
    59                 var       = 0x00'00'00'00'00'01'ff'00,
    60                 spec      = 0x00'00'00'00'00'00'fe'00,
    61                 reference = 0x00'00'00'00'00'00'ff'01,
     52                zero      = 0x00'00'00'00'00'ff'00'00,
     53                infinity  = 0xff'ff'ff'ff'ff'00'ff'ff,
     54                unsafe    = 0x01'00'00'00'00'ff'00'00,
     55                poly      = 0x00'01'00'00'00'ff'00'00,
     56                safe      = 0x00'00'01'00'00'ff'00'00,
     57                sign      = 0x00'00'00'01'00'ff'00'00,
     58                var       = 0x00'00'00'00'01'ff'00'00,
     59                spec      = 0x00'00'00'00'00'fe'00'00,
     60                reference = 0x00'00'00'00'00'ff'01'00,
    6261        }; //'
    6362
    6463        Cost( uint64_t all ) { Cost::all = all; }
    65         Cost( int unsafeCost, int polyCost, int safeCost, int signCost, int implicitCost, int varCost, int specCost, int referenceCost ) {
     64        Cost( int unsafeCost, int polyCost, int safeCost, int signCost, int varCost, int specCost, int referenceCost ) {
    6665                // Assume little-endian => first value is low priority and last is high priority.
    6766                v = {
    6867                #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
     68                        (unsigned char)0,                                               // padding
    6969                        (unsigned char)referenceCost,                   // low priority
    7070                        (unsigned char)(specCost + correctb),   // correct for signedness
     
    7373                        (unsigned char)safeCost,
    7474                        (unsigned char)polyCost,
    75                         (unsigned char)implicitCost,
    7675                        (unsigned char)unsafeCost,                              // high priority
    7776                #else
     
    8281
    8382        int get_unsafeCost() const { return v.unsafeCost; }
    84         int get_implictCost() const { return v.implicitCost; }
    8583        int get_polyCost() const { return v.polyCost; }
    8684        int get_safeCost() const { return v.safeCost; }
     
    114112        Cost incUnsafe( int inc = 1 ) {
    115113                if ( all != infinity ) { assert( v.unsafeCost + inc <= UCHAR_MAX ); v.unsafeCost += inc; }
    116                 return *this;
    117         }
    118 
    119         Cost incImplicit( int inc = 1 ) {
    120                 if ( all != infinity ) { assert( v.implicitCost + inc <= UCHAR_MAX ); v.implicitCost += inc; }
    121114                return *this;
    122115        }
     
    175168
    176169inline std::ostream & operator<<( std::ostream & os, const Cost cost ) {
    177         return os << "( " << cost.get_unsafeCost() << ", " << cost.get_implictCost() << ", " << cost.get_polyCost() << ", " << cost.get_safeCost()
     170        return os << "( " << cost.get_unsafeCost() << ", " << cost.get_polyCost() << ", " << cost.get_safeCost()
    178171                          << ", " << cost.get_signCost() << ", " << cost.get_varCost() << ", " << cost.get_specCost()
    179172                          << ", " << cost.get_referenceCost() << " )";
  • src/ResolvExpr/ResolveTypeof.cpp

    r1e12f07 rd39d8a4  
    130130        mutDecl->type = renameTyVars(mutDecl->type, RenameMode::GEN_EXPR_ID);
    131131        mutDecl->isTypeFixed = true;
    132 
    133         auto enumInst = decl->type.as<ast::EnumInstType>();
    134         if ( enumInst && enumInst->base->isCfa ) {
    135                 if ( auto init = decl->init.as<ast::SingleInit>() ) {
    136                         if ( auto initExpr = init->value.as<ast::ConstantExpr>() ) {
    137                                 if ( initExpr->result.as<ast::ZeroType>() ) {
    138                                         auto newInit = new ast::SingleInit( init->location,
    139                                                 ast::UntypedExpr::createCall( init->location, "lowerBound", {} )
    140                                         );
    141                                         mutDecl->init = newInit;
    142                                 }
    143                         }
    144                 }
    145         }
    146 
    147132        return mutDecl;
    148133}
  • tests/.expect/castError.txt

    r1e12f07 rd39d8a4  
    66... with resolved type:
    77  char Alternatives are:
    8 Cost ( 1, 0, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     8Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    99      Variable Expression: f: double
    1010      ... with resolved type:
     
    1919  Environment:
    2020
    21 Cost ( 1, 0, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     21Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2222      Variable Expression: f: function
    2323        accepting unspecified arguments
     
    3838  Environment:
    3939
    40 Cost ( 1, 0, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     40Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    4141      Variable Expression: f: signed int
    4242      ... with resolved type:
     
    6262... with resolved type:
    6363  void Alternatives are:
    64 Cost ( 0, 0, 0, 2, 0, 0, 0, 0 ): Generated Cast of:
     64Cost ( 0, 0, 2, 0, 0, 0, 0 ): Generated Cast of:
    6565      Comma Expression:
    6666        Constant Expression (3: signed int)
     
    8080  Environment:
    8181
    82 Cost ( 0, 0, 0, 2, 0, 0, 0, 0 ): Generated Cast of:
     82Cost ( 0, 0, 2, 0, 0, 0, 0 ): Generated Cast of:
    8383      Comma Expression:
    8484        Constant Expression (3: signed int)
  • tests/errors/.expect/completeType.x64.txt

    r1e12f07 rd39d8a4  
    99... with resolved type:
    1010  void Alternatives are:
    11 Cost ( 0, 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
     11Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
    1212      Application of
    1313        Variable Expression: *?: forall
     
    4444
    4545
    46 Cost ( 0, 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
     46Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of:
    4747      Application of
    4848        Variable Expression: *?: forall
     
    111111
    112112      Unsatisfiable alternative:
    113 Cost ( 0, 0, 1, 0, 0, 1, -5, 0 ): Application of
     113Cost ( 0, 1, 0, 0, 1, -5, 0 ): Application of
    114114            Variable Expression: baz: forall
    115115              instance of type T (not function type)
  • tests/meta/.expect/arch.x64.txt

    r1e12f07 rd39d8a4  
    66... with resolved type:
    77  char Alternatives are:
    8 Cost ( 1, 0, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     8Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    99      Variable Expression: FX64: double
    1010      ... with resolved type:
     
    1919  Environment:
    2020
    21 Cost ( 1, 0, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     21Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2222      Variable Expression: FX64: function
    2323        accepting unspecified arguments
     
    3838  Environment:
    3939
    40 Cost ( 1, 0, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     40Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    4141      Variable Expression: FX64: signed int
    4242      ... with resolved type:
Note: See TracChangeset for help on using the changeset viewer.