Exemplo n.º 1
0
  /**
   * The caller will have pushed a DataValueFactory and value of that can be converted to the
   * correct type, e.g. int for a SQL INTEGER.
   *
   * <p>Thus upon entry the stack looks like: ...,dvf,value
   *
   * <p>If field is not null then it is used as the holder of the generated DataValueDescriptor to
   * avoid object creations on multiple passes through this code. The field may contain null or a
   * valid value.
   *
   * <p>This method then sets up to call the required method on DataValueFactory using the
   * dataValueMethodName(). The value left on the stack will be a DataValueDescriptor of the correct
   * type:
   *
   * <p>If the field contained a valid value then generated code will return that value rather than
   * a newly created object. If field was not-null then the generated code will set the value of
   * field to be the return from the DataValueFactory method call. Thus if the field was empty (set
   * to null) when this code is executed it will contain the newly generated value, otherwise it
   * will be reset to the same value.
   *
   * <p>...,dvd
   *
   * @see TypeCompiler#generateDataValue(MethodBuilder, int, LocalField)
   */
  public void generateDataValue(MethodBuilder mb, int collationType, LocalField field) {

    String interfaceName = interfaceName();

    // push the second argument

    /* If fieldName is null, then there is no
     * reusable wrapper (null), else we
     * reuse the field.
     */
    if (field == null) {
      mb.pushNull(interfaceName);
    } else {
      mb.getField(field);
    }

    int argCount;
    if (pushCollationForDataValue(collationType)) {
      mb.push(collationType);
      argCount = 3;
    } else argCount = 2;

    mb.callMethod(
        VMOpcode.INVOKEINTERFACE, (String) null, dataValueMethodName(), interfaceName, argCount);

    if (field != null) {
      /* Store the result of the method call in the field,
       * so we can re-use the wrapper.
       */
      mb.putField(field);
    }
  }
Exemplo n.º 2
0
  /**
   * The caller will have pushed a DataValueFactory and a null or a value of the correct type
   * (interfaceName()). Thus upon entry the stack looks like on of: ...,dvf,ref ...,dvf,null
   *
   * <p>This method then sets up to call the required method on DataValueFactory using the
   * nullMethodName(). The value left on the stack will be a DataValueDescriptor of the correct
   * type:
   *
   * <p>...,dvd
   *
   * @see TypeCompiler#generateNull(MethodBuilder, int)
   */
  public void generateNull(MethodBuilder mb, int collationType) {
    int argCount;
    if (pushCollationForDataValue(collationType)) {
      mb.push(collationType);
      argCount = 2;
    } else argCount = 1;

    mb.callMethod(
        VMOpcode.INVOKEINTERFACE, (String) null, nullMethodName(), interfaceName(), argCount);
  }