Changeset 1db306a


Ignore:
Timestamp:
Dec 3, 2020, 11:30:33 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
636d3715, 63ec5fa
Parents:
cd6a6ff
Message:

First attempt to sort alternatives before printing.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rcd6a6ff r1db306a  
    132132        void printAlts( const AltList &list, std::ostream &os, unsigned int indentAmt ) {
    133133                Indenter indent = { indentAmt };
     134
     135                std::vector<int> idx;
     136                idx.reserve(list.size());
     137                for(int i = 0; i < list.size(); i++) { idx.push_back(i); }
     138
     139                std::sort(idx.begin(), idx.end(), [&list](int lhs_idx, int rhs_idx) -> bool {
     140                        const auto & lhs = list.at(lhs_idx);
     141                        const auto & rhs = list.at(rhs_idx);
     142                        if(lhs.expr->location.startsBefore(rhs.expr->location)) return true;
     143                        if(rhs.expr->location.startsBefore(lhs.expr->location)) return false;
     144
     145                        if(lhs.env.size() < rhs.env.size()) return true;
     146                        if(lhs.env.size() > rhs.env.size()) return false;
     147
     148                        if(lhs.openVars.size() < rhs.openVars.size()) return true;
     149                        if(lhs.openVars.size() > rhs.openVars.size()) return false;
     150
     151                        if(lhs.need.size() < rhs.need.size()) return true;
     152                        if(lhs.need.size() > rhs.need.size()) return false;
     153
     154                        return false;
     155                });
     156
    134157                for ( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) {
    135158                        i->print( os, indent );
     
    17181741                                        std::cerr << std::endl;
    17191742                                )
    1720                                
     1743
    17211744                                if ( thisCost != Cost::infinity ) {
    17221745                                        // count one safe conversion for each value that is thrown away
  • src/ResolvExpr/TypeEnvironment.h

    rcd6a6ff r1db306a  
    149149                iterator end() const { return env.end(); }
    150150
     151                auto size() const { return env.size(); }
     152
    151153          private:
    152154                ClassList env;
  • tests/meta/.expect/archVast.nast.x64.txt

    rcd6a6ff r1db306a  
    33  Name: FX64
    44... to:
     5  char
     6... with resolved type:
    57  char Alternatives are:
    68Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    79      Variable Expression: FX64: signed int
     10      ... with resolved type:
     11        signed int
    812    ... to:
     13      char
     14    ... with resolved type:
    915      char
    1016  (types:
     
    1824      ... returning nothing
    1925
     26      ... with resolved type:
     27        pointer to function
     28          accepting unspecified arguments
     29        ... returning nothing
     30
    2031    ... to:
     32      char
     33    ... with resolved type:
    2134      char
    2235  (types:
     
    2740Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2841      Variable Expression: FX64: double
     42      ... with resolved type:
     43        double
    2944    ... to:
     45      char
     46    ... with resolved type:
    3047      char
    3148  (types:
  • tests/meta/.expect/archVast.nast.x86.txt

    rcd6a6ff r1db306a  
    33  Name: FX86
    44... to:
     5  char
     6... with resolved type:
    57  char Alternatives are:
    68Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    79      Variable Expression: FX86: signed int
     10      ... with resolved type:
     11        signed int
    812    ... to:
     13      char
     14    ... with resolved type:
    915      char
    1016  (types:
     
    1824      ... returning nothing
    1925
     26      ... with resolved type:
     27        pointer to function
     28          accepting unspecified arguments
     29        ... returning nothing
     30
    2031    ... to:
     32      char
     33    ... with resolved type:
    2134      char
    2235  (types:
     
    2740Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2841      Variable Expression: FX86: double
     42      ... with resolved type:
     43        double
    2944    ... to:
     45      char
     46    ... with resolved type:
    3047      char
    3148  (types:
  • tests/meta/.expect/archVast.oast.x64.txt

    rcd6a6ff r1db306a  
    33  Name: FX64
    44... to:
     5  char
     6with resolved type:
    57  char Alternatives are:
    68Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     
    911      ... returning nothing
    1012
     13      with resolved type:
     14        pointer to function
     15          accepting unspecified arguments
     16        ... returning nothing
     17
    1118    ... to:
     19      char
     20    with resolved type:
    1221      char
    1322  (types:
     
    1827Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    1928      Variable Expression: FX64: double
     29      with resolved type:
     30        double
    2031    ... to:
     32      char
     33    with resolved type:
    2134      char
    2235  (types:
     
    2740Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2841      Variable Expression: FX64: signed int
     42      with resolved type:
     43        signed int
    2944    ... to:
     45      char
     46    with resolved type:
    3047      char
    3148  (types:
  • tests/meta/.expect/archVast.oast.x86.txt

    rcd6a6ff r1db306a  
    33  Name: FX86
    44... to:
     5  char
     6with resolved type:
    57  char Alternatives are:
    68Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
     
    911      ... returning nothing
    1012
     13      with resolved type:
     14        pointer to function
     15          accepting unspecified arguments
     16        ... returning nothing
     17
    1118    ... to:
     19      char
     20    with resolved type:
    1221      char
    1322  (types:
     
    1827Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    1928      Variable Expression: FX86: double
     29      with resolved type:
     30        double
    2031    ... to:
     32      char
     33    with resolved type:
    2134      char
    2235  (types:
     
    2740Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of:
    2841      Variable Expression: FX86: signed int
     42      with resolved type:
     43        signed int
    2944    ... to:
     45      char
     46    with resolved type:
    3047      char
    3148  (types:
Note: See TracChangeset for help on using the changeset viewer.