Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package soot.toolkits.scalar;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 - 1999 Raja Vallee-Rai
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import soot.Body;
import soot.BodyTransformer;
import soot.G;
import soot.IdentityUnit;
import soot.Local;
import soot.PhaseOptions;
import soot.Singletons;
import soot.Type;
import soot.Unit;
import soot.ValueBox;
import soot.jimple.GroupIntPair;
import soot.options.Options;
import soot.util.DeterministicHashMap;
/**
* A BodyTransformer that attemps to minimize the number of local variables used in Body by 'reusing' them when possible.
* Implemented as a singleton. For example the code:
*
* for(int i; i < k; i++); for(int j; j < k; j++);
*
* would be transformed into: for(int i; i < k; i++); for(int i; i < k; i++);
*
* assuming to further conflicting uses of i and j.
*
* Note: LocalSplitter is corresponds to the inverse transformation.
*
* @see BodyTransformer
* @see Body
* @see LocalSplitter
*/
public class LocalPacker extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(LocalPacker.class);
public LocalPacker(Singletons.Global g) {
}
public static LocalPacker v() {
return G.v().soot_toolkits_scalar_LocalPacker();
}
protected void internalTransform(Body body, String phaseName, Map options) {
boolean isUnsplit = PhaseOptions.getBoolean(options, "unsplit-original-locals");
if (Options.v().verbose()) {
logger.debug("[" + body.getMethod().getName() + "] Packing locals...");
}
Map localToGroup = new DeterministicHashMap(body.getLocalCount() * 2 + 1, 0.7f);
// A group represents a bunch of locals which may potentially interfere
// with each other
// 2 separate groups can not possibly interfere with each other
// (coloring say ints and doubles)
Map