Changeset 937e51d for src/SymTab/Validate.cc
- Timestamp:
- Jun 26, 2015, 4:00:26 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 0df292b, e0ff3e6
- Parents:
- eb50842 (diff), 1869adf (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
-
src/SymTab/Validate.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
reb50842 r937e51d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue May 19 16:50:09201513 // Update Count : 3 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jun 24 16:20:50 2015 13 // Update Count : 30 14 14 // 15 15 … … 45 45 #include "SynTree/Type.h" 46 46 #include "SynTree/Statement.h" 47 #include "SynTree/TypeSubstitution.h" 47 48 #include "Indexer.h" 48 #include "SynTree/TypeSubstitution.h"49 49 #include "FixFunction.h" 50 50 #include "ImplementationType.h" … … 176 176 acceptAll( translationUnit, pass1 ); 177 177 acceptAll( translationUnit, pass2 ); 178 // need to collect all of the assignment operators prior to 179 // this point and only generate assignment operators if one doesn't exist 178 180 AddStructAssignment::addStructAssignment( translationUnit ); 179 181 acceptAll( translationUnit, pass3 ); … … 506 508 if ( ! array->get_dimension() ) return; 507 509 508 ObjectDecl *index = new ObjectDecl( indexName.newName(), Declaration ::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 );510 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 ); 509 511 *out++ = new DeclStmt( noLabels, index ); 510 512 … … 544 546 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 545 547 546 ObjectDecl *returnVal = new ObjectDecl( "", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );548 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 ); 547 549 assignType->get_returnVals().push_back( returnVal ); 548 550 549 ObjectDecl *dstParam = new ObjectDecl( "_dst", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 );551 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 ); 550 552 assignType->get_parameters().push_back( dstParam ); 551 553 552 ObjectDecl *srcParam = new ObjectDecl( "_src", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 );554 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 ); 553 555 assignType->get_parameters().push_back( srcParam ); 554 556 555 557 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 556 558 // because each unit generates copies of the default routines for each aggregate. 557 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? Declaration ::NoStorageClass : Declaration::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true );559 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false ); 558 560 assignDecl->fixUniqueId(); 559 561 560 562 for ( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) { 561 563 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member ) ) { 564 // query the type qualifiers of this field and skip assigning it if it is marked const. 565 // If it is an array type, we need to strip off the array layers to find its qualifiers. 566 Type * type = dwt->get_type(); 567 while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) { 568 type = at->get_base(); 569 } 570 571 if ( type->get_qualifiers().isConst ) { 572 // don't assign const members 573 continue; 574 } 575 562 576 if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) { 563 577 makeArrayAssignment( srcParam, dstParam, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) ); … … 575 589 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 576 590 577 ObjectDecl *returnVal = new ObjectDecl( "", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );591 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 ); 578 592 assignType->get_returnVals().push_back( returnVal ); 579 593 580 ObjectDecl *dstParam = new ObjectDecl( "_dst", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 );594 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 ); 581 595 assignType->get_parameters().push_back( dstParam ); 582 596 583 ObjectDecl *srcParam = new ObjectDecl( "_src", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 );597 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 ); 584 598 assignType->get_parameters().push_back( srcParam ); 585 599 586 600 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 587 601 // because each unit generates copies of the default routines for each aggregate. 588 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? Declaration ::NoStorageClass : Declaration::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true );602 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false ); 589 603 assignDecl->fixUniqueId(); 590 604 … … 621 635 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); 622 636 typeInst->set_baseType( typeDecl ); 623 ObjectDecl *src = new ObjectDecl( "_src", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 );624 ObjectDecl *dst = new ObjectDecl( "_dst", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 );637 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 ); 638 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 ); 625 639 if ( typeDecl->get_base() ) { 626 640 stmts = new CompoundStmt( std::list< Label >() ); … … 631 645 } // if 632 646 FunctionType *type = new FunctionType( Type::Qualifiers(), false ); 633 type->get_returnVals().push_back( new ObjectDecl( "", Declaration ::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );647 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) ); 634 648 type->get_parameters().push_back( dst ); 635 649 type->get_parameters().push_back( src ); 636 FunctionDecl *func = new FunctionDecl( "?=?", Declaration ::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false );650 FunctionDecl *func = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false, false ); 637 651 declsToAdd.push_back( func ); 638 652 } 639 653 640 654 void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) { 641 if ( ! declsToAdd.empty() ) { 642 for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) { 643 statements.insert( i, new DeclStmt( noLabels, *decl ) ); 644 } // for 645 declsToAdd.clear(); 646 } // if 655 for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) { 656 statements.insert( i, new DeclStmt( noLabels, *decl ) ); 657 } // for 658 declsToAdd.clear(); 647 659 } 648 660
Note:
See TracChangeset
for help on using the changeset viewer.