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

Function fxTryNodeCode

xs/sources/xsCode.c:4567–4652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4565}
4566
4567void fxTryNodeCode(void* it, void* param)
4568{
4569 txTryNode* self = it;
4570 txCoder* coder = param;
4571 txInteger exception;
4572 txInteger selector;
4573 txInteger result;
4574 txInteger selection;
4575 txTargetCode* catchTarget;
4576 txTargetCode* normalTarget;
4577 txTargetCode* finallyTarget;
4578
4579 exception = fxCoderUseTemporaryVariable(coder);
4580 selector = fxCoderUseTemporaryVariable(coder);
4581 result = fxCoderUseTemporaryVariable(coder);
4582
4583 coder->firstBreakTarget = fxCoderAliasTargets(param, coder->firstBreakTarget);
4584 coder->firstContinueTarget = fxCoderAliasTargets(param, coder->firstContinueTarget);
4585 coder->returnTarget = fxCoderAliasTargets(param, coder->returnTarget);
4586 catchTarget = fxCoderCreateTarget(param);
4587 normalTarget = fxCoderCreateTarget(param);
4588 finallyTarget = fxCoderCreateTarget(param);
4589
4590 fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, 0);
4591 fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, selector);
4592 fxCoderAddByte(param, -1, XS_CODE_POP);
4593
4594 fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
4595 if (coder->programFlag) {
4596 fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4597 fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4598 }
4599 fxNodeDispatchCode(self->tryBlock, param);
4600 fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, normalTarget);
4601 if (self->catchBlock) {
4602 fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
4603 fxCoderAdd(param, 0, catchTarget);
4604 catchTarget = fxCoderCreateTarget(param);
4605 fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
4606 if (coder->programFlag) {
4607 fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4608 fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4609 }
4610 fxNodeDispatchCode(self->catchBlock, param);
4611 fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, normalTarget);
4612 }
4613
4614 selection = 1;
4615 coder->firstBreakTarget = fxCoderFinalizeTargets(param, coder->firstBreakTarget, selector, &selection, finallyTarget);
4616 coder->firstContinueTarget = fxCoderFinalizeTargets(param, coder->firstContinueTarget, selector, &selection, finallyTarget);
4617 coder->returnTarget = fxCoderFinalizeTargets(param, coder->returnTarget, selector, &selection, finallyTarget);
4618 fxCoderAdd(param, 0, normalTarget);
4619 fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, selection);
4620 fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, selector);
4621 fxCoderAddByte(param, -1, XS_CODE_POP);
4622 fxCoderAdd(param, 0, finallyTarget);
4623 fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
4624 fxCoderAdd(param, 0, catchTarget);

Callers

nothing calls this directly

Calls 12

fxCoderAliasTargetsFunction · 0.85
fxCoderCreateTargetFunction · 0.85
fxCoderAddIntegerFunction · 0.85
fxCoderAddIndexFunction · 0.85
fxCoderAddByteFunction · 0.85
fxCoderAddBranchFunction · 0.85
fxNodeDispatchCodeFunction · 0.85
fxCoderAddFunction · 0.85
fxCoderFinalizeTargetsFunction · 0.85
fxCoderJumpTargetsFunction · 0.85

Tested by

no test coverage detected