Changes in src/SymTab/Validate.cc [1869adf:843054c2]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r1869adf r843054c2 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Jun 24 16:20:50201513 // Update Count : 3 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 19 16:50:09 2015 13 // Update Count : 3 14 14 // 15 15 … … 45 45 #include "SynTree/Type.h" 46 46 #include "SynTree/Statement.h" 47 #include "Indexer.h" 47 48 #include "SynTree/TypeSubstitution.h" 48 #include "Indexer.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 to179 // this point and only generate assignment operators if one doesn't exist180 178 AddStructAssignment::addStructAssignment( translationUnit ); 181 179 acceptAll( translationUnit, pass3 ); … … 508 506 if ( ! array->get_dimension() ) return; 509 507 510 ObjectDecl *index = new ObjectDecl( indexName.newName(), Declaration Node::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 );508 ObjectDecl *index = new ObjectDecl( indexName.newName(), Declaration::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 ); 511 509 *out++ = new DeclStmt( noLabels, index ); 512 510 … … 546 544 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 547 545 548 ObjectDecl *returnVal = new ObjectDecl( "", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );546 ObjectDecl *returnVal = new ObjectDecl( "", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 ); 549 547 assignType->get_returnVals().push_back( returnVal ); 550 548 551 ObjectDecl *dstParam = new ObjectDecl( "_dst", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 );549 ObjectDecl *dstParam = new ObjectDecl( "_dst", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 ); 552 550 assignType->get_parameters().push_back( dstParam ); 553 551 554 ObjectDecl *srcParam = new ObjectDecl( "_src", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 );552 ObjectDecl *srcParam = new ObjectDecl( "_src", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 ); 555 553 assignType->get_parameters().push_back( srcParam ); 556 554 557 555 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 558 556 // because each unit generates copies of the default routines for each aggregate. 559 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? Declaration Node::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false );557 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? Declaration::NoStorageClass : Declaration::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true ); 560 558 assignDecl->fixUniqueId(); 561 559 562 560 for ( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) { 563 561 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 members573 continue;574 }575 576 562 if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) { 577 563 makeArrayAssignment( srcParam, dstParam, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) ); … … 589 575 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 590 576 591 ObjectDecl *returnVal = new ObjectDecl( "", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );577 ObjectDecl *returnVal = new ObjectDecl( "", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 ); 592 578 assignType->get_returnVals().push_back( returnVal ); 593 579 594 ObjectDecl *dstParam = new ObjectDecl( "_dst", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 );580 ObjectDecl *dstParam = new ObjectDecl( "_dst", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType->clone() ), 0 ); 595 581 assignType->get_parameters().push_back( dstParam ); 596 582 597 ObjectDecl *srcParam = new ObjectDecl( "_src", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 );583 ObjectDecl *srcParam = new ObjectDecl( "_src", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, refType, 0 ); 598 584 assignType->get_parameters().push_back( srcParam ); 599 585 600 586 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 601 587 // because each unit generates copies of the default routines for each aggregate. 602 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? Declaration Node::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false );588 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? Declaration::NoStorageClass : Declaration::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true ); 603 589 assignDecl->fixUniqueId(); 604 590 … … 635 621 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); 636 622 typeInst->set_baseType( typeDecl ); 637 ObjectDecl *src = new ObjectDecl( "_src", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 );638 ObjectDecl *dst = new ObjectDecl( "_dst", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 );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 ); 639 625 if ( typeDecl->get_base() ) { 640 626 stmts = new CompoundStmt( std::list< Label >() ); … … 645 631 } // if 646 632 FunctionType *type = new FunctionType( Type::Qualifiers(), false ); 647 type->get_returnVals().push_back( new ObjectDecl( "", Declaration Node::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );633 type->get_returnVals().push_back( new ObjectDecl( "", Declaration::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) ); 648 634 type->get_parameters().push_back( dst ); 649 635 type->get_parameters().push_back( src ); 650 FunctionDecl *func = new FunctionDecl( "?=?", Declaration Node::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false, false );636 FunctionDecl *func = new FunctionDecl( "?=?", Declaration::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false ); 651 637 declsToAdd.push_back( func ); 652 638 } 653 639 654 640 void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) { 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(); 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 659 647 } 660 648
Note:
See TracChangeset
for help on using the changeset viewer.