Changeset 7a780ad for src/Parser
- Timestamp:
- Apr 18, 2024, 5:19:17 PM (4 months ago)
- Branches:
- master
- Children:
- 38093ae
- Parents:
- 60c5b6d
- Location:
- src/Parser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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(
Note: See TracChangeset
for help on using the changeset viewer.