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