Changeset 59db689 for src/Parser/DeclarationNode.cc
- Timestamp:
- Jun 6, 2015, 11:38:58 PM (9 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:
- cd623a4
- Parents:
- a65d92e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
ra65d92e r59db689 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 3 11:54:32201513 // Update Count : 1412 // Last Modified On : Sat Jun 6 23:29:13 2015 13 // Update Count : 23 14 14 // 15 15 … … 74 74 75 75 void DeclarationNode::print( std::ostream &os, int indent ) const { 76 os << string( indent, ' ' );76 os << string( indent, ' ' ); 77 77 if ( name == "" ) { 78 78 os << "unnamed: "; … … 93 93 94 94 if ( bitfieldWidth ) { 95 os << endl << string( indent+2, ' ') << "with bitfield width ";95 os << endl << string( indent + 2, ' ' ) << "with bitfield width "; 96 96 bitfieldWidth->printOneLine( os ); 97 97 } 98 98 99 99 if ( initializer != 0 ) { 100 os << endl << string( indent+2, ' ') << "with initializer ";100 os << endl << string( indent + 2, ' ' ) << "with initializer "; 101 101 initializer->printOneLine( os ); 102 102 } … … 161 161 } 162 162 163 DeclarationNode *DeclarationNode::newForall( DeclarationNode *forall ) {163 DeclarationNode *DeclarationNode::newForall( DeclarationNode *forall ) { 164 164 DeclarationNode *newnode = new DeclarationNode; 165 165 newnode->type = new TypeData( TypeData::Unknown ); … … 168 168 } 169 169 170 DeclarationNode *DeclarationNode::newFromTypedef( std::string *name ) {170 DeclarationNode *DeclarationNode::newFromTypedef( std::string *name ) { 171 171 DeclarationNode *newnode = new DeclarationNode; 172 172 newnode->type = new TypeData( TypeData::SymbolicInst ); … … 177 177 } 178 178 179 DeclarationNode *DeclarationNode::newAggregate( TyCon kind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields ) {179 DeclarationNode *DeclarationNode::newAggregate( TyCon kind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields ) { 180 180 DeclarationNode *newnode = new DeclarationNode; 181 181 newnode->type = new TypeData( TypeData::Aggregate ); … … 203 203 } 204 204 205 DeclarationNode *DeclarationNode::newEnumConstant( std::string *name, ExpressionNode *constant ) {205 DeclarationNode *DeclarationNode::newEnumConstant( std::string *name, ExpressionNode *constant ) { 206 206 DeclarationNode *newnode = new DeclarationNode; 207 207 newnode->name = assign_strptr( name ); … … 210 210 } 211 211 212 DeclarationNode *DeclarationNode::newName( std::string *name ) {212 DeclarationNode *DeclarationNode::newName( std::string *name ) { 213 213 DeclarationNode *newnode = new DeclarationNode; 214 214 newnode->name = assign_strptr( name ); … … 216 216 } 217 217 218 DeclarationNode *DeclarationNode::newFromTypeGen( std::string *name, ExpressionNode *params ) {218 DeclarationNode *DeclarationNode::newFromTypeGen( std::string *name, ExpressionNode *params ) { 219 219 DeclarationNode *newnode = new DeclarationNode; 220 220 newnode->type = new TypeData( TypeData::SymbolicInst ); … … 225 225 } 226 226 227 DeclarationNode *DeclarationNode::newTypeParam( TypeClass tc, std::string *name ) {227 DeclarationNode *DeclarationNode::newTypeParam( TypeClass tc, std::string *name ) { 228 228 DeclarationNode *newnode = new DeclarationNode; 229 229 newnode->name = assign_strptr( name ); … … 467 467 } 468 468 469 DeclarationNode *DeclarationNode::addAssertions( DeclarationNode *assertions ) {469 DeclarationNode *DeclarationNode::addAssertions( DeclarationNode *assertions ) { 470 470 assert( type ); 471 471 switch ( type->kind ) { … … 493 493 } 494 494 495 DeclarationNode *DeclarationNode::addName( std::string *newname ) {495 DeclarationNode *DeclarationNode::addName( std::string *newname ) { 496 496 name = assign_strptr( newname ); 497 497 return this; … … 758 758 void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList ) { 759 759 SemanticError errors; 760 std::back_insert_iterator< std::list< Declaration *> > out( outputList );760 std::back_insert_iterator< std::list< Declaration *> > out( outputList ); 761 761 const DeclarationNode *cur = firstNode; 762 762 while ( cur ) { … … 776 776 errors.append( e ); 777 777 } // try 778 cur = dynamic_cast< DeclarationNode *>( cur->get_link() );778 cur = dynamic_cast< DeclarationNode *>( cur->get_link() ); 779 779 } // while 780 780 if ( ! errors.isEmpty() ) { … … 783 783 } 784 784 785 void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType *> &outputList ) {785 void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType *> &outputList ) { 786 786 SemanticError errors; 787 std::back_insert_iterator< std::list< DeclarationWithType *> > out( outputList );787 std::back_insert_iterator< std::list< DeclarationWithType *> > out( outputList ); 788 788 const DeclarationNode *cur = firstNode; 789 789 while ( cur ) { … … 799 799 Declaration *decl = cur->build(); 800 800 if ( decl ) { 801 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType *>( decl ) ) {801 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType *>( decl ) ) { 802 802 *out++ = dwt; 803 } else if ( StructDecl *agg = dynamic_cast< StructDecl *>( decl ) ) {803 } else if ( StructDecl *agg = dynamic_cast< StructDecl *>( decl ) ) { 804 804 StructInstType *inst = new StructInstType( Type::Qualifiers(), agg->get_name() ); 805 805 *out++ = new ObjectDecl( "", Declaration::NoStorageClass, linkage, 0, inst, 0 ); 806 806 delete agg; 807 } else if ( UnionDecl *agg = dynamic_cast< UnionDecl *>( decl ) ) {807 } else if ( UnionDecl *agg = dynamic_cast< UnionDecl *>( decl ) ) { 808 808 UnionInstType *inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); 809 809 *out++ = new ObjectDecl( "", Declaration::NoStorageClass, linkage, 0, inst, 0 ); … … 813 813 errors.append( e ); 814 814 } // try 815 cur = dynamic_cast< DeclarationNode *>( cur->get_link() );815 cur = dynamic_cast< DeclarationNode *>( cur->get_link() ); 816 816 } // while 817 817 if ( ! errors.isEmpty() ) { … … 820 820 } 821 821 822 void buildTypeList( const DeclarationNode *firstNode, std::list< Type *> &outputList ) {822 void buildTypeList( const DeclarationNode *firstNode, std::list< Type *> &outputList ) { 823 823 SemanticError errors; 824 std::back_insert_iterator< std::list< Type *> > out( outputList );824 std::back_insert_iterator< std::list< Type *> > out( outputList ); 825 825 const DeclarationNode *cur = firstNode; 826 826 while ( cur ) { … … 830 830 errors.append( e ); 831 831 } // try 832 cur = dynamic_cast< DeclarationNode *>( cur->get_link() );832 cur = dynamic_cast< DeclarationNode *>( cur->get_link() ); 833 833 } // while 834 834 if ( ! errors.isEmpty() ) {
Note: See TracChangeset
for help on using the changeset viewer.