Examples of LocalField


Examples of org.apache.derby.iapi.services.compiler.LocalField

    generate support information for CURRENT_TIME,
    that would otherwise be painful to create manually.
   */
  void getCurrentTimeExpression(MethodBuilder mb) {
    // do any needed setup
    LocalField lf = getCurrentSetup();

    // generated Java:
    //    this.cdt.getCurrentTime();
    mb.getField(lf);
    mb.callMethod(VMOpcode.INVOKEVIRTUAL, (String) null, "getCurrentTime", "java.sql.Time", 0);
View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

    generate support information for CURRENT_TIMESTAMP,
    that would otherwise be painful to create manually.
   */
  void getCurrentTimestampExpression(MethodBuilder mb) {
    // do any needed setup
    LocalField lf = getCurrentSetup();

    // generated Java:
    //    this.cdt.getCurrentTimestamp();
    mb.getField(lf);
    mb.callMethod(VMOpcode.INVOKEVIRTUAL, (String) null,
View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

    if(cascadeDelete)
    {
      parentResultSetId = targetTableDescriptor.getSchemaName() +
                             "." + targetTableDescriptor.getName();
      // Generate the code to build the array
      LocalField arrayField =
        acb.newFieldDeclaration(Modifier.PRIVATE, resultSetArrayType);
      mb.pushNewArray(ClassName.ResultSet, dependentNodes.length)// new ResultSet[size]
      mb.setField(arrayField);
      for(int index=0 ; index <  dependentNodes.length ; index++)
      {
View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

    int      argumentsListSize = argumentsList.size();
    String    receiverType = ClassName.DataValueDescriptor;
    String    argumentsListInterfaceType = ClassName.DataValueDescriptor + "[]";

    // Generate the code to build the array
    LocalField arrayField =
      acb.newFieldDeclaration(Modifier.PRIVATE, argumentsListInterfaceType);

    /* The array gets created in the constructor.
     * All constant elements in the array are initialized
     * in the constructor. 
     */
    /* Assign the initializer to the DataValueDescriptor[] field */
    MethodBuilder cb = acb.getConstructor();
    cb.pushNewArray(ClassName.DataValueDescriptor, argumentsListSize);
    cb.setField(arrayField);

    /* Set the array elements that are constant */
    int numConstants = 0;
    MethodBuilder nonConstantMethod = null;
    MethodBuilder currentConstMethod = cb;
    for (int index = 0; index < argumentsListSize; index++)
    {
      MethodBuilder setArrayMethod;
 
      if (argumentsList.elementAt(index) instanceof ConstantNode)
      {
        numConstants++;
   
        /*if too many statements are added  to a  method,
        *size of method can hit  65k limit, which will
        *lead to the class format errors at load time.
        *To avoid this problem, when number of statements added
        *to a method is > 2048, remaing statements are added to  a new function
        *and called from the function which created the function.
        *See Beetle 5135 or 4293 for further details on this type of problem.
        */
        if(currentConstMethod.statementNumHitLimit(1))
        {
          MethodBuilder genConstantMethod = acb.newGeneratedFun("void", Modifier.PRIVATE);
          currentConstMethod.pushThis();
          currentConstMethod.callMethod(VMOpcode.INVOKEVIRTUAL,
                          (String) null,
                          genConstantMethod.getName(),
                          "void", 0);
          //if it is a generate function, close the metod.
          if(currentConstMethod != cb){
            currentConstMethod.methodReturn();
            currentConstMethod.complete();
          }
          currentConstMethod = genConstantMethod;
        }
        setArrayMethod = currentConstMethod;
      } else {
        if (nonConstantMethod == null)
          nonConstantMethod = acb.newGeneratedFun("void", Modifier.PROTECTED);
        setArrayMethod = nonConstantMethod;

      }

      setArrayMethod.getField(arrayField);
      ((ValueNode) argumentsList.elementAt(index)).generateExpression(acb, setArrayMethod);
      setArrayMethod.upCast(receiverType);
      setArrayMethod.setArrayElement(index);
    }

    //if a generated function was created to reduce the size of the methods close the functions.
    if(currentConstMethod != cb){
      currentConstMethod.methodReturn();
      currentConstMethod.complete();
    }

    if (nonConstantMethod != null) {
      nonConstantMethod.methodReturn();
      nonConstantMethod.complete();
      mb.pushThis();
      mb.callMethod(VMOpcode.INVOKEVIRTUAL, (String) null, nonConstantMethod.getName(), "void", 0);
    }

    /*
    **  Call the method for coalesce/value function.
    **  First generate following
    **  <first non-param argument in the list>.method(<all the arguments>, <resultType>)
    **  Next, if we are dealing with result type that is variable length, then generate a call to setWidth.
    */

    // coalesce will be called on this non-parameter argument
    ((ValueNode) argumentsList.elementAt(firstNonParameterNodeIdx)).
      generateExpression(acb, mb);

    mb.upCast(ClassName.DataValueDescriptor);

    mb.getField(arrayField); // first arg to the coalesce function

    //Following is for the second arg. This arg will be used to pass the return value.
    //COALESCE method expects this to be initialized to NULL SQLxxx type object.
    LocalField field = acb.newFieldDeclaration(Modifier.PRIVATE, receiverType);
    acb.generateNull(mb, getTypeCompiler(), getTypeServices().getCollationType());
    mb.upCast(ClassName.DataValueDescriptor);
    mb.putField(field);

    mb.callMethod(VMOpcode.INVOKEINTERFACE, receiverType, "coalesce", receiverType, 2);
View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

       // this sets up the method and the static field.
       MethodBuilder userExprFun = acb.newUserExprFun();

    /* Declare the field */
    LocalField field = acb.newFieldDeclaration(Modifier.PRIVATE, ClassName.ExecRow);

    // Generate the code to create the row in the constructor
    genCreateRow(acb, field, "getValueRow", ClassName.ExecRow, size());

    ResultColumn rc;
View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

      rowAllocatorType = ClassName.ExecRow;
    }
    numCols = size();

    /* Declare the field */
    LocalField lf = acb.newFieldDeclaration(Modifier.PRIVATE, ClassName.ExecRow);
    // Generate the code to create the row in the constructor
    genCreateRow(acb, lf, rowAllocatorMethod, rowAllocatorType, highestColumnNumber + 1);

    // now we fill in the body of the function

View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

   */
  protected LocalField getCurrentSetup()
  {
    if (cdtField != null) return cdtField;

    LocalField lf = super.getCurrentSetup();

    // 3) the execute method gets a statement (prior to the return)
    //    to tell cdt to restart:
    //    cdt.forget();

View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

      ** There is a receiver.  Generate a null SQL value to return
      ** in case the receiver is null.  First, create a field to hold
      ** the null SQL value.
      */
      String nullValueClass = getTypeCompiler().interfaceName();
      LocalField nullValueField =
        acb.newFieldDeclaration(Modifier.PRIVATE, nullValueClass);
      /*
      ** There is a receiver.  Generate the following to test
      ** for null:
      **
      **    (receiverExpression == null) ?
      */

      mb.conditionalIfNull();
      mb.getField(nullValueField);
      acb.generateNullWithExpress(mb, getTypeCompiler());


      /*
      ** We have now generated the expression to test, and the
      ** "true" side of the ?: operator.  Finish the "true" side
      ** so we can generate the "false" side.
      */
      mb.startElseCode();
    }
   
    resultType = getTypeId();
    TypeCompiler tc = getTypeCompiler();

    resultTypeName = tc.interfaceName();

    /* Allocate an object for re-use to hold the result of the conversion */
    LocalField field = acb.newFieldDeclaration(Modifier.PRIVATE, resultTypeName);

    /* Generate the expression for the Java value under us */
    javaNode.generateExpression(acb, mb);

    /* Generate the SQL value, which is always nullable */
 
View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

    int      argumentsListSize = argumentsList.size();
    String    receiverType = ClassName.DataValueDescriptor;
    String    argumentsListInterfaceType = ClassName.DataValueDescriptor + "[]";

    // Generate the code to build the array
    LocalField arrayField =
      acb.newFieldDeclaration(Modifier.PRIVATE, argumentsListInterfaceType);

    /* The array gets created in the constructor.
     * All constant elements in the array are initialized
     * in the constructor. 
     */
    /* Assign the initializer to the DataValueDescriptor[] field */
    MethodBuilder cb = acb.getConstructor();
    cb.pushNewArray(ClassName.DataValueDescriptor, argumentsListSize);
    cb.setField(arrayField);

    /* Set the array elements that are constant */
    int numConstants = 0;
    MethodBuilder nonConstantMethod = null;
    MethodBuilder currentConstMethod = cb;
    for (int index = 0; index < argumentsListSize; index++)
    {
      MethodBuilder setArrayMethod;
 
      if (argumentsList.elementAt(index) instanceof ConstantNode)
      {
        numConstants++;
   
        /*if too many statements are added  to a  method,
        *size of method can hit  65k limit, which will
        *lead to the class format errors at load time.
        *To avoid this problem, when number of statements added
        *to a method is > 2048, remaing statements are added to  a new function
        *and called from the function which created the function.
        *See Beetle 5135 or 4293 for further details on this type of problem.
        */
        if(currentConstMethod.statementNumHitLimit(1))
        {
          MethodBuilder genConstantMethod = acb.newGeneratedFun("void", Modifier.PRIVATE);
          currentConstMethod.pushThis();
          currentConstMethod.callMethod(VMOpcode.INVOKEVIRTUAL,
                          (String) null,
                          genConstantMethod.getName(),
                          "void", 0);
          //if it is a generate function, close the metod.
          if(currentConstMethod != cb){
            currentConstMethod.methodReturn();
            currentConstMethod.complete();
          }
          currentConstMethod = genConstantMethod;
        }
        setArrayMethod = currentConstMethod;
      } else {
        if (nonConstantMethod == null)
          nonConstantMethod = acb.newGeneratedFun("void", Modifier.PROTECTED);
        setArrayMethod = nonConstantMethod;

      }

      setArrayMethod.getField(arrayField);
      ((ValueNode) argumentsList.elementAt(index)).generateExpression(acb, setArrayMethod);
      setArrayMethod.upCast(receiverType);
      setArrayMethod.setArrayElement(index);
    }

    //if a generated function was created to reduce the size of the methods close the functions.
    if(currentConstMethod != cb){
      currentConstMethod.methodReturn();
      currentConstMethod.complete();
    }

    if (nonConstantMethod != null) {
      nonConstantMethod.methodReturn();
      nonConstantMethod.complete();
      mb.pushThis();
      mb.callMethod(VMOpcode.INVOKEVIRTUAL, (String) null, nonConstantMethod.getName(), "void", 0);
    }

    /*
    **  Call the method for coalesce/value function.
    **  First generate following
    **  <first non-param argument in the list>.method(<all the arguments>, <resultType>)
    **  Next, if we are dealing with result type that is variable length, then generate a call to setWidth.
    */

    firstNonParameterNode.generateExpression(acb, mb); //coalesce will be called on this non-parameter argument
    mb.upCast(ClassName.DataValueDescriptor);

    mb.getField(arrayField); // first arg to the coalesce function

    //Following is for the second arg. This arg will be used to pass the return value.
    //COALESCE method expects this to be initialized to NULL SQLxxx type object.
    LocalField field = acb.newFieldDeclaration(Modifier.PRIVATE, receiverType);
    acb.generateNull(mb, getTypeCompiler());
    mb.upCast(ClassName.DataValueDescriptor);
    mb.putField(field);

    mb.callMethod(VMOpcode.INVOKEINTERFACE, receiverType, "coalesce", receiverType, 2);
View Full Code Here

Examples of org.apache.derby.iapi.services.compiler.LocalField

    /* Generate a new method */
    /* only used within the other exprFuns, so can be private */
    MethodBuilder mb = acb.newGeneratedFun(ClassName.DataValueDescriptor, Modifier.PROTECTED);
   
    /* Allocate an object for re-use to hold the result of the operator */
    LocalField field =
      acb.newFieldDeclaration(Modifier.PRIVATE, ClassName.RefDataValue);


    /* Fill in the body of the method
     * generates:
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.