kekyo / IL2C

IL2C - A translator for ECMA-335 CIL/MSIL to C language.
Apache License 2.0
401 stars 36 forks source link

Feature/testcase enhancement #119

Closed kekyo closed 2 years ago

kekyo commented 2 years ago

Related #100

kekyo commented 2 years ago

Causes some testcases are failed.

 System.Exception : gcc [Path="D:\Projects\IL2C\test-artifacts\Debug\net48\RuntimeSystems\ExceptionThrownByCLI\NullReferenceTwoTimes_0", ExitCode=1]: In file included from D:\Projects\IL2C\test-artifacts\Debug\net48\RuntimeSystems\ExceptionThrownByCLI\NullReferenceTwoTimes_0\IL2C.Core.Test.RuntimeSystems_bundle.c:7:0,
                     from D:\Projects\IL2C\test-artifacts\Debug\net48\RuntimeSystems\ExceptionThrownByCLI\NullReferenceTwoTimes_0\test.c:22:
    D:\Projects\IL2C\test-artifacts\Debug\net48\RuntimeSystems\ExceptionThrownByCLI\NullReferenceTwoTimes_0\IL2C.Core.Test.RuntimeSystems/IL2C/RuntimeSystems/NullReferenceExceptions.c:52:20: error: duplicate member 'r'
         System_String* r;
                        ^
    D:\Projects\IL2C\test-artifacts\Debug\net48\RuntimeSystems\ExceptionThrownByCLI\NullReferenceTwoTimes_0\IL2C.Core.Test.RuntimeSystems/IL2C/RuntimeSystems/NullReferenceExceptions.c:53:36: error: duplicate member 'ex'
         System_NullReferenceException* ex;
                                        ^

  Stack Trace: 
    <BuildAsync>d__0.MoveNext() line 171
    TaskAwaiter.ThrowForNonSuccess(Task task)
    TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    TaskAwaiter`1.GetResult()
    <ExecuteTestAsync>d__8.MoveNext() line 452
    TaskAwaiter.ThrowForNonSuccess(Task task)
    TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    TaskAwaiter`1.GetResult()
    TestMethodCommand.RunTestMethod(TestExecutionContext context)
    TestMethodCommand.Execute(TestExecutionContext context)
    <>c__DisplayClass4_0.<PerformWork>b__0()
    <>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)
    ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    ContextUtils.DoIsolated(ContextCallback callback, Object state)
    ContextUtils.DoIsolated[T](Func`1 func)
    SimpleWorkItem.PerformWork()

  Standard Output: 
    IL.Verification: IL2C.RuntimeSystems.NullReferenceExceptions.NullReferenceTwoTimes: [StackUnexpected/None]: Unexpected type on the stack.: Offset=3,Found=ref 'object': [0x0003]: Callvirt
    IL.Verification: IL2C.RuntimeSystems.NullReferenceExceptions.NullReferenceTwoTimes: [StackUnexpected/None]: Unexpected type on the stack.: Offset=45,Found=ref 'object': [0x002d]: Callvirt

Following test case:

        public static bool NullReferenceTwoTimes(object v)
        {
            try
            {
                var r = v.ToString();
            }
            catch (NullReferenceException ex)
            {
                if (ex.Message != "Object reference not set to an instance of an object.")
                {
                    return false;
                }
            }

            try
            {
                var r = v.ToString();
            }
            catch (NullReferenceException ex)
            {
                return ex.Message == "Object reference not set to an instance of an object.";
            }

            return false;
        }

Duplicated local variable name r and ex, IL2C has to check and avoid symbol naming duplication from CIL local variable name.

Better way for appending increased suffix number:

kekyo commented 2 years ago

Hmm, CI was failed in referring ILAsm package.

kekyo commented 2 years ago

Unit tests building processes are made stable, next step is fixing unit test bodies on failing.

kekyo commented 2 years ago

I had planned to move on to the next step once everything was green, but the problem with #124 is significant, so I will proceed with it for now.

kekyo commented 2 years ago

There is still the implementation of the process of executing native binary in the test case, but it will be merged and moved to another PR.