@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.iconrow, null); } Local o = items.get(position); if (o != null) { // poblamos la lista de elementos TextView tt = (TextView) v.findViewById(R.id.row_toptext); TextView tta = (TextView) v.findViewById(R.id.row_bottomtext); ImageView im = (ImageView) v.findViewById(R.id.icon); if (im != null) { im.setImageResource(o.getLocalImage()); } if (tta != null) { tta.setText(o.getLocalMedida()); } if (tt != null) { tt.setText(o.getLocalName()); } } return v; }
public Reserva( String id, float preu, boolean penalitzacioTemps, boolean penalitzacioMoto, float penalitzacio, String dataInicial, String horaInicial, String dataFinal, String horaFinal, Local localInicial, Local localFinal, Client clientReserva, String idMoto) { this.id = id; this.preu = preu; this.penalitzacioTemps = penalitzacioTemps; this.penalitzacioMoto = penalitzacioMoto; this.penalitzacio = penalitzacio; this.dataInicial = Data.crearData(dataInicial, horaInicial); this.dataFinal = Data.crearData(dataFinal, horaFinal); this.localInicial = localInicial; this.localFinal = localFinal; this.clientReserva = clientReserva; if (localFinal.getMoto(idMoto) != null) { this.motoReserva = localFinal.getMoto(idMoto); } else { this.motoReserva = localInicial.getMoto(idMoto); } }
private void analyzeLocal(SootMethod method, Value value) { Local l = (Local) value; boolean objIsThreadLocal = tloa.isObjectThreadLocal(l, method); if (objIsThreadLocal) { G.v().out.println("[lg.tlo] LOCAL " + l.toString() + " is thread-local in method " + method); } else { G.v().out.println("[lg.tlo] LOCAL " + l.toString() + " is thread-shared in method " + method); } }
private void addLocalMap(Local local) { Marker lMarker = this.mMap.addMarker( new MarkerOptions() .title(local.getTitulo()) .snippet("Ver más detalles") .position(new LatLng(local.getLat(), local.getLng()))); mHashMap.put(lMarker, local); }
@java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { if (o == this) return true; if (!(o instanceof Local)) return false; final Local other = (Local) o; if (!other.canEqual((java.lang.Object) this)) return false; if (this.getX() != other.getX()) return false; return true; }
/** Prints the given <code>JimpleBody</code> to the specified <code>PrintWriter</code>. */ private void printLocalsInBody(Body body, UnitPrinter up) { // Print out local variables { Map typeToLocals = new DeterministicHashMap(body.getLocalCount() * 2 + 1, 0.7f); // Collect locals { Iterator localIt = body.getLocals().iterator(); while (localIt.hasNext()) { Local local = (Local) localIt.next(); List localList; Type t = local.getType(); if (typeToLocals.containsKey(t)) localList = (List) typeToLocals.get(t); else { localList = new ArrayList(); typeToLocals.put(t, localList); } localList.add(local); } } // Print locals { Iterator typeIt = typeToLocals.keySet().iterator(); while (typeIt.hasNext()) { Type type = (Type) typeIt.next(); List localList = (List) typeToLocals.get(type); Object[] locals = localList.toArray(); up.type(type); up.literal(" "); for (int k = 0; k < locals.length; k++) { if (k != 0) up.literal(", "); up.local((Local) locals[k]); } up.literal(";"); up.newline(); } } if (!typeToLocals.isEmpty()) { up.newline(); } } }
public long insertLocal(Local local) { String nullColumnHack = null; SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); ContentValues initialValues = new ContentValues(); initialValues.put(LATITUDE, local.getLatitude()); initialValues.put(LONGITUDE, local.getLongitude()); initialValues.put(NAME, local.getName()); // initialValues.put(ID_LOCALTYPE, local.getId_localType()); return sqlite.insert(TABLE, nullColumnHack, initialValues); }
public void outADeclaration(ADeclaration node) { List localNameList = (List) mProductions.removeLast(); Type type = (Type) mProductions.removeLast(); Iterator it = localNameList.iterator(); List localList = new ArrayList(); while (it.hasNext()) { Local l = Jimple.v().newLocal((String) it.next(), type); mLocals.put(l.getName(), l); localList.add(l); } mProductions.addLast(localList); }
public Local getLocal(Event event) { SQLiteDatabase sqliteDB = dbHelper.getReadableDatabase(); String s = "SELECT * FROM " + TABLE + " WHERE " + _ID + "=" + event.getId_local(); Cursor crsr = sqliteDB.rawQuery(s, null); crsr.moveToFirst(); Local local = new Local(crsr.getDouble(1), crsr.getDouble(2), crsr.getString(3)); local.setId(crsr.getInt(0)); crsr.close(); return local; }
/** * Get a <code>Local</code> instance to represent a value of a given type that will be * stored/loaded to/from a given local variable. * * @param type the type of the value * @param index the index of the local variable * @param isParameter true if the local is a parameter * @return the variable at index <code>index</code> in which values of type <code>type</code> are * stored */ private Local allocateLocalPrim(Klass type, int index, boolean isParameter) { Assert.that(localTypes.length < 0xFFFF); Assert.that( index >= 0 && index < localTypes.length, "index=" + index + " localTypes.length=" + localTypes.length); Klass localType = getLocalTypeFor(type); int key = localType.getSuiteID(); /* We need a hard partition between uses of a slot as a reference vs. an Address, Offset, or UWord. * The partitioning of java primitives and objects is accomplished not only by the type passed in here, but * by the bytecode verifier. We can't be sure that some bytecodes are refering to the same local variable * as both a reference and as a Squawk primitive. Without that kind of support we are conservative here * and force a clash whenever javac uses the same local index for a reference and a Squawk primitive. */ if (localType.isSquawkPrimitive()) { key = Klass.REFERENCE.getSuiteID(); } key = key << 16 | index; if (localValues == null) { localValues = new IntHashtable(); } Local local = (Local) localValues.get(key); if (local == null) { local = new Local(localType, index, isParameter); localValues.put(key, local); } /* * Ensure that the original class file does not use the same local variable * for both a Squawk primitive value and any other reference value. This prevents the * translator from having to do a complete liveness analysis to de-multiplex * such a local variable slot. Such de-multiplexing is required as Squawk primitives * are 'magically' translated into integers (or longs on a 64 bit system). */ if (localType.isSquawkPrimitive() || local.getType().isSquawkPrimitive()) { if (localType != local.getType()) { throw codeParser.verifyError( getBadAddressLocalVariableMessage(index, localType, local.getType())); } } // System.out.println("allocated: "+local+" index "+index); /// *if[SCOPEDLOCALVARIABLES]*/ codeParser.localVariableAllocated(codeParser.getCurrentIP(), local); /// *end[SCOPEDLOCALVARIABLES]*/ return local; }
public static Local createLocal(EOEditingContext editingContext, String cLocal) { Local eo = null; EOClassDescription classDescription = EOClassDescription.classDescriptionForEntityName(_Local.ENTITY_NAME); if (classDescription == null) { throw new IllegalArgumentException( "Could not find EOClassDescription for entity name '" + _Local.ENTITY_NAME + "' !"); } else { eo = (Local) classDescription.createInstanceWithEditingContext(editingContext, null); editingContext.insertObject(eo); } eo.setCLocal(cLocal); return eo; }
/** Metode que posa la moto de la reserva al seu local final. */ public void afegirMotoLocalFinal() { try { localFinal.afegirMoto(motoReserva); } catch (LlistaPlenaException ex) { Consola.escriu(ex.getMessage()); } }
public void caseInstanceFieldRef(InstanceFieldRef arg0) { Value base = arg0.getBase(); if (base instanceof Local == false) throw new UnsupportedOperationException("How do I handle base is not a local?"); Local local = (Local) base; Type type = local.getType(); if (type instanceof RefType == false) throw new UnsupportedOperationException("How do I handle type is not a ref type?"); RefType ref = (RefType) type; OpenCLField ocl_field = new OpenCLField(arg0.getField(), ref.getSootClass()); if (isLhs()) { m_output.append(ocl_field.getInstanceSetterInvoke(arg0.getBase())); } else { m_output.append(ocl_field.getInstanceGetterInvoke(arg0.getBase())); } setCheckException(); }
protected boolean differentPackageAndPrivate(RefType ref_inspecting) { RefType ref_type = (RefType) m_thisRef.getType(); SootClass this_class = getClassForType(ref_type); SootClass class_inspecting = getClassForType(ref_inspecting); if (this_class.getPackageName().equals(class_inspecting.getPackageName())) return false; if (class_inspecting.isPublic() == false) return true; return false; }
/** Flatten complex expressions within the AST */ public Node leave(Node old, Node n, NodeVisitor v) { if (n == noFlatten) { noFlatten = null; return n; } if (n instanceof Block) { List l = (List) stack.removeFirst(); return ((Block) n).statements(l); } else if (n instanceof Stmt && !(n instanceof LocalDecl)) { List l = (List) stack.getFirst(); l.add(n); return n; } else if (n instanceof Expr && !(n instanceof Lit) && !(n instanceof Special) && !(n instanceof Local)) { Expr e = (Expr) n; if (e instanceof Assign) { return n; } // create a local temp, initialized to the value of the complex // expression String name = newID(); LocalDecl def = nf.LocalDecl( e.position(), Flags.FINAL, nf.CanonicalTypeNode(e.position(), e.type()), name, e); def = def.localInstance(ts.localInstance(e.position(), Flags.FINAL, e.type(), name)); List l = (List) stack.getFirst(); l.add(def); // return the local temp instead of the complex expression Local use = nf.Local(e.position(), name); use = (Local) use.type(e.type()); use = use.localInstance(ts.localInstance(e.position(), Flags.FINAL, e.type(), name)); return use; } return n; }
public Local getLocalByName(String name) { SQLiteDatabase sqliteDB = dbHelper.getReadableDatabase(); String s = "SELECT * FROM " + TABLE + " WHERE " + NAME + "='" + name + "'"; Cursor crsr2 = sqliteDB.rawQuery(s, null); if (crsr2.getCount() > 0) { crsr2.moveToFirst(); Local local = new Local(crsr2.getDouble(1), crsr2.getDouble(2), crsr2.getString(3)); local.setId(crsr2.getInt(0)); crsr2.close(); return local; } return null; }
/** Perform the appropriate flow operations for assignment to a local variable */ protected Map flowLocalAssign( DataFlowItem inItem, FlowGraph graph, LocalAssign a, Set succEdgeKeys) { Local l = (Local) a.left(); Map m = new HashMap(inItem.initStatus); MinMaxInitCount initCount = (MinMaxInitCount) m.get(l.localInstance()); // initcount could be null if the local is defined in the outer // class, or if we have not yet seen its declaration (i.e. the // local is used in its own initialization) if (initCount == null) { initCount = new MinMaxInitCount(InitCount.ZERO, InitCount.ZERO); } initCount = new MinMaxInitCount(initCount.getMin().increment(), initCount.getMax().increment()); m.put(l.localInstance(), initCount); return itemToMap(new DataFlowItem(m), succEdgeKeys); }
/** * Emulates the storing of a value to a local variable. * * @param index the index of the local variable being stored to * @param type the type of the value * @param local the variable to which the value is stored */ public void store(int index, Klass type, Local local) { Klass localType = local.getType(); Assert.that(localType.isAssignableFrom(type) || localType == getLocalTypeFor(type)); verifyLocalVariableIndex(localType, index); localTypes[index] = type; if (localType.isDoubleWord()) { localTypes[index + 1] = Klass.getSecondWordType(localType); } else { verifyUseOfSquawkPrimitive(localType, type); } }
public int updateServerID(Local local, String server_id) { SQLiteDatabase sqliteDB = dbHelper.getReadableDatabase(); ContentValues values = new ContentValues(); values.put(SERVER_ID, server_id); // updating row return sqliteDB.update( TABLE, values, _ID + " = ?", new String[] {String.valueOf(local.getId())}); }
/** * Create a method conveniently. The method is added to the class "TestClass". Parameters can be * given as an (positional) array of local variables (the "identity statements", required by Soot * to map parameters to local variables, are inserted automatically) */ public SootMethod makeMethod( int modifier, String name, List<Local> params, soot.Type retType, List<Unit> bodyStmts) { SootMethod m = new SootMethod( name, params.stream().map(Local::getType).collect(toList()), retType, modifier); this.testClass.addMethod(m); Body body = Jimple.v().newBody(m); m.setActiveBody(body); // set the statements for the body.. first the identity statements, then the bodyStmts if (!m.isStatic()) { body.getLocals().add(localThis); body.getUnits() .add(Jimple.v().newIdentityStmt(localThis, Jimple.v().newThisRef(testClass.getType()))); } IntStream.range(0, params.size()) .forEach( pos -> { Local l = params.get(pos); ParameterRef pr = Jimple.v().newParameterRef(l.getType(), pos); body.getUnits().add(Jimple.v().newIdentityStmt(l, pr)); }); body.getUnits().addAll(bodyStmts); // set the locals for the body Set<Local> locals = Stream.concat( params.stream(), body.getUseAndDefBoxes() .stream() .filter(b -> b.getValue() instanceof Local) .map(b -> (Local) b.getValue())) .collect(toSet()); locals.removeAll(body.getLocals()); body.getLocals().addAll(locals); return m; }
@Override public String toString() { String str; str = "\nReserva amb ID: " + id + "\n"; str += "--------------------------------------\n"; str += "Client: " + clientReserva.getId() + "\n"; str += "Moto: " + motoReserva.getIdMoto() + "\n"; str += "Cost: " + preu + "€\n"; if (penalitzacioMoto) { str += "La moto té algun desperfecte.\n"; } else { str += "La moto s'ha retornat amb bon estat.\n"; } if (penalitzacioTemps) { str += "La moto no s'ha retornat a temps.\n"; } else { str += "La moto s'ha retornat a temps.\n"; } str += "Local d'inici: " + localInicial.toString() + "\n"; str += "Data d'inici: " + dataInicial.toString() + "\n"; str += "Local de finalització: " + localFinal.toString() + "\n"; str += "Data de finalització: " + dataFinal.toString() + "\n"; return str; }
/** Check that the local variable <code>l</code> is used correctly. */ protected void checkLocal(FlowGraph graph, Local l, DataFlowItem dfIn, DataFlowItem dfOut) throws SemanticException { if (!currCBI.localDeclarations.contains(l.localInstance())) { // it's a local variable that has not been declared within // this scope. The only way this can arise is from an // inner class that is not a member of a class (typically // a local class, or an anonymous class declared in a method, // constructor or initializer). // We need to check that it is a final local, and also // keep track of it, to ensure that it has been definitely // assigned at this point. currCBI.outerLocalsUsed.add(l.localInstance()); } else { MinMaxInitCount initCount = (MinMaxInitCount) dfIn.initStatus.get(l.localInstance()); if (initCount != null && InitCount.ZERO.equals(initCount.getMin())) { // the local variable may not have been initialized. // However, we only want to complain if the local is reachable if (l.reachable()) { throw new SemanticException( "Local variable \"" + l.name() + "\" may not have been initialized", l.position()); } } } }
/** * Creates a Frame instance to emulate and verify the execution of a single class file method. * * @param codeParser the parser used to parse the "Code" attribute of the method being emulated * @param extraLocals the number of extra local variables needed */ public Frame(CodeParser codeParser, int extraLocals) { this.maxStack = codeParser.getMaxStack(); this.codeParser = codeParser; /* * Initialize the operand stack */ stack = new StackProducer[maxStack]; /* * Initialize the types in the local variables */ localTypes = new Klass[codeParser.getMaxLocals() + extraLocals]; Method method = codeParser.getMethod(); Klass[] parameterTypes = method.getParameterTypes(); Local[] parameterLocals = null; if (Translator.REVERSE_PARAMETERS && method.isInterpreterInvoked()) { parameterLocals = new Local[parameterTypes.length]; } int javacIndex = 0; /* * Initialize 'this' in non-static methods. The type of 'this' is * UNINITIALIZED_THIS if this method is a constructor in any class * except java.lang.Object otherwise it is the class in which the * method was defined. */ if (!method.isStatic() || method.isConstructor()) { Assert.that(parameterLocals == null); Klass thisType = method.getDefiningClass(); if (method.isConstructor() && thisType != Klass.OBJECT) { thisType = Klass.UNINITIALIZED_THIS; } Local thisLocal = allocateParameter(thisType, javacIndex); store(javacIndex, thisType, thisLocal); javacIndex++; } /* * Initialize locals for the parameters. */ int parameterIndex = javacIndex; for (int i = 0; i < parameterTypes.length; i++) { Klass parameterType = parameterTypes[i]; Local parameterLocal = allocateParameter(parameterType, javacIndex); if (parameterLocals != null) { parameterLocals[i] = parameterLocal; } if (Klass.SQUAWK_64) { if (javacIndex != parameterIndex) { Assert.that(parameterIndex < javacIndex); parameterLocal.setParameterIndex(parameterIndex); } parameterIndex++; } store(javacIndex, parameterType, parameterLocal); javacIndex += (parameterType.isDoubleWord() ? 2 : 1); } parameterLocalsCount = javacIndex; /* * Adjust the parameter offsets for parameter order reversal. */ if (parameterLocals != null) { parameterIndex = 0; for (int i = parameterTypes.length - 1; i >= 0; i--) { Klass parameterType = parameterTypes[i]; parameterLocals[i].setParameterIndex(parameterIndex++); if (!Klass.SQUAWK_64 && parameterType.isDoubleWord()) { parameterIndex++; } } } /* * Initialize the remaining local variables to the TOP type */ while (javacIndex < localTypes.length) { localTypes[javacIndex++] = Klass.TOP; } }
private Value mutate(Value value) { if (value instanceof FieldRef) { FieldRef ref = (FieldRef) value; SootField field = ref.getField(); Type type = field.getType(); if (type instanceof RefType) { RefType ref_type = (RefType) type; SootClass soot_class = ref_type.getSootClass(); if (shouldMap(soot_class)) { addField(field, ref); } } else if (type instanceof ArrayType) { ArrayType array_type = (ArrayType) type; Type base_type = array_type.baseType; if (base_type instanceof RefType) { RefType ref_type = (RefType) base_type; SootClass soot_class = ref_type.getSootClass(); if (shouldMap(soot_class)) { addField(field, ref); } } } SootClass soot_class = field.getDeclaringClass(); if (shouldMap(soot_class)) { addField(field, ref); } return value; } else if (value instanceof InvokeExpr) { InvokeExpr expr = (InvokeExpr) value; SootMethodRef ref = expr.getMethodRef(); SootClass soot_class = ref.declaringClass(); final NumberedString subSignature = ref.getSubSignature(); if (shouldMap(soot_class)) { SootClass new_class = getMapping(soot_class); if (new_class.declaresMethod(subSignature)) { SootMethod new_method = RootbeerScene.v().getMethod(new_class, subSignature.getString()); addAddedMethod(new_method); fixArguments(new_method); RootbeerScene.v().getDfsInfo().addReachableMethodSig(new_method.getSignature()); expr.setMethodRef(new_method.makeRef()); } } else { if (soot_class.declaresMethod(ref.getSubSignature())) { SootMethod method = soot_class.getMethod(ref.getSubSignature()); fixArguments(method); } } ref = remapRef(ref); try { if (shouldMap(soot_class)) { soot_class = getMapping(soot_class); } SootMethod method = soot_class.getMethod(ref.getSubSignature()); RootbeerScene.v().getDfsInfo().addReachableMethodSig(method.getSignature()); expr.setMethodRef(method.makeRef()); } catch (Exception ex) { // ex.printStackTrace(); } return value; } else if (value instanceof NewExpr) { NewExpr expr = (NewExpr) value; RefType base_type = expr.getBaseType(); SootClass soot_class = base_type.getSootClass(); if (shouldMap(soot_class)) { SootClass new_class = getMapping(soot_class); expr.setBaseType(new_class.getType()); } return value; } else if (value instanceof NewArrayExpr) { NewArrayExpr expr = (NewArrayExpr) value; Type base_type = expr.getBaseType(); base_type = fixType(base_type); expr.setBaseType(base_type); return value; } else if (value instanceof NewMultiArrayExpr) { NewMultiArrayExpr expr = (NewMultiArrayExpr) value; ArrayType array_type = expr.getBaseType(); Type base_type = array_type.baseType; if (base_type instanceof RefType) { RefType ref_type = (RefType) base_type; SootClass soot_class = ref_type.getSootClass(); if (shouldMap(soot_class)) { SootClass new_class = getMapping(soot_class); ArrayType new_type = ArrayType.v(new_class.getType(), array_type.numDimensions); expr.setBaseType(new_type); } } return value; } else if (value instanceof CastExpr) { CastExpr expr = (CastExpr) value; Type cast_type = expr.getCastType(); cast_type = fixType(cast_type); expr.setCastType(cast_type); return value; } else if (value instanceof ParameterRef) { ParameterRef ref = (ParameterRef) value; Type new_type = fixType(ref.getType()); return new ParameterRef(new_type, ref.getIndex()); } else if (value instanceof ThisRef) { ThisRef ref = (ThisRef) value; Type new_type = fixType(ref.getType()); return new ThisRef((RefType) new_type); } else if (value instanceof Local) { Local local = (Local) value; Type type = local.getType(); local.setType(fixType(type)); return value; } else { return value; } }
/** Returns the set of objects pointed to by variable l. */ public PointsToSet reachingObjects(Local l) { Type t = l.getType(); if (t instanceof RefType) return FullObjectSet.v((RefType) t); return FullObjectSet.v(); }
private static boolean internalAggregate( StmtBody body, Map<ValueBox, Zone> boxToZone, boolean onlyStackVars) { LocalUses localUses; LocalDefs localDefs; ExceptionalUnitGraph graph; boolean hadAggregation = false; Chain<Unit> units = body.getUnits(); graph = new ExceptionalUnitGraph(body); localDefs = new SmartLocalDefs(graph, new SimpleLiveLocals(graph)); localUses = new SimpleLocalUses(graph, localDefs); List<Unit> unitList = new PseudoTopologicalOrderer<Unit>().newList(graph, false); for (Unit u : unitList) { if (!(u instanceof AssignStmt)) continue; AssignStmt s = (AssignStmt) u; Value lhs = s.getLeftOp(); if (!(lhs instanceof Local)) continue; Local lhsLocal = (Local) lhs; if (onlyStackVars && !lhsLocal.getName().startsWith("$")) continue; List<UnitValueBoxPair> lu = localUses.getUsesOf(s); if (lu.size() != 1) continue; UnitValueBoxPair usepair = lu.get(0); Unit use = usepair.unit; ValueBox useBox = usepair.valueBox; List<Unit> ld = localDefs.getDefsOfAt(lhsLocal, use); if (ld.size() != 1) continue; // Check to make sure aggregation pair in the same zone if (boxToZone.get(s.getRightOpBox()) != boxToZone.get(usepair.valueBox)) { continue; } /* we need to check the path between def and use */ /* to see if there are any intervening re-defs of RHS */ /* in fact, we should check that this path is unique. */ /* if the RHS uses only locals, then we know what to do; if RHS has a method invocation f(a, b, c) or field access, we must ban field writes, other method calls and (as usual) writes to a, b, c. */ boolean cantAggr = false; boolean propagatingInvokeExpr = false; boolean propagatingFieldRef = false; boolean propagatingArrayRef = false; ArrayList<FieldRef> fieldRefList = new ArrayList<FieldRef>(); LinkedList<Value> localsUsed = new LinkedList<Value>(); for (ValueBox vb : s.getUseBoxes()) { Value v = vb.getValue(); if (v instanceof Local) localsUsed.add(v); else if (v instanceof InvokeExpr) propagatingInvokeExpr = true; else if (v instanceof ArrayRef) propagatingArrayRef = true; else if (v instanceof FieldRef) { propagatingFieldRef = true; fieldRefList.add((FieldRef) v); } } // look for a path from s to use in graph. // only look in an extended basic block, though. List<Unit> path = graph.getExtendedBasicBlockPathBetween(s, use); if (path == null) continue; Iterator<Unit> pathIt = path.iterator(); // skip s. if (pathIt.hasNext()) pathIt.next(); while (pathIt.hasNext() && !cantAggr) { Stmt between = (Stmt) (pathIt.next()); if (between != use) { // Check for killing definitions for (ValueBox vb : between.getDefBoxes()) { Value v = vb.getValue(); if (localsUsed.contains(v)) { cantAggr = true; break; } if (propagatingInvokeExpr || propagatingFieldRef || propagatingArrayRef) { if (v instanceof FieldRef) { if (propagatingInvokeExpr) { cantAggr = true; break; } else if (propagatingFieldRef) { // Can't aggregate a field access if passing a definition of a field // with the same name, because they might be aliased for (FieldRef fieldRef : fieldRefList) { if (((FieldRef) v).getField() == fieldRef.getField()) { cantAggr = true; break; } } } } else if (v instanceof ArrayRef) { if (propagatingInvokeExpr) { // Cannot aggregate an invoke expr past an array write cantAggr = true; break; } else if (propagatingArrayRef) { // cannot aggregate an array read past a write // this is somewhat conservative // (if types differ they may not be aliased) cantAggr = true; break; } } } } // Make sure not propagating past a {enter,exit}Monitor if (propagatingInvokeExpr && between instanceof MonitorStmt) cantAggr = true; } // Check for intervening side effects due to method calls if (propagatingInvokeExpr || propagatingFieldRef || propagatingArrayRef) { for (final ValueBox box : between.getUseBoxes()) { if (between == use && box == useBox) { // Reached use point, stop looking for // side effects break; } Value v = box.getValue(); if (v instanceof InvokeExpr || (propagatingInvokeExpr && (v instanceof FieldRef || v instanceof ArrayRef))) { cantAggr = true; break; } } } } // we give up: can't aggregate. if (cantAggr) { continue; } /* assuming that the d-u chains are correct, */ /* we need not check the actual contents of ld */ Value aggregatee = s.getRightOp(); if (usepair.valueBox.canContainValue(aggregatee)) { boolean wasSimpleCopy = isSimpleCopy(usepair.unit); usepair.valueBox.setValue(aggregatee); units.remove(s); hadAggregation = true; // clean up the tags. If s was not a simple copy, the new statement should get // the tags of s. // OK, this fix was wrong. The condition should not be // "If s was not a simple copy", but rather "If usepair.unit // was a simple copy". This way, when there's a load of a constant // followed by an invoke, the invoke gets the tags. if (wasSimpleCopy) { // usepair.unit.removeAllTags(); usepair.unit.addAllTagsOf(s); } } else { /* if(Options.v().verbose()) { G.v().out.println("[debug] failed aggregation"); G.v().out.println("[debug] tried to put "+aggregatee+ " into "+usepair.stmt + ": in particular, "+usepair.valueBox); G.v().out.println("[debug] aggregatee instanceof Expr: " +(aggregatee instanceof Expr)); }*/ } } return hadAggregation; }
@ConstructorDescriptor("EnclosingConstructorTests()") EnclosingConstructorTests() { class Local {}; Local l = new Local(); localClass = l.getClass(); }
public void caseLocal(Local arg0) { m_output.append(" " + arg0.getName() + " "); m_previousLocal = arg0.getName(); }
protected SootClass getGcVisitorClass(Local visitor) { RefType type = (RefType) visitor.getType(); SootClass gc_visitor = Scene.v().getSootClass(type.getClassName()); return gc_visitor; }
@ConstructorDescriptor("private EnclosingConstructorTests(int)") private EnclosingConstructorTests(int i) { class Local {}; Local l = new Local(); anotherLocalClass = l.getClass(); }