Changeset 7a780ad
- Timestamp:
- Apr 18, 2024, 5:19:17 PM (14 months ago)
- Branches:
- master
- Children:
- 38093ae
- Parents:
- 60c5b6d
- Location:
- src
- Files:
-
- 1 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.cpp
r60c5b6d r7a780ad 246 246 ConstantExpr * ConstantExpr::from_bool( const CodeLocation & loc, bool b ) { 247 247 return new ConstantExpr{ 248 loc, new BasicType{ Basic Type::Bool }, b ? "1" : "0", (unsigned long long)b };248 loc, new BasicType{ BasicKind::Bool }, b ? "1" : "0", (unsigned long long)b }; 249 249 } 250 250 251 251 ConstantExpr * ConstantExpr::from_int( const CodeLocation & loc, int i ) { 252 252 return new ConstantExpr{ 253 loc, new BasicType{ Basic Type::SignedInt }, std::to_string( i ), (unsigned long long)i };253 loc, new BasicType{ BasicKind::SignedInt }, std::to_string( i ), (unsigned long long)i }; 254 254 } 255 255 256 256 ConstantExpr * ConstantExpr::from_ulong( const CodeLocation & loc, unsigned long i ) { 257 257 return new ConstantExpr{ 258 loc, new BasicType{ Basic Type::LongUnsignedInt }, std::to_string( i ),258 loc, new BasicType{ BasicKind::LongUnsignedInt }, std::to_string( i ), 259 259 (unsigned long long)i }; 260 260 } 261 261 262 262 ConstantExpr * ConstantExpr::from_string( const CodeLocation & loc, const std::string & str ) { 263 const Type * charType = new BasicType( Basic Type::Char );263 const Type * charType = new BasicType( BasicKind::Char ); 264 264 // Adjust the length of the string for the terminator. 265 265 const Expr * strSize = from_ulong( loc, str.size() + 1 ); … … 277 277 278 278 SizeofExpr::SizeofExpr( const CodeLocation & loc, const Expr * e ) 279 : Expr( loc, new BasicType{ Basic Type::LongUnsignedInt } ), expr( e ), type( nullptr ) {}279 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( e ), type( nullptr ) {} 280 280 281 281 SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * t ) 282 : Expr( loc, new BasicType{ Basic Type::LongUnsignedInt } ), expr( nullptr ), type( t ) {}282 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( nullptr ), type( t ) {} 283 283 284 284 // --- AlignofExpr 285 285 286 286 AlignofExpr::AlignofExpr( const CodeLocation & loc, const Expr * e ) 287 : Expr( loc, new BasicType{ Basic Type::LongUnsignedInt } ), expr( e ), type( nullptr ) {}287 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( e ), type( nullptr ) {} 288 288 289 289 AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * t ) 290 : Expr( loc, new BasicType{ Basic Type::LongUnsignedInt } ), expr( nullptr ), type( t ) {}290 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( nullptr ), type( t ) {} 291 291 292 292 // --- OffsetofExpr 293 293 294 294 OffsetofExpr::OffsetofExpr( const CodeLocation & loc, const Type * ty, const DeclWithType * mem ) 295 : Expr( loc, new BasicType{ Basic Type::LongUnsignedInt } ), type( ty ), member( mem ) {295 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( ty ), member( mem ) { 296 296 assert( type ); 297 297 assert( member ); … … 302 302 OffsetPackExpr::OffsetPackExpr( const CodeLocation & loc, const StructInstType * ty ) 303 303 : Expr( loc, new ArrayType{ 304 new BasicType{ Basic Type::LongUnsignedInt }, nullptr, FixedLen, DynamicDim }304 new BasicType{ BasicKind::LongUnsignedInt }, nullptr, FixedLen, DynamicDim } 305 305 ), type( ty ) { 306 306 assert( type ); … … 311 311 LogicalExpr::LogicalExpr( 312 312 const CodeLocation & loc, const Expr * a1, const Expr * a2, LogicalFlag ia ) 313 : Expr( loc, new BasicType{ Basic Type::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {}313 : Expr( loc, new BasicType{ BasicKind::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {} 314 314 315 315 // --- CommaExpr -
src/AST/Pass.impl.hpp
r60c5b6d r7a780ad 477 477 CodeLocation{}, "__func__", 478 478 new ast::ArrayType{ 479 new ast::BasicType{ ast::Basic Type::Char, ast::CV::Const },479 new ast::BasicType{ ast::BasicKind::Char, ast::CV::Const }, 480 480 nullptr, VariableLen, DynamicDim 481 481 }, -
src/AST/Type.hpp
r60c5b6d r7a780ad 22 22 #include <vector> 23 23 24 #include "BasicKind.hpp" // for BasicKind 24 25 #include "CVQualifiers.hpp" 25 26 #include "Decl.hpp" // for AggregateDecl subclasses … … 114 115 class BasicType final : public Type { 115 116 public: 116 // GENERATED START, DO NOT EDIT 117 // GENERATED BY BasicTypes-gen.cc 118 enum Kind { 119 Bool, 120 Char, 121 SignedChar, 122 UnsignedChar, 123 ShortSignedInt, 124 ShortUnsignedInt, 125 SignedInt, 126 UnsignedInt, 127 LongSignedInt, 128 LongUnsignedInt, 129 LongLongSignedInt, 130 LongLongUnsignedInt, 131 SignedInt128, 132 UnsignedInt128, 133 uFloat16, 134 uFloat16Complex, 135 uFloat32, 136 uFloat32Complex, 137 Float, 138 FloatComplex, 139 uFloat32x, 140 uFloat32xComplex, 141 uFloat64, 142 uFloat64Complex, 143 Double, 144 DoubleComplex, 145 uFloat64x, 146 uFloat64xComplex, 147 uuFloat80, 148 uFloat128, 149 uFloat128Complex, 150 uuFloat128, 151 LongDouble, 152 LongDoubleComplex, 153 uFloat128x, 154 uFloat128xComplex, 155 NUMBER_OF_BASIC_TYPES 156 } kind; 157 // GENERATED END 158 159 /// xxx -- MAX_INTEGER_TYPE should probably be in BasicTypes-gen.cc, rather than hardcoded here 160 enum { MAX_INTEGER_TYPE = UnsignedInt128 }; 117 BasicKind kind; 161 118 162 119 /// string names of basic types; generated to match with Kind 163 120 static const char *typeNames[]; 164 121 165 BasicType( Kind k, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )122 BasicType( BasicKind k, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 166 123 : Type(q, std::move(as)), kind(k) {} 167 124 168 125 /// Check if this type represents an integer type 169 bool isInteger() const { return (unsigned)kind <= (unsigned)MAX_INTEGER_TYPE; }126 bool isInteger() const { return kind <= MAX_INTEGER_TYPE; } 170 127 171 128 const Type * accept( Visitor & v ) const override { return v.visit( this ); } -
src/AST/module.mk
r60c5b6d r7a780ad 18 18 AST/Attribute.cpp \ 19 19 AST/Attribute.hpp \ 20 AST/BasicKind.hpp \ 20 21 AST/Bitfield.hpp \ 21 22 AST/Chain.hpp \ -
src/BasicTypes-gen.cc
r60c5b6d r7a780ad 249 249 } // for 250 250 } // for 251 int lastInteger = NUMBER_OF_BASIC_TYPES; 251 252 252 253 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // perform breath-first traversal to generate cost graph … … 259 260 } // for 260 261 } // for 262 263 // Find the last integer type. 264 // Assumes at least 1, and all come before the floating types. 265 for ( int i = 1 ; i < NUMBER_OF_BASIC_TYPES ; i += 1 ) { 266 if ( Floating == graph[i].sign ) { 267 lastInteger = (i - 1); 268 break; 269 } 270 } 261 271 262 272 #define STARTMK "// GENERATED START, DO NOT EDIT" … … 272 282 size_t start, end; 273 283 274 #define TypeH_AST TOP_SRCDIR "src/AST/ Type.hpp"284 #define TypeH_AST TOP_SRCDIR "src/AST/BasicKind.hpp" 275 285 resetInput( file, TypeH_AST, buffer, code, str ); 276 286 … … 279 289 code << str.substr( 0, start ); 280 290 281 code << "\t" <<BYMK << endl;282 code << " \tenumKind {" << endl;291 code << BYMK << endl; 292 code << "enum BasicKind {" << endl; 283 293 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 284 code << "\t \t" << graph[r].name << "," << endl;285 } // for 286 code << "\t \tNUMBER_OF_BASIC_TYPES" << endl;287 code << "\t } kind;" << endl;288 code << " \t"; // indentation for end marker294 code << "\t" << graph[r].name << "," << endl; 295 } // for 296 code << "\tNUMBER_OF_BASIC_TYPES," << endl; 297 code << "\tMAX_INTEGER_TYPE = " << graph[lastInteger].name << "," << endl; 298 code << "};" << endl; 289 299 290 300 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH_AST ); … … 347 357 348 358 code << "\t" << BYMK << endl; 349 code << "\tstatic const int costMatrix[ast::Basic Type::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl359 code << "\tstatic const int costMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl 350 360 << "\t\t/* "; 351 361 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles … … 372 382 373 383 code << "\t" << BYMK << endl; 374 code << "\tstatic const int signMatrix[ast::Basic Type::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl384 code << "\tstatic const int signMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl 375 385 << "\t\t/* "; 376 386 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles … … 404 414 enum { PER_ROW = 6 }; 405 415 code << "\t" << BYMK << endl; 406 code << "\t#define BT ast::Basic Type::" << endl;416 code << "\t#define BT ast::BasicKind::" << endl; 407 417 code << "\tstatic const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl 408 418 << "\t\t/*\t\t "; … … 460 470 "// - \"Ds\" char16_t\n"; 461 471 462 code << "const std::string basicTypes[ast::Basic Type::NUMBER_OF_BASIC_TYPES] = {" << endl;472 code << "const std::string basicTypes[ast::BasicKind::NUMBER_OF_BASIC_TYPES] = {" << endl; 463 473 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 464 474 code << "\t\"" << graph[r].mangled << "\"," << setw(9 - strlen(graph[r].mangled)) << ' ' << "// " << graph[r].type << endl; -
src/CodeGen/FixMain.cc
r60c5b6d r7a780ad 52 52 ast::ObjectDecl * makeIntObj(){ 53 53 return new ast::ObjectDecl( CodeLocation(), "", 54 new ast::BasicType( ast::Basic Type::SignedInt ) );54 new ast::BasicType( ast::BasicKind::SignedInt ) ); 55 55 } 56 56 … … 59 59 new ast::PointerType( 60 60 new ast::PointerType( 61 new ast::BasicType( ast::Basic Type::Char ) ) ) );61 new ast::BasicType( ast::BasicKind::Char ) ) ) ); 62 62 } 63 63 -
src/CodeGen/GenType.cc
r60c5b6d r7a780ad 87 87 88 88 void GenType::postvisit( ast::BasicType const * type ) { 89 ast::Basic Type::Kind kind = type->kind;90 assert( 0 <= kind && kind < ast::Basic Type::NUMBER_OF_BASIC_TYPES );89 ast::BasicKind kind = type->kind; 90 assert( 0 <= kind && kind < ast::BasicKind::NUMBER_OF_BASIC_TYPES ); 91 91 result = std::string( ast::BasicType::typeNames[kind] ) + " " + result; 92 92 handleQualifiers( type ); -
src/Common/ResolvProtoDump.cpp
r60c5b6d r7a780ad 229 229 void previsit( const ast::EnumInstType * ) { 230 230 // TODO: Add the meaningful text representation of typed enum 231 ss << (int)ast::Basic Type::SignedInt;231 ss << (int)ast::BasicKind::SignedInt; 232 232 } 233 233 … … 255 255 // TODO: Support 0 and 1 with their type names and conversions. 256 256 void previsit( const ast::ZeroType * ) { 257 ss << (int)ast::Basic Type::SignedInt;257 ss << (int)ast::BasicKind::SignedInt; 258 258 } 259 259 260 260 void previsit( const ast::OneType * ) { 261 ss << (int)ast::Basic Type::SignedInt;261 ss << (int)ast::BasicKind::SignedInt; 262 262 } 263 263 … … 366 366 // TODO: Extra expression to resolve argument. 367 367 void previsit( const ast::SizeofExpr * ) { 368 ss << (int)ast::Basic Type::LongUnsignedInt;368 ss << (int)ast::BasicKind::LongUnsignedInt; 369 369 visit_children = false; 370 370 } 371 371 void previsit( const ast::AlignofExpr * ) { 372 ss << (int)ast::Basic Type::LongUnsignedInt;372 ss << (int)ast::BasicKind::LongUnsignedInt; 373 373 visit_children = false; 374 374 } 375 375 void previsit( const ast::UntypedOffsetofExpr * ) { 376 ss << (int)ast::Basic Type::LongUnsignedInt;376 ss << (int)ast::BasicKind::LongUnsignedInt; 377 377 visit_children = false; 378 378 } … … 753 753 // &? Address of operator. 754 754 out << "#$ptr<T> $addr T" << std::endl; 755 const int intId = (int)ast::Basic Type::SignedInt;755 const int intId = (int)ast::BasicKind::SignedInt; 756 756 // ?&&? ?||? ?: Logical operators. 757 757 out << intId << " $and " << intId << ' ' << intId << std::endl; -
src/Concurrency/Corun.cpp
r60c5b6d r7a780ad 130 130 new ObjectDecl( loc, 131 131 numProcsName, 132 new BasicType( Basic Type::Kind::UnsignedInt ),132 new BasicType( BasicKind::UnsignedInt ), 133 133 new SingleInit( loc, 134 134 new UntypedExpr( loc, … … 146 146 new ObjectDecl( loc, 147 147 currProcsName, 148 new BasicType( Basic Type::Kind::UnsignedInt ),148 new BasicType( BasicKind::UnsignedInt ), 149 149 new SingleInit( loc, ConstantExpr::from_int( loc, 0 ) ) 150 150 ) -
src/Concurrency/Waitfor.cpp
r60c5b6d r7a780ad 244 244 ast::ObjectDecl * flag = new ast::ObjectDecl( location, 245 245 namer_flg.newName(), 246 new ast::BasicType( ast::Basic Type::Bool ),246 new ast::BasicType( ast::BasicKind::Bool ), 247 247 new ast::SingleInit( location, 248 248 ast::ConstantExpr::from_ulong( location, 0 ) … … 349 349 ast::ObjectDecl * timeout = new ast::ObjectDecl( topLocation, 350 350 namer_tim.newName(), 351 new ast::BasicType( ast::Basic Type::LongLongUnsignedInt ),351 new ast::BasicType( ast::BasicKind::LongLongUnsignedInt ), 352 352 new ast::SingleInit( topLocation, 353 353 ast::ConstantExpr::from_int( topLocation, -1 ) … … 397 397 ast::ObjectDecl * index = new ast::ObjectDecl( location, 398 398 namer_idx.newName(), 399 new ast::BasicType( ast::Basic Type::ShortSignedInt ),399 new ast::BasicType( ast::BasicKind::ShortSignedInt ), 400 400 new ast::SingleInit( location, 401 401 ast::ConstantExpr::from_int( location, -1 ) -
src/Concurrency/Waituntil.cpp
r60c5b6d r7a780ad 498 498 rightExpr = genPredExpr( loc, currNode->right, idx, genLeaf ); 499 499 return new LogicalExpr( loc, 500 new CastExpr( loc, leftExpr, new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast ),501 new CastExpr( loc, rightExpr, new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast ),500 new CastExpr( loc, leftExpr, new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast ), 501 new CastExpr( loc, rightExpr, new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast ), 502 502 LogicalFlag::AndExpr 503 503 ); … … 507 507 rightExpr = genPredExpr( loc, currNode->right, idx, genLeaf ); 508 508 return new LogicalExpr( loc, 509 new CastExpr( loc, leftExpr, new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast ),510 new CastExpr( loc, rightExpr, new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast ),509 new CastExpr( loc, leftExpr, new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast ), 510 new CastExpr( loc, rightExpr, new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast ), 511 511 LogicalFlag::OrExpr ); 512 512 break; … … 556 556 new ObjectDecl( loc, 557 557 "clause_statuses", 558 new PointerType( new BasicType( Basic Type::Kind::LongUnsignedInt ) )558 new PointerType( new BasicType( BasicKind::LongUnsignedInt ) ) 559 559 ) 560 560 }, … … 562 562 new ObjectDecl( loc, 563 563 "sat_ret", 564 new BasicType( Basic Type::Kind::Bool )564 new BasicType( BasicKind::Bool ) 565 565 ) 566 566 }, … … 766 766 new ObjectDecl( loc, 767 767 idxName, 768 new BasicType( Basic Type::Kind::SignedInt ),768 new BasicType( BasicKind::SignedInt ), 769 769 new SingleInit( loc, ConstantExpr::from_int( loc, 0 ) ) 770 770 ) … … 893 893 new ObjectDecl( cLoc, 894 894 currClause->whenName, 895 new BasicType( Basic Type::Kind::Bool ),895 new BasicType( BasicKind::Bool ), 896 896 new SingleInit( cLoc, ast::deepCopy( stmt->clauses.at(i)->when_cond ) ) 897 897 ) … … 915 915 new ObjectDecl( stmt->else_cond->location, 916 916 elseWhenName, 917 new BasicType( Basic Type::Kind::Bool ),917 new BasicType( BasicKind::Bool ), 918 918 new SingleInit( stmt->else_cond->location, ast::deepCopy( stmt->else_cond ) ) 919 919 ) … … 945 945 new CastExpr( cLoc, 946 946 new AddressExpr( cLoc, new NameExpr( cLoc, data.at(i)->nodeName ) ), 947 new BasicType( Basic Type::Kind::LongUnsignedInt ), GeneratedFlag::ExplicitCast947 new BasicType( BasicKind::LongUnsignedInt ), GeneratedFlag::ExplicitCast 948 948 ) 949 949 } … … 986 986 new CastExpr( cLoc, 987 987 new NameExpr( cLoc, elseWhenName ), 988 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast988 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 989 989 ), 990 990 new CastExpr( cLoc, 991 991 raceFnCall, 992 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast992 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 993 993 ), 994 994 LogicalFlag::AndExpr … … 1016 1016 new CastExpr( cLoc, 1017 1017 new NameExpr( cLoc, data.at(idx)->whenName ), 1018 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1018 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1019 1019 ), 1020 1020 new CastExpr( cLoc, 1021 1021 baseCond, 1022 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1022 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1023 1023 ), 1024 1024 LogicalFlag::AndExpr … … 1034 1034 new NameExpr( cLoc, data.at(idx)->nodeName ), 1035 1035 new AddressExpr( cLoc, new NameExpr( cLoc, data.at(idx)->statusName ) ), 1036 ConstantExpr::null( cLoc, new PointerType( new BasicType( Basic Type::Kind::SignedInt ) ) )1036 ConstantExpr::null( cLoc, new PointerType( new BasicType( BasicKind::SignedInt ) ) ) 1037 1037 } 1038 1038 ) … … 1096 1096 new ObjectDecl( loc, 1097 1097 statusName, 1098 new BasicType( Basic Type::Kind::LongUnsignedInt ),1098 new BasicType( BasicKind::LongUnsignedInt ), 1099 1099 new SingleInit( loc, ConstantExpr::from_int( loc, 0 ) ) 1100 1100 ) … … 1114 1114 new NameExpr( cLoc, "?!=?" ), 1115 1115 { 1116 ConstantExpr::null( cLoc, new PointerType( new BasicType( Basic Type::Kind::LongUnsignedInt ) ) ),1116 ConstantExpr::null( cLoc, new PointerType( new BasicType( BasicKind::LongUnsignedInt ) ) ), 1117 1117 new UntypedExpr( cLoc, 1118 1118 new NameExpr( cLoc, "__get_clause_status" ), … … 1128 1128 new CastExpr( cLoc, 1129 1129 new NameExpr( cLoc, clauseData.at(i)->whenName ), 1130 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1130 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1131 1131 ), 1132 1132 new CastExpr( cLoc, 1133 1133 statusPtrCheck, 1134 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1134 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1135 1135 ), 1136 1136 LogicalFlag::AndExpr … … 1162 1162 new CastExpr( loc, 1163 1163 new NameExpr( loc, clauseData.at( whenIndices.at(i) )->whenName ), 1164 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1164 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1165 1165 ), 1166 1166 new CastExpr( loc, 1167 1167 lastExpr, 1168 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1168 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1169 1169 ), 1170 1170 LogicalFlag::OrExpr … … 1220 1220 new ObjectDecl( loc, 1221 1221 pCountName, 1222 new BasicType( Basic Type::Kind::SignedInt ),1222 new BasicType( BasicKind::SignedInt ), 1223 1223 new SingleInit( loc, ConstantExpr::from_int( loc, 0 ) ) 1224 1224 ) … … 1229 1229 new ObjectDecl( loc, 1230 1230 statusArrName, 1231 new ArrayType( new BasicType( Basic Type::Kind::LongUnsignedInt ), ConstantExpr::from_int( loc, numClauses ), LengthFlag::FixedLen, DimensionFlag::DynamicDim ),1231 new ArrayType( new BasicType( BasicKind::LongUnsignedInt ), ConstantExpr::from_int( loc, numClauses ), LengthFlag::FixedLen, DimensionFlag::DynamicDim ), 1232 1232 new ListInit( loc, 1233 1233 { … … 1331 1331 new CastExpr( cLoc, 1332 1332 statusExpr, 1333 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1333 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1334 1334 ), 1335 1335 new CastExpr( cLoc, 1336 1336 genSelectTraitCall( stmt->clauses.at(i), clauseData.at(i), "unregister_select" ), 1337 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1337 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1338 1338 ), 1339 1339 LogicalFlag::AndExpr … … 1346 1346 new CastExpr( cLoc, 1347 1347 new NameExpr( cLoc, clauseData.at(i)->whenName ), 1348 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1348 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1349 1349 ), 1350 1350 new CastExpr( cLoc, 1351 1351 statusExpr, 1352 new BasicType( Basic Type::Kind::Bool ), GeneratedFlag::ExplicitCast1352 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast 1353 1353 ), 1354 1354 LogicalFlag::AndExpr -
src/ControlStruct/ExceptDecl.cpp
r60c5b6d r7a780ad 99 99 createExceptionInstType( exceptionName, params ) ) ); 100 100 type->returns.push_back( new ast::PointerType( 101 new ast::BasicType( ast::Basic Type::Char, ast::CV::Const ) ) );101 new ast::BasicType( ast::BasicKind::Char, ast::CV::Const ) ) ); 102 102 return type; 103 103 } … … 344 344 "", 345 345 new ast::PointerType( 346 new ast::BasicType( ast::Basic Type::Char, ast::CV::Const ) )346 new ast::BasicType( ast::BasicKind::Char, ast::CV::Const ) ) 347 347 ), 348 348 }, -
src/ControlStruct/ExceptTranslate.cpp
r60c5b6d r7a780ad 182 182 location, 183 183 "__handler_index", 184 new ast::BasicType( ast::Basic Type::SignedInt )184 new ast::BasicType( ast::BasicKind::SignedInt ) 185 185 ); 186 186 } … … 201 201 location, 202 202 "__ret_bool", 203 new ast::BasicType( ast::Basic Type::Bool ),203 new ast::BasicType( ast::BasicKind::Bool ), 204 204 nullptr, //init 205 205 ast::Storage::Classes{}, … … 231 231 location, 232 232 "__handler_index", 233 new ast::BasicType( ast::BasicType::SignedInt),233 new ast::BasicType( ast::BasicKind::SignedInt ), 234 234 nullptr, 235 235 ast::Storage::Classes{}, -
src/GenPoly/Box.cpp
r60c5b6d r7a780ad 43 43 /// The layout type is used to represent sizes, alignments and offsets. 44 44 ast::BasicType * makeLayoutType() { 45 return new ast::BasicType( ast::Basic Type::LongUnsignedInt );45 return new ast::BasicType( ast::BasicKind::LongUnsignedInt ); 46 46 } 47 47 48 48 /// Fixed version of layout type (just adding a 'C' in C++ style). 49 49 ast::BasicType * makeLayoutCType() { 50 return new ast::BasicType( ast::Basic Type::LongUnsignedInt,50 return new ast::BasicType( ast::BasicKind::LongUnsignedInt, 51 51 ast::CV::Qualifiers( ast::CV::Const ) ); 52 52 } … … 1617 1617 ast::Type * polyToMonoType( CodeLocation const & location, 1618 1618 ast::Type const * declType ) { 1619 auto charType = new ast::BasicType( ast::Basic Type::Char );1619 auto charType = new ast::BasicType( ast::BasicKind::Char ); 1620 1620 auto size = new ast::NameExpr( location, 1621 1621 sizeofName( Mangle::mangleType( declType ) ) ); -
src/InitTweak/FixInit.cpp
r60c5b6d r7a780ad 847 847 848 848 // static bool __objName_uninitialized = true 849 auto boolType = new ast::BasicType( ast::Basic Type::Kind::Bool );849 auto boolType = new ast::BasicType( ast::BasicKind::Bool ); 850 850 auto boolInitExpr = new ast::SingleInit(loc, ast::ConstantExpr::from_int(loc, 1 ) ); 851 851 auto isUninitializedVar = new ast::ObjectDecl(loc, objDecl->mangleName + "_uninitialized", boolType, boolInitExpr, ast::Storage::Static, ast::Linkage::Cforall); -
src/Makefile.am
r60c5b6d r7a780ad 53 53 include Virtual/module.mk 54 54 55 $(addprefix $(srcdir)/, ResolvExpr/ConversionCost.cc ResolvExpr/CommonType.cc SymTab/ManglerCommon.cc) : $(srcdir)/AST/ Type.hpp55 $(addprefix $(srcdir)/, ResolvExpr/ConversionCost.cc ResolvExpr/CommonType.cc SymTab/ManglerCommon.cc) : $(srcdir)/AST/BasicKind.hpp 56 56 57 $(srcdir)/AST/ Type.hpp : BasicTypes-gen.cc57 $(srcdir)/AST/BasicKind.hpp : BasicTypes-gen.cc 58 58 ${AM_V_GEN}${CXXCOMPILE} $< -o BasicTypes-gen -Wall -Wextra -Werror=return-type 59 59 @./BasicTypes-gen -
src/Parser/ExpressionNode.cc
r60c5b6d r7a780ad 23 23 #include <string> // for string, operator+, operator== 24 24 25 #include "AST/BasicKind.hpp" // for BasicKind 25 26 #include "AST/Expr.hpp" // for NameExpr 26 #include "AST/Type.hpp" // for BaseType, SueInstType27 #include "AST/Type.hpp" // for Type, LengthFlag, DimentionFlag 27 28 #include "Common/SemanticError.h" // for SemanticError 28 29 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... … … 126 127 ast::Expr * build_constantInteger( 127 128 const CodeLocation & location, string & str ) { 128 static const ast::Basic Type::Kind kind[2][6] = {129 static const ast::BasicKind kind[2][6] = { 129 130 // short (h) must be before char (hh) because shorter type has the longer suffix 130 { ast::Basic Type::ShortSignedInt, ast::BasicType::SignedChar, ast::BasicType::SignedInt, ast::BasicType::LongSignedInt, ast::BasicType::LongLongSignedInt, /* BasicType::SignedInt128 */ ast::BasicType::LongLongSignedInt, },131 { ast::Basic Type::ShortUnsignedInt, ast::BasicType::UnsignedChar, ast::BasicType::UnsignedInt, ast::BasicType::LongUnsignedInt, ast::BasicType::LongLongUnsignedInt, /* BasicType::UnsignedInt128 */ ast::BasicType::LongLongUnsignedInt, },131 { ast::BasicKind::ShortSignedInt, ast::BasicKind::SignedChar, ast::BasicKind::SignedInt, ast::BasicKind::LongSignedInt, ast::BasicKind::LongLongSignedInt, /* BasicKind::SignedInt128 */ ast::BasicKind::LongLongSignedInt, }, 132 { ast::BasicKind::ShortUnsignedInt, ast::BasicKind::UnsignedChar, ast::BasicKind::UnsignedInt, ast::BasicKind::LongUnsignedInt, ast::BasicKind::LongLongUnsignedInt, /* BasicKind::UnsignedInt128 */ ast::BasicKind::LongLongUnsignedInt, }, 132 133 }; 133 134 … … 313 314 if ( ltype == 6 ) { // int128, (int128)constant 314 315 ret2 = new ast::ConstantExpr( location, 315 new ast::BasicType( ast::Basic Type::LongLongSignedInt ),316 new ast::BasicType( ast::BasicKind::LongLongSignedInt ), 316 317 str2, 317 318 v2 ); … … 379 380 ast::Expr * build_constantFloat( 380 381 const CodeLocation & location, string & str ) { 381 static const ast::Basic Type::Kind kind[2][12] = {382 { ast::Basic Type::Float, ast::BasicType::Double, ast::BasicType::LongDouble, ast::BasicType::uuFloat80, ast::BasicType::uuFloat128, ast::BasicType::uFloat16, ast::BasicType::uFloat32, ast::BasicType::uFloat32x, ast::BasicType::uFloat64, ast::BasicType::uFloat64x, ast::BasicType::uFloat128, ast::BasicType::uFloat128x },383 { ast::Basic Type::FloatComplex, ast::BasicType::DoubleComplex, ast::BasicType::LongDoubleComplex, ast::BasicType::NUMBER_OF_BASIC_TYPES, ast::BasicType::NUMBER_OF_BASIC_TYPES, ast::BasicType::uFloat16Complex, ast::BasicType::uFloat32Complex, ast::BasicType::uFloat32xComplex, ast::BasicType::uFloat64Complex, ast::BasicType::uFloat64xComplex, ast::BasicType::uFloat128Complex, ast::BasicType::uFloat128xComplex },382 static const ast::BasicKind kind[2][12] = { 383 { ast::BasicKind::Float, ast::BasicKind::Double, ast::BasicKind::LongDouble, ast::BasicKind::uuFloat80, ast::BasicKind::uuFloat128, ast::BasicKind::uFloat16, ast::BasicKind::uFloat32, ast::BasicKind::uFloat32x, ast::BasicKind::uFloat64, ast::BasicKind::uFloat64x, ast::BasicKind::uFloat128, ast::BasicKind::uFloat128x }, 384 { ast::BasicKind::FloatComplex, ast::BasicKind::DoubleComplex, ast::BasicKind::LongDoubleComplex, ast::BasicKind::NUMBER_OF_BASIC_TYPES, ast::BasicKind::NUMBER_OF_BASIC_TYPES, ast::BasicKind::uFloat16Complex, ast::BasicKind::uFloat32Complex, ast::BasicKind::uFloat32xComplex, ast::BasicKind::uFloat64Complex, ast::BasicKind::uFloat64xComplex, ast::BasicKind::uFloat128Complex, ast::BasicKind::uFloat128xComplex }, 384 385 }; 385 386 … … 447 448 448 449 ast::Expr * ret = new ast::ConstantExpr( location, 449 new ast::BasicType( ast::Basic Type::Char ),450 new ast::BasicType( ast::BasicKind::Char ), 450 451 str, 451 452 (unsigned long long int)(unsigned char)str[1] ); … … 482 483 Default: // char default string type 483 484 default: 484 strtype = new ast::BasicType( ast::Basic Type::Char );485 strtype = new ast::BasicType( ast::BasicKind::Char ); 485 486 } // switch 486 487 ast::ArrayType * at = new ast::ArrayType( … … 664 665 member->name 665 666 ); 666 ret->result = new ast::BasicType( ast::Basic Type::LongUnsignedInt );667 ret->result = new ast::BasicType( ast::BasicKind::LongUnsignedInt ); 667 668 delete member; 668 669 return ret; -
src/Parser/TypeData.cc
r60c5b6d r7a780ad 19 19 #include <ostream> // for operator<<, ostream, basic_ostream 20 20 21 #include "AST/Attribute.hpp" // for Attribute 21 22 #include "AST/Decl.hpp" // for AggregateDecl, ObjectDecl, TypeDe... 22 #include "AST/Attribute.hpp" // for Attribute23 23 #include "AST/Init.hpp" // for SingleInit, ListInit 24 24 #include "AST/Print.hpp" // for print 25 #include "AST/Type.hpp" // for Type 25 26 #include "Common/SemanticError.h" // for SemanticError 26 27 #include "Common/utility.h" // for splice, spliceBegin … … 1010 1011 // fill in implicit int 1011 1012 return new ast::BasicType( 1012 ast::Basic Type::SignedInt,1013 ast::BasicKind::SignedInt, 1013 1014 buildQualifiers( td ) 1014 1015 ); … … 1095 1096 1096 1097 ast::Type * buildBasicType( const TypeData * td ) { 1097 ast::Basic Type::Kind ret;1098 ast::BasicKind ret; 1098 1099 1099 1100 switch ( td->basictype ) { … … 1116 1117 } // if 1117 1118 1118 ret = ast::Basic Type::Bool;1119 ret = ast::BasicKind::Bool; 1119 1120 break; 1120 1121 … … 1123 1124 // character types. The implementation shall define char to have the same range, representation, and behavior as 1124 1125 // either signed char or unsigned char. 1125 static ast::Basic Type::Kind chartype[] = { ast::BasicType::SignedChar, ast::BasicType::UnsignedChar, ast::BasicType::Char };1126 static ast::BasicKind chartype[] = { ast::BasicKind::SignedChar, ast::BasicKind::UnsignedChar, ast::BasicKind::Char }; 1126 1127 1127 1128 if ( td->length != TypeData::NoLength ) { … … 1133 1134 1134 1135 case TypeData::Int: 1135 static ast::Basic Type::Kind inttype[2][4] = {1136 { ast::Basic Type::ShortSignedInt, ast::BasicType::LongSignedInt, ast::BasicType::LongLongSignedInt, ast::BasicType::SignedInt },1137 { ast::Basic Type::ShortUnsignedInt, ast::BasicType::LongUnsignedInt, ast::BasicType::LongLongUnsignedInt, ast::BasicType::UnsignedInt },1136 static ast::BasicKind inttype[2][4] = { 1137 { ast::BasicKind::ShortSignedInt, ast::BasicKind::LongSignedInt, ast::BasicKind::LongLongSignedInt, ast::BasicKind::SignedInt }, 1138 { ast::BasicKind::ShortUnsignedInt, ast::BasicKind::LongUnsignedInt, ast::BasicKind::LongLongUnsignedInt, ast::BasicKind::UnsignedInt }, 1138 1139 }; 1139 1140 … … 1146 1147 1147 1148 case TypeData::Int128: 1148 ret = td->signedness == TypeData::Unsigned ? ast::Basic Type::UnsignedInt128 : ast::BasicType::SignedInt128;1149 ret = td->signedness == TypeData::Unsigned ? ast::BasicKind::UnsignedInt128 : ast::BasicKind::SignedInt128; 1149 1150 if ( td->length != TypeData::NoLength ) { 1150 1151 genTSError( TypeData::lengthNames[ td->length ], td->basictype ); … … 1164 1165 case TypeData::uFloat128: 1165 1166 case TypeData::uFloat128x: 1166 static ast::Basic Type::Kind floattype[2][12] = {1167 { ast::Basic Type::FloatComplex, ast::BasicType::DoubleComplex, ast::BasicType::LongDoubleComplex, (ast::BasicType::Kind)-1, (ast::BasicType::Kind)-1, ast::BasicType::uFloat16Complex, ast::BasicType::uFloat32Complex, ast::BasicType::uFloat32xComplex, ast::BasicType::uFloat64Complex, ast::BasicType::uFloat64xComplex, ast::BasicType::uFloat128Complex, ast::BasicType::uFloat128xComplex, },1168 { ast::Basic Type::Float, ast::BasicType::Double, ast::BasicType::LongDouble, ast::BasicType::uuFloat80, ast::BasicType::uuFloat128, ast::BasicType::uFloat16, ast::BasicType::uFloat32, ast::BasicType::uFloat32x, ast::BasicType::uFloat64, ast::BasicType::uFloat64x, ast::BasicType::uFloat128, ast::BasicType::uFloat128x, },1167 static ast::BasicKind floattype[2][12] = { 1168 { ast::BasicKind::FloatComplex, ast::BasicKind::DoubleComplex, ast::BasicKind::LongDoubleComplex, (ast::BasicKind)-1, (ast::BasicKind)-1, ast::BasicKind::uFloat16Complex, ast::BasicKind::uFloat32Complex, ast::BasicKind::uFloat32xComplex, ast::BasicKind::uFloat64Complex, ast::BasicKind::uFloat64xComplex, ast::BasicKind::uFloat128Complex, ast::BasicKind::uFloat128xComplex, }, 1169 { ast::BasicKind::Float, ast::BasicKind::Double, ast::BasicKind::LongDouble, ast::BasicKind::uuFloat80, ast::BasicKind::uuFloat128, ast::BasicKind::uFloat16, ast::BasicKind::uFloat32, ast::BasicKind::uFloat32x, ast::BasicKind::uFloat64, ast::BasicKind::uFloat64x, ast::BasicKind::uFloat128, ast::BasicKind::uFloat128x, }, 1169 1170 }; 1170 1171 … … 1213 1214 1214 1215 static ast::Type * buildDefaultType( const TypeData * td ) { 1215 return ( td ) ? typebuild( td ) : new ast::BasicType( ast::Basic Type::SignedInt );1216 return ( td ) ? typebuild( td ) : new ast::BasicType( ast::BasicKind::SignedInt ); 1216 1217 } // buildDefaultType 1217 1218 … … 1579 1580 td->location, 1580 1581 "", 1581 new ast::BasicType( ast::Basic Type::SignedInt ),1582 new ast::BasicType( ast::BasicKind::SignedInt ), 1582 1583 (ast::Init *)nullptr, 1583 1584 ast::Storage::Classes(), … … 1667 1668 } else { 1668 1669 ft->returns.push_back( 1669 new ast::BasicType( ast::Basic Type::SignedInt ) );1670 new ast::BasicType( ast::BasicKind::SignedInt ) ); 1670 1671 } // if 1671 1672 return ft; -
src/Parser/TypeData.h
r60c5b6d r7a780ad 20 20 #include <string> // for string 21 21 22 #include "AST/Type.hpp" // for Type 22 #include "AST/CVQualifiers.hpp" // for CV 23 #include "AST/Fwd.hpp" // for Type 23 24 #include "DeclarationNode.h" // for DeclarationNode 24 25 -
src/Parser/parser.yy
r60c5b6d r7a780ad 55 55 #include "TypedefTable.h" 56 56 #include "TypeData.h" 57 #include "AST/Type.hpp" // for BasicType, BasicKind 57 58 #include "Common/SemanticError.h" // error_str 58 59 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... … … 260 261 ast::ConstantExpr * constant = dynamic_cast<ast::ConstantExpr *>(type->expr.get()); 261 262 if ( constant && (constant->rep == "0" || constant->rep == "1") ) { 262 type = new ExpressionNode( new ast::CastExpr( location, maybeMoveBuild(type), new ast::BasicType( ast::Basic Type::SignedInt ) ) );263 type = new ExpressionNode( new ast::CastExpr( location, maybeMoveBuild(type), new ast::BasicType( ast::BasicKind::SignedInt ) ) ); 263 264 } // if 264 265 DeclarationNode * initDecl = distAttr( -
src/ResolvExpr/CandidateFinder.cpp
r60c5b6d r7a780ad 2176 2176 } 2177 2177 ), 2178 new ast::BasicType( ast::Basic Type::SignedInt )2178 new ast::BasicType( ast::BasicKind::SignedInt ) 2179 2179 ); 2180 2180 } -
src/ResolvExpr/CommonType.cc
r60c5b6d r7a780ad 38 38 // GENERATED START, DO NOT EDIT 39 39 // GENERATED BY BasicTypes-gen.cc 40 #define BT ast::Basic Type::41 static const BTKind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor40 #define BT ast::BasicKind:: 41 static const ast::BasicKind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor 42 42 /* B C SC UC SI SUI 43 43 I UI LI LUI LLI LLUI … … 339 339 // GENERATED END 340 340 static_assert( 341 sizeof(commonTypes)/sizeof(commonTypes[0][0]) == ast::Basic Type::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,341 sizeof(commonTypes)/sizeof(commonTypes[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES, 342 342 "Each basic type kind should have a corresponding row in the combined type matrix" 343 343 ); … … 366 366 void postvisit( const ast::BasicType * basic ) { 367 367 if ( auto basic2 = dynamic_cast< const ast::BasicType * >( type2 ) ) { 368 ast::Basic Type::Kind kind;368 ast::BasicKind kind; 369 369 if (basic->kind != basic2->kind && !widen.first && !widen.second) return; 370 370 else if (!widen.first) kind = basic->kind; // widen.second … … 386 386 const ast::EnumDecl* enumDecl = enumInst->base; 387 387 if ( !enumDecl->base ) { 388 ast::Basic Type::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];388 ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ]; 389 389 if ( 390 390 ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers ) … … 398 398 } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) { 399 399 if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) { 400 ast::Basic Type::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];400 ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ]; 401 401 if ( 402 402 ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers ) … … 649 649 void postvisit( const ast::EnumInstType * enumInst ) { 650 650 if ( enumInst->base && !enumInst->base->base ) { 651 auto basicType = new ast::BasicType( ast::Basic Type::UnsignedInt );651 auto basicType = new ast::BasicType( ast::BasicKind::UnsignedInt ); 652 652 result = commonType( basicType, type2, tenv, need, have, open, widen); 653 653 } … … 674 674 } else if ( widen.second && dynamic_cast< const ast::OneType * >( type2 ) ) { 675 675 result = new ast::BasicType{ 676 ast::Basic Type::SignedInt, zero->qualifiers | type2->qualifiers };676 ast::BasicKind::SignedInt, zero->qualifiers | type2->qualifiers }; 677 677 } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) { 678 678 const ast::EnumDecl * enumDecl = enumInst->base; … … 695 695 } else if ( widen.second && dynamic_cast< const ast::ZeroType * >( type2 ) ) { 696 696 result = new ast::BasicType{ 697 ast::Basic Type::SignedInt, one->qualifiers | type2->qualifiers };697 ast::BasicKind::SignedInt, one->qualifiers | type2->qualifiers }; 698 698 } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) { 699 699 const ast::EnumDecl * enumDecl = enumInst->base; -
src/ResolvExpr/ConversionCost.cc
r60c5b6d r7a780ad 59 59 // GENERATED START, DO NOT EDIT 60 60 // GENERATED BY BasicTypes-gen.cc 61 static const int costMatrix[ast::Basic Type::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node61 static const int costMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // path length from root to node 62 62 /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */ 63 63 /* B */ { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 17, 16, 18, 17, }, … … 101 101 // GENERATED END 102 102 static_assert( 103 sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::Basic Type::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,103 sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES, 104 104 "Missing row in the cost matrix" 105 105 ); … … 107 107 // GENERATED START, DO NOT EDIT 108 108 // GENERATED BY BasicTypes-gen.cc 109 static const int signMatrix[ast::Basic Type::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion109 static const int signMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion 110 110 /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */ 111 111 /* B */ { 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, … … 148 148 // GENERATED END 149 149 static_assert( 150 sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::Basic Type::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,150 sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES, 151 151 "Missing row in the sign matrix" 152 152 ); … … 279 279 conversionCostFromBasicToBasic( basicType, dstAsBasic ); 280 280 } else if ( dynamic_cast< const ast::EnumAttrType *>(dst) ) { 281 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::Basic Type::SignedInt ) };281 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 282 282 cost = costCalc( basicType, integer, srcIsLvalue, symtab, env ); 283 283 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { … … 383 383 } 384 384 return; 385 } 386 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::Basic Type::SignedInt ) };385 } 386 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 387 387 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 388 388 if ( cost < Cost::unsafe ) { … … 396 396 if ( dstAsEnumAttrType && dstAsEnumAttrType->attr == ast::EnumAttribute::Label ) { 397 397 cost = costCalc( src->instance, dstAsEnumAttrType->instance, srcIsLvalue, symtab, env ); 398 } 398 } 399 399 // Add Conversion To String 400 400 } else if ( src->attr == ast::EnumAttribute::Value ) { … … 413 413 if ( cost < Cost::unsafe ) cost.incSafe(); 414 414 } else { 415 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::Basic Type::SignedInt ) };415 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) }; 416 416 cost = costCalc( integer, dst, srcIsLvalue, symtab, env ); 417 417 if ( cost < Cost::unsafe ) { … … 478 478 } else if ( const ast::BasicType * dstAsBasic = 479 479 dynamic_cast< const ast::BasicType * >( dst ) ) { 480 int tableResult = costMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ];480 int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ]; 481 481 if ( -1 == tableResult ) { 482 482 cost = Cost::unsafe; … … 484 484 cost = Cost::zero; 485 485 cost.incSafe( tableResult + 1 ); 486 cost.incSign( signMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ] );486 cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] ); 487 487 } 488 488 // this has the effect of letting any expr such as x+0, x+1 to be typed … … 510 510 } else if ( const ast::BasicType * dstAsBasic = 511 511 dynamic_cast< const ast::BasicType * >( dst ) ) { 512 int tableResult = costMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ];512 int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ]; 513 513 if ( -1 == tableResult ) { 514 514 cost = Cost::unsafe; … … 516 516 cost = Cost::zero; 517 517 cost.incSafe( tableResult + 1 ); 518 cost.incSign( signMatrix[ ast::Basic Type::SignedInt ][ dstAsBasic->kind ] );518 cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] ); 519 519 } 520 520 } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) { -
src/ResolvExpr/PtrsCastable.cc
r60c5b6d r7a780ad 100 100 result = 1; 101 101 } else if ( auto bt = dynamic_cast< const ast::BasicType * >( dst ) ) { 102 if ( bt->kind == ast::Basic Type::SignedInt ) {102 if ( bt->kind == ast::BasicKind::SignedInt ) { 103 103 result = 0; 104 104 } else { -
src/ResolvExpr/ResolveTypeof.cc
r60c5b6d r7a780ad 63 63 if ( newType.as< ast::EnumInstType >() ) { 64 64 newType = new ast::BasicType( 65 ast::Basic Type::SignedInt, newType->qualifiers, copy(newType->attributes) );65 ast::BasicKind::SignedInt, newType->qualifiers, copy(newType->attributes) ); 66 66 } 67 67 reset_qualifiers( … … 91 91 auto mutType = mutate(arrayType); 92 92 auto globalSizeType = context.global.sizeType; 93 ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType( ast::BasicType::LongUnsignedInt);93 ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType( ast::BasicKind::LongUnsignedInt ); 94 94 mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, context ); 95 95 -
src/ResolvExpr/Resolver.cc
r60c5b6d r7a780ad 351 351 bool isCharType( const ast::Type * t ) { 352 352 if ( auto bt = dynamic_cast< const ast::BasicType * >( t ) ) { 353 return bt->kind == ast::Basic Type::Char354 || bt->kind == ast::Basic Type::SignedChar355 || bt->kind == ast::Basic Type::UnsignedChar;353 return bt->kind == ast::BasicKind::Char 354 || bt->kind == ast::BasicKind::SignedChar 355 || bt->kind == ast::BasicKind::UnsignedChar; 356 356 } 357 357 return false; … … 458 458 if (attr->params.size() == 1) { 459 459 auto arg = attr->params.front(); 460 auto resolved = ResolvExpr::findSingleExpression( arg, new ast::BasicType( ast::Basic Type::LongLongSignedInt ), context );460 auto resolved = ResolvExpr::findSingleExpression( arg, new ast::BasicType( ast::BasicKind::LongLongSignedInt ), context ); 461 461 auto result = eval(arg); 462 462 … … 624 624 objectDecl = fixObjectType( objectDecl, context ); 625 625 currentObject = ast::CurrentObject{ 626 objectDecl->location, new ast::BasicType{ ast::Basic Type::SignedInt } };626 objectDecl->location, new ast::BasicType{ ast::BasicKind::SignedInt } }; 627 627 } 628 628 } else { … … 1095 1095 // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally 1096 1096 ast::ptr< ast::Type > target = 1097 new ast::BasicType{ ast::Basic Type::LongLongUnsignedInt };1097 new ast::BasicType{ ast::BasicKind::LongLongUnsignedInt }; 1098 1098 auto timeout_time = findSingleExpression( stmt->timeout_time, target, context ); 1099 1099 auto timeout_cond = findCondExpression( stmt->timeout_cond, context ); -
src/SymTab/GenImplicitCall.cpp
r60c5b6d r7a780ad 133 133 134 134 ast::ptr< ast::DeclWithType > index = new ast::ObjectDecl( 135 loc, indexName.newName(), new ast::BasicType( ast::Basic Type::SignedInt ),135 loc, indexName.newName(), new ast::BasicType( ast::BasicKind::SignedInt ), 136 136 new ast::SingleInit( loc, begin ) ); 137 137 ast::ptr< ast::Expr > indexVar = new ast::VariableExpr( loc, index ); -
src/SymTab/Mangler.cc
r60c5b6d r7a780ad 142 142 void Mangler::postvisit( const ast::BasicType * basicType ) { 143 143 printQualifiers( basicType ); 144 assertf( basicType->kind < ast::Basic Type::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->kind );144 assertf( basicType->kind < ast::BasicKind::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->kind ); 145 145 mangleName += Encoding::basicTypes[ basicType->kind ]; 146 146 } -
src/SymTab/ManglerCommon.cc
r60c5b6d r7a780ad 41 41 // - "Di" char32_t 42 42 // - "Ds" char16_t 43 const std::string basicTypes[ast::Basic Type::NUMBER_OF_BASIC_TYPES] = {43 const std::string basicTypes[ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { 44 44 "b", // _Bool 45 45 "c", // char … … 81 81 // GENERATED END 82 82 static_assert( 83 sizeof(basicTypes) / sizeof(basicTypes[0]) == ast::Basic Type::NUMBER_OF_BASIC_TYPES,83 sizeof(basicTypes) / sizeof(basicTypes[0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES, 84 84 "Each basic type kind should have a corresponding mangler letter" 85 85 ); -
src/Tuples/TupleExpansion.cpp
r60c5b6d r7a780ad 106 106 assignUnq = commaExpr->arg1; 107 107 } 108 auto finished = new ast::ObjectDecl( loc, toString( "_unq", id, "_finished_" ), new ast::BasicType( ast::Basic Type::Kind::Bool ),108 auto finished = new ast::ObjectDecl( loc, toString( "_unq", id, "_finished_" ), new ast::BasicType( ast::BasicKind::Bool ), 109 109 new ast::SingleInit( loc, ast::ConstantExpr::from_int( loc, 0 ) ), {}, ast::Linkage::Cforall ); 110 110 declsToAddBefore.push_back( finished ); … … 175 175 new ast::ObjectDecl( location, 176 176 "dummy", 177 new ast::BasicType( ast::Basic Type::SignedInt ),177 new ast::BasicType( ast::BasicKind::SignedInt ), 178 178 nullptr, 179 179 ast::Storage::Classes(), -
src/Validate/GenericParameter.cpp
r60c5b6d r7a780ad 289 289 return new ast::TypeExpr( expr->location, 290 290 new ast::ArrayType( 291 new ast::BasicType( ast::Basic Type::Char ),291 new ast::BasicType( ast::BasicKind::Char ), 292 292 expr, 293 293 ast::VariableLen, -
src/Validate/ImplementEnumFunc.cpp
r60c5b6d r7a780ad 311 311 {new ast::ObjectDecl( 312 312 getLocation(), "_ret", 313 new ast::PointerType(new ast::BasicType{ast::Basic Type::Char}))});313 new ast::PointerType(new ast::BasicType{ast::BasicKind::Char}))}); 314 314 } 315 315 … … 364 364 attr == ast::EnumAttribute::Value 365 365 ? decl->base 366 : new ast::PointerType(new ast::BasicType{ast::Basic Type::Char}),366 : new ast::PointerType(new ast::BasicType{ast::BasicKind::Char}), 367 367 ast::ConstantExpr::from_int(decl->location, decl->members.size()), 368 368 ast::LengthFlag::FixedLen, ast::DimensionFlag::DynamicDim); -
src/Validate/ReplaceTypedef.cpp
r60c5b6d r7a780ad 349 349 // Perhaps this should be a warning instead. 350 350 translationUnit.global.sizeType = 351 new ast::BasicType( ast::Basic Type::LongUnsignedInt );351 new ast::BasicType( ast::BasicKind::LongUnsignedInt ); 352 352 } 353 353 }
Note: See TracChangeset
for help on using the changeset viewer.