diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index bb74b52b..73067537 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -2523,7 +2523,7 @@ void BfModule::HandleCEAttributes(CeEmitContext* ceEmitContext, BfTypeInstance* callSource.mKind = CeCallSource::Kind_TypeDone; } - result = ceContext->Call(callSource, this, methodInstance, args, CeEvalFlags_ForceReturnThis, NULL); + result = ceContext->Call(callSource, this, methodInstance, args, (CeEvalFlags)(CeEvalFlags_ForceReturnThis | CeEvalFlags_IgnoreConstEncodeFailure), NULL); } if (fieldInstance != NULL) mCompiler->mCeMachine->mFieldInstanceSet.Remove(fieldInstance); diff --git a/IDEHelper/Compiler/CeMachine.cpp b/IDEHelper/Compiler/CeMachine.cpp index a1a01aa5..7cca34cb 100644 --- a/IDEHelper/Compiler/CeMachine.cpp +++ b/IDEHelper/Compiler/CeMachine.cpp @@ -4801,8 +4801,9 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType return instResult; } - Fail(StrFormat("Span return type '%s' must be received by a sized array", module->TypeToString(typeInst).c_str())); - return BfIRValue(); + if ((mCurEvalFlags & CeEvalFlags_IgnoreConstEncodeFailure) == 0) + Fail(StrFormat("Span return type '%s' must be received by a sized array", module->TypeToString(typeInst).c_str())); + return irBuilder->CreateConstAggZero(irBuilder->MapType(typeInst)); } if (typeInst->IsInstanceOf(ceModule->mCompiler->mTypeTypeDef)) @@ -4824,6 +4825,11 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType addr_ce typeId = *(int*)(instData); BfType* type = GetBfType(typeId); + if (type == NULL) + { + Fail("Unable to locate type"); + return BfIRValue(); + } if (type->IsInstanceOf(mCeMachine->mCompiler->mStringTypeDef)) { @@ -4860,8 +4866,9 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType if (typeInst->IsObjectOrInterface()) { - Fail(StrFormat("Reference type '%s' return value not allowed", module->TypeToString(typeInst).c_str())); - return BfIRValue(); + if ((mCurEvalFlags & CeEvalFlags_IgnoreConstEncodeFailure) == 0) + Fail(StrFormat("Reference type '%s' return value not allowed", module->TypeToString(typeInst).c_str())); + return irBuilder->CreateConstNull(irBuilder->MapType(typeInst)); } if (typeInst->mBaseType != NULL) @@ -4931,8 +4938,9 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType if (bfType->IsPointer()) { - Fail(StrFormat("Pointer type '%s' return value not allowed", module->TypeToString(bfType).c_str())); - return BfIRValue(); + if ((mCurEvalFlags & CeEvalFlags_IgnoreConstEncodeFailure) == 0) + Fail(StrFormat("Pointer type '%s' return value not allowed", module->TypeToString(bfType).c_str())); + return irBuilder->CreateConstNull(irBuilder->MapType(bfType)); } if ((bfType->IsSizedArray()) && (!bfType->IsUnknownSizedArrayType())) @@ -7575,7 +7583,7 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8* auto valueType = GetBfType(objTypeId); if ((ifaceType == NULL) || (valueType == NULL)) { - _Fail("Invalid type"); + _Fail("Invalid type in CeOp_DynamicCastCheck"); return false; } diff --git a/IDEHelper/Compiler/CeMachine.h b/IDEHelper/Compiler/CeMachine.h index 548412e3..0741bc4f 100644 --- a/IDEHelper/Compiler/CeMachine.h +++ b/IDEHelper/Compiler/CeMachine.h @@ -700,7 +700,8 @@ enum CeEvalFlags CeEvalFlags_DeferIfNotOnlyError = 4, CeEvalFlags_NoRebuild = 8, CeEvalFlags_ForceReturnThis = 0x10, - CeEvalFlags_DbgCall = 0x20 + CeEvalFlags_IgnoreConstEncodeFailure = 0x20, + CeEvalFlags_DbgCall = 0x40 }; #define BF_CE_DEFAULT_STACK_SIZE 4*1024*1024