Changeset b5629d8 for src


Ignore:
Timestamp:
Dec 3, 2020, 1:49:01 PM (5 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:
62e456f, ab0257b9
Parents:
f0d67e5 (diff), fa11053 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Print.cpp

    rf0d67e5 rb5629d8  
    205205
    206206        void preprint( const ast::NamedTypeDecl * node ) {
    207                 if ( ! node->name.empty() ) os << node->name << ": ";
     207                if ( ! node->name.empty() ) {
     208                        if( deterministic_output && isUnboundType(node->name) ) os << "[unbound]:";
     209                        else os << node->name << ": ";
     210                }
    208211
    209212                if ( ! short_mode && node->linkage != Linkage::Cforall ) {
     
    240243
    241244                if ( node->result ) {
    242                         if (!deterministic_output) {
    243                                 os << endl << indent << "... with resolved type:" << endl;
    244                                 ++indent;
    245                                 os << indent;
    246                                 node->result->accept( *this );
    247                                 --indent;
    248                         }
     245                        os << endl << indent << "... with resolved type:" << endl;
     246                        ++indent;
     247                        os << indent;
     248                        node->result->accept( *this );
     249                        --indent;
    249250                }
    250251
     
    13821383        virtual const ast::Type * visit( const ast::TypeInstType * node ) override final {
    13831384                preprint( node );
    1384                 os << "instance of type " << node->name
     1385                const auto & _name = deterministic_output && isUnboundType(node) ? "[unbound]" : node->name;
     1386                os << "instance of type " << _name
    13851387                   << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)";
    13861388                print( node->params );
  • src/AST/Type.cpp

    rf0d67e5 rb5629d8  
    133133
    134134BaseInstType::BaseInstType( const BaseInstType & o )
    135 : ParameterizedType( o.qualifiers, copy( o.attributes ) ), params(), name( o.name ), 
     135: ParameterizedType( o.qualifiers, copy( o.attributes ) ), params(), name( o.name ),
    136136  hoistType( o.hoistType ) {
    137137        Pass< ForallSubstitutor > sub;
     
    222222                // TODO: once TypeInstType representation is updated, it should properly check
    223223                // if the context id is filled. this is a temporary hack for now
    224                 if (std::count(typeInst->name.begin(), typeInst->name.end(), '_') >= 3) {
    225                         return true;
    226                 }
     224                return isUnboundType(typeInst->name);
     225        }
     226        return false;
     227}
     228
     229bool isUnboundType(const std::string & tname) {
     230        // xxx - look for a type name produced by renameTyVars.
     231
     232        // TODO: once TypeInstType representation is updated, it should properly check
     233        // if the context id is filled. this is a temporary hack for now
     234        if (std::count(tname.begin(), tname.end(), '_') >= 3) {
     235                return true;
    227236        }
    228237        return false;
  • src/AST/Type.hpp

    rf0d67e5 rb5629d8  
    536536
    537537bool isUnboundType(const Type * type);
     538bool isUnboundType(const std::string & tname);
    538539
    539540}
  • src/AST/TypeEnvironment.cpp

    rf0d67e5 rb5629d8  
    3434#include "ResolvExpr/Unify.h"      // for unifyInexact
    3535#include "Tuples/Tuples.h"         // for isTtype
     36#include "CompilationState.h"
    3637
    3738using ResolvExpr::WidenMode;
     
    5657
    5758void print( std::ostream & out, const EqvClass & clz, Indenter indent ) {
    58         out << "( ";
    59         std::copy( clz.vars.begin(), clz.vars.end(), std::ostream_iterator< std::string >( out, " " ) );
     59        out << "(";
     60        bool first = true;
     61        for(const auto & var : clz.vars) {
     62                if(first) first = false;
     63                else out << " ";
     64                if( deterministic_output && isUnboundType(var) ) out << "[unbound]";
     65                else out << var;
     66        }
    6067        out << ")";
    6168
  • src/Common/CodeLocation.h

    rf0d67e5 rb5629d8  
    4242        }
    4343
    44         bool followedBy( CodeLocation const & other, int seperation ) {
     44        bool startsBefore( CodeLocation const & other ) const {
     45                if( filename < other.filename ) return true;
     46                if( filename > other.filename ) return false;
     47
     48                if( first_line < other.first_line ) return true;
     49                if( first_line > other.first_line ) return false;
     50
     51                if( last_line < other.last_line ) return true;
     52                return false;
     53        }
     54
     55        bool followedBy( CodeLocation const & other, int seperation ) const {
    4556                return (first_line + seperation == other.first_line &&
    4657                        filename == other.filename);
    4758        }
    4859
    49         bool operator==( CodeLocation const & other ) {
     60        bool operator==( CodeLocation const & other ) const {
    5061                return followedBy( other, 0 );
    5162        }
    5263
    53         bool operator!=( CodeLocation const & other ) {
     64        bool operator!=( CodeLocation const & other ) const {
    5465                return !(*this == other);
    5566        }
  • src/Common/SemanticError.cc

    rf0d67e5 rb5629d8  
    9090void SemanticErrorException::print() {
    9191        using std::to_string;
     92
     93        errors.sort([](const error & lhs, const error & rhs) -> bool {
     94                if(lhs.location.startsBefore(rhs.location)) return true;
     95                if(rhs.location.startsBefore(lhs.location)) return false;
     96
     97                return lhs.description < rhs.description;
     98        });
     99
    92100        for( auto err : errors ) {
    93101                std::cerr << ErrorHelpers::bold() << err.location << ErrorHelpers::error_str() << ErrorHelpers::reset_font() << err.description << std::endl;
  • src/ResolvExpr/AlternativeFinder.cc

    rf0d67e5 rb5629d8  
    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.cc

    rf0d67e5 rb5629d8  
    107107
    108108        void EqvClass::print( std::ostream &os, Indenter indent ) const {
    109                 if( !deterministic_output ) {
    110                         os << "( ";
    111                         std::copy( vars.begin(), vars.end(), std::ostream_iterator< std::string >( os, " " ) );
    112                         os << ")";
    113                 }
     109                os << "(";
     110                bool first = true;
     111                for(const auto & var : vars) {
     112                        if(first) first = false;
     113                        else os << " ";
     114                        if( deterministic_output && isUnboundType(var) ) os << "[unbound]";
     115                        else os << var;
     116                }
     117                os << ")";
    114118                if ( type ) {
    115119                        os << " -> ";
  • src/ResolvExpr/TypeEnvironment.h

    rf0d67e5 rb5629d8  
    149149                iterator end() const { return env.end(); }
    150150
     151                auto size() const { return env.size(); }
     152
    151153          private:
    152154                ClassList env;
  • src/SynTree/Expression.cc

    rf0d67e5 rb5629d8  
    7272
    7373        if ( result ) {
    74                 if (!deterministic_output) {
    75                         os << std::endl << indent << "with resolved type:" << std::endl;
    76                         os << (indent+1);
    77                         result->print( os, indent+1 );
    78                 }
     74                os << std::endl << indent << "with resolved type:" << std::endl;
     75                os << (indent+1);
     76                result->print( os, indent+1 );
    7977        }
    8078
  • src/SynTree/NamedTypeDecl.cc

    rf0d67e5 rb5629d8  
    2222#include "LinkageSpec.h"         // for Spec, Cforall, linkageName
    2323#include "Type.h"                // for Type, Type::StorageClasses
     24#include "CompilationState.h"
    2425
    2526NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
     
    4142        using namespace std;
    4243
    43         if ( name != "" ) os << name << ": ";
     44        if ( ! name.empty() ) {
     45                if( deterministic_output && isUnboundType(name) ) os << "[unbound]:";
     46                else os << name << ": ";
     47        }
    4448
    4549        if ( linkage != LinkageSpec::Cforall ) {
  • src/SynTree/ReferenceToType.cc

    rf0d67e5 rb5629d8  
    2424#include "Type.h"             // for TypeInstType, StructInstType, UnionInstType
    2525#include "TypeSubstitution.h" // for TypeSubstitution
     26#include "CompilationState.h"
    2627
    2728class Attribute;
     
    205206
    206207        Type::print( os, indent );
    207         os << "instance of " << typeString() << " " << get_name() << " (" << ( isFtype ? "" : "not" ) << " function type)";
     208        os << "instance of " << typeString() << " ";
     209        const auto & name_ = get_name();
     210        if( deterministic_output && isUnboundType(name) ) os << "[unbound]";
     211        else os << name;
     212        os << " (" << ( isFtype ? "" : "not" ) << " function type)";
    208213        if ( ! parameters.empty() ) {
    209214                os << endl << indent << "... with parameters" << endl;
  • src/SynTree/Type.cc

    rf0d67e5 rb5629d8  
    156156const Type::Qualifiers noQualifiers;
    157157
     158bool isUnboundType(const Type * type) {
     159        if (auto typeInst = dynamic_cast<const TypeInstType *>(type)) {
     160                // xxx - look for a type name produced by renameTyVars.
     161
     162                // TODO: once TypeInstType representation is updated, it should properly check
     163                // if the context id is filled. this is a temporary hack for now
     164                return isUnboundType(typeInst->name);
     165        }
     166        return false;
     167}
     168
     169bool isUnboundType(const std::string & tname) {
     170        // xxx - look for a type name produced by renameTyVars.
     171
     172        // TODO: once TypeInstType representation is updated, it should properly check
     173        // if the context id is filled. this is a temporary hack for now
     174        if (std::count(tname.begin(), tname.end(), '_') >= 3) {
     175                return true;
     176        }
     177        return false;
     178}
     179
    158180// Local Variables: //
    159181// tab-width: 4 //
  • src/SynTree/Type.h

    rf0d67e5 rb5629d8  
    733733};
    734734
     735
     736bool isUnboundType(const Type * type);
     737bool isUnboundType(const std::string & tname);
     738
    735739// Local Variables: //
    736740// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.