Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
body: () => {
let out = [
// If the conditional is false, jump to the ELSE label.
op(Op.JumpUnless, label('ELSE')),
// Otherwise, execute the code associated with the true branch.
ifTrue(),
// We're done, so return. In the initial execution, this runs
// the cleanup code. In the updating VM, it exits the updating
// routine.
op(MachineOp.Jump, label('FINALLY')),
op('Label', 'ELSE'),
];
// If the conditional is false, and code associatied ith the
// false branch was provided, execute it. If there was no code
// associated with the false branch, jumping to the else statement
// has no other behavior.
if (ifFalse) {
out.push(ifFalse());
}
export function WrappedComponent(
layout: LayoutWithContext,
attrsBlockNumber: number
): StatementCompileActions {
return [
op('StartLabels'),
WithSavedRegister($s1, () => [
op(Op.GetComponentTagName, $s0),
op(Op.PrimitiveReference),
op(Op.Dup, $sp, 0),
]),
op(Op.JumpUnless, label('BODY')),
op(Op.Fetch, $s1),
op(Op.PutComponentOperations),
op(Op.OpenDynamicElement),
op(Op.DidCreateElement, $s0),
YieldBlock(attrsBlockNumber, EMPTY_ARRAY),
op(Op.FlushElement),
op('Label', 'BODY'),
InvokeStaticBlock(blockForLayout(layout)),
op(Op.Fetch, $s1),
op(Op.JumpUnless, label('END')),
op(Op.CloseElement),
op('Label', 'END'),
op(Op.Load, $s1),
op('StopLabels'),
];
}
METADATA[Op.JumpIf] = {
name: 'JumpIf',
mnemonic: 'iftrue',
before: null,
stackChange: -1,
ops: [
{
name: 'to',
type: 'u32',
},
],
operands: 1,
check: true,
};
METADATA[Op.JumpUnless] = {
name: 'JumpUnless',
mnemonic: 'iffalse',
before: null,
stackChange: -1,
ops: [
{
name: 'to',
type: 'u32',
},
],
operands: 1,
check: true,
};
METADATA[Op.JumpEq] = {
name: 'JumpEq',
body() {
let out: StatementCompileActions = [
op(Op.PutIterator),
op(Op.JumpUnless, label('ELSE')),
op(MachineOp.PushFrame),
op(Op.Dup, $fp, 1),
op(MachineOp.ReturnTo, label('ITER')),
op(Op.EnterList, label('BODY')),
op('Label', 'ITER'),
op(Op.Iterate, label('BREAK')),
op('Label', 'BODY'),
invokeStaticBlockWithStack(unwrap(blocks.get('default')), 2),
op(Op.Pop, 2),
op(MachineOp.Jump, label('FINALLY')),
op('Label', 'BREAK'),
op(Op.ExitList),
op(MachineOp.PopFrame),
op(MachineOp.Jump, label('FINALLY')),
op('Label', 'ELSE'),
];
WithSavedRegister($s1, () => [
op(Op.GetComponentTagName, $s0),
op(Op.PrimitiveReference),
op(Op.Dup, $sp, 0),
]),
op(Op.JumpUnless, label('BODY')),
op(Op.Fetch, $s1),
op(Op.PutComponentOperations),
op(Op.OpenDynamicElement),
op(Op.DidCreateElement, $s0),
YieldBlock(attrsBlockNumber, EMPTY_ARRAY),
op(Op.FlushElement),
op('Label', 'BODY'),
InvokeStaticBlock(blockForLayout(layout)),
op(Op.Fetch, $s1),
op(Op.JumpUnless, label('END')),
op(Op.CloseElement),
op('Label', 'END'),
op(Op.Load, $s1),
op('StopLabels'),
];
}