proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
soot-oss_soot | soot/src/main/java/soot/toDex/instructions/Insn35c.java | Insn35c | getIncompatibleRegs | class Insn35c extends AbstractInsn implements FiveRegInsn {
private int regCount;
private final Reference referencedItem;
public Insn35c(Opcode opc, int regCount, Register regD, Register regE, Register regF, Register regG, Register regA,
Reference referencedItem) {
super(opc);
this.regCount = reg... |
BitSet incompatRegs = new BitSet(5);
int[] realRegNumbers = getRealRegNumbers();
for (int i = 0; i < realRegNumbers.length; i++) {
// real regs aren't wide, because those are represented as two non-wide regs
boolean isCompatible = Register.fitsByte(realRegNumbers[i], false);
if (!isCompat... | 921 | 236 | 1,157 | <methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int g... |
soot-oss_soot | soot/src/main/java/soot/toDex/instructions/Insn3rc.java | Insn3rc | getIncompatibleRegs | class Insn3rc extends AbstractInsn {
private short regCount;
private Reference referencedItem;
public Insn3rc(Opcode opc, List<Register> regs, short regCount, Reference referencedItem) {
super(opc);
this.regs = regs;
this.regCount = regCount;
this.referencedItem = referencedItem;
}
@Overri... |
// if there is one problem -> all regs are incompatible (this could be optimized in reg allocation, probably)
int regCount = SootToDexUtils.getRealRegCount(regs);
if (hasHoleInRange()) {
return getAllIncompatible(regCount);
}
for (Register r : regs) {
if (!r.fitsUnconstrained()) {
... | 503 | 195 | 698 | <methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int g... |
soot-oss_soot | soot/src/main/java/soot/toDex/instructions/Insn51l.java | Insn51l | getIncompatibleRegs | class Insn51l extends AbstractInsn implements OneRegInsn {
private long litB;
public Insn51l(Opcode opc, Register regA, long litB) {
super(opc);
regs.add(regA);
this.litB = litB;
}
public Register getRegA() {
return regs.get(REG_A_IDX);
}
public long getLitB() {
return litB;
}
@... |
BitSet incompatRegs = new BitSet(1);
if (!getRegA().fitsShort()) {
incompatRegs.set(REG_A_IDX);
}
return incompatRegs;
| 249 | 57 | 306 | <methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int g... |
soot-oss_soot | soot/src/main/java/soot/toDex/instructions/InsnWithOffset.java | InsnWithOffset | setTarget | class InsnWithOffset extends AbstractInsn {
protected Stmt target;
public InsnWithOffset(Opcode opc) {
super(opc);
}
public void setTarget(Stmt target) {<FILL_FUNCTION_BODY>}
public Stmt getTarget() {
return this.target;
}
/**
* Gets the maximum number of words available for the jump offse... |
if (target == null) {
throw new RuntimeException("Cannot jump to a NULL target");
}
this.target = target;
| 143 | 37 | 180 | <methods>public void <init>(org.jf.dexlib2.Opcode) ,public java.util.BitSet getIncompatibleRegs() ,public int getMinimumRegsNeeded() ,public org.jf.dexlib2.Opcode getOpcode() ,public org.jf.dexlib2.builder.BuilderInstruction getRealInsn(soot.toDex.LabelAssigner) ,public List<soot.toDex.Register> getRegs() ,public int g... |
soot-oss_soot | soot/src/main/java/soot/toolkits/astmetrics/ASTMetric.java | ASTMetric | leave | class ASTMetric extends NodeVisitor implements MetricInterface {
polyglot.ast.Node astNode;
String className = null; // name of Class being currently processed
public ASTMetric(polyglot.ast.Node astNode) {
this.astNode = astNode;
reset();
}
/*
* Taking care of the change in classes within a polyg... |
if (n instanceof ClassDecl) {
if (className == null) {
throw new RuntimeException("className is null");
}
System.out.println("Done with class " + className);
// get the classData object for this class
ClassData data = getClassData();
addMetrics(data);
reset();
... | 602 | 99 | 701 | <methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.No... |
soot-oss_soot | soot/src/main/java/soot/toolkits/astmetrics/AbruptEdgesMetric.java | AbruptEdgesMetric | enter | class AbruptEdgesMetric extends ASTMetric {
private int iBreaks, eBreaks;
private int iContinues, eContinues;
public AbruptEdgesMetric(polyglot.ast.Node astNode) {
super(astNode);
}
/*
* (non-Javadoc)
*
* @see soot.toolkits.astmetrics.ASTMetric#reset() Implementation of the abstract method whi... |
if (n instanceof Branch) {
Branch branch = (Branch) n;
if (branch.kind().equals(Branch.BREAK)) {
if (branch.label() != null) {
eBreaks++;
} else {
iBreaks++;
}
} else if (branch.kind().equals(Branch.CONTINUE)) {
if (branch.label() != null) {
... | 481 | 173 | 654 | <methods>public void <init>(polyglot.ast.Node) ,public abstract void addMetrics(soot.toolkits.astmetrics.ClassData) ,public final polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public final void execute() ,public final soot.toolkits.astmetrics.ClassData getClassData() ,public final polyglot.ast.Node leave(polyglo... |
soot-oss_soot | soot/src/main/java/soot/toolkits/astmetrics/ClassData.java | ClassData | addMetric | class ClassData {
String className; // the name of the class whose data is being stored
ArrayList<MetricData> metricData; // each element should be a MetricData
public ClassData(String name) {
className = name;
metricData = new ArrayList<MetricData>();
}
public String getClassName() {
return cla... |
Iterator<MetricData> it = metricData.iterator();
while (it.hasNext()) {
MetricData temp = it.next();
if (temp.metricName.equals(data.metricName)) {
// System.out.println("Not adding same metric again......"+temp.metricName);
return;
}
}
metricData.add(data);
| 311 | 99 | 410 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/astmetrics/ComputeASTMetrics.java | ComputeASTMetrics | apply | class ComputeASTMetrics {
ArrayList<ASTMetric> metrics;
/*
* New metrics should be added into the metrics linked list
*/
public ComputeASTMetrics(Node astNode) {
metrics = new ArrayList<ASTMetric>();
// add new metrics below this line
// REMEMBER ALL METRICS NEED TO implement MetricInterface
... |
if (!Options.v().ast_metrics()) {
return;
}
Iterator<ASTMetric> metricIt = metrics.iterator();
while (metricIt.hasNext()) {
metricIt.next().execute();
}
| 242 | 65 | 307 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/astmetrics/ConditionComplexityMetric.java | ConditionComplexityMetric | condComplexity | class ConditionComplexityMetric extends ASTMetric {
int loopComplexity;
int ifComplexity;
public ConditionComplexityMetric(polyglot.ast.Node node) {
super(node);
}
public void reset() {
loopComplexity = ifComplexity = 0;
}
public void addMetrics(ClassData data) {
data.addMetric(new MetricDa... |
// boolean literal
// binary check for AND and OR ... else its relational!!
// unary (Check for NOT)
if (expr instanceof Binary) {
Binary b = (Binary) expr;
if (b.operator() == Binary.COND_AND || b.operator() == Binary.COND_OR) {
// System.out.println(">>>>>>>> Binary (AND or OR) ... | 330 | 351 | 681 | <methods>public void <init>(polyglot.ast.Node) ,public abstract void addMetrics(soot.toolkits.astmetrics.ClassData) ,public final polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public final void execute() ,public final soot.toolkits.astmetrics.ClassData getClassData() ,public final polyglot.ast.Node leave(polyglo... |
soot-oss_soot | soot/src/main/java/soot/toolkits/astmetrics/ConstructNumbersMetric.java | ConstructNumbersMetric | enter | class ConstructNumbersMetric extends ASTMetric {
private int numIf, numIfElse;
private int numLabeledBlocks;
private int doLoop, forLoop, whileLoop, whileTrue;
public ConstructNumbersMetric(Node node) {
super(node);
}
public void reset() {
numIf = numIfElse = 0;
numLabeledBlocks = 0;
do... |
/*
* Num if and ifelse
*/
if (n instanceof If) {
// check if there is the "optional" else branch present
If ifNode = (If) n;
Stmt temp = ifNode.alternative();
if (temp == null) {
// else branch is empty
// System.out.println("This was an if stmt"+n);
n... | 415 | 426 | 841 | <methods>public void <init>(polyglot.ast.Node) ,public abstract void addMetrics(soot.toolkits.astmetrics.ClassData) ,public final polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public final void execute() ,public final soot.toolkits.astmetrics.ClassData getClassData() ,public final polyglot.ast.Node leave(polyglo... |
soot-oss_soot | soot/src/main/java/soot/toolkits/astmetrics/MetricData.java | MetricData | toString | class MetricData {
String metricName;
Object value;
public MetricData(String name, Object val) {
metricName = name;
value = val;
}
public String toString() {<FILL_FUNCTION_BODY>}
} |
StringBuffer b = new StringBuffer();
b.append("<Metric>\n");
b.append(" <MetricName>" + metricName + "</MetricName>\n");
b.append(" <Value>" + value.toString() + "</Value>\n");
b.append("</Metric>\n");
return b.toString();
| 71 | 97 | 168 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/astmetrics/StmtSumWeightedByDepth.java | StmtSumWeightedByDepth | leave | class StmtSumWeightedByDepth extends ASTMetric {
int currentDepth;
int sum;
int maxDepth;
int numNodes;
Stack<ArrayList> labelNodesSoFar = new Stack<ArrayList>();
ArrayList<Node> blocksWithAbruptFlow = new ArrayList<Node>();
HashMap<Node, Integer> stmtToMetric = new HashMap<Node, Integer>();
HashMap<N... |
// stack maintenance, if leaving a method
if (n instanceof CodeDecl) {
labelNodesSoFar.pop();
}
if (n instanceof If || n instanceof Loop || n instanceof Try || n instanceof Switch || n instanceof LocalClassDecl
|| n instanceof Synchronized || n instanceof ProcedureDecl || n instanceof I... | 1,387 | 125 | 1,512 | <methods>public void <init>(polyglot.ast.Node) ,public abstract void addMetrics(soot.toolkits.astmetrics.ClassData) ,public final polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public final void execute() ,public final soot.toolkits.astmetrics.ClassData getClassData() ,public final polyglot.ast.Node leave(polyglo... |
soot-oss_soot | soot/src/main/java/soot/toolkits/exceptions/DuplicateCatchAllTrapRemover.java | DuplicateCatchAllTrapRemover | internalTransform | class DuplicateCatchAllTrapRemover extends BodyTransformer {
public DuplicateCatchAllTrapRemover(Singletons.Global g) {
}
public static DuplicateCatchAllTrapRemover v() {
return soot.G.v().soot_toolkits_exceptions_DuplicateCatchAllTrapRemover();
}
@Override
protected void internalTransform(Body b, St... |
// Find two traps that use java.lang.Throwable as their type and that
// span the same code region
for (Iterator<Trap> t1It = b.getTraps().snapshotIterator(); t1It.hasNext();) {
Trap t1 = t1It.next();
if (t1.getException().getName().equals(Scene.v().getBaseExceptionType().toString())) {
... | 341 | 511 | 852 | <methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyM... |
soot-oss_soot | soot/src/main/java/soot/toolkits/exceptions/ThrowAnalysisFactory.java | ThrowAnalysisFactory | checkInitThrowAnalysis | class ThrowAnalysisFactory {
/**
* Resolve the ThrowAnalysis to be used for initialization checking (e.g. soot.Body.checkInit())
*/
public static ThrowAnalysis checkInitThrowAnalysis() {<FILL_FUNCTION_BODY>}
private ThrowAnalysisFactory() {
}
} |
final Options opts = Options.v();
switch (opts.check_init_throw_analysis()) {
case Options.check_init_throw_analysis_auto:
if (!opts.android_jars().isEmpty() || !opts.force_android_jar().isEmpty()) {
// If Android related options are set, use 'dalvik' throw analysis.
return Da... | 83 | 227 | 310 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/exceptions/TrapTightener.java | TrapTightener | internalTransform | class TrapTightener extends TrapTransformer {
private static final Logger logger = LoggerFactory.getLogger(TrapTightener.class);
protected ThrowAnalysis throwAnalysis = null;
public TrapTightener(Singletons.Global g) {
}
public static TrapTightener v() {
return soot.G.v().soot_toolkits_exceptions_TrapT... |
if (this.throwAnalysis == null) {
this.throwAnalysis = Scene.v().getDefaultThrowAnalysis();
}
if (Options.v().verbose()) {
logger.debug("[" + body.getMethod().getName() + "] Tightening trap boundaries...");
}
Chain<Trap> trapChain = body.getTraps();
Chain<Unit> unitChain = body.ge... | 400 | 765 | 1,165 | <methods>public non-sealed void <init>() ,public Set<soot.Unit> getUnitsWithMonitor(soot.toolkits.graph.UnitGraph) <variables> |
soot-oss_soot | soot/src/main/java/soot/toolkits/exceptions/TrapTransformer.java | TrapTransformer | getUnitsWithMonitor | class TrapTransformer extends BodyTransformer {
public Set<Unit> getUnitsWithMonitor(UnitGraph ug) {<FILL_FUNCTION_BODY>}
} |
// Idea: Associate each unit with a set of monitors held at that
// statement
MultiMap<Unit, Value> unitMonitors = new HashMultiMap<>();
// Start at the heads of the unit graph
List<Unit> workList = new ArrayList<>();
Set<Unit> doneSet = new HashSet<>();
for (Unit head : ug.getHeads()) {
... | 45 | 419 | 464 | <methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyM... |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/ArrayRefBlockGraph.java | ArrayRefBlockGraph | computeLeaders | class ArrayRefBlockGraph extends BlockGraph {
/**
* <p>
* Constructs an {@link ArrayRefBlockGraph} from the given {@link Body}.
* </p>
*
* <p>
* Note that this constructor builds a {@link BriefUnitGraph} internally when splitting <tt>body</tt>'s {@link Unit}s into
* {@link Block}s. Callers who ne... |
Body body = unitGraph.getBody();
if (body != mBody) {
throw new RuntimeException(
"ArrayRefBlockGraph.computeLeaders() called with a UnitGraph that doesn't match its mBody.");
}
Set<Unit> leaders = super.computeLeaders(unitGraph);
for (Unit unit : body.getUnits()) {
if (((uni... | 705 | 152 | 857 | <methods>public List<soot.toolkits.graph.Block> getBlocks() ,public soot.Body getBody() ,public List<soot.toolkits.graph.Block> getHeads() ,public List<soot.toolkits.graph.Block> getPredsOf(soot.toolkits.graph.Block) ,public List<soot.toolkits.graph.Block> getSuccsOf(soot.toolkits.graph.Block) ,public List<soot.toolkit... |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/ClassicCompleteUnitGraph.java | ClassicCompleteUnitGraph | buildExceptionalEdges | class ClassicCompleteUnitGraph extends TrapUnitGraph {
/**
* Constructs the graph from a given Body instance.
*
* @param body
* the Body instance from which the graph is built.
*/
public ClassicCompleteUnitGraph(Body body) {
// The TrapUnitGraph constructor will use our buildExceptionalE... |
// First, add the same edges as TrapUnitGraph.
super.buildExceptionalEdges(unitToSuccs, unitToPreds);
// Then add edges from the predecessors of the first
// trapped Unit for each Trap.
for (Trap trap : body.getTraps()) {
Unit catcher = trap.getHandlerUnit();
// Make a copy of firstTrap... | 399 | 254 | 653 | <methods>public void <init>(soot.Body) <variables> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/CytronDominanceFrontier.java | CytronDominanceFrontier | processNode | class CytronDominanceFrontier<N> implements DominanceFrontier<N> {
protected DominatorTree<N> dt;
protected Map<DominatorNode<N>, List<DominatorNode<N>>> nodeToFrontier;
public CytronDominanceFrontier(DominatorTree<N> dt) {
this.dt = dt;
this.nodeToFrontier = new HashMap<DominatorNode<N>, List<Dominator... |
HashSet<DominatorNode<N>> dominanceFrontier = new HashSet<DominatorNode<N>>();
// local
for (DominatorNode<N> succ : dt.getSuccsOf(node)) {
if (!dt.isImmediateDominatorOf(node, succ)) {
dominanceFrontier.add(succ);
}
}
// up
for (DominatorNode<N> child : dt.getChildrenOf(n... | 851 | 222 | 1,073 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/DominatorNode.java | DominatorNode | addChild | class DominatorNode<N> {
protected N gode;
protected DominatorNode<N> parent;
protected List<DominatorNode<N>> children;
protected DominatorNode(N gode) {
this.gode = gode;
this.children = new ArrayList<DominatorNode<N>>();
}
/**
* Sets the parent of this node in the DominatorTree. Usually cal... |
if (children.contains(child)) {
return false;
} else {
children.add(child);
return true;
}
| 473 | 40 | 513 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/DominatorTree.java | DominatorTree | fetchParent | class DominatorTree<N> implements Iterable<DominatorNode<N>> {
private static final Logger logger = LoggerFactory.getLogger(DominatorTree.class);
protected final DominatorsFinder<N> dominators;
protected final DirectedGraph<N> graph;
protected final List<DominatorNode<N>> heads;
protected final List<Dominato... |
N immediateDominator = dominators.getImmediateDominator(gode);
return (immediateDominator == null) ? null : fetchDode(immediateDominator);
| 1,761 | 49 | 1,810 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/HashReversibleGraph.java | HashReversibleGraph | addEdge | class HashReversibleGraph<N> extends HashMutableDirectedGraph<N> implements ReversibleGraph<N> {
protected boolean reversed;
public HashReversibleGraph(DirectedGraph<N> dg) {
this();
for (N s : dg) {
addNode(s);
}
for (N s : dg) {
for (N t : dg.getSuccsOf(s)) {
addEdge(s, t);
... |
if (reversed) {
super.addEdge(to, from);
} else {
super.addEdge(from, to);
}
| 594 | 42 | 636 | <methods>public void <init>() ,public void <init>(HashMutableDirectedGraph<N>) ,public void addEdge(N, N) ,public void addNode(N) ,public void clearAll() ,public java.lang.Object clone() ,public boolean containsEdge(N, N) ,public boolean containsNode(N) ,public List<N> getHeads() ,public List<N> getNodes() ,public List... |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/MHGDominatorsFinder.java | MHGDominatorsFinder | isDominatedByAll | class MHGDominatorsFinder<N> implements DominatorsFinder<N> {
protected final DirectedGraph<N> graph;
protected final Set<N> heads;
protected final Map<N, BitSet> nodeToFlowSet;
protected final Map<N, Integer> nodeToIndex;
protected final Map<Integer, N> indexToNode;
protected int lastIndex = 0;
public ... |
BitSet s1 = getDominatorsBitSet(node);
for (int i = doms.nextSetBit(0); i >= 0; i = doms.nextSetBit(i + 1)) {
if (!s1.get(i)) {
return false;
}
if (i == Integer.MAX_VALUE) {
break; // or (i+1) would overflow
}
}
return true;
| 1,419 | 110 | 1,529 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/MemoryEfficientGraph.java | MemoryEfficientGraph | removeEdge | class MemoryEfficientGraph<N> extends HashMutableDirectedGraph<N> {
HashMap<N, N> self = new HashMap<N, N>();
@Override
public void addNode(N o) {
super.addNode(o);
self.put(o, o);
}
@Override
public void removeNode(N o) {
super.removeNode(o);
self.remove(o);
}
@Override
public voi... |
if (containsNode(from) && containsNode(to)) {
super.removeEdge(self.get(from), self.get(to));
} else if (!containsNode(from)) {
throw new RuntimeException(from.toString() + " not in graph!");
} else {
throw new RuntimeException(to.toString() + " not in graph!");
}
| 261 | 94 | 355 | <methods>public void <init>() ,public void <init>(HashMutableDirectedGraph<N>) ,public void addEdge(N, N) ,public void addNode(N) ,public void clearAll() ,public java.lang.Object clone() ,public boolean containsEdge(N, N) ,public boolean containsNode(N) ,public List<N> getHeads() ,public List<N> getNodes() ,public List... |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/PseudoTopologicalOrderer.java | ReverseOrderBuilder | computeOrder | class ReverseOrderBuilder<N> {
private final DirectedGraph<N> graph;
private final int graphSize;
private final int[] indexStack;
private final N[] stmtStack;
private final Set<N> visited;
private final N[] order;
private int orderLength;
/**
* @param g
* a DirectedG... |
// Visit each node
for (N s : graph) {
if (visited.add(s)) {
visitNode(s);
}
if (orderLength == graphSize) {
break;
}
}
if (reverse) {
reverseArray(order);
}
return Arrays.asList(order);
| 783 | 92 | 875 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/SimpleDominatorsFinder.java | SimpleDominatorsFinder | isDominatedByAll | class SimpleDominatorsFinder<N> implements DominatorsFinder<N> {
private static final Logger logger = LoggerFactory.getLogger(SimpleDominatorsFinder.class);
protected final DirectedGraph<N> graph;
protected final Map<N, FlowSet<N>> nodeToDominators;
/**
* Compute dominators for provided singled-headed dire... |
FlowSet<N> f = nodeToDominators.get(node);
for (N n : dominators) {
if (!f.contains(n)) {
return false;
}
}
return true;
| 606 | 60 | 666 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/StronglyConnectedComponents.java | StronglyConnectedComponents | visitNode | class StronglyConnectedComponents {
private static final Logger logger = LoggerFactory.getLogger(StronglyConnectedComponents.class);
private HashMap<Object, Object> nodeToColor;
private static final Object Visited = new Object();
private static final Object Black = new Object();
private final LinkedList<Objec... |
last = 0;
nodeToColor.put(startNode, Visited);
nodeStack[last] = startNode;
indexStack[last++] = -1;
while (last > 0) {
int toVisitIndex = ++indexStack[last - 1];
Object toVisitNode = nodeStack[last - 1];
if (toVisitIndex >= graph.getSuccsOf(toVisitNode).size()) {
// Vi... | 1,386 | 260 | 1,646 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/interaction/FlowInfo.java | FlowInfo | toString | class FlowInfo<I, U> {
private I info;
private U unit;
private boolean before;
public FlowInfo(I info, U unit, boolean b) {
info(info);
unit(unit);
setBefore(b);
}
public U unit() {
return unit;
}
public void unit(U u) {
unit = u;
}
public I info() {
return info;
}
... |
StringBuffer sb = new StringBuffer();
sb.append("unit: " + unit);
sb.append(" info: " + info);
sb.append(" before: " + before);
return sb.toString();
| 201 | 56 | 257 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/interaction/InteractionHandler.java | InteractionHandler | handleCfgEvent | class InteractionHandler {
private static final Logger logger = LoggerFactory.getLogger(InteractionHandler.class);
public InteractionHandler(Singletons.Global g) {
}
public static InteractionHandler v() {
return G.v().soot_toolkits_graph_interaction_InteractionHandler();
}
private ArrayList<Object> s... |
if (currentPhaseEnabled()) {
logger.debug("Analyzing: " + currentPhaseName());
doInteraction(new InteractionEvent(IInteractionConstants.NEW_ANALYSIS, currentPhaseName()));
}
if (isInteractThisAnalysis()) {
doInteraction(new InteractionEvent(IInteractionConstants.NEW_CFG, g));
}
| 1,759 | 97 | 1,856 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/graph/pdg/Region.java | Region | toString | class Region implements IRegion {
private SootClass m_class = null;
private SootMethod m_method = null;
private List<Block> m_blocks = null;
private List<Unit> m_units = null;
private int m_id = -1;
private UnitGraph m_unitGraph = null;
// The following are needed to create a tree of regions based on th... |
String str = new String();
str += "Begin-----------Region: " + this.m_id + "-------------\n";
List<Unit> regionUnits = this.getUnits();
for (Iterator<Unit> itr = regionUnits.iterator(); itr.hasNext();) {
Unit u = itr.next();
str += u + "\n";
}
str += "End Region " + this.m_id + "... | 1,251 | 128 | 1,379 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/AbstractBoundedFlowSet.java | AbstractBoundedFlowSet | complement | class AbstractBoundedFlowSet<T> extends AbstractFlowSet<T> implements BoundedFlowSet<T> {
@Override
public void complement() {
complement(this);
}
@Override
public void complement(FlowSet<T> dest) {<FILL_FUNCTION_BODY>}
@Override
public FlowSet<T> topSet() {
BoundedFlowSet<T> tmp = (BoundedFlow... |
if (this == dest) {
complement();
} else {
BoundedFlowSet<T> tmp = (BoundedFlowSet<T>) topSet();
tmp.difference(this, dest);
}
| 135 | 58 | 193 | <methods>public non-sealed void <init>() ,public abstract void add(T) ,public void add(T, FlowSet<T>) ,public void clear() ,public abstract AbstractFlowSet<T> clone() ,public abstract boolean contains(T) ,public void copy(FlowSet<T>) ,public void difference(FlowSet<T>) ,public void difference(FlowSet<T>, FlowSet<T>) ,p... |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/AbstractFlowAnalysis.java | AbstractFlowAnalysis | mergeInto | class AbstractFlowAnalysis<N, A> {
/** The graph being analysed. */
protected final DirectedGraph<N> graph;
/** Maps graph nodes to IN sets. */
protected final Map<N, A> unitToBeforeFlow;
/** Filtered: Maps graph nodes to IN sets. */
protected Map<N, A> filterUnitToBeforeFlow;
/** Constructs a flow an... |
A tmp = newInitialFlow();
merge(succNode, inout, in, tmp);
copy(tmp, inout);
| 783 | 36 | 819 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/AbstractFlowSet.java | AbstractFlowSet | difference | class AbstractFlowSet<T> implements FlowSet<T> {
@Override
public abstract AbstractFlowSet<T> clone();
/**
* implemented, but inefficient.
*/
@Override
public FlowSet<T> emptySet() {
FlowSet<T> t = clone();
t.clear();
return t;
}
@Override
public void copy(FlowSet<T> dest) {
if ... |
if (dest == this && dest == other) {
dest.clear();
return;
}
FlowSet<T> flowSet = (other == dest) ? other.clone() : other;
dest.clear(); // now safe, since we have copies of this & other
for (T t : this) {
if (!flowSet.contains(t)) {
dest.add(t);
}
}
| 1,256 | 108 | 1,364 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/ArrayPackedSet.java | ArrayPackedSet | iterator | class ArrayPackedSet<T> extends AbstractBoundedFlowSet<T> {
protected final ObjectIntMapper<T> map;
protected final BitSet bits;
public ArrayPackedSet(FlowUniverse<T> universe) {
this(new ObjectIntMapper<T>(universe));
}
ArrayPackedSet(ObjectIntMapper<T> map) {
this(map, new BitSet());
}
Array... |
return new Iterator<T>() {
int curr = -1;
int next = bits.nextSetBit(0);
@Override
public boolean hasNext() {
return (next >= 0);
}
@Override
public T next() {
if (next < 0) {
throw new NoSuchElementException();
}
curr = next;
... | 1,726 | 185 | 1,911 | <methods>public non-sealed void <init>() ,public void complement() ,public void complement(FlowSet<T>) ,public FlowSet<T> topSet() <variables> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/BackwardFlowAnalysis.java | BackwardFlowAnalysis | doAnalysis | class BackwardFlowAnalysis<N, A> extends FlowAnalysis<N, A> {
/**
* Construct the analysis from a DirectedGraph representation of a Body.
*/
public BackwardFlowAnalysis(DirectedGraph<N> graph) {
super(graph);
}
/**
* Returns <code>false</code>
*
* @return false
**/
@Override
protecte... |
doAnalysis(GraphView.BACKWARD, InteractionFlowHandler.BACKWARD, unitToAfterFlow, unitToBeforeFlow);
// soot.Timers.v().totalFlowNodes += graph.size();
// soot.Timers.v().totalFlowComputations += numComputations;
| 146 | 74 | 220 | <methods>public void <init>(DirectedGraph<N>) ,public A getFlowAfter(N) ,public A getFlowBefore(N) <variables>protected Map<N,A> filterUnitToAfterFlow,protected final non-sealed Map<N,A> unitToAfterFlow |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/BinaryIdentitySet.java | BinaryIdentitySet | equals | class BinaryIdentitySet<T> {
protected final T o1;
protected final T o2;
protected final int hashCode;
public BinaryIdentitySet(T o1, T o2) {
this.o1 = o1;
this.o2 = o2;
this.hashCode = computeHashCode();
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return hashCode... |
if (this == obj) {
return true;
}
if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
final BinaryIdentitySet<?> other = (BinaryIdentitySet<?>) obj;
// must be commutative
return (this.o1 == other.o1 || this.o1 == other.o2) && (this.o2 == other.o2 || this.o2 ... | 293 | 124 | 417 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/ConstantValueToInitializerTransformer.java | ConstantValueToInitializerTransformer | getOrCreateInitializer | class ConstantValueToInitializerTransformer extends SceneTransformer {
public static ConstantValueToInitializerTransformer v() {
return new ConstantValueToInitializerTransformer();
}
@Override
protected void internalTransform(String phaseName, Map<String, String> options) {
for (SootClass sc : Scene.v... |
// Create a static initializer if we don't already have one
SootMethod smInit = sc.getMethodByNameUnsafe(SootMethod.staticInitializerName);
if (smInit == null) {
smInit = Scene.v().makeSootMethod(SootMethod.staticInitializerName, Collections.<Type>emptyList(), VoidType.v());
smInit.setActiveBod... | 1,387 | 290 | 1,677 | <methods>public non-sealed void <init>() ,public final void transform(java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(java.lang.String) ,public final void transform() <variables> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/FastColorer.java | UnitInterferenceGraph | setInterference | class UnitInterferenceGraph {
// Maps a local to its interfering locals.
final Map<Local, Set<Local>> localToLocals;
final List<Local> locals;
public UnitInterferenceGraph(Body body, Map<Local, ? extends Object> localToGroup, LiveLocals liveLocals,
ExceptionalUnitGraph unitGraph) {
this... |
// We need the mapping in both directions
// l1 -> l2
Set<Local> locals = localToLocals.get(l1);
if (locals == null) {
locals = new ArraySet<Local>();
localToLocals.put(l1, locals);
}
locals.add(l2);
// l2 -> l1
locals = localToLocals.get(l2);
if (... | 871 | 158 | 1,029 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/FlowAnalysis.java | Entry | newUniverse | class Entry<D, F> implements Numberable {
final D data;
int number;
/**
* This Entry is part of a real scc.
*/
boolean isRealStronglyConnected;
Entry<D, F>[] in;
Entry<D, F>[] out;
F inFlow;
F outFlow;
@SuppressWarnings("unchecked")
Entry(D u, Entry<D, F> pred) {
... |
final int n = g.size();
Deque<Entry<D, F>> s = new ArrayDeque<Entry<D, F>>(n);
List<Entry<D, F>> universe = new ArrayList<Entry<D, F>>(n);
Map<D, Entry<D, F>> visited = new HashMap<D, Entry<D, F>>(((n + 1) * 4) / 3);
// out of universe node
Entry<D, F> superEntry = new Entry<D, F>... | 402 | 941 | 1,343 | <methods>public void <init>(DirectedGraph<N>) ,public A getFlowBefore(N) <variables>protected Map<N,A> filterUnitToBeforeFlow,protected final non-sealed DirectedGraph<N> graph,protected final non-sealed Map<N,A> unitToBeforeFlow |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/ForwardFlowAnalysis.java | ForwardFlowAnalysis | doAnalysis | class ForwardFlowAnalysis<N, A> extends FlowAnalysis<N, A> {
/**
* Construct the analysis from a DirectedGraph representation of a Body.
*/
public ForwardFlowAnalysis(DirectedGraph<N> graph) {
super(graph);
}
@Override
protected boolean isForward() {
return true;
}
@Override
protected v... |
int i = doAnalysis(GraphView.FORWARD, InteractionFlowHandler.FORWARD, unitToBeforeFlow, unitToAfterFlow);
soot.Timers.v().totalFlowNodes += graph.size();
soot.Timers.v().totalFlowComputations += i;
| 118 | 73 | 191 | <methods>public void <init>(DirectedGraph<N>) ,public A getFlowAfter(N) ,public A getFlowBefore(N) <variables>protected Map<N,A> filterUnitToAfterFlow,protected final non-sealed Map<N,A> unitToAfterFlow |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/HashSparseSet.java | HashSparseSet | union | class HashSparseSet<T> extends AbstractFlowSet<T> {
protected LinkedHashSet<T> elements;
public HashSparseSet() {
@SuppressWarnings("unchecked")
LinkedHashSet<T> newElements = new LinkedHashSet<T>();
elements = newElements;
}
private HashSparseSet(HashSparseSet<T> other) {
elements = new Linke... |
if (sameType(otherFlow) && sameType(destFlow)) {
HashSparseSet<T> other = (HashSparseSet<T>) otherFlow;
HashSparseSet<T> dest = (HashSparseSet<T>) destFlow;
dest.elements.addAll(this.elements);
dest.elements.addAll(other.elements);
} else {
super.union(otherFlow, destFlow);
}
... | 1,247 | 113 | 1,360 | <methods>public non-sealed void <init>() ,public abstract void add(T) ,public void add(T, FlowSet<T>) ,public void clear() ,public abstract AbstractFlowSet<T> clone() ,public abstract boolean contains(T) ,public void copy(FlowSet<T>) ,public void difference(FlowSet<T>) ,public void difference(FlowSet<T>, FlowSet<T>) ,p... |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/InitAnalysis.java | InitAnalysis | flowThrough | class InitAnalysis extends ForwardFlowAnalysis<Unit, FlowSet<Local>> {
protected final FlowSet<Local> allLocals = new ArraySparseSet<Local>();
public InitAnalysis(DirectedBodyGraph<Unit> g) {
super(g);
FlowSet<Local> allLocalsRef = this.allLocals;
for (Local loc : g.getBody().getLocals()) {
all... |
in.copy(out);
for (ValueBox defBox : unit.getDefBoxes()) {
Value lhs = defBox.getValue();
if (lhs instanceof Local) {
out.add((Local) lhs);
}
}
| 342 | 67 | 409 | <methods>public void <init>(DirectedGraph<soot.Unit>) <variables> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/LocalPacker.java | LocalPacker | internalTransform | 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();
}
@Override
protected void internalTransform(Body... |
if (Options.v().verbose()) {
logger.debug("[" + body.getMethod().getName() + "] Packing locals...");
}
final Chain<Local> bodyLocalsRef = body.getLocals();
final int origLocalCount = bodyLocalsRef.size();
if (origLocalCount < 1) {
return;
}
// A group represents a bunch of loc... | 128 | 1,294 | 1,422 | <methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyM... |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/LocalSplitter.java | LocalSplitter | internalTransform | class LocalSplitter extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(LocalSplitter.class);
protected ThrowAnalysis throwAnalysis;
protected boolean omitExceptingUnitEdges;
public LocalSplitter(Singletons.Global g) {
}
public LocalSplitter(ThrowAnalysis ta) {
this... |
if (Options.v().verbose()) {
logger.debug("[" + body.getMethod().getName() + "] Splitting locals...");
}
if (Options.v().time()) {
Timers.v().splitTimer.start();
Timers.v().splitPhase1Timer.start();
}
if (throwAnalysis == null) {
throwAnalysis = Scene.v().getDefaultThrowAn... | 229 | 1,261 | 1,490 | <methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyM... |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/LocalUnitPair.java | LocalUnitPair | equals | class LocalUnitPair {
Local local;
Unit unit;
/**
* Constructs a LocalUnitPair from a Unit object and a Local object.
*
* @param local
* some Local
* @param unit
* some Unit.
*/
public LocalUnitPair(Local local, Unit unit) {
this.local = local;
this.unit = unit;
... |
if (other instanceof LocalUnitPair) {
LocalUnitPair temp = (LocalUnitPair) other;
return temp.local == this.local && temp.unit == this.unit;
} else {
return false;
}
| 269 | 60 | 329 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/SharedInitializationLocalSplitter.java | Cluster | internalTransform | class Cluster {
protected final List<Unit> constantInitializers;
protected final Unit use;
public Cluster(Unit use, List<Unit> constantInitializers) {
this.use = use;
this.constantInitializers = constantInitializers;
}
@Override
public String toString() {
StringBuilder sb = ... |
if (Options.v().verbose()) {
logger.debug("[" + body.getMethod().getName() + "] Splitting for shared initialization of locals...");
}
if (throwAnalysis == null) {
throwAnalysis = Scene.v().getDefaultThrowAnalysis();
}
if (!omitExceptingUnitEdges) {
omitExceptingUnitEdges = Optio... | 222 | 865 | 1,087 | <methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyM... |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/SmartLocalDefsPool.java | SmartLocalDefsPool | getSmartLocalDefsFor | class SmartLocalDefsPool {
protected Map<Body, Pair<Long, SmartLocalDefs>> pool = Maps.newHashMap();
/**
* This method returns a fresh instance of a {@link SmartLocalDefs} analysis, based on a freshly created
* {@link ExceptionalUnitGraph} for b, with standard parameters. If the body b's modification count ... |
Pair<Long, SmartLocalDefs> modCountAndSLD = pool.get(b);
if (modCountAndSLD != null && modCountAndSLD.o1.longValue() == b.getModificationCount()) {
return modCountAndSLD.o2;
} else {
ExceptionalUnitGraph g = ExceptionalUnitGraphFactory.createExceptionalUnitGraph(b);
SmartLocalDefs newSLD ... | 270 | 167 | 437 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/UnitValueBoxPair.java | UnitValueBoxPair | equals | class UnitValueBoxPair {
public Unit unit;
public ValueBox valueBox;
/**
* Constructs a UnitValueBoxPair from a Unit object and a ValueBox object.
*
* @param unit
* some Unit
* @param valueBox
* some ValueBox
*/
public UnitValueBoxPair(Unit unit, ValueBox valueBox) {
... |
if (other instanceof UnitValueBoxPair) {
UnitValueBoxPair otherPair = (UnitValueBoxPair) other;
if (this.unit.equals(otherPair.unit) && this.valueBox.equals(otherPair.valueBox)) {
return true;
}
}
return false;
| 309 | 78 | 387 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/UnusedLocalEliminator.java | UnusedLocalEliminator | internalTransform | class UnusedLocalEliminator extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(UnusedLocalEliminator.class);
public UnusedLocalEliminator(Singletons.Global g) {
}
public static UnusedLocalEliminator v() {
return G.v().soot_toolkits_scalar_UnusedLocalEliminator();
}
... |
if (Options.v().verbose()) {
logger.debug("[" + body.getMethod().getName() + "] Eliminating unused locals...");
}
final Chain<Local> locals = body.getLocals();
final int numLocals = locals.size();
final int[] oldNumbers = new int[numLocals];
{
int i = 0;
for (Local local : lo... | 143 | 443 | 586 | <methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyM... |
soot-oss_soot | soot/src/main/java/soot/toolkits/scalar/ValueUnitPair.java | ValueUnitPair | clone | class ValueUnitPair extends AbstractValueBox implements UnitBox, EquivTo {
// oub was initially a private inner class. ended up being a
// *bad* *bad* idea with endless opportunity for *evil* *evil*
// pointer bugs. in the end so much code needed to be copy pasted
// that using an innerclass to reuse code from ... |
// Note to self: Do not try to "fix" this. Yes, it should be
// a shallow copy in order to conform with the rest of Soot.
// When a body is cloned, the Values are cloned explicitly and
// replaced, and UnitBoxes are explicitly patched. See
// Body.importBodyContentsFrom for details.
Value cv = ... | 1,113 | 123 | 1,236 | <methods>public non-sealed void <init>() ,public soot.Value getValue() ,public void setValue(soot.Value) ,public void toString(soot.UnitPrinter) ,public java.lang.String toString() <variables>protected soot.Value value |
soot-oss_soot | soot/src/main/java/soot/tools/BadFields.java | BadFields | handleMethod | class BadFields extends SceneTransformer {
private static final Logger logger = LoggerFactory.getLogger(BadFields.class);
public static void main(String[] args) {
PackManager.v().getPack("cg").add(new Transform("cg.badfields", new BadFields()));
soot.Main.main(args);
}
private SootClass lastClass;
p... |
if (!m.isConcrete()) {
return;
}
for (Iterator<ValueBox> bIt = m.retrieveActiveBody().getUseAndDefBoxes().iterator(); bIt.hasNext();) {
final ValueBox b = bIt.next();
Value v = b.getValue();
if (!(v instanceof StaticFieldRef)) {
continue;
}
StaticFieldRef sfr = (... | 854 | 578 | 1,432 | <methods>public non-sealed void <init>() ,public final void transform(java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(java.lang.String) ,public final void transform() <variables> |
soot-oss_soot | soot/src/main/java/soot/util/AbstractMultiMap.java | EntryIterator | hasNext | class EntryIterator implements Iterator<Pair<K, V>> {
Iterator<K> keyIterator = keySet().iterator();
Iterator<V> valueIterator = null;
K currentKey = null;
@Override
public boolean hasNext() {<FILL_FUNCTION_BODY>}
@Override
public Pair<K, V> next() {
// Obtain the next key
if ... |
if (valueIterator != null && valueIterator.hasNext()) {
return true;
}
// Prepare for the next key
valueIterator = null;
currentKey = null;
return keyIterator.hasNext();
| 256 | 61 | 317 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/ArrayNumberer.java | ArrayNumberer | get | class ArrayNumberer<E extends Numberable> implements IterableNumberer<E> {
protected E[] numberToObj;
protected int lastNumber;
protected BitSet freeNumbers;
@SuppressWarnings("unchecked")
public ArrayNumberer() {
this.numberToObj = (E[]) new Numberable[1024];
this.lastNumber = 0;
}
public Arra... |
if (o == null) {
return 0;
}
int ret = o.getNumber();
if (ret == 0) {
throw new RuntimeException("unnumbered: " + o);
}
return ret;
| 799 | 63 | 862 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/ArraySet.java | ArraySet | addAll | class ArraySet<E> extends AbstractSet<E> {
private static final int DEFAULT_SIZE = 8;
private int numElements;
private int maxElements;
private E[] elements;
public ArraySet(int size) {
maxElements = size;
@SuppressWarnings("unchecked")
E[] newElements = (E[]) new Object[size];
elements = ne... |
if (s instanceof ArraySet) {
boolean ret = false;
ArraySet<? extends E> as = (ArraySet<? extends E>) s;
for (E elem : as.elements) {
ret |= add(elem);
}
return ret;
} else {
return super.addAll(s);
}
| 1,223 | 88 | 1,311 | <methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables> |
soot-oss_soot | soot/src/main/java/soot/util/BitSetIterator.java | BitSetIterator | next | class BitSetIterator {
long[] bits; // Bits inherited from the underlying BitVector
int index; // The 64-bit block currently being examined
long save = 0; // A copy of the 64-bit block (for fast access)
/*
* Computes log_2(x) modulo 67. This uses the fact that 2 is a primitive root modulo 67
*/
final ... |
if (index >= bits.length) {
throw new NoSuchElementException();
}
long k = (save & (save - 1)); // Clears the last non-zero bit. save is guaranteed non-zero.
long diff = save ^ k; // Finds out which bit it is. diff has exactly one bit set.
save = k;
// Computes the position of the set b... | 594 | 212 | 806 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/ConcurrentHashMultiMap.java | ConcurrentHashMultiMap | findSet | class ConcurrentHashMultiMap<K, V> extends AbstractMultiMap<K, V> {
private static final long serialVersionUID = -3182515910302586044L;
private final Map<K, ConcurrentMap<V, V>> m = new ConcurrentHashMap<K, ConcurrentMap<V, V>>(0);
public ConcurrentHashMultiMap() {
}
public ConcurrentHashMultiMap(MultiMap... |
ConcurrentMap<V, V> s = m.get(key);
if (s == null) {
synchronized (this) {
// Better check twice, another thread may have created a set in
// the meantime
s = m.get(key);
if (s == null) {
s = newSet();
m.put(key, s);
}
}
}
return s... | 1,396 | 108 | 1,504 | <methods>public non-sealed void <init>() ,public boolean contains(K, V) ,public boolean isEmpty() ,public Iterator<Pair<K,V>> iterator() ,public boolean putAll(MultiMap<K,V>) ,public boolean putAll(Map<K,Collection<V>>) ,public boolean putMap(Map<K,V>) <variables>private static final long serialVersionUID |
soot-oss_soot | soot/src/main/java/soot/util/DeterministicHashMap.java | ArrayIterator | removeElementAt | class ArrayIterator implements Iterator<T> {
private int nextIndex;
ArrayIterator() {
nextIndex = 0;
}
@Override
public boolean hasNext() {
return nextIndex < numElements;
}
@Override
public T next() throws NoSuchElementException {
if (!(nextIndex < numElements)) {
... |
throw new UnsupportedOperationException();
/*
* // Handle simple case if(index == numElements - 1) { numElements--; return; }
*
* // Else, shift over elements System.arraycopy(elements, index + 1, elements, index, numElements - (index + 1));
* numElements--;
*/
| 212 | 86 | 298 | <methods>public void <init>() ,public void <init>(int) ,public void <init>(Map<? extends K,? extends V>) ,public void <init>(int, float) ,public void clear() ,public java.lang.Object clone() ,public V compute(K, BiFunction<? super K,? super V,? extends V>) ,public V computeIfAbsent(K, Function<? super K,? extends V>) ,... |
soot-oss_soot | soot/src/main/java/soot/util/EmptyChain.java | EmptyChainSingleton | insertBefore | class EmptyChainSingleton {
static final EmptyChain<Object> INSTANCE = new EmptyChain<Object>();
}
public static <X> EmptyChain<X> v() {
@SuppressWarnings("unchecked")
EmptyChain<X> retVal = (EmptyChain<X>) EmptyChainSingleton.INSTANCE;
return retVal;
}
@Override
public String toString() {
... |
throw new RuntimeException("Cannot add elements to an unmodifiable chain");
| 666 | 20 | 686 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/HashChain.java | EmptyIteratorSingleton | insertBefore | class EmptyIteratorSingleton {
static final Iterator<Object> INSTANCE = new Iterator<Object>() {
@Override
public boolean hasNext() {
return false;
}
@Override
public Object next() {
return null;
}
@Override
public void remove() {
// do noth... |
if (toInsert == null) {
throw new RuntimeException("Cannot insert a null object into a Chain!");
}
if (point == null) {
throw new RuntimeException("Insertion point cannot be null!");
}
if (map.containsKey(toInsert)) {
throw new RuntimeException("Chain already contains object.");
... | 1,114 | 169 | 1,283 | <methods>public boolean add(E) ,public boolean addAll(Collection<? extends E>) ,public void clear() ,public boolean contains(java.lang.Object) ,public boolean containsAll(Collection<?>) ,public boolean isEmpty() ,public abstract Iterator<E> iterator() ,public boolean remove(java.lang.Object) ,public boolean removeAll(C... |
soot-oss_soot | soot/src/main/java/soot/util/IntegerNumberer.java | IntegerNumberer | size | class IntegerNumberer implements Numberer<Long> {
/** Tells the numberer that a new object needs to be assigned a number. */
@Override
public void add(Long o) {
}
/**
* Should return the number that was assigned to object o that was previously passed as an argument to add().
*/
@Override
public lon... |
throw new RuntimeException("IntegerNumberer does not implement the size() method.");
| 248 | 22 | 270 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/IterableSet.java | IterableSet | union | class IterableSet<T> extends HashChain<T> implements Set<T> {
public IterableSet(Collection<T> c) {
super();
addAll(c);
}
public IterableSet() {
super();
}
@Override
public boolean add(T o) {
if (o == null) {
throw new IllegalArgumentException("Cannot add \"null\" to an IterableSet.... |
if (other == null) {
throw new IllegalArgumentException("Cannot set union an IterableSet with \"null\".");
}
IterableSet<T> c = new IterableSet<T>();
c.addAll(this);
c.addAll(other);
return c;
| 1,306 | 76 | 1,382 | <methods>public void <init>() ,public void <init>(int) ,public void <init>(Chain<T>) ,public synchronized boolean add(T) ,public synchronized void addFirst(T) ,public synchronized void addLast(T) ,public synchronized void clear() ,public synchronized boolean contains(java.lang.Object) ,public synchronized boolean conta... |
soot-oss_soot | soot/src/main/java/soot/util/LargeNumberedMap.java | LargeNumberedMap | put | class LargeNumberedMap<K extends Numberable, V> implements INumberedMap<K, V> {
private final IterableNumberer<K> universe;
private V[] values;
public LargeNumberedMap(IterableNumberer<K> universe) {
this.universe = universe;
int size = universe.size();
this.values = newArray(size < 8 ? 8 : size);
... |
int number = key.getNumber();
if (number == 0) {
throw new RuntimeException(String.format("oops, forgot to initialize. Object is of type %s, and looks like this: %s",
key.getClass().getName(), key.toString()));
}
if (number >= values.length) {
Object[] oldValues = values;
va... | 466 | 170 | 636 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/LargePriorityQueue.java | LargePriorityQueue | nextSetBit | class LargePriorityQueue<E> extends PriorityQueue<E> {
private final BitSet queue;
private long modCount = 0;
LargePriorityQueue(List<? extends E> universe, Map<E, Integer> ordinalMap) {
super(universe, ordinalMap);
queue = new BitSet(N);
}
@Override
boolean add(int ordinal) {
if (contains(or... |
int i = queue.nextSetBit(fromIndex);
return (i < 0) ? Integer.MAX_VALUE : i;
| 407 | 34 | 441 | <methods>public final boolean add(E) ,public final boolean contains(java.lang.Object) ,public boolean isEmpty() ,public static PriorityQueue<E> noneOf(E[]) ,public static PriorityQueue<E> noneOf(List<? extends E>) ,public static PriorityQueue<E> noneOf(List<? extends E>, boolean) ,public static PriorityQueue<E> of(E[])... |
soot-oss_soot | soot/src/main/java/soot/util/LocalBitSetPacker.java | LocalBitSetPacker | unpack | class LocalBitSetPacker {
private final Body body;
private Local[] locals;
private int[] oldNumbers;
public LocalBitSetPacker(Body body) {
this.body = body;
}
/**
* Reassigns the local numbers such that a dense bit set can be created over them
*/
public void pack() {
int n = body.getLoca... |
for (int i = 0; i < locals.length; i++) {
locals[i].setNumber(oldNumbers[i]);
}
locals = null;
oldNumbers = null;
| 248 | 54 | 302 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/MapNumberer.java | MapNumberer | get | class MapNumberer<T> implements Numberer<T> {
final Map<T, Integer> map = new HashMap<T, Integer>();
final ArrayList<T> al = new ArrayList<T>();
int nextIndex = 1;
public MapNumberer() {
al.add(null);
}
@Override
public void add(T o) {
if (!map.containsKey(o)) {
map.put(o, nextIndex);
... |
if (o == null) {
return 0;
}
Integer i = map.get(o);
if (i == null) {
throw new RuntimeException("couldn't find " + o);
}
return i;
| 322 | 65 | 387 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/MediumPriorityQueue.java | MediumPriorityQueue | nextSetBit | class MediumPriorityQueue<E> extends PriorityQueue<E> {
final static int MAX_CAPACITY = Long.SIZE * Long.SIZE;
private final long[] data;
private int size = 0;
private long modCount = 0;
private long lookup = 0;
MediumPriorityQueue(List<? extends E> universe, Map<E, Integer> ordinalMap) {
super(univer... |
assert fromIndex >= 0;
for (int bb = fromIndex >>> 6; fromIndex < N;) {
// remove everything from t1 that is less than "fromIndex",
long m1 = -1L << fromIndex;
// t1 contains now all active bits
long t1 = data[bb] & m1;
// the expected index m1 in t1 is set (optional test if NOTZ... | 742 | 311 | 1,053 | <methods>public final boolean add(E) ,public final boolean contains(java.lang.Object) ,public boolean isEmpty() ,public static PriorityQueue<E> noneOf(E[]) ,public static PriorityQueue<E> noneOf(List<? extends E>) ,public static PriorityQueue<E> noneOf(List<? extends E>, boolean) ,public static PriorityQueue<E> of(E[])... |
soot-oss_soot | soot/src/main/java/soot/util/SharedBitSet.java | SharedBitSet | and | class SharedBitSet {
BitVector value;
boolean own = true;
public SharedBitSet(int i) {
this.value = new BitVector(i);
}
public SharedBitSet() {
this(32);
}
private void acquire() {
if (own) {
return;
}
own = true;
value = (BitVector) value.clone();
}
private void cano... |
if (own) {
value.and(other.value);
} else {
value = BitVector.and(value, other.value);
own = true;
}
canonicalize();
| 589 | 54 | 643 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/SharedBitSetCache.java | SharedBitSetCache | canonicalize | class SharedBitSetCache {
public SharedBitSetCache(Singletons.Global g) {
}
public static SharedBitSetCache v() {
return G.v().soot_util_SharedBitSetCache();
}
public static final int size = 32749; // a nice prime about 32k
public BitVector[] cache = new BitVector[size];
public BitVector[] orAndAnd... |
int hash = set.hashCode();
if (hash < 0) {
hash = -hash;
}
hash %= size;
BitVector hashed = cache[hash];
if (hashed != null && hashed.equals(set)) {
return hashed;
} else {
cache[hash] = set;
return set;
}
| 146 | 96 | 242 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/SmallNumberedMap.java | SmallNumberedMapIterator | findPosition | class SmallNumberedMapIterator<C> implements Iterator<C> {
private final C[] data;
private int cur;
SmallNumberedMapIterator(C[] data) {
this.data = data;
this.cur = 0;
seekNext();
}
protected final void seekNext() {
V[] temp = SmallNumberedMap.this.values;
try {
... |
int number = o.getNumber();
if (number == 0) {
throw new RuntimeException("unnumbered");
}
number = number & (array.length - 1);
while (true) {
K key = array[number];
if (key == o || key == null) {
return number;
}
number = (number + 1) & (array.length - 1);
... | 291 | 108 | 399 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/SmallPriorityQueue.java | SmallPriorityQueue | removeAll | class SmallPriorityQueue<E> extends PriorityQueue<E> {
final static int MAX_CAPACITY = Long.SIZE;
private long queue = 0;
SmallPriorityQueue(List<? extends E> universe, Map<E, Integer> ordinalMap) {
super(universe, ordinalMap);
assert universe.size() <= Long.SIZE;
}
@Override
void addAll() {
... |
long mask = 0;
for (Object o : c) {
mask |= (1L << getOrdinal(o));
}
long old = queue;
queue &= ~mask;
min = nextSetBit(min);
return old != queue;
| 880 | 71 | 951 | <methods>public final boolean add(E) ,public final boolean contains(java.lang.Object) ,public boolean isEmpty() ,public static PriorityQueue<E> noneOf(E[]) ,public static PriorityQueue<E> noneOf(List<? extends E>) ,public static PriorityQueue<E> noneOf(List<? extends E>, boolean) ,public static PriorityQueue<E> of(E[])... |
soot-oss_soot | soot/src/main/java/soot/util/StringNumberer.java | StringNumberer | findOrAdd | class StringNumberer extends ArrayNumberer<NumberedString> {
private final Map<String, NumberedString> stringToNumbered = new HashMap<String, NumberedString>(1024);
public synchronized NumberedString findOrAdd(String s) {<FILL_FUNCTION_BODY>}
public NumberedString find(String s) {
return stringToNumbered.g... |
NumberedString ret = stringToNumbered.get(s);
if (ret == null) {
ret = new NumberedString(s);
stringToNumbered.put(s, ret);
add(ret);
}
return ret;
| 110 | 66 | 176 | <methods>public void <init>() ,public void <init>(soot.util.NumberedString[]) ,public synchronized void add(soot.util.NumberedString) ,public long get(soot.util.NumberedString) ,public soot.util.NumberedString get(long) ,public Iterator<soot.util.NumberedString> iterator() ,public boolean remove(soot.util.NumberedStrin... |
soot-oss_soot | soot/src/main/java/soot/util/StringTools.java | StringTools | getUnEscapedStringOf | class StringTools {
/** Convenience field storing the system line separator. */
public final static String lineSeparator = System.getProperty("line.separator");
/**
* Returns fromString, but with non-isalpha() characters printed as <code>'\\unnnn'</code>. Used by SootClass to generate
* output.
*/
pu... |
StringBuilder buf = new StringBuilder();
CharacterIterator iter = new StringCharacterIterator(str);
for (char ch = iter.first(); ch != CharacterIterator.DONE; ch = iter.next()) {
if (ch != '\\') {
buf.append(ch);
} else { // enter escaped mode
ch = iter.next();
char form... | 1,161 | 260 | 1,421 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/annotations/AnnotationElemSwitch.java | AnnotationElemResult | caseAnnotationArrayElem | class AnnotationElemResult<V> {
private final String name;
private final V value;
public AnnotationElemResult(String name, V value) {
this.name = name;
this.value = value;
}
public String getKey() {
return name;
}
public V getValue() {
return value;
}
}
@... |
/*
* for arrays, apply a new AnnotationElemSwitch to every array element and collect the results. Note that the component
* type of the result is unknown here, s.t. object has to be used.
*/
Object[] result = new Object[v.getNumValues()];
int i = 0;
for (AnnotationElem elem : v.getValue... | 211 | 165 | 376 | <methods>public non-sealed void <init>() ,public void caseAnnotationAnnotationElem(soot.tagkit.AnnotationAnnotationElem) ,public void caseAnnotationArrayElem(soot.tagkit.AnnotationArrayElem) ,public void caseAnnotationBooleanElem(soot.tagkit.AnnotationBooleanElem) ,public void caseAnnotationClassElem(soot.tagkit.Annota... |
soot-oss_soot | soot/src/main/java/soot/util/annotations/ClassLoaderUtils.java | ClassLoaderUtils | loadClass | class ClassLoaderUtils {
/**
* Don't call me. Just don't.
*
* @param className
* @return
* @throws ClassNotFoundException
*/
public static Class<?> loadClass(String className) throws ClassNotFoundException {
return loadClass(className, true);
}
/**
* Don't call me. Just don't.
*
... |
// Do we have a primitive class
if (allowPrimitives) {
switch (className) {
case "B":
case "byte":
return Byte.TYPE;
case "C":
case "char":
return Character.TYPE;
case "D":
case "double":
return Double.TYPE;
case "F":
... | 165 | 386 | 551 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/backend/ASMBackendUtils.java | ASMBackendUtils | toTypeDesc | class ASMBackendUtils {
/**
* Convert class identifiers and signatures by replacing dots by slashes.
*
* @param s
* String to convert
* @return Converted identifier
*/
public static String slashify(String s) {
if (s == null) {
return null;
}
return s.replace('.', '/');
... |
final StringBuilder sb = new StringBuilder(1);
type.apply(new TypeSwitch() {
@Override
public void defaultCase(Type t) {
throw new RuntimeException("Invalid type " + t.toString());
}
@Override
public void caseDoubleType(DoubleType t) {
sb.append('D');
}
... | 1,283 | 426 | 1,709 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/backend/SootASMClassWriter.java | SootASMClassWriter | getCommonSuperClass | class SootASMClassWriter extends ClassWriter {
/**
* Constructs a new {@link ClassWriter} object.
*
* @param flags
* option flags that can be used to modify the default behavior of this class. See {@link #COMPUTE_MAXS},
* {@link #COMPUTE_FRAMES}.
*/
public SootASMClassWriter(int... |
String typeName1 = type1.replace('/', '.');
String typeName2 = type2.replace('/', '.');
SootClass s1 = Scene.v().getSootClass(typeName1);
SootClass s2 = Scene.v().getSootClass(typeName2);
// If these two classes haven't been loaded yet or are phantom, we take
// java.lang.Object as the common... | 246 | 297 | 543 | <methods>public void <init>(int) ,public void <init>(org.objectweb.asm.ClassReader, int) ,public boolean hasFlags(int) ,public int newClass(java.lang.String) ,public int newConst(java.lang.Object) ,public transient int newConstantDynamic(java.lang.String, java.lang.String, org.objectweb.asm.Handle, java.lang.Object[]) ... |
soot-oss_soot | soot/src/main/java/soot/util/cfgcmd/CFGOptionMatcher.java | CFGOption | help | class CFGOption {
private final String name;
protected CFGOption(String name) {
this.name = name;
}
public String name() {
return name;
}
}
private final CFGOption[] options;
/**
* Creates a CFGOptionMatcher.
*
* @param options
* The set of command options ... |
StringBuilder newLineBuf = new StringBuilder(2 + rightMargin);
newLineBuf.append('\n');
if (hangingIndent < 0) {
hangingIndent = 0;
}
for (int i = 0; i < hangingIndent; i++) {
newLineBuf.append(' ');
}
String newLine = newLineBuf.toString();
StringBuilder result = new Strin... | 795 | 284 | 1,079 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/cfgcmd/CFGToDotGraph.java | ExceptionDestComparator | drawCFG | class ExceptionDestComparator<T> implements Comparator<ExceptionDest<T>> {
private final DotNamer<T> namer;
ExceptionDestComparator(DotNamer<T> namer) {
this.namer = namer;
}
private int getValue(ExceptionDest<T> o) {
T handler = o.getHandlerNode();
if (handler == null) {
ret... |
Body body = graph.getBody();
DotGraph canvas = initDotGraph(body);
DotNamer<Object> namer = new DotNamer<Object>((int) (graph.size() / 0.7f), 0.7f);
@SuppressWarnings("unchecked")
NodeComparator<N> nodeComparator = new NodeComparator<N>((DotNamer<N>) namer);
// Prelabel nodes in iterator order... | 932 | 828 | 1,760 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/util/dot/DotGraphUtility.java | DotGraphUtility | replaceReturns | class DotGraphUtility {
private static final Logger logger = LoggerFactory.getLogger(DotGraphUtility.class);
/**
* Replace any {@code "} with {@code \"}. If the {@code "} character was already escaped (i.e. {@code \"}), then the escape
* character is also escaped (i.e. {@code \\\"}).
*
* @param origina... |
byte[] ord = original.getBytes();
int quotes = 0;
for (byte element : ord) {
if (element == '\n') {
quotes++;
}
}
if (quotes == 0) {
return original;
}
byte[] newsrc = new byte[ord.length + quotes];
for (int i = 0, j = 0, n = ord.length; i < n; i++, j++) {
... | 599 | 226 | 825 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/xml/Key.java | Key | print | class Key {
private final int red;
private final int green;
private final int blue;
private final String key;
private String aType;
public Key(int r, int g, int b, String k) {
this.red = r;
this.green = g;
this.blue = b;
this.key = k;
}
public int red() {
return this.red;
}
p... |
writerOut.println("<key red=\"" + red() + "\" green=\"" + green() + "\" blue=\"" + blue() + "\" key=\"" + key()
+ "\" aType=\"" + aType() + "\"/>");
| 237 | 68 | 305 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/xml/TagCollector.java | TagCollector | collectBodyTags | class TagCollector {
private final ArrayList<Attribute> attributes;
private final ArrayList<Key> keys;
public TagCollector() {
this.attributes = new ArrayList<Attribute>();
this.keys = new ArrayList<Key>();
}
public boolean isEmpty() {
return attributes.isEmpty() && keys.isEmpty();
}
/**
... |
for (Unit u : b.getUnits()) {
Attribute ua = new Attribute();
JimpleLineNumberTag jlnt = null;
for (Tag t : u.getTags()) {
ua.addTag(t);
if (t instanceof JimpleLineNumberTag) {
jlnt = (JimpleLineNumberTag) t;
}
// System.out.println("adding unit tag: "+t)... | 906 | 318 | 1,224 | <no_super_class> |
soot-oss_soot | soot/src/main/java/soot/xml/XMLRoot.java | XMLRoot | addElement | class XMLRoot {
public String name = ""; // <NAME attr1="val1" attr2="val2"...>val</NAME>
public String value = ""; // <name attr1="val1" attr2="val2"...>VAL</name>
public String[] attributes = { "" }; // <name ATTR1="val1" ATTR2="val2"...>val</name>
public String[] values = { "" }; // <name attr1="VAL1" attr2... |
XMLNode newnode = new XMLNode(name, value, attributes, values);
newnode.root = this;
if (this.child == null) {
this.child = newnode;
newnode.parent = null; // root's children have NO PARENTS :(
} else {
XMLNode current = this.child;
while (current.next != null) {
curren... | 435 | 139 | 574 | <no_super_class> |
speedment_speedment | speedment/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractClearTablesMojo.java | AbstractClearTablesMojo | execute | class AbstractClearTablesMojo extends AbstractSpeedmentMojo {
@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject mavenProject;
private @Parameter(defaultValue = "${debug}") Boolean debug;
private @Parameter(defaultValue = "${dbms.host}") String dbmsHost;
private @Param... |
getLog().info("Saving default configuration from database to '" + configLocation().toAbsolutePath() + "'.");
final ConfigFileHelper helper = speedment.getOrThrow(ConfigFileHelper.class);
try {
helper.setCurrentlyOpenFile(configLocation().toFile());
helper.clearTablesAndSaveToFile();
} catch (final Exce... | 531 | 144 | 675 | <methods>public final void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException<variables>private static final java.nio.file.Path DEFAULT_CONFIG,private static final Consumer<ApplicationBuilder<?,?>> NOTHING,static final java.lang.String SPECIFIED_CLASS,private f... |
speedment_speedment | speedment/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractGenerateMojo.java | AbstractGenerateMojo | execute | class AbstractGenerateMojo extends AbstractSpeedmentMojo {
private static final Logger LOGGER = LoggerManager.getLogger(AbstractGenerateMojo.class);
@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject mavenProject;
private @Parameter(defaultValue = "... |
getLog().info("Generating code using JSON configuration file: '" + configLocation().toAbsolutePath() + "'.");
if (hasConfigFile()) {
try {
final Project project = speedment.getOrThrow(ProjectComponent.class).getProject();
speedment.getOrThrow(Transla... | 627 | 310 | 937 | <methods>public final void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException<variables>private static final java.nio.file.Path DEFAULT_CONFIG,private static final Consumer<ApplicationBuilder<?,?>> NOTHING,static final java.lang.String SPECIFIED_CLASS,private f... |
speedment_speedment | speedment/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/AbstractToolMojo.java | AbstractToolMojo | execute | class AbstractToolMojo extends AbstractSpeedmentMojo {
@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject mavenProject;
private @Parameter(defaultValue = "${debug}") Boolean debug;
private @Parameter(defaultValue = "${dbms.host}") String dbmsHost;
... |
final Injector injector = speedment.getOrThrow(Injector.class);
MainApp.setInjector(injector);
if (hasConfigFile()) {
Application.launch(MainApp.class, configLocation().toAbsolutePath().toString());
} else {
Application.launch(MainApp.class);
}
... | 635 | 90 | 725 | <methods>public final void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException<variables>private static final java.nio.file.Path DEFAULT_CONFIG,private static final Consumer<ApplicationBuilder<?,?>> NOTHING,static final java.lang.String SPECIFIED_CLASS,private f... |
speedment_speedment | speedment/build-parent/maven-plugin/src/main/java/com/speedment/maven/abstractmojo/TypeMapperInstaller.java | TypeMapperInstaller | installInTypeMapper | class TypeMapperInstaller { // This class must be public
private final Mapping[] mappings;
public TypeMapperInstaller(Mapping[] mappings) {
this.mappings = mappings; // Nullable
}
@ExecuteBefore(RESOLVED)
public void installInTypeMapper(
final Injector injector,
final @Wit... |
if (mappings != null) {
for (final Mapping mapping : mappings) {
final Class<?> databaseType = databaseTypeFromMapping(injector, mapping);
try {
final Class<?> uncasted = injector.classLoader()
.loadClass(mapping.getImplem... | 486 | 428 | 914 | <no_super_class> |
speedment_speedment | speedment/build-parent/maven-plugin/src/main/java/com/speedment/maven/component/MavenPathComponent.java | MavenPathComponent | baseDir | class MavenPathComponent implements PathComponent {
public static final String MAVEN_BASE_DIR = "maven.baseDir";
private final String mavenBaseDir;
private final ProjectComponent projectComponent;
public MavenPathComponent(
@Config(name=MAVEN_BASE_DIR, value="") final String mavenBaseDir,... |
if (mavenBaseDir.isEmpty()) {
return Paths.get(System.getProperty("user.home"));
} else {
return Paths.get(mavenBaseDir);
}
| 201 | 51 | 252 | <no_super_class> |
speedment_speedment | speedment/build-parent/maven-plugin/src/main/java/com/speedment/maven/internal/util/ConfigUtil.java | ConfigUtil | hasConfigFile | class ConfigUtil {
private ConfigUtil() {}
/**
* Returns if the specified file is non-null, exists and is readable. If,
* not, {@code false} is returned and an appropriate message is shown in the
* console.
*
* @param file the config file to check
* @param log the log for outputt... |
requireNonNull(log);
if (file == null) {
final String msg = "The expected .json-file is null.";
log.info(msg);
return false;
} else if (!file.toFile().exists()) {
final String msg = "The expected .json-file '"
+ file + "' does not... | 138 | 170 | 308 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/constant/SimpleParameterizedType.java | SimpleParameterizedType | hashCode | class SimpleParameterizedType implements ParameterizedType {
/**
* Creates a new {@code SimpleParameterizedType} based on the class name of
* the specified class and the specified parameters.
*
* @param mainType the class to get the name from
* @param parameters list of generic parame... |
int hash = 5;
hash = 29 * hash + Objects.hashCode(this.fullName);
hash = 29 * hash + Arrays.deepHashCode(this.parameters);
return hash;
| 745 | 55 | 800 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/constant/SimpleTypeUtil.java | SimpleTypeUtil | pathTo | class SimpleTypeUtil {
private SimpleTypeUtil() {}
/**
* Creates a full name for the specified class in the specified file,
* suitable to be used as a TypeName.
*
* @param file the file to reference
* @param clazz the class to reference
* @return the full name of the cl... |
for (final ClassOrInterface<?> child : parent.getClasses()) {
final String childName = child.getName();
final String newPath = path.isEmpty() ? "" : path + "." + childName;
if (childName.equals(needle)) {
return Optional.of(newPath);
... | 299 | 141 | 440 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/controller/AlignTabs.java | AlignTabs | accept | class AlignTabs<T> implements Consumer<T> {
@Override
public void accept(T model) {<FILL_FUNCTION_BODY>}
private static <T> void alignTabs(
final List<T> models,
final Function<T, String> getRow,
final BiConsumer<T, String> setRow
) {
final AtomicInteger maxIndex = ... |
if (model instanceof HasCode) {
@SuppressWarnings("unchecked")
final HasCode<?> casted = (HasCode<?>) model;
Formatting.alignTabs(casted.getCode());
}
if (model instanceof HasClasses) {
@SuppressWarnings("unchecked")
final Has... | 448 | 654 | 1,102 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/controller/AutoConstructor.java | AutoConstructor | accept | class AutoConstructor implements Consumer<Class> {
@Override
public void accept(Class aClass) {<FILL_FUNCTION_BODY>}
} |
aClass.add(Constructor.newPublic()
.call(constr -> aClass.getFields().stream()
.filter(f -> f.getModifiers().contains(FINAL))
.map(Field::copy)
.forEachOrdered(f -> {
f.getModifiers().clear();
f.final_();
... | 41 | 197 | 238 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/controller/AutoEquals.java | AutoEquals | hasMethod | class AutoEquals<T extends HasFields<T> & HasMethods<T> & HasName<T>>
implements Consumer<T> {
protected final HasImports<?> importer;
protected static final String EQUALS = "equals";
protected static final String HASHCODE = "hashCode";
/**
* Instantiates the <code>AutoEquals</code> usin... |
requireNonNull(model);
requireNonNull(method);
requireNonNull(params);
for (Method m : model.getMethods()) {
if (method.equals(m.getName()) && m.getFields().size() == params) {
return true;
}
}
return false;
| 1,905 | 80 | 1,985 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/controller/AutoJavadoc.java | AutoJavadoc | createJavadoc | class AutoJavadoc<T extends HasJavadoc<?>> implements Consumer<T> {
private static final String DEFAULT_TEXT = "Write some documentation here.";
private static final String DEFAULT_NAME = "Your Name";
/**
* Parses the specified model recursively to find all models that implements
* the {@link Has... |
final Javadoc doc = requireNonNull(model).getJavadoc().orElse(Javadoc.of(DEFAULT_TEXT));
model.set(doc);
if (model instanceof HasGenerics) {
// Add @param for each type variable.
((HasGenerics<?>) model).getGenerics().forEach(g ->
g.getLowerBound().ifPresent(t -> addTag(doc,
P... | 610 | 473 | 1,083 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/BridgeTransform.java | BridgeTransform | transform | class BridgeTransform<A, B> implements Transform<A, B> {
private final List<Transform<?, ?>> steps;
private final Class<A> from;
private final Class<B> to;
private final TransformFactory factory;
private Class<?> end;
/**
* Constructs a new transform from one model class to anothe... |
requireNonNull(gen);
requireNonNull(model);
Object o = model;
for (final Transform<?, ?> step : steps) {
if (o == null) {
return Optional.empty();
} else {
@SuppressWarnings("unchecked")
final Tran... | 1,598 | 278 | 1,876 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/DefaultRenderStack.java | DefaultRenderStack | all | class DefaultRenderStack implements RenderStack {
private final Deque<Object> stack;
/**
* Constructs the stack.
*/
public DefaultRenderStack() {
stack = new ArrayDeque<>();
}
/**
* Constructs the stack using an existing stack as a prototype. This creates
*... |
requireNonNull(i);
final Iterable<Object> it = () -> i;
return StreamSupport.stream(it.spliterator(), false);
| 679 | 41 | 720 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/GeneratorImpl.java | GeneratorImpl | transform | class GeneratorImpl implements Generator {
private final DependencyManager mgr;
private final TransformFactory factory;
private final DefaultRenderStack renderStack;
private final LinkedList<RenderTree.Builder> renderTreeBuilder;
/**
* Creates a new generator.
*
* @param mgr the depende... |
requireNonNulls(transform, model, factory);
final RenderTree.Builder parent = renderTreeBuilder.peek();
final RenderTree.Builder branch = RenderTree.builder();
renderTreeBuilder.push(branch);
renderStack.push(model);
final Optional<Meta<A, B>> meta = t... | 467 | 202 | 669 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/MetaImpl.java | MetaImpl | toString | class MetaImpl<A, B> implements Meta<A, B> {
private final A model;
private final B result;
private final Transform<A, B> transform;
private final TransformFactory factory;
private final RenderStack stack;
private final RenderTree tree;
private MetaImpl(
A model,
... |
return "MetaImpl{" + "model=" + model + ", result=" + result + ", transform=" + transform + ", factory=" + factory + ", stack=" + stack + ", tree=" + tree + '}';
| 840 | 56 | 896 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/TransformFactoryImpl.java | TransformFactoryImpl | install | class TransformFactoryImpl implements TransformFactory {
private final Map<Class<?>, Set<Map.Entry<Class<?>, Supplier<? extends Transform<?, ?>>>>> transforms;
private final String name;
/**
* Instantiates the factory.
*
* @param name the unique name to use
*/
public TransformFacto... |
requireNonNulls(from, to, transform);
transforms.computeIfAbsent(from, f -> new HashSet<>())
.add(new AbstractMap.SimpleEntry<>(to, transform));
return this;
| 414 | 60 | 474 | <no_super_class> |
speedment_speedment | speedment/common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/java/JavaGenerator.java | JavaGenerator | compileAll | class JavaGenerator implements Generator {
private static final Pattern[] IGNORED = compileAll(
"^void$",
"^byte$",
"^short$",
"^char$",
"^int$",
"^long$",
"^boolean$",
"^float$",
"^double$",
"^java\\.lang\\.[^\\.]+$"
);
private final... |
final Set<Pattern> patterns = Stream.of(regexp)
.map(Pattern::compile)
.collect(Collectors.toSet());
return patterns.toArray(new Pattern[patterns.size()]);
| 824 | 58 | 882 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.