org.mozilla.javascript.UintMap类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 JavaScript  
字(7.5k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中org.mozilla.javascript.UintMap类的一些代码示例,展示了UintMap类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UintMap类的具体详情如下:
包路径:org.mozilla.javascript.UintMap
类名称:UintMap

UintMap介绍

[英]Map to associate non-negative integers to objects or integers. The map does not synchronize any of its operation, so either use it from a single thread or do own synchronization or perform all mutation operations on one thread before passing the map to others.
[中]映射以将非负整数与对象或整数关联。map不会同步其任何操作,因此可以从单个线程使用它,或者在将map传递给其他线程之前在一个线程上执行自己的同步或所有变异操作。

代码示例

代码示例来源:origin: geogebra/geogebra

int addConstant(String k)
{
  int utf8Index = 0xFFFF & addUtf8(k);
  int theIndex = itsStringConstHash.getInt(utf8Index, -1);
  if (theIndex == -1) {
    theIndex = itsTopIndex++;
    ensure(3);
    itsPool[itsTop++] = CONSTANT_String;
    itsTop = ClassFileWriter.putInt16(utf8Index, itsPool, itsTop);
    itsStringConstHash.put(utf8Index, theIndex);
  }
  itsPoolTypes.put(theIndex, CONSTANT_String);
  return theIndex;
}

代码示例来源:origin: rhino/js

private void resolveGoto(int fromPC, int jumpPC)
{
  int offset = jumpPC - fromPC;
  // Ensure that jumps do not overlap
  if (0 <= offset && offset <= 2) throw Kit.codeBug();
  int offsetSite = fromPC + 1;
  if (offset != (short)offset) {
    if (itsData.longJumps == null) {
      itsData.longJumps = new UintMap();
    }
    itsData.longJumps.put(offsetSite, jumpPC);
    offset = 0;
  }
  byte[] array = itsData.itsICode;
  array[offsetSite] = (byte)(offset >> 8);
  array[offsetSite + 1] = (byte)offset;
}

代码示例来源:origin: rhino/js

/**
 * Set object value of the key.
 * If key does not exist, also set its int value to 0.
 */
public void put(int key, Object value) {
  if (key < 0) Kit.codeBug();
  int index = ensureIndex(key, false);
  if (values == null) {
    values = new Object[1 << power];
  }
  values[index] = value;
}

代码示例来源:origin: rhino/js

int step = tableLookupStep(fraction, mask, power);
int n = 0;
do {
rehashTable(intType);
keys = this.keys;
return insertNewKey(key);

代码示例来源:origin: rhino/js

static int[] getLineNumbers(InterpreterData data)
{
  UintMap presentLines = new UintMap();
  byte[] iCode = data.itsICode;
  int iCodeLength = iCode.length;
  for (int pc = 0; pc != iCodeLength;) {
    int bytecode = iCode[pc];
    int span = bytecodeSpan(bytecode);
    if (bytecode == Icode_LINE) {
      if (span != 3) Kit.codeBug();
      int line = getIndex(iCode, pc + 1);
      presentLines.put(line, 0);
    }
    pc += span;
  }
  return presentLines.getKeys();
}

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
 * Calculate partial dependencies for super blocks.
 *
 * This is used as a workaround for dead code that is generated. Only
 * one dependency per super block is given.
 */
private SuperBlock[] getSuperBlockDependencies() {
  SuperBlock[] deps = new SuperBlock[superBlocks.length];
  for (int i = 0; i < itsExceptionTableTop; i++) {
    ExceptionTableEntry ete = itsExceptionTable[i];
    short startPC = (short) getLabelPC(ete.itsStartLabel);
    short handlerPC = (short) getLabelPC(ete.itsHandlerLabel);
    SuperBlock handlerSB = getSuperBlockFromOffset(handlerPC);
    SuperBlock dep = getSuperBlockFromOffset(startPC);
    deps[handlerSB.getIndex()] = dep;
  }
  int[] targetPCs = itsJumpFroms.getKeys();
  for (int i = 0; i < targetPCs.length; i++) {
    int targetPC = targetPCs[i];
    int branchPC = itsJumpFroms.getInt(targetPC, -1);
    SuperBlock branchSB = getSuperBlockFromOffset(branchPC);
    SuperBlock targetSB = getSuperBlockFromOffset(targetPC);
    deps[targetSB.getIndex()] = branchSB;
  }
  return deps;
}

代码示例来源:origin: geogebra/geogebra

public final void markTableSwitchCase(int switchStart, int caseIndex,
                   int stackTop)
{
  if (!(0 <= stackTop && stackTop <= itsMaxStack))
    throw new IllegalArgumentException("Bad stack index: "+stackTop);
  itsStackTop = (short)stackTop;
  addSuperBlockStart(itsCodeBufferTop);
  itsJumpFroms.put(itsCodeBufferTop, switchStart);
  setTableSwitchJump(switchStart, caseIndex, itsCodeBufferTop);
}

代码示例来源:origin: rhino/js

public void remove(int key) {
  if (key < 0) Kit.codeBug();
  int index = findIndex(key);
  if (0 <= index) {
    keys[index] = DELETED;
    --keyCount;
    // Allow to GC value and make sure that new key with the deleted
    // slot shall get proper default values
    if (values != null) { values[index] = null; }
    if (ivaluesShift != 0) { keys[ivaluesShift + index] = 0; }
  }
}

代码示例来源:origin: rhino/js

private int insertNewKey(int key) {
  if (check && occupiedCount != keyCount) Kit.codeBug();
  if (check && keyCount == 1 << power) Kit.codeBug();
  int[] keys = this.keys;
  int fraction = key * A;
  int index = fraction >>> (32 - power);
  if (keys[index] != EMPTY) {
    int mask = (1 << power) - 1;
    int step = tableLookupStep(fraction, mask, power);
    int firstIndex = index;
    do {
      if (check && keys[index] == DELETED) Kit.codeBug();
      index = (index + step) & mask;
      if (check && firstIndex == index) Kit.codeBug();
    } while (keys[index] != EMPTY);
  }
  keys[index] = key;
  ++occupiedCount;
  ++keyCount;
  return index;
}

代码示例来源:origin: geogebra/geogebra

int key = old[i];
if (key != EMPTY && key != DELETED) {
  int index = insertNewKey(key);
  if (oldValues != null) {
    values[index] = oldValues[i];

代码示例来源:origin: geogebra/geogebra

byte getConstantType(int index)
{
  return (byte) itsPoolTypes.getInt(index, 0);
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

} else {
  frame.pc = frame.idata.longJumps.
          getExistingInt(frame.pc);

代码示例来源:origin: geogebra/geogebra

static int[] getLineNumbers(InterpreterData data)
{
  UintMap presentLines = new UintMap();
  byte[] iCode = data.itsICode;
  int iCodeLength = iCode.length;
  for (int pc = 0; pc != iCodeLength;) {
    int bytecode = iCode[pc];
    int span = bytecodeSpan(bytecode);
    if (bytecode == Icode_LINE) {
      if (span != 3) Kit.codeBug();
      int line = getIndex(iCode, pc + 1);
      presentLines.put(line, 0);
    }
    pc += span;
  }
  return presentLines.getKeys();
}

代码示例来源:origin: geogebra/geogebra

int step = tableLookupStep(fraction, mask, power);
int n = 0;
do {
rehashTable(intType);
return insertNewKey(key);

代码示例来源:origin: com.github.tntim96/rhino

/**
 * Calculate partial dependencies for super blocks.
 *
 * This is used as a workaround for dead code that is generated. Only
 * one dependency per super block is given.
 */
private SuperBlock[] getSuperBlockDependencies() {
  SuperBlock[] deps = new SuperBlock[superBlocks.length];
  for (int i = 0; i < itsExceptionTableTop; i++) {
    ExceptionTableEntry ete = itsExceptionTable[i];
    short startPC = (short) getLabelPC(ete.itsStartLabel);
    short handlerPC = (short) getLabelPC(ete.itsHandlerLabel);
    SuperBlock handlerSB = getSuperBlockFromOffset(handlerPC);
    SuperBlock dep = getSuperBlockFromOffset(startPC);
    deps[handlerSB.getIndex()] = dep;
  }
  int[] targetPCs = itsJumpFroms.getKeys();
  for (int i = 0; i < targetPCs.length; i++) {
    int targetPC = targetPCs[i];
    int branchPC = itsJumpFroms.getInt(targetPC, -1);
    SuperBlock branchSB = getSuperBlockFromOffset(branchPC);
    SuperBlock targetSB = getSuperBlockFromOffset(targetPC);
    deps[targetSB.getIndex()] = branchSB;
  }
  return deps;
}

代码示例来源:origin: geogebra/geogebra

int addConstant(float k)
{
  ensure(5);
  itsPool[itsTop++] = CONSTANT_Float;
  int bits = Float.floatToIntBits(k);
  itsTop = ClassFileWriter.putInt32(bits, itsPool, itsTop);
  itsPoolTypes.put(itsTopIndex, CONSTANT_Float);
  return itsTopIndex++;
}

代码示例来源:origin: geogebra/geogebra

public void remove(int key) {
  if (key < 0) Kit.codeBug();
  int index = findIndex(key);
  if (0 <= index) {
    keys[index] = DELETED;
    --keyCount;
    // Allow to GC value and make sure that new key with the deleted
    // slot shall get proper default values
    if (values != null) { values[index] = null; }
    if (ivaluesShift != 0) { keys[ivaluesShift + index] = 0; }
  }
}

代码示例来源:origin: com.github.tntim96/rhino

private int insertNewKey(int key) {
  if (check && occupiedCount != keyCount) Kit.codeBug();
  if (check && keyCount == 1 << power) Kit.codeBug();
  int[] keys = this.keys;
  int fraction = key * A;
  int index = fraction >>> (32 - power);
  if (keys[index] != EMPTY) {
    int mask = (1 << power) - 1;
    int step = tableLookupStep(fraction, mask, power);
    int firstIndex = index;
    do {
      if (check && keys[index] == DELETED) Kit.codeBug();
      index = (index + step) & mask;
      if (check && firstIndex == index) Kit.codeBug();
    } while (keys[index] != EMPTY);
  }
  keys[index] = key;
  ++occupiedCount;
  ++keyCount;
  return index;
}

代码示例来源:origin: rhino/js

int key = old[i];
if (key != EMPTY && key != DELETED) {
  int index = insertNewKey(key);
  if (oldValues != null) {
    values[index] = oldValues[i];

代码示例来源:origin: io.apigee/rhino

byte getConstantType(int index)
{
  return (byte) itsPoolTypes.getInt(index, 0);
}

相关文章