| 4364 | #define CE_GETC(T) *(T*)(mMemory.mVals + addr) |
| 4365 | |
| 4366 | bool CeContext::WriteConstant(BfModule* module, addr_ce addr, BfConstant* constant, BfType* type, bool isParams) |
| 4367 | { |
| 4368 | int ptrSize = mCeMachine->mCeModule->mSystem->mPtrSize; |
| 4369 | |
| 4370 | switch (constant->mTypeCode) |
| 4371 | { |
| 4372 | case BfTypeCode_None: |
| 4373 | return true; |
| 4374 | case BfTypeCode_Int8: |
| 4375 | case BfTypeCode_UInt8: |
| 4376 | case BfTypeCode_Boolean: |
| 4377 | case BfTypeCode_Char8: |
| 4378 | CE_GETC(int8) = constant->mInt8; |
| 4379 | return true; |
| 4380 | case BfTypeCode_Int16: |
| 4381 | case BfTypeCode_UInt16: |
| 4382 | case BfTypeCode_Char16: |
| 4383 | CE_GETC(int16) = constant->mInt16; |
| 4384 | return true; |
| 4385 | case BfTypeCode_Int32: |
| 4386 | case BfTypeCode_UInt32: |
| 4387 | case BfTypeCode_Char32: |
| 4388 | CE_GETC(int32) = constant->mInt32; |
| 4389 | return true; |
| 4390 | case BfTypeCode_Int64: |
| 4391 | case BfTypeCode_UInt64: |
| 4392 | CE_GETC(int64) = constant->mInt64; |
| 4393 | return true; |
| 4394 | case BfTypeCode_NullPtr: |
| 4395 | if (ptrSize == 4) |
| 4396 | CE_GETC(int32) = 0; |
| 4397 | else |
| 4398 | CE_GETC(int64) = 0; |
| 4399 | return true; |
| 4400 | case BfTypeCode_Float: |
| 4401 | CE_GETC(float) = (float)constant->mDouble; |
| 4402 | return true; |
| 4403 | case BfTypeCode_Double: |
| 4404 | CE_GETC(double) = constant->mDouble; |
| 4405 | return true; |
| 4406 | } |
| 4407 | |
| 4408 | if (constant->mConstType == BfConstType_Agg) |
| 4409 | { |
| 4410 | if (type->IsPointer()) |
| 4411 | { |
| 4412 | auto elementType = type->GetUnderlyingType(); |
| 4413 | auto toPtr = CeMallocZero(elementType->mSize); |
| 4414 | addr_ce toAddr = (addr_ce)(toPtr - mMemory.mVals); |
| 4415 | if (ptrSize == 4) |
| 4416 | CE_GETC(int32) = (int32)toAddr; |
| 4417 | else |
| 4418 | CE_GETC(int64) = (int64)toAddr; |
| 4419 | return WriteConstant(module, toAddr, constant, elementType, isParams); |
| 4420 | } |
| 4421 | |
| 4422 | auto aggConstant = (BfConstantAgg*)constant; |
| 4423 | if (type->IsSizedArray()) |
no test coverage detected