Changes in src/AST/Print.cpp [3e5dd913:07de76b]
- File:
-
- 1 edited
-
src/AST/Print.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Print.cpp
r3e5dd913 r07de76b 21 21 #include "Type.hpp" 22 22 #include "TypeSubstitution.hpp" 23 #include "CompilationState.h"24 23 25 24 #include "Common/utility.h" // for group_iterate … … 30 29 31 30 template <typename C, typename... T> 32 constexpr array<C,sizeof...(T)> make_array(T&&... values) 31 constexpr auto make_array(T&&... values) -> 32 array<C,sizeof...(T)> 33 33 { 34 34 return array<C,sizeof...(T)>{ … … 129 129 130 130 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() 133 135 << " pending inference slots" << endl; 134 } 135 if (inferred.data.inferParams && !inferred.data.inferParams->empty()) { 136 return; 137 } 138 case ast::Expr::InferUnion::Params: { 136 139 os << indent << "with inferred parameters " << level << ":" << endl; 137 140 ++indent; 138 for ( const auto & i : *inferred.data.inferParams ) {141 for ( const auto & i : inferred.data.inferParams ) { 139 142 os << indent; 140 short_print( i.second.declptr);143 short_print( Decl::fromId( i.second.decl ) ); 141 144 os << endl; 142 145 print( i.second.expr->inferred, level+1 ); 143 146 } 144 147 --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 ) { 149 154 if ( forall.empty() ) return; 150 155 os << "forall" << endl; 151 156 ++indent; 152 157 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);162 158 os << indent; 163 159 --indent; … … 214 210 215 211 void preprint( const ast::NamedTypeDecl * node ) { 216 if ( ! node->name.empty() ) { 217 os << node->name << ": "; 218 } 212 if ( ! node->name.empty() ) os << node->name << ": "; 219 213 220 214 if ( ! short_mode && node->linkage != Linkage::Cforall ) { … … 232 226 } 233 227 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() ) { 235 236 os << endl << indent << "... with assertions" << endl; 236 237 ++indent; … … 243 244 print( node->inferred ); 244 245 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 253 246 if ( node->env ) { 254 247 os << endl << indent << "... with environment:" << endl; … … 267 260 } 268 261 269 void preprint( const ast:: FunctionType * node ) {262 void preprint( const ast::ParameterizedType * node ) { 270 263 print( node->forall ); 271 print( node->assertions );272 264 print( node->qualifiers ); 273 265 } 274 266 275 void preprint( const ast::BaseInstType * node ) { 267 void preprint( const ast::ReferenceToType * node ) { 268 print( node->forall ); 276 269 print( node->attributes ); 277 270 print( node->qualifiers ); … … 685 678 } 686 679 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 706 680 virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) override final { 707 681 os << "Waitfor Statement" << endl; … … 849 823 virtual const ast::Expr * visit( const ast::CastExpr * node ) override final { 850 824 ++indent; 851 os << (node->isGenerated ? "Generated" : "Explicit") << " Cast of:" << endl << indent;825 os << (node->isGenerated ? "Generated" : "Explicit") << " cast of:" << endl << indent; 852 826 safe_print( node->arg ); 853 827 os << endl << indent-1 << "... to:"; … … 1384 1358 virtual const ast::Type * visit( const ast::TypeInstType * node ) override final { 1385 1359 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 1388 1361 << " (" << (node->kind == ast::TypeDecl::Ftype ? "" : "not ") << "function type)"; 1389 1362 print( node->params ); … … 1511 1484 os << indent << "Types:" << endl; 1512 1485 for ( const auto& i : *node ) { 1513 os << indent+1 << i.first .typeString()<< " -> ";1486 os << indent+1 << i.first << " -> "; 1514 1487 indent += 2; 1515 1488 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 ); 1516 1497 indent -= 2; 1517 1498 os << endl;
Note:
See TracChangeset
for help on using the changeset viewer.