diff --git a/src/Common/src/System/Diagnostics/Debug.cs b/src/Common/src/System/Diagnostics/Debug.cs index 86edcb559..1093beca3 100644 --- a/src/Common/src/System/Diagnostics/Debug.cs +++ b/src/Common/src/System/Diagnostics/Debug.cs @@ -30,6 +30,10 @@ namespace System.Diagnostics { if (!condition) { +#if CORERT + // CORERT-TODO + unsafe { *(int *)0 = 0; } +#else string stackTrace; try @@ -43,6 +47,7 @@ namespace System.Diagnostics WriteAssert(stackTrace, message, detailMessage); s_logger.ShowAssertDialog(stackTrace, message, detailMessage); +#endif } } diff --git a/src/ILToNative.Compiler/src/CppCodeGen/CppWriter.cs b/src/ILToNative.Compiler/src/CppCodeGen/CppWriter.cs index 1969ccc4d..383e480c2 100644 --- a/src/ILToNative.Compiler/src/CppCodeGen/CppWriter.cs +++ b/src/ILToNative.Compiler/src/CppCodeGen/CppWriter.cs @@ -47,7 +47,6 @@ namespace ILToNative.CppCodeGen // TODO: For now, ensure that all types/methods referenced by temporary implementation in stubs.cpp are present var stringType = _compilation.TypeSystemContext.GetWellKnownType(WellKnownType.String); - _compilation.AddMethod(stringType.GetMethod("get_Chars", null)); AddInstanceFields(stringType); var stringArrayType = stringType.MakeArrayType(); @@ -303,7 +302,7 @@ namespace ILToNative.CppCodeGen importName = ecmaMethod.Name; // TODO: hacky special-case - if (importName != "memmove") // memmove is already declared by the CRT headers + if (importName != "memmove" && importName != "malloc") // some methods are already declared by the CRT headers { builder.AppendLine(GetCppMethodDeclaration(method, false, importName)); } diff --git a/src/ILToNative.Compiler/src/CppCodeGen/ILToCppImporter.cs b/src/ILToNative.Compiler/src/CppCodeGen/ILToCppImporter.cs index ddd42b641..2789e6c23 100644 --- a/src/ILToNative.Compiler/src/CppCodeGen/ILToCppImporter.cs +++ b/src/ILToNative.Compiler/src/CppCodeGen/ILToCppImporter.cs @@ -1944,7 +1944,44 @@ namespace Internal.IL void ImportUnbox(int token, ILOpcode opCode) { - throw new NotImplementedException(); + var type = ResolveTypeToken(token); + + var obj = Pop(); + + if (opCode == ILOpcode.unbox) + { + PushTemp(StackValueKind.ByRef, type.MakeByRefType()); + } + else + { + PushTemp(GetStackValueKind(type), type); + } + + if (type.IsValueType) + { + // TODO: Unbox of nullable types + if (type.IsNullable) + throw new NotImplementedException(); + + if (opCode == ILOpcode.unbox_any) + { + string typeName = GetStackValueKindCPPTypeName(GetStackValueKind(type), type); + Append("*("); + Append(typeName); + Append("*)"); + } + + Append("((void **)"); + Append(obj.Value.Name); + Append("+1)"); + } + else + { + // TODO: Cast + Append(obj.Value.Name); + } + + Finish(); } void ImportRefAnyVal(int token) diff --git a/src/ILToNative/reproNative/main.cpp b/src/ILToNative/reproNative/main.cpp index 79c121f98..b0299c285 100644 --- a/src/ILToNative/reproNative/main.cpp +++ b/src/ILToNative/reproNative/main.cpp @@ -287,11 +287,31 @@ extern "C" uint8_t RhIsValueType(MethodTable*) throw 42; } -extern "C" intptr_t RhHandleAllocDependent(Object*, Object*) +extern "C" uint8_t RhIsArray(MethodTable*) { throw 42; } +extern "C" uint8_t RhTypeCast_AreTypesEquivalent(MethodTable*, MethodTable*) +{ + throw 42; +} + +extern "C" void RhGetCurrentThreadStackTrace() +{ + throw 42; +} + +extern "C" intptr_t RhHandleAlloc(Object * pObject, int type) +{ + return (intptr_t)CreateTypedHandle(g_HandleTableMap.pBuckets[0]->pTable[GetCurrentThreadHomeHeapNumber()], pObject, type); +} + +extern "C" intptr_t RhHandleAllocDependent(Object* pPrimary, Object* pSecondary) +{ + return (intptr_t)CreateDependentHandle(g_HandleTableMap.pBuckets[0]->pTable[GetCurrentThreadHomeHeapNumber()], pPrimary, pSecondary); +} + extern "C" void RhpUniversalTransition() { throw 42;