MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxDelegateNodeCode

Function fxDelegateNodeCode

xs/sources/xsCode.c:2896–3035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2894}
2895
2896void fxDelegateNodeCode(void* it, void* param)
2897{
2898 txStatementNode* self = it;
2899 txBoolean async = (self->flags & mxAsyncFlag) ? 1 : 0;
2900 txCoder* coder = param;
2901 txInteger iterator;
2902 txInteger method;
2903 txInteger next;
2904 txInteger result;
2905
2906 txTargetCode* nextTarget = fxCoderCreateTarget(param);
2907 txTargetCode* catchTarget = fxCoderCreateTarget(param);
2908 txTargetCode* rethrowTarget = fxCoderCreateTarget(param);
2909 txTargetCode* returnTarget = fxCoderCreateTarget(param);
2910 txTargetCode* normalTarget = fxCoderCreateTarget(param);
2911 txTargetCode* doneTarget = fxCoderCreateTarget(param);
2912
2913 iterator = fxCoderUseTemporaryVariable(param);
2914 method = fxCoderUseTemporaryVariable(param);
2915 next = fxCoderUseTemporaryVariable(param);
2916 result = fxCoderUseTemporaryVariable(param);
2917
2918 fxNodeDispatchCode(self->expression, param);
2919 if (async)
2920 fxCoderAddByte(param, 0, XS_CODE_FOR_AWAIT_OF);
2921 else
2922 fxCoderAddByte(param, 0, XS_CODE_FOR_OF);
2923 fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, iterator);
2924 fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->nextSymbol);
2925 fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, next);
2926 fxCoderAddByte(param, -1, XS_CODE_POP);
2927
2928 fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
2929 fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2930 fxCoderAddByte(param, -1, XS_CODE_POP);
2931 fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
2932 fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, normalTarget);
2933
2934// LOOP
2935 fxCoderAdd(param, 0, nextTarget);
2936 if (async)
2937 fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
2938 fxCoderAddByte(coder, 0, XS_CODE_YIELD_STAR);
2939 fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2940 fxCoderAddByte(param, -1, XS_CODE_POP);
2941 fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
2942 fxCoderAddBranch(coder, 1, XS_CODE_BRANCH_STATUS_1, normalTarget);
2943
2944// RETURN
2945 fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
2946 if (async) {
2947 fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
2948 fxCoderAddByte(param, 0, XS_CODE_AWAIT);
2949 fxCoderAddByte(param, 0, XS_CODE_THROW_STATUS);
2950 fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2951 fxCoderAddByte(param, -1, XS_CODE_POP);
2952 }
2953

Callers

nothing calls this directly

Calls 12

fxCoderCreateTargetFunction · 0.85
fxNodeDispatchCodeFunction · 0.85
fxCoderAddByteFunction · 0.85
fxCoderAddIndexFunction · 0.85
fxCoderAddSymbolFunction · 0.85
fxCoderAddBranchFunction · 0.85
fxCoderAddFunction · 0.85
fxCoderAddIntegerFunction · 0.85
fxCoderAdjustEnvironmentFunction · 0.85
fxCoderAdjustScopeFunction · 0.85

Tested by

no test coverage detected