| 286 | } |
| 287 | |
| 288 | String BfIRConstHolder::ToString(BfIRValue irValue) |
| 289 | { |
| 290 | if ((irValue.mFlags & BfIRValueFlags_Const) != 0) |
| 291 | { |
| 292 | auto constant = GetConstantById(irValue.mId); |
| 293 | |
| 294 | if (constant->mTypeCode == BfTypeCode_None) |
| 295 | { |
| 296 | return "void"; |
| 297 | } |
| 298 | else if (constant->mTypeCode == BfTypeCode_NullPtr) |
| 299 | { |
| 300 | String ret; |
| 301 | if (constant->mIRType) |
| 302 | { |
| 303 | ret += ToString(constant->mIRType); |
| 304 | ret += " "; |
| 305 | } |
| 306 | ret += "null"; |
| 307 | return ret; |
| 308 | } |
| 309 | else if (constant->mTypeCode == BfTypeCode_Boolean) |
| 310 | { |
| 311 | return constant->mBool ? "true" : "false"; |
| 312 | } |
| 313 | else if (constant->mTypeCode == BfTypeCode_Float) |
| 314 | { |
| 315 | return StrFormat("Constant %ff", constant->mDouble); |
| 316 | } |
| 317 | else if (constant->mTypeCode == BfTypeCode_Double) |
| 318 | { |
| 319 | return StrFormat("Constant %f", constant->mDouble); |
| 320 | } |
| 321 | else if (IsInt(constant->mTypeCode)) |
| 322 | { |
| 323 | return StrFormat("Constant %lld", constant->mInt64); |
| 324 | } |
| 325 | else if (constant->mTypeCode == BfTypeCode_CharPtr) |
| 326 | { |
| 327 | return StrFormat("CharPtr %d", constant->mInt64); |
| 328 | } |
| 329 | else if (constant->mTypeCode == BfTypeCode_StringId) |
| 330 | { |
| 331 | return StrFormat("StringId %d", constant->mInt64); |
| 332 | } |
| 333 | else if (constant->mConstType == BfConstType_GlobalVar) |
| 334 | { |
| 335 | auto gvConst = (BfGlobalVar*)constant; |
| 336 | return String("GlobalVar ") + gvConst->mName; |
| 337 | } |
| 338 | else if (constant->mConstType == BfConstType_BitCast) |
| 339 | { |
| 340 | auto bitcast = (BfConstantBitCast*)constant; |
| 341 | BfIRValue targetConst(BfIRValueFlags_Const, bitcast->mTarget); |
| 342 | return ToString(bitcast->mToType) += " bitcast " + ToString(targetConst); |
| 343 | } |
| 344 | else if (constant->mConstType == BfConstType_Box) |
| 345 | { |
no test coverage detected