How to use the @glimmer/interfaces.Op.AssertSame 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
// Setup the switch DSL
  let clauses: Array<{ match: number; label: string; callback: () => CompileActions }> = [];

  let count = 0;

  function when(match: number, callback: () => CompileActions): void {
    clauses.push({ match, callback, label: `CLAUSE${count++}` });
  }

  // Call the callback
  callback(when);

  // Emit the opcodes for the switch
  let out: CompileActions = [
    op(Op.Enter, 2),
    op(Op.AssertSame),
    op(Op.ReifyU32),
    op('StartLabels'),
  ];

  // First, emit the jump opcodes. We don't need a jump for the last
  // opcode, since it bleeds directly into its clause.
  for (let clause of clauses.slice(0, -1)) {
    out.push(op(Op.JumpEq, label(clause.label), clause.match));
  }

  // Enumerate the clauses in reverse order. Earlier matches will
  // require fewer checks.
  for (let i = clauses.length - 1; i >= 0; i--) {
    let clause = clauses[i];

    out.push(op('Label', clause.label), op(Op.Pop, 2), clause.callback());
github glimmerjs / glimmer-vm / packages / @glimmer / debug / lib / opcode-metadata.ts View on Github external
stackChange: 0,
  ops: [
    {
      name: 'to',
      type: 'i32',
    },
    {
      name: 'comparison',
      type: 'i32',
    },
  ],
  operands: 2,
  check: true,
};

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

METADATA[Op.Enter] = {
  name: 'Enter',
  mnemonic: 'blk_start',
  before: null,
  stackChange: 0,
  ops: [
    {
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / opcode-builder / helpers / stdlib.ts View on Github external
when(ContentType.String, () => {
        if (trusting) {
          return [op(Op.AssertSame), op(Op.AppendHTML)];
        } else {
          return op(Op.AppendText);
        }
      });