Examples of ArrayRef


Examples of org.renjin.gcc.translate.expr.ArrayRef

   * If pointers are being used in the comparison, than we
   * need to interpret them as integers.
   */
  private ImExpr pointerToInteger(FunctionContext context, ImExpr a) {
    if(a instanceof ImIndirectExpr) {
      ArrayRef arrayRef = ((ImIndirectExpr) a).translateToArrayRef(context);
      return new ImLiteralPrimitiveExpr(arrayRef.getIndexExpr(), ImPrimitiveType.INT);
    } else {
      return a;
    }
  }
View Full Code Here

Examples of org.renjin.gcc.translate.expr.ArrayRef

import org.renjin.gcc.translate.type.PrimitiveTypes;

public class PtrWrapperUtils {

  public static JimpleExpr wrapPointer(FunctionContext context, ImIndirectExpr ptr) {
    ArrayRef ref = ptr.translateToArrayRef(context);
    JimpleType wrapperType = ptr.type().getWrapperType();

    String tempWrapper = context.declareTemp(wrapperType);
    context.getBuilder().addStatement(tempWrapper + " = new " + wrapperType);
    context.getBuilder().addStatement(
        "specialinvoke " + tempWrapper + ".<" + wrapperType + ": void <init>("
            + ptr.type().getArrayType() + ", int)>(" + ref.getArrayExpr() + ", " + ref.getIndexExpr() + ")");

    return new JimpleExpr(tempWrapper);
  }
View Full Code Here

Examples of org.renjin.gcc.translate.expr.ArrayRef

    context.getBuilder().addVarDecl(JimpleType.INT, jimpleStartIndexName);
  }

  @Override
  public ArrayRef translateToArrayRef(FunctionContext context) {
    return new ArrayRef(jimpleArrayName, jimpleStartIndexName);
  }
View Full Code Here

Examples of org.renjin.gcc.translate.expr.ArrayRef

  @Override
  public void writeAssignment(FunctionContext context, ImExpr rhs) {
    if(rhs instanceof ImIndirectExpr) {
      ImIndirectExpr ptr = (ImIndirectExpr) rhs;
      ArrayRef ref = ptr.translateToArrayRef(context);
      context.getBuilder().addAssignment(jimpleArrayName, ref.getArrayExpr());
      context.getBuilder().addAssignment(jimpleStartIndexName, ref.getIndexExpr());
    } else {
      throw new UnsupportedOperationException(rhs.toString());
    }
  }
View Full Code Here

