Changeset 1fbab5a for src/Parser
- Timestamp:
- Mar 16, 2017, 4:50:08 PM (9 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:
- 395fc37, 64ac636, ef42b143
- Parents:
- 2f26687a (diff), d6d747d (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. - Location:
- src/Parser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r2f26687a r1fbab5a 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 10:19:38201713 // Update Count : 96412 // Last Modified On : Thu Mar 16 09:10:57 2017 13 // Update Count : 1007 14 14 // 15 15 … … 33 33 34 34 // These must remain in the same order as the corresponding DeclarationNode enumerations. 35 const char * DeclarationNode::storageClassNames[] = { "extern", "static", "auto", "register", "_Thread_local", "NoStorageClassNames" };36 const char * DeclarationNode::funcSpecifierNames[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" };37 const char * DeclarationNode::typeQualifierNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" };38 35 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" }; 39 36 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" }; … … 116 113 } 117 114 118 void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) {119 if ( storageClasses.val != 0 ) { // storage classes ?120 for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; i += 1 ) {121 if ( storageClasses[i] ) {122 output << DeclarationNode::storageClassNames[i] << ' ';123 } // if124 } // for125 } // if126 } // print_StorageClass127 128 void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) {129 if ( funcSpec.val != 0 ) { // function specifiers ?130 for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; i += 1 ) {131 if ( funcSpec[i] ) {132 output << DeclarationNode::funcSpecifierNames[i] << ' ';133 } // if134 } // for135 } // if136 } // print_FuncSpec137 138 115 void DeclarationNode::print( std::ostream &os, int indent ) const { 139 116 os << string( indent, ' ' ); … … 148 125 } // if 149 126 150 print_StorageClass( os, storageClasses );151 print_FuncSpec( os, funcSpecs );127 storageClasses.print( os ); 128 funcSpecs.print( os ); 152 129 153 130 if ( type ) { … … 202 179 203 180 204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClasses sc ) {181 DeclarationNode * DeclarationNode::newStorageClass( Type::StorageClasses sc ) { 205 182 DeclarationNode * newnode = new DeclarationNode; 206 183 newnode->storageClasses = sc; … … 208 185 } // DeclarationNode::newStorageClass 209 186 210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifiers fs ) {187 DeclarationNode * DeclarationNode::newFuncSpecifier( Type::FuncSpecifiers fs ) { 211 188 DeclarationNode * newnode = new DeclarationNode; 212 189 newnode->funcSpecs = fs; … … 214 191 } // DeclarationNode::newFuncSpecifier 215 192 216 DeclarationNode * DeclarationNode::newTypeQualifier( Type Qualifiertq ) {193 DeclarationNode * DeclarationNode::newTypeQualifier( Type::Qualifiers tq ) { 217 194 DeclarationNode * newnode = new DeclarationNode; 218 195 newnode->type = new TypeData(); 219 newnode->type-> typeQualifiers[ tq ] = true;196 newnode->type->qualifiers = tq; 220 197 return newnode; 221 198 } // DeclarationNode::newQualifier … … 457 434 458 435 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 459 const Type Data::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization460 461 if ( (qsrc & qdst).any() ) {// duplicates ?462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates436 const Type::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization 437 438 if ( (qsrc.val & qdst.val) != 0 ) { // duplicates ? 439 for ( unsigned int i = 0; i < Type::NumTypeQualifier; i += 1 ) { // find duplicates 463 440 if ( qsrc[i] && qdst[i] ) { 464 appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] );441 appendError( error, string( "duplicate " ) + Type::Qualifiers::Names[i] ); 465 442 } // if 466 443 } // for … … 469 446 470 447 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 471 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { 472 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find duplicates448 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { // duplicates ? 449 for ( unsigned int i = 0; i < Type::NumFuncSpecifier; i += 1 ) { // find duplicates 473 450 if ( funcSpecs[i] && src->funcSpecs[i] ) { 474 appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] );451 appendError( error, string( "duplicate " ) + Type::FuncSpecifiers::Names[i] ); 475 452 } // if 476 453 } // for 477 454 } // if 478 455 479 if ( storageClasses. val != 0 && src->storageClasses.val != 0) { // any reason to check ?456 if ( storageClasses.any() && src->storageClasses.any() ) { // any reason to check ? 480 457 if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ? 481 for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates458 for ( unsigned int i = 0; i < Type::NumStorageClass; i += 1 ) { // find duplicates 482 459 if ( storageClasses[i] && src->storageClasses[i] ) { 483 appendError( error, string( "duplicate " ) + storageClassNames[i] );460 appendError( error, string( "duplicate " ) + Type::StorageClasses::Names[i] ); 484 461 } // if 485 462 } // for 486 463 // src is the new item being added and has a single bit 487 464 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ? 488 appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.val ) - 1] +489 " & " + storageClassNames[ffs( src->storageClasses.val ) - 1] );465 appendError( error, string( "conflicting " ) + Type::StorageClasses::Names[ffs( storageClasses.val ) - 1] + 466 " & " + Type::StorageClasses::Names[ffs( src->storageClasses.val ) - 1] ); 490 467 src->storageClasses.val = 0; // FIX to preserve invariant of one basic storage specifier 491 468 } // if … … 496 473 497 474 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 498 funcSpecs.val = funcSpecs.val |q->funcSpecs.val;499 storageClasses.val = storageClasses.val |q->storageClasses.val;475 funcSpecs.val |= q->funcSpecs.val; 476 storageClasses.val |= q->storageClasses.val; 500 477 501 478 for ( Attribute *attr: reverseIterate( q->attributes ) ) { … … 520 497 src = nullptr; 521 498 } else { 522 dst-> typeQualifiers |= src->typeQualifiers;499 dst->qualifiers += src->qualifiers; 523 500 } // if 524 501 } // addQualifiersToType … … 578 555 switch ( dst->kind ) { 579 556 case TypeData::Unknown: 580 src-> typeQualifiers |= dst->typeQualifiers;557 src->qualifiers += dst->qualifiers; 581 558 dst = src; 582 559 src = nullptr; 583 560 break; 584 561 case TypeData::Basic: 585 dst-> typeQualifiers |= src->typeQualifiers;562 dst->qualifiers += src->qualifiers; 586 563 if ( src->kind != TypeData::Unknown ) { 587 564 assert( src->kind == TypeData::Basic ); … … 619 596 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 620 597 } // if 621 dst->base-> typeQualifiers |= src->typeQualifiers;598 dst->base->qualifiers += src->qualifiers; 622 599 src = nullptr; 623 600 break; … … 651 628 type->aggInst.hoistType = o->type->enumeration.body; 652 629 } // if 653 type-> typeQualifiers |= o->type->typeQualifiers;630 type->qualifiers += o->type->qualifiers; 654 631 } else { 655 632 type = o->type; … … 807 784 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 808 785 } // if 809 p->type->base-> typeQualifiers |= type->typeQualifiers;786 p->type->base->qualifiers += type->qualifiers; 810 787 break; 811 788 … … 832 809 833 810 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) { 834 if ( a ) { 835 assert( a->type->kind == TypeData::Array ); 836 TypeData * lastArray = findLast( a->type ); 837 if ( type ) { 838 switch ( type->kind ) { 839 case TypeData::Aggregate: 840 case TypeData::Enum: 841 lastArray->base = new TypeData( TypeData::AggregateInst ); 842 lastArray->base->aggInst.aggregate = type; 843 if ( type->kind == TypeData::Aggregate ) { 844 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 845 } // if 846 lastArray->base->typeQualifiers |= type->typeQualifiers; 847 break; 848 default: 849 lastArray->base = type; 850 } // switch 851 type = nullptr; 852 } // if 853 delete this; 854 return a; 855 } else { 856 return this; 857 } // if 811 if ( ! a ) return this; 812 assert( a->type->kind == TypeData::Array ); 813 TypeData * lastArray = findLast( a->type ); 814 if ( type ) { 815 switch ( type->kind ) { 816 case TypeData::Aggregate: 817 case TypeData::Enum: 818 lastArray->base = new TypeData( TypeData::AggregateInst ); 819 lastArray->base->aggInst.aggregate = type; 820 if ( type->kind == TypeData::Aggregate ) { 821 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 822 } // if 823 lastArray->base->qualifiers += type->qualifiers; 824 break; 825 default: 826 lastArray->base = type; 827 } // switch 828 type = nullptr; 829 } // if 830 delete this; 831 return a; 858 832 } 859 833 … … 994 968 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 995 969 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() ); 996 auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );970 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 997 971 obj->location = cur->location; 998 972 * out++ = obj; … … 1000 974 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 1001 975 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); 1002 auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );976 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 1003 977 obj->location = cur->location; 1004 978 * out++ = obj; … … 1047 1021 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." ); 1048 1022 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1049 TypeDecl * ret = new TypeDecl( *name, DeclarationNode::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );1023 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ] ); 1050 1024 buildList( variable.assertions, ret->get_assertions() ); 1051 1025 return ret; … … 1058 1032 // inline _Noreturn int g( int i ); // allowed 1059 1033 // inline _Noreturn int i; // disallowed 1060 if ( type->kind != TypeData::Function && funcSpecs. val != 0) {1034 if ( type->kind != TypeData::Function && funcSpecs.any() ) { 1061 1035 throw SemanticError( "invalid function specifier for ", this ); 1062 1036 } // if … … 1068 1042 // inlne _Noreturn struct S { ... }; // disallowed 1069 1043 // inlne _Noreturn enum E { ... }; // disallowed 1070 if ( funcSpecs. val != 0) {1044 if ( funcSpecs.any() ) { 1071 1045 throw SemanticError( "invalid function specifier for ", this ); 1072 1046 } // if -
src/Parser/ParseNode.h
r2f26687a r1fbab5a 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 14 11:05:05201713 // Update Count : 7 5212 // Last Modified On : Thu Mar 16 08:32:43 2017 13 // Update Count : 776 14 14 // 15 15 … … 19 19 #include <string> 20 20 #include <list> 21 #include <bitset>22 21 #include <iterator> 23 22 #include <memory> … … 202 201 class DeclarationNode : public ParseNode { 203 202 public: 204 // These must remain in the same order as the corresponding DeclarationNode names.205 206 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NoStorageClass = 5 };207 union StorageClasses {208 unsigned int val;209 struct {210 bool is_extern : 1;211 bool is_static : 1;212 bool is_auto : 1;213 bool is_register : 1;214 bool is_threadlocal : 1;215 };216 StorageClasses() : val( 0 ) {}217 StorageClasses( unsigned int val ) : val( val ) {}218 bool operator[]( unsigned int i ) const { return val & (1 << i); }219 }; // StorageClasses220 221 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NoFuncSpecifier = 3 };222 union FuncSpecifiers {223 unsigned int val;224 struct {225 bool is_inline : 1;226 bool is_noreturn : 1;227 bool is_fortran : 1;228 };229 FuncSpecifiers() : val( 0 ) {}230 FuncSpecifiers( unsigned int val ) : val( val ) {}231 bool operator[]( unsigned int i ) const { return val & (1 << i); }232 }; // FuncSpecifiers233 234 enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier };235 203 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 236 204 enum ComplexType { Complex, Imaginary, NoComplexType }; … … 241 209 enum BuiltinType { Valist, Zero, One, NoBuiltinType }; 242 210 243 static const char * storageClassNames[];244 static const char * funcSpecifierNames[];245 static const char * typeQualifierNames[];246 211 static const char * basicTypeNames[]; 247 212 static const char * complexTypeNames[]; … … 252 217 static const char * builtinTypeNames[]; 253 218 254 static DeclarationNode * newStorageClass( StorageClasses );255 static DeclarationNode * newFuncSpecifier( FuncSpecifiers );256 static DeclarationNode * newTypeQualifier( Type Qualifier);219 static DeclarationNode * newStorageClass( Type::StorageClasses ); 220 static DeclarationNode * newFuncSpecifier( Type::FuncSpecifiers ); 221 static DeclarationNode * newTypeQualifier( Type::Qualifiers ); 257 222 static DeclarationNode * newBasicType( BasicType ); 258 223 static DeclarationNode * newComplexType( ComplexType ); … … 350 315 TypeData * type; 351 316 352 StorageClasses storageClasses; 353 static void print_StorageClass( std::ostream & output, StorageClasses storageClasses ); 354 355 FuncSpecifiers funcSpecs; 356 static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs ); 317 Type::FuncSpecifiers funcSpecs; 318 Type::StorageClasses storageClasses; 357 319 358 320 ExpressionNode * bitfieldWidth; -
src/Parser/TypeData.cc
r2f26687a r1fbab5a 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 08:08:21201713 // Update Count : 5 3812 // Last Modified On : Thu Mar 16 08:32:42 2017 13 // Update Count : 559 14 14 // 15 15 … … 26 26 using namespace std; 27 27 28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ { 29 29 switch ( kind ) { 30 30 case Unknown: … … 50 50 function.newStyle = false; 51 51 break; 52 // Enum is an Aggregate, so both structures are initialized together. 53 case Enum: 54 // enumeration = new Enumeration_t; 55 enumeration.name = nullptr; 56 enumeration.constants = nullptr; 57 enumeration.body = false; 52 58 case Aggregate: 53 59 // aggregate = new Aggregate_t; … … 64 70 aggInst.hoistType = false;; 65 71 break; 66 case Enum:67 // enumeration = new Enumeration_t;68 enumeration.name = nullptr;69 enumeration.constants = nullptr;70 enumeration.body = false;71 break;72 72 case Symbolic: 73 73 case SymbolicInst: … … 157 157 TypeData * TypeData::clone() const { 158 158 TypeData * newtype = new TypeData( kind ); 159 newtype-> typeQualifiers = typeQualifiers;159 newtype->qualifiers = qualifiers; 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::NoTypeQualifier; i += 1 ) {229 if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' ';228 for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) { 229 if ( qualifiers[i] ) os << Type::Qualifiers::Names[ i ] << ' '; 230 230 } // for 231 231 … … 398 398 // add dtor: void ^?{}(T *) 399 399 FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false ); 400 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), 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::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) );400 dtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 401 td->get_assertions().push_front( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) ); 402 402 403 403 // add copy ctor: void ?{}(T *, T) 404 404 FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false ); 405 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );406 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );407 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) );405 copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 406 copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 407 td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) ); 408 408 409 409 // add default ctor: void ?{}(T *) 410 410 FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false ); 411 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), 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::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) );411 ctorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 412 td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) ); 413 413 414 414 // add assignment operator: T * ?=?(T *, T) 415 415 FunctionType * assignType = new FunctionType( Type::Qualifiers(), false ); 416 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );417 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );418 assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );419 td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) );416 assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 417 assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 418 assignType->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 419 td->get_assertions().push_front( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) ); 420 420 } // if 421 421 } // for … … 493 493 494 494 Type::Qualifiers buildQualifiers( const TypeData * td ) { 495 Type::Qualifiers q; 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 return q; 495 return td->qualifiers; 502 496 } // buildQualifiers 503 497 … … 732 726 } // buildAggInst 733 727 734 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClasses scs ) {728 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs ) { 735 729 assert( td->kind == TypeData::Symbolic ); 736 730 NamedTypeDecl * ret; … … 784 778 } // buildTypeof 785 779 786 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClasses scs, Expression * bitfieldWidth, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {780 Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 787 781 if ( td->kind == TypeData::Function ) { 788 782 if ( td->function.idList ) { // KR function ? … … 820 814 break; 821 815 default: 822 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", DeclarationNode::StorageClasses(), nullptr, DeclarationNode::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );816 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) ); 823 817 } // switch 824 818 } else { 825 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );819 ft->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 826 820 } // if 827 821 return ft; -
src/Parser/TypeData.h
r2f26687a r1fbab5a 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 8 22:28:33201713 // Update Count : 1 7412 // Last Modified On : Thu Mar 16 08:32:39 2017 13 // Update Count : 185 14 14 // 15 15 16 16 #ifndef TYPEDATA_H 17 17 #define TYPEDATA_H 18 19 #include <bitset>20 18 21 19 #include "ParseNode.h" … … 77 75 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; 78 76 79 typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers; 80 TypeQualifiers typeQualifiers; 77 Type::Qualifiers qualifiers; 81 78 DeclarationNode * forall; 82 79 … … 112 109 TupleType * buildTuple( const TypeData * ); 113 110 TypeofType * buildTypeof( const TypeData * ); 114 Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClasses, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );111 Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 115 112 FunctionType * buildFunction( const TypeData * ); 116 113 void buildKRFunction( const TypeData::Function_t & function ); -
src/Parser/parser.yy
r2f26687a r1fbab5a 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 9 21:40:20201713 // Update Count : 2 29212 // Last Modified On : Thu Mar 16 08:36:17 2017 13 // Update Count : 2310 14 14 // 15 15 … … 441 441 argument_expression: 442 442 // empty 443 { $$ = nullptr; } // use default argument 443 { $$ = nullptr; } 444 // | '@' // use default argument 445 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); } 444 446 | assignment_expression 445 447 ; … … 1408 1410 type_qualifier_name: 1409 1411 CONST 1410 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Const ); }1412 { $$ = DeclarationNode::newTypeQualifier( Type::Const ); } 1411 1413 | RESTRICT 1412 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Restrict ); }1414 { $$ = DeclarationNode::newTypeQualifier( Type::Restrict ); } 1413 1415 | VOLATILE 1414 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Volatile ); }1416 { $$ = DeclarationNode::newTypeQualifier( Type::Volatile ); } 1415 1417 | LVALUE // CFA 1416 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Lvalue ); }1418 { $$ = DeclarationNode::newTypeQualifier( Type::Lvalue ); } 1417 1419 | MUTEX 1418 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Mutex ); }1420 { $$ = DeclarationNode::newTypeQualifier( Type::Mutex ); } 1419 1421 | ATOMIC 1420 { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Atomic ); }1422 { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); } 1421 1423 | FORALL '(' 1422 1424 { … … 1451 1453 storage_class: 1452 1454 EXTERN 1453 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }1455 { $$ = DeclarationNode::newStorageClass( Type::Extern ); } 1454 1456 | STATIC 1455 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Static ); }1457 { $$ = DeclarationNode::newStorageClass( Type::Static ); } 1456 1458 | AUTO 1457 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }1459 { $$ = DeclarationNode::newStorageClass( Type::Auto ); } 1458 1460 | REGISTER 1459 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); }1461 { $$ = DeclarationNode::newStorageClass( Type::Register ); } 1460 1462 | THREADLOCAL // C11 1461 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); }1463 { $$ = DeclarationNode::newStorageClass( Type::Threadlocal ); } 1462 1464 // Put function specifiers here to simplify parsing rules, but separate them semantically. 1463 1465 | INLINE // C99 1464 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); }1466 { $$ = DeclarationNode::newFuncSpecifier( Type::Inline ); } 1465 1467 | FORTRAN // C99 1466 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); }1468 { $$ = DeclarationNode::newFuncSpecifier( Type::Fortran ); } 1467 1469 | NORETURN // C11 1468 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); }1470 { $$ = DeclarationNode::newFuncSpecifier( Type::Noreturn ); } 1469 1471 ; 1470 1472 … … 1686 1688 // empty 1687 1689 { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name 1690 // '@' // empty 1691 // { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name 1688 1692 | bit_subrange_size // no field name 1689 1693 { $$ = DeclarationNode::newBitfield( $1 ); }
Note:
See TracChangeset
for help on using the changeset viewer.