Changeset 3a5131ed for src/Parser
- Timestamp:
- Feb 16, 2017, 3:36:45 PM (8 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:
- 317450e
- Parents:
- c3d9adc
- Location:
- src/Parser
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Parser/DeclarationNode.cc ¶
rc3d9adc r3a5131ed 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 9 15:54:59201713 // Update Count : 7 4212 // Last Modified On : Thu Feb 16 13:06:50 2017 13 // Update Count : 753 14 14 // 15 15 … … 913 913 SemanticError errors; 914 914 std::back_insert_iterator< std::list< Declaration * > > out( outputList ); 915 const DeclarationNode * cur = firstNode; 916 917 while ( cur ) { 915 916 for ( const DeclarationNode * cur = firstNode; cur; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) { 918 917 try { 919 918 if ( DeclarationNode * extr = cur->extractAggregate() ) { … … 936 935 errors.append( e ); 937 936 } // try 938 cur = dynamic_cast< DeclarationNode * >( cur->get_next() );939 937 } // while 940 938 … … 947 945 SemanticError errors; 948 946 std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList ); 949 const DeclarationNode * cur = firstNode;950 while ( cur) {947 948 for ( const DeclarationNode * cur = firstNode; cur; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) { 951 949 try { 952 950 Declaration * decl = cur->build(); … … 972 970 errors.append( e ); 973 971 } // try 974 cur = dynamic_cast< DeclarationNode * >( cur->get_next() );975 } // while 972 } // for 973 976 974 if ( ! errors.isEmpty() ) { 977 975 throw errors; -
TabularUnified src/Parser/ParseNode.h ¶
rc3d9adc r3a5131ed 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 9 14:45:28201713 // Update Count : 6 5812 // Last Modified On : Thu Feb 16 13:15:55 2017 13 // Update Count : 661 14 14 // 15 15 … … 437 437 template< typename SynTreeType, typename NodeType > 438 438 void buildMoveList( const NodeType * firstNode, std::list< SynTreeType * > &outputList ) { 439 buildList( firstNode, outputList);439 buildList( firstNode, outputList ); 440 440 delete firstNode; 441 441 } -
TabularUnified src/Parser/TypeData.cc ¶
rc3d9adc r3a5131ed 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 27 15:28:56201713 // Update Count : 4 2812 // Last Modified On : Thu Feb 16 15:06:59 2017 13 // Update Count : 455 14 14 // 15 15 … … 724 724 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 725 725 if ( td->kind == TypeData::Function ) { 726 if ( td->function.idList ) { 727 buildKRFunction( td->function ); 728 } // if 729 726 730 FunctionDecl * decl; 727 731 if ( td->function.hasBody ) { … … 738 742 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), nullptr, isInline, isNoreturn, attributes ); 739 743 } // if 740 for ( DeclarationNode * cur = td->function.idList; cur != nullptr; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) {741 if ( cur->name ) {742 decl->get_oldIdents().insert( decl->get_oldIdents().end(), *cur->name );743 } // if744 } // for745 buildList( td->function.oldDeclList, decl->get_oldDecls() );746 744 return decl->set_asmName( asmName ); 747 745 } else if ( td->kind == TypeData::Aggregate ) { … … 778 776 } // buildFunction 779 777 778 void buildKRFunction( const TypeData::Function_t & function ) { 779 assert( ! function.params ); 780 for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = dynamic_cast< DeclarationNode* >( decl->get_next() ) ) { 781 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode* >( param->get_next() ) ) { 782 if ( *decl->name == *param->name ) { 783 if ( param->type ) throw SemanticError( string( "duplicate declaration name " ) + *param->name ); 784 if ( ! decl->type ) throw SemanticError( string( "duplicate parameter name " ) + *param->name ); 785 param->type = decl->type; 786 decl->type = nullptr; 787 param->attributes.splice( param->attributes.end(), decl->attributes ); 788 } // if 789 } // for 790 if ( decl->type ) throw SemanticError( string( "missing name in parameter list " ) + *decl->name ); 791 } // for 792 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode* >( param->get_next() ) ) { 793 if ( ! param->type ) { 794 param->type = new TypeData( TypeData::Basic ); 795 param->type->basictype = DeclarationNode::Int; 796 } // if 797 } // for 798 799 function.params = function.idList; 800 function.idList = nullptr; 801 delete function.oldDeclList; 802 function.oldDeclList = nullptr; 803 } // buildKRFunction 804 780 805 // Local Variables: // 781 806 // tab-width: 4 // -
TabularUnified src/Parser/TypeData.h ¶
rc3d9adc r3a5131ed 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 17:02:09201713 // Update Count : 1 4612 // Last Modified On : Thu Feb 16 14:30:05 2017 13 // Update Count : 153 14 14 // 15 15 … … 52 52 53 53 struct Function_t { 54 DeclarationNode * params;55 DeclarationNode * idList;// old-style56 DeclarationNode * oldDeclList;54 mutable DeclarationNode * params; // mutables modified in buildKRFunction 55 mutable DeclarationNode * idList; // old-style 56 mutable DeclarationNode * oldDeclList; 57 57 StatementNode * body; 58 58 bool hasBody; … … 113 113 Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 114 114 FunctionType * buildFunction( const TypeData * ); 115 void buildKRFunction( const TypeData::Function_t & function ); 115 116 116 117 #endif // TYPEDATA_H
Note: See TracChangeset
for help on using the changeset viewer.