Examples of soot.jimple.ArrayRef

                            if (debug) {
                                System.out
                                        .println("handling as assignment to Array");
                            }

                            ArrayRef arrayRef = (ArrayRef) stmt.getLeftOp();
                            Local baseLocal = (Local) arrayRef.getBase();
                            Map fieldToReplacementArrayLocal = (Map) localToFieldToLocal
                                    .get(baseLocal);
                            Map fieldToReplacementLocal = (Map) localToFieldToLocal
                                    .get(stmt.getRightOp());

                            if (debug) {
                                System.out
                                        .println("fieldToReplacementArrayLocal = "
                                                + fieldToReplacementArrayLocal);
                            }

                            if (debug) {
                                System.out.println("fieldToReplacementLocal = "
                                        + fieldToReplacementLocal);
                            }

                            if ((fieldToReplacementLocal != null)
                                    && (fieldToReplacementArrayLocal != null)) {
                                doneSomething = true;
                                body
                                        .getUnits()
                                        .insertBefore(
                                                Jimple
                                                        .v()
                                                        .newAssignStmt(
                                                                Jimple
                                                                        .v()
                                                                        .newArrayRef(
                                                                                (Local) localToIsNotNullLocal
                                                                                        .get(baseLocal),
                                                                                arrayRef
                                                                                        .getIndex()),
                                                                (Local) localToIsNotNullLocal
                                                                        .get(stmt
                                                                                .getRightOp())),
                                                unit);

                                if (debug) {
                                    System.out.println("local = "
                                            + stmt.getLeftOp());
                                }

                                for (Iterator tokenFields = fieldToReplacementLocal
                                        .keySet().iterator(); tokenFields
                                        .hasNext();) {
                                    SootField tokenField = (SootField) tokenFields
                                            .next();

                                    if (debug) {
                                        System.out.println("tokenField = "
                                                + tokenField);
                                    }

                                    Local replacementArrayLocal = (Local) fieldToReplacementArrayLocal
                                            .get(tokenField);
                                    Local replacementLocal = (Local) fieldToReplacementLocal
                                            .get(tokenField);

                                    body
                                            .getUnits()
                                            .insertBefore(
                                                    Jimple
                                                            .v()
                                                            .newAssignStmt(
                                                                    Jimple
                                                                            .v()
                                                                            .newArrayRef(
                                                                                    replacementArrayLocal,
                                                                                    arrayRef
                                                                                            .getIndex()),
                                                                    replacementLocal),
                                                    unit);
                                }

                                // Have to remove here, because otherwise we'll try to
                                // index into a null array.
                                //stmt.getRightOpBox().setValue(NullConstant.v());
                                body.getUnits().remove(unit);
                            }
                        } else if (stmt.getLeftOp() instanceof Local
                                && stmt.getRightOp() instanceof ArrayRef) {
                            if (debug) {
                                System.out
                                        .println("handling as assignment from Array");
                            }

                            ArrayRef arrayRef = (ArrayRef) stmt.getRightOp();
                            Map fieldToReplacementLocal = (Map) localToFieldToLocal
                                    .get(stmt.getLeftOp());
                            Local baseLocal = (Local) arrayRef.getBase();
                            Map fieldToReplacementArrayLocal = (Map) localToFieldToLocal
                                    .get(baseLocal);

                            if ((fieldToReplacementLocal != null)
                                    && (fieldToReplacementArrayLocal != null)) {
                                doneSomething = true;

                                body
                                        .getUnits()
                                        .insertBefore(
                                                Jimple
                                                        .v()
                                                        .newAssignStmt(
                                                                (Local) localToIsNotNullLocal
                                                                        .get(stmt
                                                                                .getLeftOp()),
                                                                Jimple
                                                                        .v()
                                                                        .newArrayRef(
                                                                                (Local) localToIsNotNullLocal
                                                                                        .get(baseLocal),
                                                                                arrayRef
                                                                                        .getIndex())),
                                                unit);

                                if (debug) {
                                    System.out.println("local = "
                                            + stmt.getLeftOp());
                                }

                                for (Iterator tokenFields = fieldToReplacementLocal
                                        .keySet().iterator(); tokenFields
                                        .hasNext();) {
                                    SootField tokenField = (SootField) tokenFields
                                            .next();

                                    if (debug) {
                                        System.out.println("tokenField = "
                                                + tokenField);
                                    }

                                    Local replacementArrayLocal = (Local) fieldToReplacementArrayLocal
                                            .get(tokenField);
                                    Local replacementLocal = (Local) fieldToReplacementLocal
                                            .get(tokenField);

                                    if (debug) {
                                        System.out
                                                .println("replacementLocal = "
                                                        + replacementLocal);
                                    }

                                    if (debug) {
                                        System.out
                                                .println("replacementArrayLocal = "
                                                        + replacementArrayLocal);
                                    }

                                    body
                                            .getUnits()
                                            .insertBefore(
                                                    Jimple
                                                            .v()
                                                            .newAssignStmt(
                                                                    replacementLocal,
                                                                    Jimple
                                                                            .v()
                                                                            .newArrayRef(
                                                                                    replacementArrayLocal,
                                                                                    arrayRef
                                                                                            .getIndex())),
                                                    unit);
                                }

                                stmt.getRightOpBox().setValue(NullConstant.v());
View Full Code Here

Examples of soot.jimple.ArrayRef

      ValueBox allowedBox = null; // the only place the statement is allowed to reference an array without breaking it
      boolean affected = false;
      if (stmt instanceof DefinitionStmt) {
        DefinitionStmt def = (DefinitionStmt)stmt;
        if (def.getLeftOp() instanceof ArrayRef) {
          ArrayRef array = (ArrayRef)def.getLeftOp();
          allowedBox = array.getBaseBox();
          if (array.getBase() == local) {
            // assignment into interesting array
            if (array.getIndex() instanceof IntConstant) {
              IntConstant index = (IntConstant)array.getIndex();
              if (index.value >= 0 && index.value < info.contents.length) {
                ArrayConstantInfo out = info.clone();
                out.contents[index.value] = def.getRightOpBox();
                dest.put(local, out);
              } else {
View Full Code Here

Examples of soot.jimple.ArrayRef

      // delegate the translation
      fieldReferenceTranslator.translateFieldAssignment(ref, result, factory);
   
    // assign into an array slot?
    } else if (stmt.getLeftOp() instanceof ArrayRef) {
      ArrayRef left = (ArrayRef)stmt.getLeftOp();
      Value array = left.getBase();
      if (array instanceof Local) {
        Local arrayLocal = (Local)array;
        Variable arrayVariable = factory.getLocal(arrayLocal);
       
        switch (result.getType()) {
View Full Code Here

Examples of soot.jimple.ArrayRef

  }
  private void assignment(DefinitionStmt s) {
    Variable right = translateExpr(s.getRightOp());
    if (s.getLeftOp() instanceof ArrayRef) {
      // A[X] = B
      ArrayRef array = (ArrayRef)s.getLeftOp();
      if (((ArrayType)array.getBase().getType()).getElementType() instanceof RefLikeType) {
        Variable left = context.getLocal(((Local)array.getBase()).getName());
        cfg.addStatement(new ArrayWriteStm(left, right, context.getCurrentOrigin()));
        // also write possible strings we can get from converting the argument using toString()
        cfg.addStatement(addStringStatement(new ArrayWriteStringStm(left, null, context.getCurrentOrigin()), s.getRightOpBox()));
      } else {
        // ignore..
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.