Changeset 15596d7
- Timestamp:
- Mar 14, 2023, 11:15:15 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 9fa61f5
- Parents:
- 089a0d7
- Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r089a0d7 r15596d7 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 25 12:15:40202313 // Update Count : 140 412 // Last Modified On : Tue Mar 14 08:54:13 2023 13 // Update Count : 1405 14 14 // 15 15 … … 600 600 } else { 601 601 switch ( dst->kind ) { 602 case TypeData::Unknown:602 case TypeData::Unknown: 603 603 src->qualifiers |= dst->qualifiers; 604 604 dst = src; 605 605 src = nullptr; 606 606 break; 607 case TypeData::Basic:607 case TypeData::Basic: 608 608 dst->qualifiers |= src->qualifiers; 609 609 if ( src->kind != TypeData::Unknown ) { … … 633 633 } // if 634 634 break; 635 default:635 default: 636 636 switch ( src->kind ) { 637 case TypeData::Aggregate:638 case TypeData::Enum:637 case TypeData::Aggregate: 638 case TypeData::Enum: 639 639 dst->base = new TypeData( TypeData::AggregateInst ); 640 640 dst->base->aggInst.aggregate = src; … … 645 645 src = nullptr; 646 646 break; 647 default:647 default: 648 648 if ( dst->forall ) { 649 649 dst->forall->appendList( src->forall ); … … 727 727 assert( type ); 728 728 switch ( type->kind ) { 729 case TypeData::Symbolic:729 case TypeData::Symbolic: 730 730 if ( type->symbolic.assertions ) { 731 731 type->symbolic.assertions->appendList( assertions ); … … 734 734 } // if 735 735 break; 736 default:736 default: 737 737 assert( false ); 738 738 } // switch … … 833 833 if ( type ) { 834 834 switch ( type->kind ) { 835 case TypeData::Aggregate:836 case TypeData::Enum:835 case TypeData::Aggregate: 836 case TypeData::Enum: 837 837 p->type->base = new TypeData( TypeData::AggregateInst ); 838 838 p->type->base->aggInst.aggregate = type; … … 843 843 break; 844 844 845 default:845 default: 846 846 p->type->base = type; 847 847 } // switch … … 865 865 866 866 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) { 867 867 if ( ! a ) return this; 868 868 assert( a->type->kind == TypeData::Array ); 869 869 TypeData * lastArray = findLast( a->type ); 870 870 if ( type ) { 871 871 switch ( type->kind ) { 872 case TypeData::Aggregate:873 case TypeData::Enum:872 case TypeData::Aggregate: 873 case TypeData::Enum: 874 874 lastArray->base = new TypeData( TypeData::AggregateInst ); 875 875 lastArray->base->aggInst.aggregate = type; … … 879 879 lastArray->base->qualifiers |= type->qualifiers; 880 880 break; 881 default:881 default: 882 882 lastArray->base = type; 883 883 } // switch … … 1245 1245 1246 1246 switch ( type->kind ) { 1247 case TypeData::Enum:1248 case TypeData::Aggregate: {1249 ReferenceToType * ret = buildComAggInst( type, attributes, linkage );1250 buildList( type->aggregate.actuals, ret->get_parameters() );1251 return ret;1252 }1253 case TypeData::Symbolic: {1254 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false, attributes );1255 buildList( type->symbolic.actuals, ret->get_parameters() );1256 return ret;1257 }1258 default:1247 case TypeData::Enum: 1248 case TypeData::Aggregate: { 1249 ReferenceToType * ret = buildComAggInst( type, attributes, linkage ); 1250 buildList( type->aggregate.actuals, ret->get_parameters() ); 1251 return ret; 1252 } 1253 case TypeData::Symbolic: { 1254 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false, attributes ); 1255 buildList( type->symbolic.actuals, ret->get_parameters() ); 1256 return ret; 1257 } 1258 default: 1259 1259 Type * simpletypes = typebuild( type ); 1260 1260 simpletypes->get_attributes() = attributes; // copy because member is const -
src/Parser/ExpressionNode.cc
r089a0d7 r15596d7 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat May 16 13:17:07 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : T hr Mar 0 10:46:00202313 // Update Count : 108 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 09:10:22 2023 13 // Update Count : 1081 14 14 // 15 15 … … 122 122 if ( str[i] == '1' ) v |= 1; 123 123 i += 1; 124 124 if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break; 125 125 v <<= 1; 126 126 } // for … … 162 162 if ( isdigit( str[str.length() - 1] ) ) { // no suffix ? 163 163 lnthSuffix( str, type, ltype ); // could have length suffix 164 // At least one digit in integer constant,165 // so safe to backup while looking for suffix.166 // pointer value167 } else if ( auto posn = str.find_last_of( "pP" ) ; posn != string::npos ) {168 ltype = 5; str.erase( posn, 1 );169 // size_t170 } else if ( auto posn = str.find_last_of( "zZ" ) ; posn != string::npos ) {171 Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 );172 // signed char173 } else if ( auto posn = str.rfind( "hh" ) ; posn != string::npos ) {174 type = 1; str.erase( posn, 2 );175 // signed char176 } else if ( auto posn = str.rfind( "HH" ) ; posn != string::npos ) {177 type = 1; str.erase( posn, 2 );178 // short179 } else if ( auto posn = str.find_last_of( "hH" ) ; posn != string::npos ) {180 type = 0; str.erase( posn, 1 );181 // int (natural number)182 } else if ( auto posn = str.find_last_of( "nN" ) ; posn != string::npos ) {183 type = 2; str.erase( posn, 1 );184 } else if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) {185 type = 4;186 164 } else { 187 lnthSuffix( str, type, ltype ); 188 } 165 // At least one digit in integer constant, so safe to backup while looking for suffix. 166 string::size_type posn; 167 // pointer value 168 if ( posn = str.find_last_of( "pP" ); posn != string::npos ) { 169 ltype = 5; str.erase( posn, 1 ); 170 // size_t 171 } else if ( posn = str.find_last_of( "zZ" ); posn != string::npos ) { 172 Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 ); 173 // signed char 174 } else if ( posn = str.rfind( "hh" ); posn != string::npos ) { 175 type = 1; str.erase( posn, 2 ); 176 // signed char 177 } else if ( posn = str.rfind( "HH" ); posn != string::npos ) { 178 type = 1; str.erase( posn, 2 ); 179 // short 180 } else if ( posn = str.find_last_of( "hH" ); posn != string::npos ) { 181 type = 0; str.erase( posn, 1 ); 182 // int (natural number) 183 } else if ( posn = str.find_last_of( "nN" ); posn != string::npos ) { 184 type = 2; str.erase( posn, 1 ); 185 } else if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) { 186 type = 4; 187 } else { 188 lnthSuffix( str, type, ltype ); 189 } // if 190 } // if 189 191 190 192 // Cannot be just "0"/"1"; sscanf stops at the suffix, if any; value goes over the wall => always generate … … 208 210 sscanf( (char *)str2.c_str(), "%llx", &v2 ); 209 211 str = str.substr( 0, len - 16 ); 210 } 212 } // if 211 213 sscanf( (char *)str.c_str(), "%llx", &v ); 212 214 #endif // __SIZEOF_INT128__ … … 434 436 Type * strtype; 435 437 switch ( str[0] ) { // str has >= 2 characters, i.e, null string "" => safe to look at subscripts 0/1 436 case 'u':438 case 'u': 437 439 if ( str[1] == '8' ) goto Default; // utf-8 characters => array of char 438 440 // lookup type of associated typedef 439 441 strtype = new TypeInstType( Type::Qualifiers( ), "char16_t", false ); 440 442 break; 441 case 'U':443 case 'U': 442 444 strtype = new TypeInstType( Type::Qualifiers( ), "char32_t", false ); 443 445 break; 444 case 'L':446 case 'L': 445 447 strtype = new TypeInstType( Type::Qualifiers( ), "wchar_t", false ); 446 448 break; 447 Default: // char default string type448 default:449 Default: // char default string type 450 default: 449 451 strtype = new BasicType( Type::Qualifiers( ), BasicType::Char ); 450 452 } // switch … … 649 651 // Local Variables: // 650 652 // tab-width: 4 // 651 // mode: c++ //652 // compile-command: "make install" //653 653 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.