MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / SLJIT_CALL callDynamic

Function SLJIT_CALL callDynamic

src/hx/cppia/Cppia.cpp:873–926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871
872#ifdef CPPIA_JIT
873void SLJIT_CALL callDynamic(CppiaCtx *ctx, hx::Object *inFunction, int inArgs)
874{
875 if (!inFunction)
876 {
877 ctx->exception = Dynamic(HX_CSTRING("Null Function")).mPtr;
878 return;
879 }
880 // ctx.frame points to 0th arg
881 hx::Object **base = ((hx::Object **)(ctx->frame) );
882 unsigned char *oldPointer = ctx->pointer;
883 ctx->pointer = ctx->frame;
884
885 //hx::Object **base = ((hx::Object **)(ctx->pointer) ) - inArgs;
886 //ctx->pointer = (unsigned char *)base;
887
888 TRY_NATIVE
889#if (HXCPP_API_LEVEL>=500)
890 Array<Dynamic> argArray = Array_obj<Dynamic>::__new(inArgs, inArgs);
891 for (int s = 0; s < inArgs; s++)
892 argArray[s] = base[s];
893 base[0] = inFunction->__Run(argArray).mPtr;
894#else
895 switch(inArgs)
896 {
897 case 0:
898 base[0] = inFunction->__run().mPtr;
899 break;
900 case 1:
901 base[0] = inFunction->__run(base[0]).mPtr;
902 break;
903 case 2:
904 base[0] = inFunction->__run(base[0],base[1]).mPtr;
905 break;
906 case 3:
907 base[0] = inFunction->__run(base[0],base[1],base[2]).mPtr;
908 break;
909 case 4:
910 base[0] = inFunction->__run(base[0],base[1],base[2],base[3]).mPtr;
911 break;
912 case 5:
913 base[0] = inFunction->__run(base[0],base[1],base[2],base[3],base[4]).mPtr;
914 break;
915 default:
916 {
917 Array<Dynamic> argArray = Array_obj<Dynamic>::__new(inArgs,inArgs);
918 for(int s=0;s<inArgs;s++)
919 argArray[s] = base[s];
920 base[0] = inFunction->__Run(argArray).mPtr;
921 }
922 }
923#endif
924 CATCH_NATIVE
925 ctx->pointer = oldPointer;
926}
927#endif
928
929

Callers

nothing calls this directly

Calls 4

__newFunction · 0.85
DynamicClass · 0.50
__RunMethod · 0.45
__runMethod · 0.45

Tested by

no test coverage detected