Examples of MethodBuilder


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

  private void genDataValueConversion(ExpressionClassBuilder acb,
                        MethodBuilder mb)
      throws StandardException
  {
    MethodBuilder  acbConstructor = acb.getConstructor();

    String resultTypeName = getTypeCompiler().interfaceName();

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

    /*
    ** Store the result of the method call in the field, so we can re-use
    ** the object.
    */

    acb.generateNull(acbConstructor, getTypeCompiler(destCTI));
    acbConstructor.setField(field);


    /*
      For most types generate

View Full Code Here

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

    else
    {
      // this sets up the method and the static field.
      // generates:
      //   Object userExprFun { }
      MethodBuilder userExprFun = acb.newUserExprFun();

      // restriction knows it is returning its value;

      /* generates:
       *    return  <restriction.generate(acb)>;
       * and adds it to userExprFun
       * NOTE: The explicit cast to DataValueDescriptor is required
       * since the restriction may simply be a boolean column or subquery
       * which returns a boolean.  For example:
       *    where booleanColumn
       */
      restriction.generateExpression(acb, userExprFun);
      userExprFun.methodReturn();

      // we are done modifying userExprFun, complete it.
      userExprFun.complete();

         // restriction is used in the final result set as an access of the new static
         // field holding a reference to this new method.
      // generates:
      //  ActivationClass.userExprFun
      // which is the static field that "points" to the userExprFun
      // that evaluates the where clause.
         acb.pushMethodReference(mb, userExprFun);
    }

    /* Determine whether or not reflection is needed for the projection.
     * Reflection is not needed if all of the columns map directly to source
     * columns.
     */
    if (reflectionNeededForProjection())
    {
      // for the resultColumns, we generate a userExprFun
      // that creates a new row from expressions against
      // the current row of the child's result.
      // (Generate optimization: see if we can simply
      // return the current row -- we could, but don't, optimize
      // the function call out and have execution understand
      // that a null function pointer means take the current row
      // as-is, with the performance trade-off as discussed above.)

      /* Generate the Row function for the projection */
      resultColumns.generateCore(acb, mb, false);
    }
    else
    {
         mb.pushNull(ClassName.GeneratedMethod);
    }
   
    mb.push(resultSetNumber);

    // if there is no constant restriction, we just want to pass null.
    if (constantRestriction == null)
    {
         mb.pushNull(ClassName.GeneratedMethod);
    }
    else
    {
      // this sets up the method and the static field.
      // generates:
      //   userExprFun { }
      MethodBuilder userExprFun = acb.newUserExprFun();

      // restriction knows it is returning its value;

      /* generates:
       *    return <restriction.generate(acb)>;
       * and adds it to userExprFun
       * NOTE: The explicit cast to DataValueDescriptor is required
       * since the restriction may simply be a boolean column or subquery
       * which returns a boolean.  For example:
       *    where booleanColumn
       */
      constantRestriction.generateExpression(acb, userExprFun);

      userExprFun.methodReturn();

      // we are done modifying userExprFun, complete it.
      userExprFun.complete();

         // restriction is used in the final result set as an access
      // of the new static field holding a reference to this new method.
      // generates:
      //  ActivationClass.userExprFun
View Full Code Here

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

     * All constant elements in the array are initialized
     * in the constructor.  All non-constant elements, if any,
     * are initialized each time the IN list is evaluated.
     */
    /* Assign the initializer to the DataValueDescriptor[] field */
    MethodBuilder cb = acb.getConstructor();
    cb.pushNewArray(ClassName.DataValueDescriptor, listSize);
    cb.setField(arrayField);

    /* Set the array elements that are constant */
    int numConstants = 0;
    MethodBuilder nonConstantMethod = null;
    MethodBuilder currentConstMethod = cb;
    for (int index = 0; index < listSize; index++)
    {
      MethodBuilder setArrayMethod;
 
      if (rightOperandList.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();
View Full Code Here

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

  public void generateQualMethod(ExpressionClassBuilder acb,
                    MethodBuilder mb,
                    Optimizable optTable)
            throws StandardException
  {
    MethodBuilder qualMethod = acb.newUserExprFun();

    /* Generate a method that returns that expression */
    acb.generateNull(qualMethod, operand.getTypeCompiler());
    qualMethod.methodReturn();
    qualMethod.complete();

    /* Return an expression that evaluates to the GeneratedMethod */
    acb.pushMethodReference(mb, qualMethod);
  }
View Full Code Here

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

  ///////////////////////////////////////////////////////////////////////

  private  final void  beginConstructor()
  {
    // create a constructor that just calls super. 
    MethodBuilder realConstructor =
      cb.newConstructorBuilder(Modifier.PUBLIC);
    realConstructor.callSuper();
    realConstructor.methodReturn();
    realConstructor.complete();

    constructor = cb.newMethodBuilder(Modifier.PUBLIC, "void", "postConstructor");
    constructor.addThrownException(ClassName.StandardException);
  }
View Full Code Here

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

    //
    // create a new method supplying the given modifiers and return Type
    // Java: #modifiers #returnType #exprName { }
    //
    MethodBuilder exprMethod;
    if (params == null)
    {
      exprMethod = cb.newMethodBuilder(modifiers, returnType, exprName);
    }
    else
    {
      exprMethod = cb.newMethodBuilder(modifiers, returnType,
                         exprName, params);
    }

    //
    // declare it to throw StandardException
    // Java: #modifiers #returnType #exprName throws StandardException { }
    //
    exprMethod.addThrownException(ClassName.StandardException);

    return exprMethod;
  }
View Full Code Here

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

   *
   * @return  A new MethodBuilder
   */
  MethodBuilder newUserExprFun() {

    MethodBuilder mb = newExprFun();
    mb.addThrownException("java.lang.Exception");
    return mb;
  }
View Full Code Here

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

         *and called from the function which created the function.
         *See Beetle 5135 or 4293 for further details on this type of problem.
        */
        if(mb.statementNumHitLimit(10))
        {
          MethodBuilder dmb = acb.newGeneratedFun(ClassName.ResultSet, Modifier.PRIVATE);
          dependentNodes[index].generate(acb,dmb); //generates the resultset expression
          dmb.methodReturn();
          dmb.complete();
          /* Generate the call to the new method */
          mb.pushThis();
          //second arg will be generated by this call
          mb.callMethod(VMOpcode.INVOKEVIRTUAL, (String) null, dmb.getName(), ClassName.ResultSet, 0);
        }else
        {
          dependentNodes[index].generate(acb,mb); //generates the resultset expression
        }

        mb.setArrayElement(index);
     
      mb.getField(arrayField); // fourth argument - array reference
    }
    else
    {
      if(isDependentTable)
      {
        mb.pushNull(resultSetArrayType); //No dependent tables for this table
      }
    }


    if(cascadeDelete || isDependentTable)
    {
      parentResultSetId = targetTableDescriptor.getSchemaName() +
                             "." + targetTableDescriptor.getName();
      mb.push(parentResultSetId);

    }
    mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, resultSetGetter, ClassName.ResultSet, argCount);


    if(!isDependentTable && cascadeDelete)
    {
      int numResultSets = acb.getRowCount();
      if(numResultSets > 0)
      {
        //generate activation.raParentResultSets = new NoPutResultSet[size]
        MethodBuilder constructor = acb.getConstructor();
        constructor.pushThis();
        constructor.pushNewArray(ClassName.CursorResultSet, numResultSets);
        constructor.putField(ClassName.BaseActivation,
                   "raParentResultSets",
                   ClassName.CursorResultSet + "[]");
        constructor.endStatement();
      }
    }
  }
View Full Code Here

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

                   MethodBuilder mb,
                   Optimizable optTable)
            throws StandardException
  {
    /* Generate a method that returns the expression */
    MethodBuilder qualMethod = acb.newUserExprFun();

    /*
    ** Generate the expression that's on the opposite side
    ** of the key column
    */
    if (keyColumnOnLeft(optTable))
    {
      rightOperand.generateExpression(acb, qualMethod);
    }
    else
    {
      leftOperand.generateExpression(acb, qualMethod);
    }

    qualMethod.methodReturn();
    qualMethod.complete();

    /* push an expression that evaluates to the GeneratedMethod */
    acb.pushMethodReference(mb, qualMethod);
  }
View Full Code Here

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

  private int getScanArguments(ExpressionClassBuilder acb,
                      MethodBuilder mb)
    throws StandardException
  {
        // get a function to allocate scan rows of the right shape and size
         MethodBuilder resultRowAllocator =
            resultColumns.generateHolderMethod(acb,
                          referencedCols,
                          (FormatableBitSet) null);

    // pass in the referenced columns on the saved objects
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.