Package org.apache.derby.iapi.services.compiler

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


  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

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

  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

    //
    // 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

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

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

         *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

                   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

  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

    // This method is an implementation of the interface method
    // Activation - ResultSet execute()

    // create an empty execute method
    MethodBuilder mb = cb.newMethodBuilder(Modifier.PUBLIC,
      ClassName.ResultSet, "execute");
    mb.addThrownException(ClassName.StandardException);

    // put a 'throwIfClosed("execute");' statement into the execute method.
    mb.pushThis(); // instance
    mb.push("execute");
    mb.callMethod(VMOpcode.INVOKEVIRTUAL, ClassName.BaseActivation, "throwIfClosed", "void", 1);

    // call this.startExecution(), so the parent class can know an execution
    // has begun.

    mb.pushThis(); // instance
    mb.callMethod(VMOpcode.INVOKEVIRTUAL, ClassName.BaseActivation, "startExecution", "void", 0);

    return  mb;
  }
View Full Code Here

    return  mb;
  }

  MethodBuilder startResetMethod() {
    MethodBuilder mb = cb.newMethodBuilder(Modifier.PUBLIC,
      "void", "reset");

    mb.addThrownException(ClassName.StandardException);
    mb.pushThis();
    mb.callMethod(VMOpcode.INVOKESPECIAL, ClassName.BaseActivation, "reset", "void", 0);


    return mb;
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.services.compiler.MethodBuilder

Copyright © 2018 www.massapicom. 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.