Changeset dd020c0 for src/Parser/TypeData.cc
- Timestamp:
- Mar 3, 2017, 10:12:02 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:
- 8191203
- Parents:
- f37147b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
rf37147b rdd020c0 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 23 21:48:55201713 // Update Count : 48512 // Last Modified On : Fri Mar 3 21:59:10 2017 13 // Update Count : 516 14 14 // 15 15 … … 157 157 TypeData * TypeData::clone() const { 158 158 TypeData * newtype = new TypeData( kind ); 159 newtype-> qualifiers = qualifiers;159 newtype->typeQualifiers = typeQualifiers; 160 160 newtype->base = maybeClone( base ); 161 161 newtype->forall = maybeClone( forall ); … … 226 226 227 227 void TypeData::print( ostream &os, int indent ) const { 228 for ( int i = 0; i < DeclarationNode::No Qualifier; i += 1 ) {229 if ( qualifiers[i] ) os << DeclarationNode::qualifierName[ i ] << ' ';228 for ( int i = 0; i < DeclarationNode::NoTypeQualifier; i += 1 ) { 229 if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' '; 230 230 } // for 231 231 … … 250 250 break; 251 251 case Basic: 252 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessName [ signedness ] << " ";253 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthName [ length ] << " ";252 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " "; 253 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " "; 254 254 assert( basictype != DeclarationNode::NoBasicType ); 255 os << DeclarationNode::basicTypeName [ basictype ] << " ";256 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeName [ complextype ] << " ";255 os << DeclarationNode::basicTypeNames[ basictype ] << " "; 256 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeNames[ complextype ] << " "; 257 257 break; 258 258 case Array: … … 301 301 break; 302 302 case Aggregate: 303 os << DeclarationNode::aggregateName [ aggregate.kind ] << ' ' << *aggregate.name << endl;303 os << DeclarationNode::aggregateNames[ aggregate.kind ] << ' ' << *aggregate.name << endl; 304 304 if ( aggregate.params ) { 305 305 os << string( indent + 2, ' ' ) << "with type parameters " << endl; … … 399 399 FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false ); 400 400 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 401 td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr , false, false) );401 td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr ) ); 402 402 403 403 // add copy ctor: void ?{}(T *, T) … … 405 405 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 406 406 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 407 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr , false, false) );407 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr ) ); 408 408 409 409 // add default ctor: void ?{}(T *) 410 410 FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false ); 411 411 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 412 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr , false, false) );412 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr ) ); 413 413 414 414 // add assignment operator: T * ?=?(T *, T) … … 417 417 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 418 418 assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 419 td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr , false, false) );419 td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr ) ); 420 420 } // if 421 421 } // for … … 494 494 Type::Qualifiers buildQualifiers( const TypeData * td ) { 495 495 Type::Qualifiers q; 496 q.isConst = td-> qualifiers[ DeclarationNode::Const ];497 q.isVolatile = td-> qualifiers[ DeclarationNode::Volatile ];498 q.isRestrict = td-> qualifiers[ DeclarationNode::Restrict ];499 q.isLvalue = td-> qualifiers[ DeclarationNode::Lvalue ];500 q.isAtomic = td-> qualifiers[ DeclarationNode::Atomic ];;496 q.isConst = td->typeQualifiers[ DeclarationNode::Const ]; 497 q.isVolatile = td->typeQualifiers[ DeclarationNode::Volatile ]; 498 q.isRestrict = td->typeQualifiers[ DeclarationNode::Restrict ]; 499 q.isLvalue = td->typeQualifiers[ DeclarationNode::Lvalue ]; 500 q.isAtomic = td->typeQualifiers[ DeclarationNode::Atomic ];; 501 501 return q; 502 502 } // buildQualifiers … … 516 516 case DeclarationNode::Bool: 517 517 if ( td->signedness != DeclarationNode::NoSignedness ) { 518 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName [ td->signedness ] + " in type: ", td );518 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td ); 519 519 } // if 520 520 if ( td->length != DeclarationNode::NoLength ) { 521 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName [ td->length ] + " in type: ", td );521 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td ); 522 522 } // if 523 523 … … 532 532 533 533 if ( td->length != DeclarationNode::NoLength ) { 534 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName [ td->length ] + " in type: ", td );534 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td ); 535 535 } // if 536 536 … … 562 562 FloatingPoint: ; 563 563 if ( td->signedness != DeclarationNode::NoSignedness ) { 564 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName [ td->signedness ] + " in type: ", td );564 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td ); 565 565 } // if 566 566 if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) { 567 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName [ td->length ] + " in type: ", td );567 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td ); 568 568 } // if 569 569 if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) { … … 784 784 } // buildTypeof 785 785 786 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 ) {786 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, DeclarationNode::FuncSpec funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 787 787 if ( td->kind == TypeData::Function ) { 788 788 if ( td->function.idList ) { // KR function ? … … 793 793 Statement * stmt = maybeBuild<Statement>( td->function.body ); 794 794 CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt ); 795 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn, attributes);795 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, attributes, funcSpec ); 796 796 return decl->set_asmName( asmName ); 797 797 } else if ( td->kind == TypeData::Aggregate ) { … … 802 802 return buildSymbolic( td, name, sc ); 803 803 } else { 804 return (new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, attributes , isInline, isNoreturn))->set_asmName( asmName );804 return (new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, attributes ))->set_asmName( asmName ); 805 805 } // if 806 806 return nullptr; … … 820 820 break; 821 821 default: 822 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base, "", DeclarationNode::NoStorageClass, nullptr, false, false, LinkageSpec::Cforall, nullptr ) ) );822 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base, "", DeclarationNode::NoStorageClass, nullptr, DeclarationNode::FuncSpecifier(), LinkageSpec::Cforall, nullptr ) ) ); 823 823 } // switch 824 824 } else {
Note: See TracChangeset
for help on using the changeset viewer.