How to use the @glimmer/program.PrimitiveType.NUMBER function in @glimmer/program

To help you get started, we’ve selected a few @glimmer/program 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
(vm, { op1: primitive }) => {
    let stack = vm.stack;
    let flag = primitive & 7; // 111
    let value = primitive >> 3;

    switch (flag) {
      case PrimitiveType.NUMBER:
        stack.push(value);
        break;
      case PrimitiveType.FLOAT:
        stack.push(vm[CONSTANTS].getNumber(value));
        break;
      case PrimitiveType.STRING:
        stack.push(vm[CONSTANTS].getString(value));
        break;
      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));
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / compiled / opcodes / vm.ts View on Github external
APPEND_OPCODES.add(Op.Primitive, (vm, { op1: primitive }) => {
  let stack = vm.stack;
  let flag = primitive & 7; // 111
  let value = primitive >> 3;

  switch (flag) {
    case PrimitiveType.NUMBER:
      stack.push(value);
      break;
    case PrimitiveType.FLOAT:
      stack.push(vm.constants.getFloat(value));
      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;
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / vm / stack.ts View on Github external
function decodeSmi(smi: number): number {
  switch (smi & 0b111) {
    case PrimitiveType.NUMBER:
      return smi >> 3;
    case PrimitiveType.NEGATIVE:
      return -(smi >> 3);
    default:
      throw unreachable();
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / vm / stack.ts View on Github external
function encodeSmi(primitive: number) {
  if (primitive < 0) {
    return Math.abs(primitive) << 3 | PrimitiveType.NEGATIVE;
  } else {
    return primitive << 3 | PrimitiveType.NUMBER;
  }
}