Changeset cd6a6ff for src/AST


Ignore:
Timestamp:
Dec 3, 2020, 10:44:40 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:
1db306a
Parents:
b37515b
Message:

Improved coverage of deterministic_output to be much finer grain.

Location:
src/AST
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/AST/Print.cpp

    rb37515b rcd6a6ff  
    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 );
  • TabularUnified src/AST/Type.cpp

    rb37515b rcd6a6ff  
    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;
  • TabularUnified src/AST/Type.hpp

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

    rb37515b rcd6a6ff  
    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
Note: See TracChangeset for help on using the changeset viewer.