Package soot.jimple

Examples of soot.jimple.DefinitionStmt


            LocalDefs localDefs) {
        //NewExpr newExpr = null;
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof NewExpr) {
                return stmt;
            } else {
                throw new RuntimeException("Found something other"
View Full Code Here


    public static TypedIOPort getPortValue(SootMethod method, Local local,
            Unit location, LocalDefs localDefs, LocalUses localUses) {
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof Local) {
                return getPortValue(method, (Local) value, stmt, localDefs,
                        localUses);
            } else if (value instanceof CastExpr) {
                return getPortValue(method, (Local) ((CastExpr) value).getOp(),
                        stmt, localDefs, localUses);
            } else if (value instanceof FieldRef) {
                SootField field = ((FieldRef) value).getField();
                return _getFieldValueTag(field);
            } else if (value instanceof NewExpr) {
                // If we get to an object creation, then try
                // to figure out where the variable is stored into a field.
                Iterator pairs = localUses.getUsesOf(stmt).iterator();

                while (pairs.hasNext()) {
                    UnitValueBoxPair pair = (UnitValueBoxPair) pairs.next();

                    if (pair.getUnit() instanceof DefinitionStmt) {
                        DefinitionStmt useStmt = (DefinitionStmt) pair
                                .getUnit();

                        if (useStmt.getLeftOp() instanceof FieldRef) {
                            SootField field = ((FieldRef) useStmt.getLeftOp())
                                    .getField();
                            return _getFieldValueTag(field);
                        }
                    }
                }
View Full Code Here

            // Otherwise, we have an attribute inside a port or
            // another attribute...  In such cases, we need to work
            // backwards to get to an entity, so we can find the
            // correct port.  Walk back and get the definition of the
            // field.
            DefinitionStmt definition = _getFieldDef(baseLocal, unit, localDefs);
            InstanceFieldRef fieldRef = (InstanceFieldRef) definition
                    .getRightOp();
            SootField baseField = fieldRef.getField();
            _replaceGetAttributeMethod(theClass, body, box, (Local) fieldRef
                    .getBase(), baseField.getName() + "." + name, definition,
                    localDefs);
View Full Code Here

    private static DefinitionStmt _getFieldDef(Local local, Unit location,
            LocalDefs localDefs) {
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof CastExpr) {
                return _getFieldDef((Local) ((CastExpr) value).getOp(), stmt,
                        localDefs);
            } else if (value instanceof FieldRef) {
View Full Code Here

            } else {
                return NullConstant.v();
            }
        } else {
            // Walk back and get the definition of the field.
            DefinitionStmt definition = _getFieldDef(baseLocal, unit, localDefs);
            InstanceFieldRef fieldRef = (InstanceFieldRef) definition
                    .getRightOp();
            SootField baseField = fieldRef.getField();
            System.out.println("baseField = " + baseField);

            SootField portField = baseField.getDeclaringClass().getFieldByName(
View Full Code Here

    private static DefinitionStmt _getFieldDef(Local local, Unit location,
            LocalDefs localDefs) {
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof CastExpr) {
                return _getFieldDef((Local) ((CastExpr) value).getOp(), stmt,
                        localDefs);
            } else if (value instanceof FieldRef) {
View Full Code Here

                            baseLocal,
                            theClass.getFieldByName(
                                    ModelTransformer.getContainerFieldName())
                                    .makeRef());
        } else {
            DefinitionStmt stmt = _getFieldDef(baseLocal, unit, localDefs);
            FieldRef ref = (FieldRef) stmt.getRightOp();
            SootField field = ref.getField();
            Entity entity = ModelTransformer.getEntityForField(field);
            Entity container = (Entity) entity.getContainer();
            return getLocalReferenceForEntity(container, sourceClass, body
                    .getThisLocal(), body, unit, _options);
View Full Code Here

        if (object != null) {
            // Then we are dealing with a getEntity call on one of the
            // classes we are generating.
            entity = ((CompositeEntity) object).getEntity(name);
        } else {
            DefinitionStmt stmt = _getFieldDef(baseLocal, unit, localDefs);
            FieldRef ref = (FieldRef) stmt.getRightOp();
            SootField field = ref.getField();
            CompositeEntity container = (CompositeEntity) ModelTransformer
                    .getEntityForField(field);
            entity = container.getEntity(name);
        }
View Full Code Here

    private static DefinitionStmt _getFieldDef(Local local, Unit location,
            LocalDefs localDefs) {
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof CastExpr) {
                return _getFieldDef((Local) ((CastExpr) value).getOp(), stmt,
                        localDefs);
            } else if (value instanceof FieldRef) {
View Full Code Here

 
  @Override
  protected void flowThrough(Map<Local, StringConstant> in, Unit d, Map<Local, StringConstant> out) {
    out.putAll(in);
    if (d instanceof DefinitionStmt) {
      DefinitionStmt def = (DefinitionStmt)d;
      if (def.getLeftOp() instanceof Local) {
        if (def.getRightOp() instanceof StringConstant) {
          out.put((Local)def.getLeftOp(), (StringConstant)def.getRightOp());
        } else {
          out.remove(def.getLeftOp());
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of soot.jimple.DefinitionStmt

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.