private void setNewVarIndices(VarTypeProcessor typeProcessor, DirectGraph graph) { final Map<VarVersionPair, VarType> mapExprentMaxTypes = typeProcessor.getMapExprentMaxTypes(); Map<VarVersionPair, VarType> mapExprentMinTypes = typeProcessor.getMapExprentMinTypes(); Map<VarVersionPair, Integer> mapFinalVars = typeProcessor.getMapFinalVars(); CounterContainer counters = DecompilerContext.getCounterContainer(); final Map<VarVersionPair, Integer> mapVarPaar = new HashMap<VarVersionPair, Integer>(); Map<Integer, Integer> mapOriginalVarIndices = new HashMap<Integer, Integer>(); // map var-version pairs on new var indexes Set<VarVersionPair> set = new HashSet<VarVersionPair>(mapExprentMinTypes.keySet()); for (VarVersionPair pair : set) { if (pair.version >= 0) { int newIndex = pair.version == 1 ? pair.var : counters.getCounterAndIncrement(CounterContainer.VAR_COUNTER); VarVersionPair newVar = new VarVersionPair(newIndex, 0); mapExprentMinTypes.put(newVar, mapExprentMinTypes.get(pair)); mapExprentMaxTypes.put(newVar, mapExprentMaxTypes.get(pair)); if (mapFinalVars.containsKey(pair)) { mapFinalVars.put(newVar, mapFinalVars.remove(pair)); } mapVarPaar.put(pair, newIndex); mapOriginalVarIndices.put(newIndex, pair.var); } } // set new vars graph.iterateExprents( new DirectGraph.ExprentIterator() { @Override public int processExprent(Exprent exprent) { List<Exprent> lst = exprent.getAllExprents(true); lst.add(exprent); for (Exprent expr : lst) { if (expr.type == Exprent.EXPRENT_VAR) { VarExprent newVar = (VarExprent) expr; Integer newVarIndex = mapVarPaar.get(new VarVersionPair(newVar)); if (newVarIndex != null) { newVar.setIndex(newVarIndex); newVar.setVersion(0); } } else if (expr.type == Exprent.EXPRENT_CONST) { VarType maxType = mapExprentMaxTypes.get(new VarVersionPair(expr.id, -1)); if (maxType != null && maxType.equals(VarType.VARTYPE_CHAR)) { ((ConstExprent) expr).setConstType(maxType); } } } return 0; } }); this.mapOriginalVarIndices = mapOriginalVarIndices; }
{ // set statement id id = DecompilerContext.getCounterContainer() .getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER); }