/**
   * Look for ConstantFloat in ConstantPool.
   *
   * @param n Float number to look for
   * @return index on success, -1 otherwise
   */
  public int lookupFloat(float n) {
    int bits = Float.floatToIntBits(n);

    for (int i = 1; i < index; i++) {
      if (constants[i] instanceof ConstantFloat) {
        ConstantFloat c = (ConstantFloat) constants[i];

        if (Float.floatToIntBits(c.getBytes()) == bits) return i;
      }
    }

    return -1;
  }
Esempio n. 2
0
 /**
  * Initialize from another object. Note that both objects use the same references (shallow copy).
  * Use clone() for a physical copy.
  */
 public ConstantFloat(ConstantFloat c) {
   this(c.getBytes());
 }