| 1504 | } |
| 1505 | |
| 1506 | CeOperand CeBuilder::GetOperand(BeValue* value, bool allowAlloca, bool allowImmediate) |
| 1507 | { |
| 1508 | if (value == NULL) |
| 1509 | return CeOperand(); |
| 1510 | |
| 1511 | BeType* errorType = mIntPtrType; |
| 1512 | CeErrorKind errorKind = CeErrorKind_None; |
| 1513 | |
| 1514 | switch (value->GetTypeId()) |
| 1515 | { |
| 1516 | case BeGlobalVariable::TypeId: |
| 1517 | { |
| 1518 | auto globalVar = (BeGlobalVariable*)value; |
| 1519 | if (globalVar->mName.StartsWith("__bfStrObj")) |
| 1520 | { |
| 1521 | int stringId = atoi(globalVar->mName.c_str() + 10); |
| 1522 | |
| 1523 | int* stringTableIdxPtr = NULL; |
| 1524 | if (mStringMap.TryAdd(stringId, NULL, &stringTableIdxPtr)) |
| 1525 | { |
| 1526 | *stringTableIdxPtr = (int)mCeFunction->mStringTable.size(); |
| 1527 | CeStringEntry ceStringEntry; |
| 1528 | ceStringEntry.mStringId = stringId; |
| 1529 | mCeFunction->mStringTable.Add(ceStringEntry); |
| 1530 | } |
| 1531 | |
| 1532 | auto result = FrameAlloc(mCeMachine->GetBeContext()->GetPointerTo(globalVar->mType)); |
| 1533 | |
| 1534 | Emit(CeOp_GetString); |
| 1535 | EmitFrameOffset(result); |
| 1536 | Emit((int32)*stringTableIdxPtr); |
| 1537 | return result; |
| 1538 | } |
| 1539 | else if (globalVar->mName.StartsWith("__bfStrData")) |
| 1540 | { |
| 1541 | int stringId = atoi(globalVar->mName.c_str() + 11); |
| 1542 | |
| 1543 | int* stringTableIdxPtr = NULL; |
| 1544 | if (mStringMap.TryAdd(stringId, NULL, &stringTableIdxPtr)) |
| 1545 | { |
| 1546 | *stringTableIdxPtr = (int)mCeFunction->mStringTable.size(); |
| 1547 | CeStringEntry ceStringEntry; |
| 1548 | ceStringEntry.mStringId = stringId; |
| 1549 | mCeFunction->mStringTable.Add(ceStringEntry); |
| 1550 | } |
| 1551 | |
| 1552 | auto result = FrameAlloc(mCeMachine->GetBeContext()->GetPointerTo(globalVar->mType)); |
| 1553 | |
| 1554 | Emit(CeOp_GetString); |
| 1555 | EmitFrameOffset(result); |
| 1556 | Emit((int32)*stringTableIdxPtr); |
| 1557 | |
| 1558 | BfTypeInstance* stringTypeInst = (BfTypeInstance*)mCeMachine->mCeModule->ResolveTypeDef( |
| 1559 | mCeMachine->mCeModule->mCompiler->mStringTypeDef, BfPopulateType_Data); |
| 1560 | |
| 1561 | Emit(CeOp_AddConst_I32); |
| 1562 | EmitFrameOffset(result); |
| 1563 | EmitFrameOffset(result); |
nothing calls this directly
no test coverage detected