MCPcopy Create free account
hub / github.com/beefytech/Beef / GetStringPoolIdx

Method GetStringPoolIdx

IDEHelper/Compiler/BfModule.cpp:1799–1838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1797}
1798
1799int BfModule::GetStringPoolIdx(BfIRValue constantStr, BfIRConstHolder* constHolder)
1800{
1801 if (constHolder == NULL)
1802 constHolder = mBfIRBuilder;
1803
1804 auto constant = constHolder->GetConstant(constantStr);
1805 if (constant == NULL)
1806 return -1;
1807
1808 if ((constant->mTypeCode == BfTypeCode_StringId) || (constant->mTypeCode == BfTypeCode_CharPtr))
1809 {
1810 return constant->mInt32;
1811 }
1812
1813 while (constant->mConstType == BfConstType_BitCast)
1814 {
1815 auto constBitCast = (BfConstantBitCast*)constant;
1816 constant = constHolder->GetConstantById(constBitCast->mTarget);
1817 }
1818
1819 if (constant->mConstType == BfConstType_GEP32_2)
1820 {
1821 auto constGEP = (BfConstantGEP32_2*)constant;
1822 constant = constHolder->GetConstantById(constGEP->mTarget);
1823 }
1824
1825 if (constant->mConstType == BfConstType_GlobalVar)
1826 {
1827 auto constGV = (BfGlobalVar*)constant;
1828 const char* strDataPrefix = "__bfStrData";
1829 if (strncmp(constGV->mName, strDataPrefix, strlen(strDataPrefix)) == 0)
1830 return atoi(constGV->mName + strlen(strDataPrefix));
1831
1832 const char* strObjPrefix = "__bfStrObj";
1833 if (strncmp(constGV->mName, strObjPrefix, strlen(strObjPrefix)) == 0)
1834 return atoi(constGV->mName + strlen(strObjPrefix));
1835 }
1836
1837 return -1;
1838}
1839
1840String* BfModule::GetStringPoolString(BfIRValue constantStr, BfIRConstHolder * constHolder)
1841{

Callers 4

ConstantToStringMethod · 0.80
ResolveMethod · 0.80

Calls 2

GetConstantByIdMethod · 0.80
GetConstantMethod · 0.45

Tested by

no test coverage detected