Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Print.cpp

    r3e5dd913 r07de76b  
    2121#include "Type.hpp"
    2222#include "TypeSubstitution.hpp"
    23 #include "CompilationState.h"
    2423
    2524#include "Common/utility.h" // for group_iterate
     
    3029
    3130template <typename C, typename... T>
    32 constexpr array<C,sizeof...(T)> make_array(T&&... values)
     31constexpr auto make_array(T&&... values) ->
     32        array<C,sizeof...(T)>
    3333{
    3434        return array<C,sizeof...(T)>{
     
    129129
    130130        void print( const ast::Expr::InferUnion & inferred, unsigned level = 0 ) {
    131                 if (inferred.data.resnSlots && !inferred.data.resnSlots->empty()) {
    132                         os << indent << "with " << inferred.data.resnSlots->size()
     131                switch ( inferred.mode ) {
     132                case ast::Expr::InferUnion::Empty: return;
     133                case ast::Expr::InferUnion::Slots: {
     134                        os << indent << "with " << inferred.data.resnSlots.size()
    133135                           << " pending inference slots" << endl;
    134                 }
    135                 if (inferred.data.inferParams && !inferred.data.inferParams->empty()) {
     136                        return;
     137                }
     138                case ast::Expr::InferUnion::Params: {
    136139                        os << indent << "with inferred parameters " << level << ":" << endl;
    137140                        ++indent;
    138                         for ( const auto & i : *inferred.data.inferParams ) {
     141                        for ( const auto & i : inferred.data.inferParams ) {
    139142                                os << indent;
    140                                 short_print( i.second.declptr );
     143                                short_print( Decl::fromId( i.second.decl ) );
    141144                                os << endl;
    142145                                print( i.second.expr->inferred, level+1 );
    143146                        }
    144147                        --indent;
    145                 }
    146         }
    147 
    148         void print( const ast::FunctionType::ForallList & forall ) {
     148                        return;
     149                }
     150                }
     151        }
     152
     153        void print( const ast::ParameterizedType::ForallList & forall ) {
    149154                if ( forall.empty() ) return;
    150155                os << "forall" << endl;
    151156                ++indent;
    152157                printAll( forall );
    153                 os << indent;
    154                 --indent;
    155         }
    156 
    157         void print( const ast::FunctionType::AssertionList & assts ) {
    158                 if (assts.empty()) return;
    159                 os << "with assertions" << endl;
    160                 ++indent;
    161                 printAll(assts);
    162158                os << indent;
    163159                --indent;
     
    214210
    215211        void preprint( const ast::NamedTypeDecl * node ) {
    216                 if ( ! node->name.empty() ) {
    217                         os << node->name << ": ";
    218                 }
     212                if ( ! node->name.empty() ) os << node->name << ": ";
    219213
    220214                if ( ! short_mode && node->linkage != Linkage::Cforall ) {
     
    232226                }
    233227
    234                 if ( ! node->assertions.empty() ) {
     228                if ( ! node->params.empty() ) {
     229                        os << endl << indent << "... with parameters" << endl;
     230                        ++indent;
     231                        printAll( node->params );
     232                        --indent;
     233                }
     234
     235                if ( ! short_mode && ! node->assertions.empty() ) {
    235236                        os << endl << indent << "... with assertions" << endl;
    236237                        ++indent;
     
    243244                print( node->inferred );
    244245
    245                 if ( node->result ) {
    246                         os << endl << indent << "... with resolved type:" << endl;
    247                         ++indent;
    248                         os << indent;
    249                         node->result->accept( *this );
    250                         --indent;
    251                 }
    252 
    253246                if ( node->env ) {
    254247                        os << endl << indent << "... with environment:" << endl;
     
    267260        }
    268261
    269         void preprint( const ast::FunctionType * node ) {
     262        void preprint( const ast::ParameterizedType * node ) {
    270263                print( node->forall );
    271                 print( node->assertions );
    272264                print( node->qualifiers );
    273265        }
    274266
    275         void preprint( const ast::BaseInstType * node ) {
     267        void preprint( const ast::ReferenceToType * node ) {
     268                print( node->forall );
    276269                print( node->attributes );
    277270                print( node->qualifiers );
     
    685678        }
    686679
    687         virtual const ast::Stmt * visit( const ast::SuspendStmt * node ) override final {
    688                 os << "Suspend Statement";
    689                 switch (node->type) {
    690                         case ast::SuspendStmt::None     : os << " with implicit target"; break;
    691                         case ast::SuspendStmt::Generator: os << " for generator"; break;
    692                         case ast::SuspendStmt::Coroutine: os << " for coroutine"; break;
    693                 }
    694                 os << endl;
    695 
    696                 ++indent;
    697                 if(node->then) {
    698                         os << indent << " with post statement :" << endl;
    699                         safe_print( node->then );
    700                 }
    701                 ++indent;
    702 
    703                 return node;
    704         }
    705 
    706680        virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) override final {
    707681                os << "Waitfor Statement" << endl;
     
    849823        virtual const ast::Expr * visit( const ast::CastExpr * node ) override final {
    850824                ++indent;
    851                 os << (node->isGenerated ? "Generated" : "Explicit") << " Cast of:" << endl << indent;
     825                os << (node->isGenerated ? "Generated" : "Explicit") << " cast of:" << endl << indent;
    852826                safe_print( node->arg );
    853827                os << endl << indent-1 << "... to:";
     
    13841358        virtual const ast::Type * visit( const ast::TypeInstType * node ) override final {
    13851359                preprint( node );
    1386                 const auto & _name = deterministic_output && isUnboundType(node) ? "[unbound]" : node->typeString();
    1387                 os << "instance of type " << _name
     1360                os << "instance of type " << node->name
    13881361                   << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)";
    13891362                print( node->params );
     
    15111484                os << indent << "Types:" << endl;
    15121485                for ( const auto& i : *node ) {
    1513                         os << indent+1 << i.first.typeString() << " -> ";
     1486                        os << indent+1 << i.first << " -> ";
    15141487                        indent += 2;
    15151488                        safe_print( i.second );
     1489                        indent -= 2;
     1490                        os << endl;
     1491                }
     1492                os << indent << "Non-types:" << endl;
     1493                for ( auto i = node->beginVar(); i != node->endVar(); ++i ) {
     1494                        os << indent+1 << i->first << " -> ";
     1495                        indent += 2;
     1496                        safe_print( i->second );
    15161497                        indent -= 2;
    15171498                        os << endl;
Note: See TracChangeset for help on using the changeset viewer.