Examples of MethodBuilder


Examples of com.alibaba.citrus.codegen.MethodBuilder

    /**
     * ����Ĭ�Ϲ��캯����
     */
    public static void addDefaultConstructor(ClassBuilder cb) {
        MethodBuilder mb = cb.addConstructor(null, null);
        CodeBuilder code = mb.startCode();

        code.loadThis();
        code.invokeConstructor(cb.getSuperType(), new com.alibaba.citrus.asm.commons.Method(CONSTRUCTOR_NAME, "()V"));
        code.returnValue();
    }
View Full Code Here

Examples of com.strobel.reflection.emit.MethodBuilder

            Modifier.PUBLIC | Modifier.FINAL,
            Types.Object,
            Type.list(Type.of(Runnable.class))
        );

        final MethodBuilder powerMethod = typeBuilder.defineMethod(
            "power",
            Modifier.PUBLIC | Modifier.FINAL,
            PrimitiveTypes.Integer,
            Type.list(PrimitiveTypes.Integer, PrimitiveTypes.Integer)
        );

        final MethodBuilder runMethod = typeBuilder.defineMethod(
            "run",
            Modifier.PUBLIC | Modifier.FINAL,
            PrimitiveTypes.Void
        );
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

       //   return fieldX;
       // }
       // static Method exprN = method pointer to exprN;

       // 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;
    int size = size();

    MethodBuilder cb = acb.getConstructor();

    for (int index = 0; index < size; index++)
    {
        // generate statements of the form
      // fieldX.setColumn(columnNumber, (DataValueDescriptor) columnExpr);
      // and add them to exprFun.
      rc = (ResultColumn) elementAt(index);

      /* If we are not generating nulls, then we can skip this RC if
       * it is simply propagating a column from the source result set.
       */
      if (!genNulls)
      {
        ValueNode sourceExpr = rc.getExpression();

        if (sourceExpr instanceof VirtualColumnNode && ! ( ((VirtualColumnNode) sourceExpr).getCorrelated()))
        {
          continue;
        }

        if (sourceExpr instanceof ColumnReference && ! ( ((ColumnReference) sourceExpr).getCorrelated()))
        {
          continue;
        }
      }


            // row add is 1-based, and iterator index is 0-based
      if (SanityManager.DEBUG)
      {
        if (index + 1 != rc.getVirtualColumnId())
        {
          SanityManager.THROWASSERT(
            "VirtualColumnId (" +
            rc.getVirtualColumnId() +
            ") does not agree with position within Vector (" +
            (index + 1) +
            ")");
        }
      }

            //
            // Generated columns should be populated after the base row because
            // the generation clauses may refer to base columns that have to be filled
            // in first. Population of generated columns is done in another
            // method, which (like CHECK CONSTRAINTS) is explicitly called by
            // InsertResultSet and UpdateResultSet.
            //
      if ( rc.hasGenerationClause() )
            {
                continue;
            }
           
      // we need the expressions to be Columns exactly.

      /* SPECIAL CASE:  Expression is a non-null constant.
       *  Generate the setColumn() call in the constructor
       *  so that it will only be executed once per instantiation.
       *
        * Increase the statement counter in constructor.  Code size in
        * constructor can become too big (more than 64K) for Java compiler
        * to handle (beetle 4293).  We set constant columns in other
        * methods if constructor has too many statements already.
        */
      if ( (! genNulls) &&
         (rc.getExpression() instanceof ConstantNode) &&
         ! ((ConstantNode) rc.getExpression()).isNull() &&
         ! cb.statementNumHitLimit(1))
      {


        cb.getField(field); // instance
        cb.push(index + 1); // first arg;

        rc.generateExpression(acb, cb);
        cb.cast(ClassName.DataValueDescriptor); // second arg
        cb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.Row, "setColumn", "void", 2);
        continue;
      }

      userExprFun.getField(field); // instance
      userExprFun.push(index + 1); // arg1
