Changeset 8b11840 for src/SymTab/Autogen.cc
- Timestamp:
- Sep 22, 2017, 1:50:00 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- b56c17c
- Parents:
- 05807e9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r05807e9 r8b11840 16 16 #include "Autogen.h" 17 17 18 #include <cstddef> // for NULL19 18 #include <algorithm> // for count_if 20 19 #include <cassert> // for strict_dynamic_cast, assert, assertf … … 32 31 #include "GenPoly/DeclMutator.h" // for DeclMutator 33 32 #include "GenPoly/ScopedSet.h" // for ScopedSet, ScopedSet<>::iterator 33 #include "InitTweak/GenInit.h" // for fixReturnStatements 34 #include "ResolvExpr/Resolver.h" // for resolveDecl 34 35 #include "SymTab/Mangler.h" // for Mangler 35 36 #include "SynTree/Attribute.h" // For Attribute … … 108 109 109 110 bool isUnnamedBitfield( ObjectDecl * obj ) { 110 return obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL;111 return obj != nullptr && obj->get_name() == "" && obj->get_bitfieldWidth() != nullptr; 111 112 } 112 113 … … 115 116 FunctionDecl * decl = functionDecl->clone(); 116 117 delete decl->get_statements(); 117 decl->set_statements( NULL);118 decl->set_statements( nullptr ); 118 119 declsToAdd.push_back( decl ); 119 120 decl->fixUniqueId(); … … 326 327 assert( ! func->get_functionType()->get_parameters().empty() ); 327 328 ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->get_parameters().front() ); 328 ObjectDecl * srcParam = NULL;329 ObjectDecl * srcParam = nullptr; 329 330 if ( func->get_functionType()->get_parameters().size() == 2 ) { 330 331 srcParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->get_parameters().back() ); … … 333 334 assert( dstParam ); 334 335 335 Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : NULL;336 Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : nullptr; 336 337 makeStructMemberOp( dstParam, srcselect, field, func, forward ); 337 338 } // if … … 372 373 } else { 373 374 // no matching parameter, initialize field with default ctor 374 makeStructMemberOp( dstParam, NULL, field, func );375 makeStructMemberOp( dstParam, nullptr, field, func ); 375 376 } 376 377 } … … 388 389 void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd, const std::vector< FuncData > & data ) { 389 390 // Builtins do not use autogeneration. 390 if ( aggregateDecl->get_linkage() == LinkageSpec::BuiltinCFA || 391 aggregateDecl->get_linkage() == LinkageSpec::BuiltinC ) { 391 if ( LinkageSpec::isBuiltin( aggregateDecl->get_linkage() ) ) { 392 392 return; 393 393 } 394 394 395 395 // Make function polymorphic in same parameters as generic struct, if applicable 396 const std::list< TypeDecl * > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions396 const std::list< TypeDecl * > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions 397 397 398 398 // generate each of the functions based on the supplied FuncData objects … … 565 565 } 566 566 567 void AutogenerateRoutines::previsit( EnumDecl * enumDecl ) {567 void AutogenerateRoutines::previsit( EnumDecl * enumDecl ) { 568 568 visit_children = false; 569 569 if ( ! enumDecl->get_members().empty() ) { … … 574 574 } 575 575 576 void AutogenerateRoutines::previsit( StructDecl * structDecl ) {576 void AutogenerateRoutines::previsit( StructDecl * structDecl ) { 577 577 visit_children = false; 578 if ( structDecl->has_body() && structsDone.find( structDecl-> get_name()) == structsDone.end() ) {579 StructInstType structInst( Type::Qualifiers(), structDecl-> get_name());580 for ( TypeDecl * typeDecl : structDecl-> get_parameters()) {578 if ( structDecl->has_body() && structsDone.find( structDecl->name ) == structsDone.end() ) { 579 StructInstType structInst( Type::Qualifiers(), structDecl->name ); 580 for ( TypeDecl * typeDecl : structDecl->parameters ) { 581 581 // need to visit assertions so that they are added to the appropriate maps 582 acceptAll( typeDecl-> get_assertions(), *visitor );583 structInst. get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) );582 acceptAll( typeDecl->assertions, *visitor ); 583 structInst.parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) ); 584 584 } 585 585 structInst.set_baseStruct( structDecl ); 586 586 makeStructFunctions( structDecl, &structInst, functionNesting, declsToAddAfter, data ); 587 structsDone.insert( structDecl-> get_name());587 structsDone.insert( structDecl->name ); 588 588 } // if 589 589 } 590 590 591 void AutogenerateRoutines::previsit( UnionDecl * unionDecl ) {591 void AutogenerateRoutines::previsit( UnionDecl * unionDecl ) { 592 592 visit_children = false; 593 593 if ( ! unionDecl->get_members().empty() ) { … … 609 609 610 610 // generate ctor/dtors/assign for typedecls, e.g., otype T = int *; 611 void AutogenerateRoutines::previsit( TypeDecl * typeDecl ) {611 void AutogenerateRoutines::previsit( TypeDecl * typeDecl ) { 612 612 visit_children = false; 613 613 if ( ! typeDecl->base ) return; … … 678 678 insert( functionDecl, destructable, InitTweak::isDestructor ); 679 679 680 maybeAccept( functionDecl-> get_functionType(), *visitor );680 maybeAccept( functionDecl->type, *visitor ); 681 681 functionNesting += 1; 682 maybeAccept( functionDecl-> get_statements(), *visitor );682 maybeAccept( functionDecl->statements, *visitor ); 683 683 functionNesting -= 1; 684 684 }
Note: See TracChangeset
for help on using the changeset viewer.