Package org.renjin.compiler.pipeline.accessor

Examples of org.renjin.compiler.pipeline.accessor.Accessor


  @Override
  public void compute(ComputeMethod method, DeferredNode node) {

    InputGraph inputGraph = new InputGraph(node);

    Accessor matrix = Accessors.create(node.getOperand(0), inputGraph);
    matrix.init(method);

    int meansLocal = method.reserveLocal(1);
    Accessor numRows = Accessors.create(node.getOperand(1), inputGraph);
    numRows.init(method);

    MethodVisitor mv = method.getVisitor();
    int numRowsLocal = method.reserveLocal(meansLocal);
    int rowLocal = method.reserveLocal(1);
    int counterLocal = method.reserveLocal(1);

    mv.visitInsn(ICONST_0);
    numRows.pushInt(method);
    mv.visitInsn(DUP);
    mv.visitVarInsn(ISTORE, numRowsLocal);

    // create array (size still on stack)
    mv.visitIntInsn(NEWARRAY, T_DOUBLE);
View Full Code Here


  @Override
  public void compute(ComputeMethod method, DeferredNode node) {

    InputGraph inputGraph = new InputGraph(node);

    Accessor accessor = Accessors.create(node.getOperands().get(0), inputGraph);
    accessor.init(method);

    MethodVisitor mv = method.getVisitor();

    // get the length of the vector
    int lengthLocal = method.reserveLocal(1);
    accessor.pushLength(method);
    mv.visitVarInsn(ISTORE, lengthLocal);

    // initial the sum variable
    int sumLocal = method.reserveLocal(2);
    mv.visitInsn(DCONST_0);
    mv.visitVarInsn(DSTORE, sumLocal);

    int counterLocal = method.reserveLocal(1);
    mv.visitInsn(ICONST_0);
    mv.visitVarInsn(ISTORE, counterLocal);

    Label l3 = new Label();
    mv.visitLabel(l3);
    mv.visitVarInsn(ILOAD, counterLocal);
    mv.visitVarInsn(ILOAD, lengthLocal);

    Label l4 = new Label();
    mv.visitJumpInsn(IF_ICMPEQ, l4);

    Label l5 = new Label();
    mv.visitLabel(l5);

    // load the sum on to the stack, and the next value
    mv.visitVarInsn(DLOAD, sumLocal);
    mv.visitVarInsn(ILOAD, counterLocal);
    accessor.pushDouble(method);

    // add the two values and store back into sum
    mv.visitInsn(DADD);
    mv.visitVarInsn(DSTORE, sumLocal);
View Full Code Here

TOP

Related Classes of org.renjin.compiler.pipeline.accessor.Accessor

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.