How to use the @glimmer/vm.Op.InvokeYield function in @glimmer/vm

To help you get started, we’ve selected a few @glimmer/vm 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 / runtime / lib / compiled / opcodes / vm.ts View on Github external
let stack = vm.stack;
    let block = stack.pop | 0>();

    if (block) {
      stack.pushSmi(block.compile() as Recast);
    } else {
      stack.pushNull();
    }

    check(vm.stack.peek(), CheckOption(CheckNumber));
  },
  OpcodeKind.Mut
);

APPEND_OPCODES.add(
  Op.InvokeYield,
  vm => {
    let { stack } = vm;

    let handle = check(stack.pop(), CheckOption(CheckHandle));
    let scope = check(stack.pop(), CheckOption(CheckScope));
    let table = check(stack.pop(), CheckOption(CheckBlockSymbolTable));

    assert(
      table === null || (table && typeof table === 'object' && Array.isArray(table.parameters)),
      stackAssert('Option', table)
    );

    let args = check(stack.pop(), CheckInstanceof(ReadonlyArguments));

    if (table === null) {
      // To balance the pop{Frame,Scope}
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / compiled / opcodes / vm.ts View on Github external
let stack = vm.stack;
  let block = stack.pop | 0>();
  stack.push(block ? block.compile() : null);

  check(vm.stack.peek(), CheckOption(CheckNumber));
});

APPEND_OPCODES.add(Op.InvokeVirtual, vm => {
  vm.call(check(vm.stack.pop(), CheckHandle));
});

APPEND_OPCODES.add(Op.InvokeStatic, (vm, { op1: handle }) => {
  vm.call(handle as Recast);
});

APPEND_OPCODES.add(Op.InvokeYield, vm => {
  let { stack } = vm;

  let handle = check(stack.pop(), CheckOption(CheckHandle));
  let table = check(stack.pop(), CheckOption(CheckBlockSymbolTable));

  assert(table === null || (table && typeof table === 'object' && Array.isArray(table.parameters)), stackAssert('Option', table));

  let args = check(stack.pop(), CheckInstanceof(Arguments));

  if (table === null) {

    // To balance the pop{Frame,Scope}
    vm.pushFrame();
    let blockScope = vm.scope().getCallerScope()!;
    vm.pushScope(blockScope);