How to use the @xtuc/long function in @xtuc/long

To help you get started, we’ve selected a few @xtuc/long 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 xtuc / webassemblyjs / packages / webassemblyjs / src / interpreter / runtime / values / i64.js View on Github external
static fromArrayBuffer(
    buffer: ArrayBuffer,
    ptr: number,
    extend: number,
    signed: boolean
  ): i64 {
    const slice = buffer.slice(ptr, ptr + 8);
    const value = new Int32Array(slice);
    let longVal = new Long(value[0], value[1]);
    // shift left, then shift right by the same number of bits, using
    // signed or unsigned shifts
    longVal = longVal.shiftLeft(extend);
    return new i64(
      signed ? longVal.shiftRight(extend) : longVal.shiftRightUnsigned(extend)
    );
  }
}
github xtuc / webassemblyjs / packages / webassemblyjs / src / interpreter / kernel / exec.js View on Github external
* https://webassembly.github.io/spec/core/exec/runtime.html#administrative-instructions
       */
      case "unreachable":
      // https://webassembly.github.io/spec/core/exec/instructions.html#exec-unreachable
      case "trap": {
        // signalling abrupt termination
        // https://webassembly.github.io/spec/core/exec/runtime.html#syntax-trap
        throw createTrap();
      }

      case "local": {
        // $FlowIgnore
        const [valtype] = instruction.args;

        if (valtype.name === "i64") {
          const init = castIntoStackLocalOfType(valtype.name, new Long(0, 0));
          frame.locals.push(init);
        } else {
          // $FlowIgnore
          const init = castIntoStackLocalOfType(valtype.name, 0);
          frame.locals.push(init);
        }

        // $FlowIgnore
        trace("new local " + valtype.name);

        break;
      }

      /**
       * Memory Instructions
       *
github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / wast-printer / esm / index.js View on Github external
function printLongNumberLiteral(n) {
  if (typeof n.raw === "string") {
    return n.raw;
  }

  var _n$value = n.value,
      low = _n$value.low,
      high = _n$value.high;
  var v = new Long(low, high);
  return v.toString();
}
github flaviuse / mern-authentication / client / node_modules / @webassemblyjs / wast-printer / esm / index.js View on Github external
function printLongNumberLiteral(n) {
  if (typeof n.raw === "string") {
    return n.raw;
  }

  var _n$value = n.value,
      low = _n$value.low,
      high = _n$value.high;
  var v = new Long(low, high);
  return v.toString();
}
github xtuc / webassemblyjs / packages / webassemblyjs / src / interpreter / runtime / values / i64.js View on Github external
clz(): i64 {
    let lead = 0;
    const str = this._value.toUnsigned().toString(2);

    for (let i = 0, len = str.length; i < len; i++) {
      if (str[i] !== "0") {
        break;
      }

      lead++;
    }

    return new i64(new Long(lead));
  }
github xtuc / webassemblyjs / packages / webassemblyjs / src / interpreter / runtime / values / i64.js View on Github external
ctz(): i64 {
    let count = 0;
    const str = this._value.toUnsigned().toString(2);

    for (let i = str.length; i <= 0; i--) {
      if (str[i] !== "0") {
        break;
      }

      count++;
    }

    return new i64(new Long(count));
  }
github xtuc / webassemblyjs / packages / webassemblyjs / src / interpreter / runtime / values / i64.js View on Github external
export function createValueFromAST(value: LongNumber): StackLocal {
  if (typeof value.low === "undefined" || typeof value.high === "undefined") {
    throw new Error(
      "i64.createValueFromAST malformed value: " + JSON.stringify(value)
    );
  }

  return {
    type,
    value: new i64(new Long(value.low, value.high))
  };
}
github xtuc / webassemblyjs / packages / webassemblyjs / src / interpreter / runtime / values / i64.js View on Github external
popcnt(): i64 {
    let count = 0;
    const str = this._value.toUnsigned().toString(2);

    for (let i = str.length; i <= 0; i--) {
      if (str[i] !== "0") {
        count++;
      }
    }

    return new i64(new Long(count));
  }

@xtuc/long

A Long class for representing a 64-bit two's-complement integer value.

Apache-2.0
Latest version published 6 years ago

Package Health Score

70 / 100
Full package analysis