Esempio n. 1
0
  /**
   * Get LocalVariable object.
   *
   * <p>This relies on that the instruction list has already been dumped to byte code or or that the
   * `setPositions' methods has been called for the instruction list.
   *
   * <p>Note that for local variables whose scope end at the last instruction of the method's code,
   * the JVM specification is ambiguous: both a start_pc+length ending at the last instruction and
   * start_pc+length ending at first index beyond the end of the code are valid.
   *
   * @param il instruction list (byte code) which this variable belongs to
   * @param cp constant pool
   */
  public LocalVariable getLocalVariable(ConstantPoolGen cp) {
    int start_pc = start.getPosition();
    int length = end.getPosition() - start_pc;

    if (length > 0) length += end.getInstruction().getLength();

    int name_index = cp.addUtf8(name);
    int signature_index = cp.addUtf8(type.getSignature());

    return new LocalVariable(
        start_pc, length, name_index, signature_index, index, cp.getConstantPool());
  }
Esempio n. 2
0
 /**
  * Classify an expression according to its numeric type. kind==0: not a number. kind==1: a
  * non-real number kind==2: real number kind==3: floating-point kind==4: exact integer
  */
 public static int classify(Type type) {
   int kind = 0;
   if (type instanceof PrimType) {
     char sig = type.getSignature().charAt(0);
     if (sig == 'V' || sig == 'Z' || sig == 'C') return 0;
     else if (sig == 'D' || sig == 'F') return 3;
     else return 4;
   } else if (type.isSubtype(Arithmetic.typeIntNum)) return 4;
   else if (type.isSubtype(Arithmetic.typeDFloNum)) return 3;
   else if (type.isSubtype(Arithmetic.typeRealNum)) return 2;
   else if (type.isSubtype(Arithmetic.typeNumeric)) return 1;
   else return 0;
 }
  /**
   * Invokes the listener method for a state change.
   *
   * @param stateChangeEvent the state change event
   */
  public void invoke(StateChangeEvent stateChangeEvent) {
    ServerConnector connector = (ServerConnector) stateChangeEvent.getSource();

    Class<?> declaringClass = this.declaringClass;
    if (declaringClass == null) {
      declaringClass = connector.getClass();
    }
    Type declaringType = TypeDataStore.getType(declaringClass);

    try {
      declaringType.getMethod(methodName).invoke(connector);
    } catch (NoDataException e) {
      throw new RuntimeException(
          "Couldn't invoke @OnStateChange method "
              + declaringType.getSignature()
              + "."
              + methodName,
          e);
    }
  }