How to use the @glimmer/interfaces.MachineOp.ReturnTo function in @glimmer/interfaces

To help you get started, we’ve selected a few @glimmer/interfaces examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / opcode-builder / helpers / conditional.ts View on Github external
body(): T;
}): T {
  // Push the arguments onto the stack. The args() function
  // tells us how many stack elements to retain for re-execution
  // when updating.
  let { count, actions } = args();

  // Start a new label frame, to give END and RETURN
  // a unique meaning.
  return [
    op('StartLabels'),
    op(MachineOp.PushFrame),

    // If the body invokes a block, its return will return to
    // END. Otherwise, the return in RETURN will return to END.
    op(MachineOp.ReturnTo, label('ENDINITIAL')),

    actions,

    // Start a new updating closure, remembering `count` elements
    // from the stack. Everything after this point, and before END,
    // will execute both initially and to update the block.
    //
    // The enter and exit opcodes also track the area of the DOM
    // associated with this block. If an assertion inside the block
    // fails (for example, the test value changes from true to false
    // in an #if), the DOM is cleared and the program is re-executed,
    // restoring `count` elements to the stack and executing the
    // instructions between the enter and exit.
    op(Op.Enter, count),

    // Evaluate the body of the block. The body of the block may
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax / builtins.ts View on Github external
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'),
        ];

        if (blocks.has('else')) {
          out.push(invokeStaticBlock(blocks.get('else')!));
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / vm / low-level.ts View on Github external
evaluateMachine(opcode: RuntimeOp) {
    switch (opcode.type) {
      case MachineOp.PushFrame:
        return this.pushFrame();
      case MachineOp.PopFrame:
        return this.popFrame();
      case MachineOp.InvokeStatic:
        return this.call(opcode.op1);
      case MachineOp.InvokeVirtual:
        return this.call(this.stack.pop());
      case MachineOp.Jump:
        return this.goto(opcode.op1);
      case MachineOp.Return:
        return this.return();
      case MachineOp.ReturnTo:
        return this.returnTo(opcode.op1);
    }
  }
github glimmerjs / glimmer-vm / packages / @glimmer / debug / lib / opcode-metadata.ts View on Github external
],
  operands: 1,
  check: true,
};

MACHINE_METADATA[MachineOp.Return] = {
  name: 'Return',
  mnemonic: 'ret',
  before: null,
  stackChange: 0,
  ops: [],
  operands: 0,
  check: false,
};

MACHINE_METADATA[MachineOp.ReturnTo] = {
  name: 'ReturnTo',
  mnemonic: 'setra',
  before: null,
  stackChange: 0,
  ops: [
    {
      name: 'offset',
      type: 'i32',
    },
  ],
  operands: 1,
  check: true,
};
METADATA[Op.Helper] = {
  name: 'Helper',
  mnemonic: 'ncall',