Skip to content

Instantly share code, notes, and snippets.

@AlexMerzlikin
Created December 15, 2022 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexMerzlikin/937550f7fd658dd3f70126a044365fc7 to your computer and use it in GitHub Desktop.
Save AlexMerzlikin/937550f7fd658dd3f70126a044365fc7 to your computer and use it in GitHub Desktop.
What a simple "await Task.Delay()" is generated into using Unity IL2CPP scripting backend.
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Task_t751C4CC3ECD055BABA8A0B6A5DFBB4283DCA8572* TestTaskMonoBehaviour_TestMethodAsync_m2608F067B822413A2380FE0CCA1A9FCB251C4454 (TestTaskMonoBehaviour_t8D0CF54D6090450EE844BEA7DA0A080B5A17A74C* __this, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&AsyncTaskMethodBuilder_Start_TisU3CTestMethodAsyncU3Ed__1_tA8A97951AA0C3E88CC6D874339C83A65065C39D0_m6D2DD2EBF8C61EB68DE2F44E96C14C78AD8BD583_RuntimeMethod_var);
il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&AsyncTaskMethodBuilder_t7A5128C134547B5918EB1AA24FE47ED4C1DF3F06_il2cpp_TypeInfo_var);
s_Il2CppMethodInitialized = true;
}
U3CTestMethodAsyncU3Ed__1_tA8A97951AA0C3E88CC6D874339C83A65065C39D0 V_0;
memset((&V_0), 0, sizeof(V_0));
{
il2cpp_codegen_runtime_class_init_inline(AsyncTaskMethodBuilder_t7A5128C134547B5918EB1AA24FE47ED4C1DF3F06_il2cpp_TypeInfo_var);
AsyncTaskMethodBuilder_t7A5128C134547B5918EB1AA24FE47ED4C1DF3F06 L_0;
L_0 = AsyncTaskMethodBuilder_Create_m24F3F260A79CA2B9EC4F1F15693A33F5EC58735A(NULL);
(&V_0)->___U3CU3Et__builder_1 = L_0;
Il2CppCodeGenWriteBarrier((void**)&((&((&(((&(&V_0)->___U3CU3Et__builder_1))->___m_builder_1))->___m_coreState_1))->___m_stateMachine_0), (void*)NULL);
#if IL2CPP_ENABLE_STRICT_WRITE_BARRIERS
Il2CppCodeGenWriteBarrier((void**)&((&((&(((&(&V_0)->___U3CU3Et__builder_1))->___m_builder_1))->___m_coreState_1))->___m_defaultContextAction_1), (void*)NULL);
#endif
#if IL2CPP_ENABLE_STRICT_WRITE_BARRIERS
Il2CppCodeGenWriteBarrier((void**)&((&(((&(&V_0)->___U3CU3Et__builder_1))->___m_builder_1))->___m_task_2), (void*)NULL);
#endif
(&V_0)->___U3CU3E1__state_0 = (-1);
AsyncTaskMethodBuilder_t7A5128C134547B5918EB1AA24FE47ED4C1DF3F06* L_1 = (&(&V_0)->___U3CU3Et__builder_1);
AsyncTaskMethodBuilder_Start_TisU3CTestMethodAsyncU3Ed__1_tA8A97951AA0C3E88CC6D874339C83A65065C39D0_m6D2DD2EBF8C61EB68DE2F44E96C14C78AD8BD583(L_1, (&V_0), AsyncTaskMethodBuilder_Start_TisU3CTestMethodAsyncU3Ed__1_tA8A97951AA0C3E88CC6D874339C83A65065C39D0_m6D2DD2EBF8C61EB68DE2F44E96C14C78AD8BD583_RuntimeMethod_var);
AsyncTaskMethodBuilder_t7A5128C134547B5918EB1AA24FE47ED4C1DF3F06* L_2 = (&(&V_0)->___U3CU3Et__builder_1);
Task_t751C4CC3ECD055BABA8A0B6A5DFBB4283DCA8572* L_3;
L_3 = AsyncTaskMethodBuilder_get_Task_mE9125D5F8B96F26D1BA5A5347ED82669521C7F9E(L_2, NULL);
return L_3;
}
}
// System.Void TestTaskMonoBehaviour::.ctor()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void TestTaskMonoBehaviour__ctor_mAA80A3B20E12DADDC6760025C42E23710A511078 (TestTaskMonoBehaviour_t8D0CF54D6090450EE844BEA7DA0A080B5A17A74C* __this, const RuntimeMethod* method)
{
{
MonoBehaviour__ctor_m592DB0105CA0BC97AA1C5F4AD27B12D68A3B7C1E(__this, NULL);
return;
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void TestTaskMonoBehaviour/<TestMethodAsync>d__1::MoveNext()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void U3CTestMethodAsyncU3Ed__1_MoveNext_m897E23B1A002E60433AE8561F10866A1C00F5F59 (U3CTestMethodAsyncU3Ed__1_tA8A97951AA0C3E88CC6D874339C83A65065C39D0* __this, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&AsyncTaskMethodBuilder_AwaitUnsafeOnCompleted_TisTaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833_TisU3CTestMethodAsyncU3Ed__1_tA8A97951AA0C3E88CC6D874339C83A65065C39D0_m841FCD2F4B2330A56573A2222B3EF6D02FB9B1DA_RuntimeMethod_var);
il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Task_t751C4CC3ECD055BABA8A0B6A5DFBB4283DCA8572_il2cpp_TypeInfo_var);
s_Il2CppMethodInitialized = true;
}
int32_t V_0 = 0;
TaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833 V_1;
memset((&V_1), 0, sizeof(V_1));
Exception_t* V_2 = NULL;
il2cpp::utils::ExceptionSupportStack<RuntimeObject*, 1> __active_exceptions;
{
int32_t L_0 = __this->___U3CU3E1__state_0;
V_0 = L_0;
}
try
{// begin try (depth: 1)
{
int32_t L_1 = V_0;
if (!L_1)
{
goto IL_0040_1;
}
}
{
// await Task.Delay(100);
il2cpp_codegen_runtime_class_init_inline(Task_t751C4CC3ECD055BABA8A0B6A5DFBB4283DCA8572_il2cpp_TypeInfo_var);
Task_t751C4CC3ECD055BABA8A0B6A5DFBB4283DCA8572* L_2;
L_2 = Task_Delay_m4B84654B4DAADEC41096D9F01C099CCEA9927A48(((int32_t)100), NULL);
NullCheck(L_2);
TaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833 L_3;
L_3 = Task_GetAwaiter_m08B368EAC939DD35D0AC428180822255A442CA29(L_2, NULL);
V_1 = L_3;
bool L_4;
L_4 = TaskAwaiter_get_IsCompleted_mC236D276FBE3A271B56EE13FCAF2C96E48453ED8((&V_1), NULL);
if (L_4)
{
goto IL_005c_1;
}
}
{
int32_t L_5 = 0;
V_0 = L_5;
__this->___U3CU3E1__state_0 = L_5;
TaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833 L_6 = V_1;
__this->___U3CU3Eu__1_2 = L_6;
Il2CppCodeGenWriteBarrier((void**)&(((&__this->___U3CU3Eu__1_2))->___m_task_0), (void*)NULL);
AsyncTaskMethodBuilder_t7A5128C134547B5918EB1AA24FE47ED4C1DF3F06* L_7 = (&__this->___U3CU3Et__builder_1);
AsyncTaskMethodBuilder_AwaitUnsafeOnCompleted_TisTaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833_TisU3CTestMethodAsyncU3Ed__1_tA8A97951AA0C3E88CC6D874339C83A65065C39D0_m841FCD2F4B2330A56573A2222B3EF6D02FB9B1DA(L_7, (&V_1), __this, AsyncTaskMethodBuilder_AwaitUnsafeOnCompleted_TisTaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833_TisU3CTestMethodAsyncU3Ed__1_tA8A97951AA0C3E88CC6D874339C83A65065C39D0_m841FCD2F4B2330A56573A2222B3EF6D02FB9B1DA_RuntimeMethod_var);
goto IL_008f;
}
IL_0040_1:
{
TaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833 L_8 = __this->___U3CU3Eu__1_2;
V_1 = L_8;
TaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833* L_9 = (&__this->___U3CU3Eu__1_2);
il2cpp_codegen_initobj(L_9, sizeof(TaskAwaiter_t9B661AC8C2EFA6BAB94C77BB24A5DDA82D61F833));
int32_t L_10 = (-1);
V_0 = L_10;
__this->___U3CU3E1__state_0 = L_10;
}
IL_005c_1:
{
TaskAwaiter_GetResult_mC1D712500AE49B4A89C85D6B79D87D1BA9A6B94D((&V_1), NULL);
goto IL_007c;
}
}// end try (depth: 1)
catch(Il2CppExceptionWrapper& e)
{
if(il2cpp_codegen_class_is_assignable_from (((RuntimeClass*)il2cpp_codegen_initialize_runtime_metadata_inline((uintptr_t*)&Exception_t_il2cpp_TypeInfo_var)), il2cpp_codegen_object_class(e.ex)))
{
IL2CPP_PUSH_ACTIVE_EXCEPTION(e.ex);
goto CATCH_0065;
}
throw e;
}
CATCH_0065:
{// begin catch(System.Exception)
V_2 = ((Exception_t*)IL2CPP_GET_ACTIVE_EXCEPTION(Exception_t*));
__this->___U3CU3E1__state_0 = ((int32_t)-2);
AsyncTaskMethodBuilder_t7A5128C134547B5918EB1AA24FE47ED4C1DF3F06* L_11 = (&__this->___U3CU3Et__builder_1);
Exception_t* L_12 = V_2;
AsyncTaskMethodBuilder_SetException_mBE41863F0571E0177A15731294087DE45E1FC10B(L_11, L_12, NULL);
IL2CPP_POP_ACTIVE_EXCEPTION();
goto IL_008f;
}// end catch (depth: 1)
IL_007c:
{
// }
__this->___U3CU3E1__state_0 = ((int32_t)-2);
AsyncTaskMethodBuilder_t7A5128C134547B5918EB1AA24FE47ED4C1DF3F06* L_13 = (&__this->___U3CU3Et__builder_1);
AsyncTaskMethodBuilder_SetResult_m76D8B84F0068257C1823B1200B00E58E0C8DDDDE(L_13, NULL);
}
IL_008f:
{
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment