Changeset 3e5dd913 for src/AST/Print.cpp


Ignore:
Timestamp:
Dec 16, 2020, 2:43:12 PM (3 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
53449a4
Parents:
13fece5
Message:

reimplement function type and eliminate deep copy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Print.cpp

    r13fece5 r3e5dd913  
    155155        }
    156156
     157        void print( const ast::FunctionType::AssertionList & assts ) {
     158                if (assts.empty()) return;
     159                os << "with assertions" << endl;
     160                ++indent;
     161                printAll(assts);
     162                os << indent;
     163                --indent;
     164        }
     165
    157166        void print( const std::vector<ptr<Attribute>> & attrs ) {
    158167                if ( attrs.empty() ) return;
     
    206215        void preprint( const ast::NamedTypeDecl * node ) {
    207216                if ( ! node->name.empty() ) {
    208                         if( deterministic_output && isUnboundType(node->name) ) os << "[unbound]:";
    209                         else os << node->name << ": ";
     217                        os << node->name << ": ";
    210218                }
    211219
     
    261269        void preprint( const ast::FunctionType * node ) {
    262270                print( node->forall );
     271                print( node->assertions );
    263272                print( node->qualifiers );
    264273        }
     
    13751384        virtual const ast::Type * visit( const ast::TypeInstType * node ) override final {
    13761385                preprint( node );
    1377                 const auto & _name = deterministic_output && isUnboundType(node) ? "[unbound]" : node->name;
     1386                const auto & _name = deterministic_output && isUnboundType(node) ? "[unbound]" : node->typeString();
    13781387                os << "instance of type " << _name
    13791388                   << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)";
     
    15021511                os << indent << "Types:" << endl;
    15031512                for ( const auto& i : *node ) {
    1504                         os << indent+1 << i.first << " -> ";
     1513                        os << indent+1 << i.first.typeString() << " -> ";
    15051514                        indent += 2;
    15061515                        safe_print( i.second );
    1507                         indent -= 2;
    1508                         os << endl;
    1509                 }
    1510                 os << indent << "Non-types:" << endl;
    1511                 for ( auto i = node->beginVar(); i != node->endVar(); ++i ) {
    1512                         os << indent+1 << i->first << " -> ";
    1513                         indent += 2;
    1514                         safe_print( i->second );
    15151516                        indent -= 2;
    15161517                        os << endl;
Note: See TracChangeset for help on using the changeset viewer.