How to use the @glimmer/interfaces.Op.Dup 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 / syntax / statements.ts View on Github external
args() {
      return {
        count: 2,
        actions: [op('Expr', name), op(Op.Dup, $sp, 0)],
      };
    },
github glimmerjs / glimmer-vm / packages / @glimmer / debug / lib / opcode-metadata.ts View on Github external
ops: [],
  operands: 0,
  check: true,
};

METADATA[Op.ReifyU32] = {
  name: 'ReifyU32',
  mnemonic: 'reifyload',
  before: null,
  stackChange: 1,
  ops: [],
  operands: 0,
  check: true,
};

METADATA[Op.Dup] = {
  name: 'Dup',
  mnemonic: 'dup',
  before: null,
  stackChange: 1,
  ops: [
    {
      name: 'register',
      type: 'u32',
    },
    {
      name: 'offset',
      type: 'u32',
    },
  ],
  operands: 2,
  check: true,
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax / builtins.ts View on Github external
args() {
        let [keys, values] = hash!;

        let actions: StatementCompileActions = [];

        for (let i = 0; i < keys.length; i++) {
          let key = keys[i];
          if (key === 'guid' || key === 'insertBefore') {
            actions.push(op('Expr', values[i]));
          } else {
            throw new Error(`SYNTAX ERROR: #in-element does not take a \`${keys[0]}\` option`);
          }
        }

        actions.push(op('Expr', params[0]), op(Op.Dup, $sp, 0));

        return { count: 4, actions };
      },
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / opcode-builder / helpers / components.ts View on Github external
if (bailOut) {
    return InvokeComponent({
      capabilities,
      attrs,
      params,
      hash,
      atNames: true,
      blocks,
      layout,
    });
  }

  let out: NestedStatementCompileActions = [
    op(Op.Fetch, $s0),
    op(Op.Dup, $sp, 1),
    op(Op.Load, $s0),
  ];

  let { symbols } = symbolTable;

  if (capabilities.createArgs) {
    out.push(op(MachineOp.PushFrame), op('SimpleArgs', { params, hash, atNames: true }));
  }

  out.push(op(Op.BeginComponentTransaction));

  if (capabilities.dynamicScope) {
    out.push(op(Op.PushDynamicScope));
  }

  if (capabilities.createInstance) {
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / opcode-builder / helpers / components.ts View on Github external
attrs,
  params,
  hash,
  atNames,
  blocks: namedBlocks,
  layout,
}: Component): StatementCompileActions {
  let bindableBlocks = !!namedBlocks;
  let bindableAtNames =
    capabilities === true || capabilities.prepareArgs || !!(hash && hash[0].length !== 0);

  let blocks = namedBlocks.with('attrs', attrs);

  return [
    op(Op.Fetch, $s0),
    op(Op.Dup, $sp, 1),
    op(Op.Load, $s0),

    op(MachineOp.PushFrame),
    op('Args', { params, hash, blocks, atNames }),
    op(Op.PrepareArgs, $s0),
    invokePreparedComponent(blocks.has('default'), bindableBlocks, bindableAtNames, () => {
      let out: NestedStatementCompileActions;

      if (layout) {
        out = [
          PushSymbolTable(layout.symbolTable),
          op('PushCompilable', layout),
          op('JitCompileBlock'),
        ];
      } else {
        out = [op('GetComponentLayout', $s0)];
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / opcode-builder / helpers / blocks.ts View on Github external
let calleeCount = parameters.length;
  let count = Math.min(callerCount, calleeCount);

  if (count === 0) {
    return InvokeStaticBlock(block);
  }

  let out: StatementCompileActions = [];

  out.push(op(MachineOp.PushFrame));

  if (count) {
    out.push(op(Op.ChildScope));

    for (let i = 0; i < count; i++) {
      out.push(op(Op.Dup, $fp, callerCount - i));
      out.push(op(Op.SetVariable, parameters[i]));
    }
  }

  out.push(op('PushCompilable', block));
  out.push(op('JitCompileBlock'));
  out.push(op(MachineOp.InvokeVirtual));

  if (count) {
    out.push(op(Op.PopScope));
  }

  out.push(op(MachineOp.PopFrame));

  return out;
}
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax / builtins.ts View on Github external
args() {
        return {
          count: 2,
          actions: [op('Expr', params[0]), op(Op.Dup, $sp, 0), op(Op.ToBoolean)],
        };
      },