- Timestamp:
- Sep 22, 2020, 11:29:12 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- 0a945fd
- Parents:
- 1c507eb (diff), 08f3ad3 (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. - Location:
- src
- Files:
-
- 6 added
- 24 edited
-
AST/Convert.cpp (modified) (2 diffs)
-
AST/Fwd.hpp (modified) (1 diff)
-
AST/GenericSubstitution.cpp (modified) (1 diff)
-
AST/Node.cpp (modified) (1 diff)
-
AST/Pass.hpp (modified) (6 diffs)
-
AST/Pass.impl.hpp (modified) (3 diffs)
-
AST/Pass.proto.hpp (modified) (2 diffs)
-
AST/Print.cpp (modified) (1 diff)
-
AST/SymbolTable.cpp (modified) (2 diffs)
-
AST/Type.cpp (modified) (4 diffs)
-
AST/Type.hpp (modified) (9 diffs)
-
AST/TypeSubstitution.cpp (modified) (1 diff)
-
AST/TypeSubstitution.hpp (modified) (1 diff)
-
Common/Examine.cc (added)
-
Common/Examine.h (added)
-
Common/Stats/ResolveTime.cc (added)
-
Common/Stats/ResolveTime.h (added)
-
Common/Stats/Stats.cc (modified) (2 diffs)
-
Common/module.mk (modified) (2 diffs)
-
Concurrency/Keywords.cc (modified) (17 diffs)
-
ResolvExpr/CandidateFinder.cpp (modified) (2 diffs)
-
ResolvExpr/ConversionCost.cc (modified) (2 diffs)
-
ResolvExpr/ConversionCost.h (modified) (1 diff)
-
ResolvExpr/CurrentObject.cc (modified) (3 diffs)
-
ResolvExpr/Resolver.cc (modified) (6 diffs)
-
SymTab/Mangler.cc (modified) (2 diffs)
-
SymTab/Validate.cc (modified) (3 diffs)
-
Virtual/Tables.cc (added)
-
Virtual/Tables.h (added)
-
Virtual/module.mk (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r1c507eb r7a80113 1162 1162 } 1163 1163 1164 const ast::Type * postvisit( const ast:: ReferenceToType * old, ReferenceToType * ty ) {1164 const ast::Type * postvisit( const ast::BaseInstType * old, ReferenceToType * ty ) { 1165 1165 ty->forall = get<TypeDecl>().acceptL( old->forall ); 1166 1166 ty->parameters = get<Expression>().acceptL( old->params ); … … 2521 2521 } 2522 2522 2523 void postvisit( const ReferenceToType * old, ast:: ReferenceToType * ty ) {2523 void postvisit( const ReferenceToType * old, ast::BaseInstType * ty ) { 2524 2524 ty->forall = GET_ACCEPT_V( forall, TypeDecl ); 2525 2525 ty->params = GET_ACCEPT_V( parameters, Expr ); -
src/AST/Fwd.hpp
r1c507eb r7a80113 107 107 class QualifiedType; 108 108 class FunctionType; 109 class ReferenceToType;109 class BaseInstType; 110 110 template<typename decl_t> class SueInstType; 111 111 using StructInstType = SueInstType<StructDecl>; -
src/AST/GenericSubstitution.cpp
r1c507eb r7a80113 42 42 private: 43 43 // make substitution for generic type 44 void makeSub( const ReferenceToType * ty ) {44 void makeSub( const BaseInstType * ty ) { 45 45 visit_children = false; 46 46 const AggregateDecl * aggr = ty->aggr(); -
src/AST/Node.cpp
r1c507eb r7a80113 266 266 template class ast::ptr_base< ast::FunctionType, ast::Node::ref_type::weak >; 267 267 template class ast::ptr_base< ast::FunctionType, ast::Node::ref_type::strong >; 268 template class ast::ptr_base< ast:: ReferenceToType, ast::Node::ref_type::weak >;269 template class ast::ptr_base< ast:: ReferenceToType, ast::Node::ref_type::strong >;268 template class ast::ptr_base< ast::BaseInstType, ast::Node::ref_type::weak >; 269 template class ast::ptr_base< ast::BaseInstType, ast::Node::ref_type::strong >; 270 270 template class ast::ptr_base< ast::StructInstType, ast::Node::ref_type::weak >; 271 271 template class ast::ptr_base< ast::StructInstType, ast::Node::ref_type::strong >; -
src/AST/Pass.hpp
r1c507eb r7a80113 50 50 // | PureVisitor - makes the visitor pure, it never modifies nodes in place and always 51 51 // clones nodes it needs to make changes to 52 // | With TypeSubstitution - provides polymorphic const TypeSubstitution * envfor the52 // | WithConstTypeSubstitution - provides polymorphic const TypeSubstitution * typeSubs for the 53 53 // current expression 54 54 // | WithStmtsToAdd - provides the ability to insert statements before or after the current … … 67 67 // | WithSymbolTable - provides symbol table functionality 68 68 // | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation 69 // 70 // Other Special Members: 71 // | result - Either a method that takes no parameters or a field. If a method (or 72 // callable field) get_result calls it, otherwise the value is returned. 69 73 //------------------------------------------------------------------------------------------------- 70 74 template< typename core_t > … … 89 93 virtual ~Pass() = default; 90 94 95 /// Storage for the actual pass. 96 core_t core; 97 98 /// If the core defines a result, call it if possible, otherwise return it. 99 inline auto get_result() -> decltype( __pass::get_result( core, '0' ) ) { 100 return __pass::get_result( core, '0' ); 101 } 102 91 103 /// Construct and run a pass on a translation unit. 92 104 template< typename... Args > … … 96 108 } 97 109 110 /// Contruct and run a pass on a pointer to extract a value. 111 template< typename node_type, typename... Args > 112 static auto read( node_type const * node, Args&&... args ) { 113 Pass<core_t> visitor( std::forward<Args>( args )... ); 114 node_type const * temp = node->accept( visitor ); 115 assert( temp == node ); 116 return visitor.get_result(); 117 } 118 119 // Versions of the above for older compilers. 98 120 template< typename... Args > 99 121 static void run( std::list< ptr<Decl> > & decls ) { … … 102 124 } 103 125 104 /// Storage for the actual pass 105 core_t core; 126 template< typename node_type, typename... Args > 127 static auto read( node_type const * node ) { 128 Pass<core_t> visitor; 129 node_type const * temp = node->accept( visitor ); 130 assert( temp == node ); 131 return visitor.get_result(); 132 } 106 133 107 134 /// Visit function declarations … … 267 294 //------------------------------------------------------------------------------------------------- 268 295 269 /// Keep track of the polymorphic const TypeSubstitution * env for the current expression270 271 296 /// If used the visitor will always clone nodes. 272 297 struct PureVisitor {}; 273 298 299 /// Keep track of the polymorphic const TypeSubstitution * typeSubs for the current expression. 274 300 struct WithConstTypeSubstitution { 275 const TypeSubstitution * env= nullptr;301 const TypeSubstitution * typeSubs = nullptr; 276 302 }; 277 303 -
src/AST/Pass.impl.hpp
r1c507eb r7a80113 154 154 __pedantic_pass_assert( expr ); 155 155 156 const ast::TypeSubstitution ** env_ptr = __pass::env( core, 0);157 if ( env_ptr && expr->env ) {158 * env_ptr = expr->env;156 const ast::TypeSubstitution ** typeSubs_ptr = __pass::typeSubs( core, 0 ); 157 if ( typeSubs_ptr && expr->env ) { 158 *typeSubs_ptr = expr->env; 159 159 } 160 160 … … 177 177 178 178 // These may be modified by subnode but most be restored once we exit this statemnet. 179 ValueGuardPtr< const ast::TypeSubstitution * > __old_env ( __pass:: env( core, 0) );179 ValueGuardPtr< const ast::TypeSubstitution * > __old_env ( __pass::typeSubs( core, 0 ) ); 180 180 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); 181 181 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); … … 1488 1488 1489 1489 // These may be modified by subnode but most be restored once we exit this statemnet. 1490 ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass:: env( core, 0) );1490 ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass::typeSubs( core, 0 ) ); 1491 1491 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); 1492 1492 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); -
src/AST/Pass.proto.hpp
r1c507eb r7a80113 236 236 237 237 // List of fields and their expected types 238 FIELD_PTR( env, const ast::TypeSubstitution * )238 FIELD_PTR( typeSubs, const ast::TypeSubstitution * ) 239 239 FIELD_PTR( stmtsToAddBefore, std::list< ast::ptr< ast::Stmt > > ) 240 240 FIELD_PTR( stmtsToAddAfter , std::list< ast::ptr< ast::Stmt > > ) … … 421 421 422 422 } // namespace forall 423 424 template<typename core_t> 425 static inline auto get_result( core_t & core, char ) -> decltype( core.result() ) { 426 return core.result(); 427 } 428 429 template<typename core_t> 430 static inline auto get_result( core_t & core, int ) -> decltype( core.result ) { 431 return core.result; 432 } 433 434 template<typename core_t> 435 static inline void get_result( core_t &, long ) {} 423 436 } // namespace __pass 424 437 } // namespace ast -
src/AST/Print.cpp
r1c507eb r7a80113 270 270 } 271 271 272 void preprint( const ast:: ReferenceToType * node ) {272 void preprint( const ast::BaseInstType * node ) { 273 273 print( node->forall ); 274 274 print( node->attributes ); -
src/AST/SymbolTable.cpp
r1c507eb r7a80113 313 313 if ( ! expr->result ) continue; 314 314 const Type * resTy = expr->result->stripReferences(); 315 auto aggrType = dynamic_cast< const ReferenceToType * >( resTy );315 auto aggrType = dynamic_cast< const BaseInstType * >( resTy ); 316 316 assertf( aggrType, "WithStmt expr has non-aggregate type: %s", 317 317 toString( expr->result ).c_str() ); … … 654 654 if ( dwt->name == "" ) { 655 655 const Type * t = dwt->get_type()->stripReferences(); 656 if ( auto rty = dynamic_cast<const ReferenceToType *>( t ) ) {656 if ( auto rty = dynamic_cast<const BaseInstType *>( t ) ) { 657 657 if ( ! dynamic_cast<const StructInstType *>(rty) 658 658 && ! dynamic_cast<const UnionInstType *>(rty) ) continue; -
src/AST/Type.cpp
r1c507eb r7a80113 124 124 } 125 125 126 // --- ReferenceToType127 128 void ReferenceToType::initWithSub( const ReferenceToType & o, Pass< ForallSubstitutor > & sub ) {126 // --- BaseInstType 127 128 void BaseInstType::initWithSub( const BaseInstType & o, Pass< ForallSubstitutor > & sub ) { 129 129 ParameterizedType::initWithSub( o, sub ); // initialize substitution 130 130 params = sub.core( o.params ); // apply to parameters 131 131 } 132 132 133 ReferenceToType::ReferenceToType( const ReferenceToType & o )133 BaseInstType::BaseInstType( const BaseInstType & o ) 134 134 : ParameterizedType( o.qualifiers, copy( o.attributes ) ), params(), name( o.name ), 135 135 hoistType( o.hoistType ) { … … 138 138 } 139 139 140 std::vector<readonly<Decl>> ReferenceToType::lookup( const std::string& name ) const {140 std::vector<readonly<Decl>> BaseInstType::lookup( const std::string& name ) const { 141 141 assertf( aggr(), "Must have aggregate to perform lookup" ); 142 142 … … 153 153 SueInstType<decl_t>::SueInstType( 154 154 const decl_t * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 155 : ReferenceToType( b->name, q, move(as) ), base( b ) {}155 : BaseInstType( b->name, q, move(as) ), base( b ) {} 156 156 157 157 template<typename decl_t> … … 168 168 TraitInstType::TraitInstType( 169 169 const TraitDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 170 : ReferenceToType( b->name, q, move(as) ), base( b ) {}170 : BaseInstType( b->name, q, move(as) ), base( b ) {} 171 171 172 172 // --- TypeInstType 173 173 174 174 TypeInstType::TypeInstType( const TypeInstType & o ) 175 : ReferenceToType( o.name, o.qualifiers, copy( o.attributes ) ), base(), kind( o.kind ) {175 : BaseInstType( o.name, o.qualifiers, copy( o.attributes ) ), base(), kind( o.kind ) { 176 176 Pass< ForallSubstitutor > sub; 177 177 initWithSub( o, sub ); // initialize substitution -
src/AST/Type.hpp
r1c507eb r7a80113 329 329 330 330 /// base class for types that refer to types declared elsewhere (aggregates and typedefs) 331 class ReferenceToType : public ParameterizedType {331 class BaseInstType : public ParameterizedType { 332 332 protected: 333 333 /// Initializes forall and parameters based on substitutor 334 void initWithSub( const ReferenceToType & o, Pass< ForallSubstitutor > & sub );334 void initWithSub( const BaseInstType & o, Pass< ForallSubstitutor > & sub ); 335 335 public: 336 336 std::vector<ptr<Expr>> params; … … 338 338 bool hoistType = false; 339 339 340 ReferenceToType(340 BaseInstType( 341 341 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 342 342 : ParameterizedType(q, std::move(as)), params(), name(n) {} 343 343 344 ReferenceToType( const ReferenceToType & o );344 BaseInstType( const BaseInstType & o ); 345 345 346 346 /// Gets aggregate declaration this type refers to … … 350 350 351 351 private: 352 virtual ReferenceToType * clone() const override = 0;352 virtual BaseInstType * clone() const override = 0; 353 353 MUTATE_FRIEND 354 354 }; … … 356 356 // Common implementation for the SUE instance types. Not to be used directly. 357 357 template<typename decl_t> 358 class SueInstType final : public ReferenceToType {358 class SueInstType final : public BaseInstType { 359 359 public: 360 360 using base_type = decl_t; … … 363 363 SueInstType( 364 364 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 365 : ReferenceToType( n, q, std::move(as) ), base() {}365 : BaseInstType( n, q, std::move(as) ), base() {} 366 366 367 367 SueInstType( … … 388 388 389 389 /// An instance of a trait type. 390 class TraitInstType final : public ReferenceToType {390 class TraitInstType final : public BaseInstType { 391 391 public: 392 392 readonly<TraitDecl> base; … … 394 394 TraitInstType( 395 395 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 396 : ReferenceToType( n, q, std::move(as) ), base() {}396 : BaseInstType( n, q, std::move(as) ), base() {} 397 397 398 398 TraitInstType( … … 411 411 412 412 /// instance of named type alias (typedef or variable) 413 class TypeInstType final : public ReferenceToType {413 class TypeInstType final : public BaseInstType { 414 414 public: 415 415 readonly<TypeDecl> base; … … 419 419 const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 420 420 std::vector<ptr<Attribute>> && as = {} ) 421 : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {}421 : BaseInstType( n, q, std::move(as) ), base( b ), kind( b->kind ) {} 422 422 TypeInstType( const std::string& n, TypeDecl::Kind k, CV::Qualifiers q = {}, 423 423 std::vector<ptr<Attribute>> && as = {} ) 424 : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {}424 : BaseInstType( n, q, std::move(as) ), base(), kind( k ) {} 425 425 426 426 TypeInstType( const TypeInstType & o ); -
src/AST/TypeSubstitution.cpp
r1c507eb r7a80113 176 176 } 177 177 178 void TypeSubstitution::Substituter::handleAggregateType( const ReferenceToType * type ) {178 void TypeSubstitution::Substituter::handleAggregateType( const BaseInstType * type ) { 179 179 GuardValue( boundVars ); 180 180 // bind type variables from forall-qualifiers -
src/AST/TypeSubstitution.hpp
r1c507eb r7a80113 169 169 void previsit( const ParameterizedType * type ); 170 170 /// Records type variable bindings from forall-statements and instantiations of generic types 171 void handleAggregateType( const ReferenceToType * type );171 void handleAggregateType( const BaseInstType * type ); 172 172 173 173 void previsit( const StructInstType * aggregateUseType ); -
src/Common/Stats/Stats.cc
r1c507eb r7a80113 35 35 } 36 36 37 namespace ResolveTime { 38 bool enabled = false; 39 } 40 37 41 struct { 38 42 const char * const opt; … … 43 47 { "heap" , Heap::enabled }, 44 48 { "time" , Time::enabled }, 49 { "resolve" , ResolveTime::enabled }, 45 50 }; 46 51 -
src/Common/module.mk
r1c507eb r7a80113 22 22 Common/ErrorObjects.h \ 23 23 Common/Eval.cc \ 24 Common/Examine.cc \ 25 Common/Examine.h \ 24 26 Common/FilterCombos.h \ 25 27 Common/Indenter.h \ … … 38 40 Common/Stats/Heap.cc \ 39 41 Common/Stats/Heap.h \ 42 Common/Stats/ResolveTime.cc \ 43 Common/Stats/ResolveTime.h \ 40 44 Common/Stats/Stats.cc \ 41 45 Common/Stats/Time.cc \ -
src/Concurrency/Keywords.cc
r1c507eb r7a80113 19 19 #include <string> // for string, operator== 20 20 21 #include <iostream> 22 23 #include "Common/Examine.h" // for isMainFor 21 24 #include "Common/PassVisitor.h" // for PassVisitor 22 25 #include "Common/SemanticError.h" // for SemanticError … … 34 37 #include "SynTree/Type.h" // for StructInstType, Type, PointerType 35 38 #include "SynTree/Visitor.h" // for Visitor, acceptAll 39 #include "Virtual/Tables.h" 36 40 37 41 class Attribute; 38 42 39 43 namespace Concurrency { 44 inline static std::string getVTableName( std::string const & exception_name ) { 45 return exception_name.empty() ? std::string() : Virtual::vtableTypeName(exception_name); 46 } 47 40 48 //============================================================================================= 41 49 // Pass declarations … … 54 62 public: 55 63 56 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, AggregateDecl::Aggregate cast_target ) : 57 type_name( type_name ), field_name( field_name ), getter_name( getter_name ), context_error( context_error ), needs_main( needs_main ), cast_target( cast_target ) {} 64 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, 65 std::string&& getter_name, std::string&& context_error, std::string&& exception_name, 66 bool needs_main, AggregateDecl::Aggregate cast_target ) : 67 type_name( type_name ), field_name( field_name ), getter_name( getter_name ), 68 context_error( context_error ), vtable_name( getVTableName( exception_name ) ), 69 needs_main( needs_main ), cast_target( cast_target ) {} 58 70 59 71 virtual ~ConcurrentSueKeyword() {} … … 63 75 64 76 void handle( StructDecl * ); 77 void addVtableForward( StructDecl * ); 65 78 FunctionDecl * forwardDeclare( StructDecl * ); 66 79 ObjectDecl * addField( StructDecl * ); … … 76 89 const std::string getter_name; 77 90 const std::string context_error; 91 const std::string vtable_name; 78 92 bool needs_main; 79 93 AggregateDecl::Aggregate cast_target; … … 81 95 StructDecl * type_decl = nullptr; 82 96 FunctionDecl * dtor_decl = nullptr; 97 StructDecl * vtable_decl = nullptr; 83 98 }; 84 99 … … 101 116 "get_thread", 102 117 "thread keyword requires threads to be in scope, add #include <thread.hfa>\n", 118 "", 103 119 true, 104 120 AggregateDecl::Thread … … 133 149 "get_coroutine", 134 150 "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>\n", 151 "CoroutineCancelled", 135 152 true, 136 153 AggregateDecl::Coroutine … … 167 184 "get_monitor", 168 185 "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>\n", 186 "", 169 187 false, 170 188 AggregateDecl::Monitor … … 198 216 "get_generator", 199 217 "Unable to find builtin type $generator\n", 218 "", 200 219 true, 201 220 AggregateDecl::Generator … … 231 250 232 251 private: 233 DeclarationWithType * is_main( FunctionDecl * );234 252 bool is_real_suspend( FunctionDecl * ); 235 253 … … 359 377 handle( decl ); 360 378 } 379 else if ( !vtable_decl && vtable_name == decl->name && decl->body ) { 380 vtable_decl = decl; 381 } 382 // Might be able to get ride of is target. 383 assert( is_target(decl) == (cast_target == decl->kind) ); 361 384 return decl; 362 385 } 363 386 364 387 DeclarationWithType * ConcurrentSueKeyword::postmutate( FunctionDecl * decl ) { 365 if( !type_decl ) return decl; 366 if( !CodeGen::isDestructor( decl->name ) ) return decl; 367 368 auto params = decl->type->parameters; 369 if( params.size() != 1 ) return decl; 370 371 auto type = dynamic_cast<ReferenceType*>( params.front()->get_type() ); 372 if( !type ) return decl; 373 374 auto stype = dynamic_cast<StructInstType*>( type->base ); 375 if( !stype ) return decl; 376 if( stype->baseStruct != type_decl ) return decl; 377 378 if( !dtor_decl ) dtor_decl = decl; 388 if ( type_decl && isDestructorFor( decl, type_decl ) ) 389 dtor_decl = decl; 390 else if ( vtable_name.empty() ) 391 ; 392 else if ( auto param = isMainFor( decl, cast_target ) ) { 393 // This should never trigger. 394 assert( vtable_decl ); 395 // Should be safe because of isMainFor. 396 StructInstType * struct_type = static_cast<StructInstType *>( 397 static_cast<ReferenceType *>( param->get_type() )->base ); 398 assert( struct_type ); 399 400 declsToAddAfter.push_back( Virtual::makeVtableInstance( vtable_decl, { 401 new TypeExpr( struct_type->clone() ), 402 }, struct_type, nullptr ) ); 403 } 404 379 405 return decl; 380 406 } … … 400 426 if( !dtor_decl ) SemanticError( decl, context_error ); 401 427 428 addVtableForward( decl ); 402 429 FunctionDecl * func = forwardDeclare( decl ); 403 430 ObjectDecl * field = addField( decl ); 404 431 addRoutines( field, func ); 432 } 433 434 void ConcurrentSueKeyword::addVtableForward( StructDecl * decl ) { 435 if ( vtable_decl ) { 436 declsToAddBefore.push_back( Virtual::makeVtableForward( vtable_decl, { 437 new TypeExpr( new StructInstType( noQualifiers, decl ) ), 438 } ) ); 439 // Its only an error if we want a vtable and don't have one. 440 } else if ( ! vtable_name.empty() ) { 441 SemanticError( decl, context_error ); 442 } 405 443 } 406 444 … … 528 566 // Suspend keyword implementation 529 567 //============================================================================================= 530 DeclarationWithType * SuspendKeyword::is_main( FunctionDecl * func) {531 if(func->name != "main") return nullptr;532 if(func->type->parameters.size() != 1) return nullptr;533 534 auto param = func->type->parameters.front();535 536 auto type = dynamic_cast<ReferenceType * >(param->get_type());537 if(!type) return nullptr;538 539 auto obj = dynamic_cast<StructInstType *>(type->base);540 if(!obj) return nullptr;541 542 if(!obj->baseStruct->is_generator()) return nullptr;543 544 return param;545 }546 547 568 bool SuspendKeyword::is_real_suspend( FunctionDecl * func ) { 548 569 if(isMangled(func->linkage)) return false; // the real suspend isn't mangled … … 565 586 566 587 // Is this the main of a generator? 567 auto param = is _main( func);588 auto param = isMainFor( func, AggregateDecl::Aggregate::Generator ); 568 589 if(!param) return; 569 590 … … 910 931 { 911 932 new SingleInit( new AddressExpr( new VariableExpr( monitors ) ) ), 912 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone(), false ) ) 933 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone(), false ) ), 934 new SingleInit( new ConstantExpr( Constant::from_bool( false ) ) ) 913 935 }, 914 936 noDesignators, … … 1033 1055 // tab-width: 4 // 1034 1056 // End: // 1057 -
src/ResolvExpr/CandidateFinder.cpp
r1c507eb r7a80113 816 816 /// Adds aggregate member interpretations 817 817 void addAggMembers( 818 const ast:: ReferenceToType * aggrInst, const ast::Expr * expr,818 const ast::BaseInstType * aggrInst, const ast::Expr * expr, 819 819 const Candidate & cand, const Cost & addedCost, const std::string & name 820 820 ) { … … 1263 1263 1264 1264 void postvisit( const ast::UntypedOffsetofExpr * offsetofExpr ) { 1265 const ast:: ReferenceToType * aggInst;1265 const ast::BaseInstType * aggInst; 1266 1266 if (( aggInst = offsetofExpr->type.as< ast::StructInstType >() )) ; 1267 1267 else if (( aggInst = offsetofExpr->type.as< ast::UnionInstType >() )) ; -
src/ResolvExpr/ConversionCost.cc
r1c507eb r7a80113 520 520 return convertToReferenceCost( src, refType, srcIsLvalue, symtab, env, localPtrsAssignable ); 521 521 } else { 522 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost ); 523 src->accept( converter ); 524 return converter.core.cost; 522 return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost ); 525 523 } 526 524 } … … 563 561 } 564 562 } else { 565 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost ); 566 src->accept( converter ); 567 return converter.core.cost; 563 return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost ); 568 564 } 569 565 } else { -
src/ResolvExpr/ConversionCost.h
r1c507eb r7a80113 88 88 static size_t traceId; 89 89 Cost cost; 90 Cost result() { return cost; } 90 91 91 92 ConversionCost_new( const ast::Type * dst, bool srcIsLvalue, const ast::SymbolTable & symtab, -
src/ResolvExpr/CurrentObject.cc
r1c507eb r7a80113 923 923 924 924 MemberIterator * createMemberIterator( const CodeLocation & loc, const Type * type ) { 925 if ( auto aggr = dynamic_cast< const ReferenceToType * >( type ) ) {925 if ( auto aggr = dynamic_cast< const BaseInstType * >( type ) ) { 926 926 if ( auto sit = dynamic_cast< const StructInstType * >( aggr ) ) { 927 927 return new StructIterator{ loc, sit }; … … 932 932 dynamic_cast< const EnumInstType * >( type ) 933 933 || dynamic_cast< const TypeInstType * >( type ), 934 "Encountered unhandled ReferenceToType in createMemberIterator: %s",934 "Encountered unhandled BaseInstType in createMemberIterator: %s", 935 935 toString( type ).c_str() ); 936 936 return new SimpleIterator{ loc, type }; … … 965 965 DesignatorChain & d = *dit; 966 966 PRINT( std::cerr << "____actual: " << t << std::endl; ) 967 if ( auto refType = dynamic_cast< const ReferenceToType * >( t ) ) {967 if ( auto refType = dynamic_cast< const BaseInstType * >( t ) ) { 968 968 // concatenate identical field names 969 969 for ( const Decl * mem : refType->lookup( nexpr->name ) ) { -
src/ResolvExpr/Resolver.cc
r1c507eb r7a80113 38 38 #include "Common/PassVisitor.h" // for PassVisitor 39 39 #include "Common/SemanticError.h" // for SemanticError 40 #include "Common/Stats/ResolveTime.h" // for ResolveTime::start(), ResolveTime::stop() 40 41 #include "Common/utility.h" // for ValueGuard, group_iterate 41 42 #include "InitTweak/GenInit.h" … … 965 966 /// Finds deleted expressions in an expression tree 966 967 struct DeleteFinder_new final : public ast::WithShortCircuiting { 967 const ast::DeletedExpr * delExpr= nullptr;968 const ast::DeletedExpr * result = nullptr; 968 969 969 970 void previsit( const ast::DeletedExpr * expr ) { 970 if ( delExpr) { visit_children = false; }971 else { delExpr= expr; }971 if ( result ) { visit_children = false; } 972 else { result = expr; } 972 973 } 973 974 974 975 void previsit( const ast::Expr * ) { 975 if ( delExpr) { visit_children = false; }976 if ( result ) { visit_children = false; } 976 977 } 977 978 }; … … 980 981 /// Check if this expression is or includes a deleted expression 981 982 const ast::DeletedExpr * findDeletedExpr( const ast::Expr * expr ) { 982 ast::Pass<DeleteFinder_new> finder; 983 expr->accept( finder ); 984 return finder.core.delExpr; 983 return ast::Pass<DeleteFinder_new>::read( expr ); 985 984 } 986 985 … … 1171 1170 const ast::Expr * untyped, const ast::SymbolTable & symtab 1172 1171 ) { 1173 return findKindExpression( untyped, symtab ); 1172 Stats::ResolveTime::start( untyped ); 1173 auto res = findKindExpression( untyped, symtab ); 1174 Stats::ResolveTime::stop(); 1175 return res; 1174 1176 } 1175 1177 } // anonymous namespace … … 1261 1263 const ast::ThrowStmt * previsit( const ast::ThrowStmt * ); 1262 1264 const ast::CatchStmt * previsit( const ast::CatchStmt * ); 1265 const ast::CatchStmt * postvisit( const ast::CatchStmt * ); 1263 1266 const ast::WaitForStmt * previsit( const ast::WaitForStmt * ); 1264 1267 … … 1493 1496 1494 1497 const ast::CatchStmt * Resolver_new::previsit( const ast::CatchStmt * catchStmt ) { 1495 // TODO: This will need a fix for the decl/cond scoping problem. 1498 // Until we are very sure this invarent (ifs that move between passes have thenPart) 1499 // holds, check it. This allows a check for when to decode the mangling. 1500 if ( auto ifStmt = catchStmt->body.as<ast::IfStmt>() ) { 1501 assert( ifStmt->thenPart ); 1502 } 1503 // Encode the catchStmt so the condition can see the declaration. 1496 1504 if ( catchStmt->cond ) { 1497 ast::ptr< ast::Type > boolType = new ast::BasicType{ ast::BasicType::Bool }; 1498 catchStmt = ast::mutate_field( 1499 catchStmt, &ast::CatchStmt::cond, 1500 findSingleExpression( catchStmt->cond, boolType, symtab ) ); 1505 ast::CatchStmt * stmt = mutate( catchStmt ); 1506 stmt->body = new ast::IfStmt( stmt->location, stmt->cond, nullptr, stmt->body ); 1507 stmt->cond = nullptr; 1508 return stmt; 1509 } 1510 return catchStmt; 1511 } 1512 1513 const ast::CatchStmt * Resolver_new::postvisit( const ast::CatchStmt * catchStmt ) { 1514 // Decode the catchStmt so everything is stored properly. 1515 const ast::IfStmt * ifStmt = catchStmt->body.as<ast::IfStmt>(); 1516 if ( nullptr != ifStmt && nullptr == ifStmt->thenPart ) { 1517 assert( ifStmt->cond ); 1518 assert( ifStmt->elsePart ); 1519 ast::CatchStmt * stmt = ast::mutate( catchStmt ); 1520 stmt->cond = ifStmt->cond; 1521 stmt->body = ifStmt->elsePart; 1522 // ifStmt should be implicately deleted here. 1523 return stmt; 1501 1524 } 1502 1525 return catchStmt; -
src/SymTab/Mangler.cc
r1c507eb r7a80113 437 437 private: 438 438 void mangleDecl( const ast::DeclWithType *declaration ); 439 void mangleRef( const ast:: ReferenceToType *refType, std::string prefix );439 void mangleRef( const ast::BaseInstType *refType, std::string prefix ); 440 440 441 441 void printQualifiers( const ast::Type *type ); … … 560 560 } 561 561 562 void Mangler_new::mangleRef( const ast:: ReferenceToType * refType, std::string prefix ) {562 void Mangler_new::mangleRef( const ast::BaseInstType * refType, std::string prefix ) { 563 563 printQualifiers( refType ); 564 564 -
src/SymTab/Validate.cc
r1c507eb r7a80113 960 960 } 961 961 962 static bool isNonParameterAttribute( Attribute * attr ) { 963 static const std::vector<std::string> bad_names = { 964 "aligned", "__aligned__", 965 }; 966 for ( auto name : bad_names ) { 967 if ( name == attr->name ) { 968 return true; 969 } 970 } 971 return false; 972 } 973 962 974 Type * ReplaceTypedef::postmutate( TypeInstType * typeInst ) { 963 975 // instances of typedef types will come here. If it is an instance … … 968 980 ret->location = typeInst->location; 969 981 ret->get_qualifiers() |= typeInst->get_qualifiers(); 970 // attributes are not carried over from typedef to function parameters/return values 971 if ( ! inFunctionType ) { 972 ret->attributes.splice( ret->attributes.end(), typeInst->attributes ); 973 } else { 974 deleteAll( ret->attributes ); 975 ret->attributes.clear(); 976 } 982 // GCC ignores certain attributes if they arrive by typedef, this mimics that. 983 if ( inFunctionType ) { 984 ret->attributes.remove_if( isNonParameterAttribute ); 985 } 986 ret->attributes.splice( ret->attributes.end(), typeInst->attributes ); 977 987 // place instance parameters on the typedef'd type 978 988 if ( ! typeInst->parameters.empty() ) { … … 1508 1518 } 1509 1519 1510 void checkGenericParameters( const ast:: ReferenceToType * inst ) {1520 void checkGenericParameters( const ast::BaseInstType * inst ) { 1511 1521 for ( const ast::Expr * param : inst->params ) { 1512 1522 if ( ! dynamic_cast< const ast::TypeExpr * >( param ) ) { -
src/Virtual/module.mk
r1c507eb r7a80113 15 15 ############################################################################### 16 16 17 SRC += Virtual/ExpandCasts.cc Virtual/ExpandCasts.h 17 SRC += Virtual/ExpandCasts.cc Virtual/ExpandCasts.h \ 18 Virtual/Tables.cc Virtual/Tables.h 19 20 SRCDEMANGLE += Virtual/Tables.cc
Note:
See TracChangeset
for help on using the changeset viewer.