View Full Code Here

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

       //   return fieldX;
       // }
       // static Method exprN = method pointer to exprN;

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

    // Allocate the right type of row, depending on
    // whether we're scanning an index or a heap.
    if (indexRow)
    {
      rowAllocatorMethod = "getIndexableRow";
      rowAllocatorType = ClassName.ExecIndexRow;
    }
    else
    {
      rowAllocatorMethod = "getValueRow";
      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

    int colNum;

    // If there is a referenced column map, the first column to fill
    // in is the first one in the bit map - otherwise, it is
    // column 0.
    if (referencedCols != null)
      colNum = referencedCols.anySetBit();
    else
      colNum = 0;

    for (int index = 0; index < numCols; index++)
    {
      ResultColumn rc = ((ResultColumn) elementAt(index));

      /* Special code generation for RID since expression is CurrentRowLocationNode.
       * Really need yet another node type that does its own code generation.
       */
      if (rc.getExpression() instanceof CurrentRowLocationNode)
      {
        ConglomerateController cc = null;
        int savedItem;
        RowLocation rl;
       
        cc = getLanguageConnectionContext().
            getTransactionCompile().openConglomerate(
              conglomerateId,
                            false,
              0,
              TransactionController.MODE_RECORD,
              TransactionController.ISOLATION_READ_COMMITTED);
        try
        {
          rl = cc.newRowLocationTemplate();
        }
        finally
        {
          if (cc != null)
          {
            cc.close();
          }
        }

        savedItem = acb.addItem(rl);
               
        // get the RowLocation template
        exprFun.getField(lf); // instance for setColumn
        exprFun.push(highestColumnNumber + 1); // first arg

        exprFun.pushThis(); // instance for getRowLocationTemplate
        exprFun.push(savedItem); // first arg
        exprFun.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.Activation, "getRowLocationTemplate",
                  ClassName.RowLocation, 1);

        exprFun.upCast(ClassName.DataValueDescriptor);
        exprFun.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.Row, "setColumn",
                      "void", 2);
        continue;
      }

      /* Skip over those columns whose source is the immediate
       * child result set.  (No need to generate a wrapper
       * for a SQL NULL when we are smart enough not to pass
       * that wrapper to the store.)
       * NOTE: Believe it or not, we have to check for the case
       * where referencedCols is not null, but no bits are set.
       * This can happen when we need to get all of the columns
       * from the heap due to a check constraint.
       */
      if (propagatedCols != null &&
        propagatedCols.getNumBitsSet() != 0)
      {
        /* We can skip this RC if it is simply propagating
         * a column from the source result set.
         */
        ValueNode sourceExpr = rc.getExpression();

        if (sourceExpr instanceof VirtualColumnNode)
        {
          // There is a referenced columns bit set, so use
          // it to figure out what the next column number is.
          // colNum = referencedCols.anySetBit(colNum);
          continue;
        }
      }

      // generate the column space creation call
           // generate statements of the form
        // r.setColumn(columnNumber, columnShape);
        //
        // This assumes that there are no "holes" in the column positions,
        // and that column positions reflect the stored format/order
      exprFun.getField(lf); // instance
      exprFun.push(colNum + 1); // first arg
      rc.generateHolder(acb, exprFun);

      exprFun.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.Row, "setColumn", "void", 2);

      // If there is a bit map of referenced columns, use it to
      // figure out what the next column is, otherwise just go
      // to the next column.
      if (referencedCols != null)
        colNum = referencedCols.anySetBit(colNum);
      else
        colNum++;
      }
     
    // generate:
    // return fieldX;
    // and add to the end of exprFun's body.
    exprFun.getField(lf);
    exprFun.methodReturn();

    // we are done putting stuff in exprFun:
    exprFun.complete();

    return exprFun;
  }
View Full Code Here

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

    throws StandardException
  {
    // Create the row in the constructor
    //   fieldX = getExecutionFactory().getValueRow(# cols);

    MethodBuilder cb = acb.getConstructor();

    acb.pushGetExecutionFactoryExpression(cb); // instance
    cb.push(numCols);
    cb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null,
              rowAllocatorMethod, rowAllocatorType, 1);
    cb.setField(field);
    /* Increase the statement counter in constructor.  Code size in
     * constructor can become too big (more than 64K) for Java compiler
     * to handle (beetle 4293).  We set constant columns in other
     * methods if constructor has too many statements already.
     */
    cb.statementNumHitLimit(1);    // ignore return value
  }
View Full Code Here

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

  public void generate(ActivationClassBuilder acb,
                MethodBuilder mb) throws StandardException
  {
    if (indexOfSessionTableNamesInSavedObjects != -1 ) //if this cursor references session schema tables, do following
    {
      MethodBuilder constructor = acb.getConstructor();
      constructor.pushThis();
      constructor.push(indexOfSessionTableNamesInSavedObjects);
      constructor.putField(org.apache.derby.iapi.reference.ClassName.BaseActivation, "indexOfSessionTableNamesInSavedObjects", "int");
      constructor.endStatement();
    }

    // generate the parameters
    generateParameterValueSet(acb);
View Full Code Here

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

    {
         mb.pushNull(ClassName.GeneratedMethod);
    }
    else
    {
      MethodBuilder  userExprFun = generateCheckConstraints(checkConstraints, ecb);

         // check constraint is used in the final result set
      // as an access of the new static
         // field holding a reference to this new method.
         ecb.pushMethodReference(mb, userExprFun);
View Full Code Here

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

    throws StandardException
  {
    // this sets up the method and the static field.
    // generates:
    //   java.lang.Object userExprFun { }
    MethodBuilder userExprFun = ecb.newUserExprFun();
   
    // check constraint knows it is returning its value;
   
    /* generates:
     *    return <checkExpress.generate(ecb)>;
     * and adds it to userExprFun
     */

    checkConstraints.generateExpression(ecb, userExprFun);
    userExprFun.methodReturn();
   
    // we are done modifying userExprFun, complete it.
    userExprFun.complete();

    return userExprFun;
  }
View Full Code Here

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

    {
         mb.pushNull(ClassName.GeneratedMethod);
    }
    else
    {
      MethodBuilder  userExprFun = generateGenerationClauses( rcl, resultSetNumber, isUpdate, ecb);

         // generation clause evaluation is used in the final result set
      // as an access of the new static
         // field holding a reference to this new method.
         ecb.pushMethodReference(mb, userExprFun);
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.