How to use the @glimmer/vm.Op.PrimitiveReference 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
break;
    case PrimitiveType.STRING:
      stack.push(vm.constants.getString(value));
      break;
    case PrimitiveType.BOOLEAN_OR_VOID:
      switch (value) {
        case 0: stack.push(false); break;
        case 1: stack.push(true); break;
        case 2: stack.push(null); break;
        case 3: stack.push(undefined); break;
      }
      break;
  }
});

APPEND_OPCODES.add(Op.PrimitiveReference, vm => {
  let stack = vm.stack;
  stack.push(PrimitiveReference.create(check(stack.pop(), CheckPrimitive)));
});

APPEND_OPCODES.add(Op.Dup, (vm, { op1: register, op2: offset }) => {
  let position = check(vm.fetchValue(register), CheckNumber) - offset;
  vm.stack.dup(position);
});

APPEND_OPCODES.add(Op.Pop, (vm, { op1: count }) => {
  vm.stack.pop(count);
});

APPEND_OPCODES.add(Op.Load, (vm, { op1: register }) => {
  vm.load(register);
});
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / compiled / opcodes / vm.ts View on Github external
case PrimitiveType.BOOLEAN_OR_VOID:
        stack.pushEncodedImmediate(primitive);
        break;
      case PrimitiveType.NEGATIVE:
        stack.push(vm[CONSTANTS].getNumber(value));
        break;
      case PrimitiveType.BIG_NUM:
        stack.push(vm[CONSTANTS].getNumber(value));
        break;
    }
  },
  OpcodeKind.Mut
);

APPEND_OPCODES.add(
  Op.PrimitiveReference,
  vm => {
    let stack = vm.stack;
    stack.push(PrimitiveReference.create(check(stack.pop(), CheckPrimitive)));
  },
  OpcodeKind.Mut
);

APPEND_OPCODES.add(
  Op.ReifyU32,
  vm => {
    let stack = vm.stack;
    stack.push(check(stack.peek(), CheckReference).value());
  },
  OpcodeKind.Mut
);