repo
stringlengths 1
191
⌀ | file
stringlengths 23
351
| code
stringlengths 0
5.32M
| file_length
int64 0
5.32M
| avg_line_length
float64 0
2.9k
| max_line_length
int64 0
288k
| extension_type
stringclasses 1
value |
|---|---|---|---|---|---|---|
soot
|
soot-master/src/main/java/soot/baf/SpecialInvokeInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface SpecialInvokeInst extends MethodArgInst {
}
| 916
| 32.962963
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/StaticGetInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface StaticGetInst extends FieldArgInst {
}
| 911
| 32.777778
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/StaticInvokeInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface StaticInvokeInst extends MethodArgInst {
}
| 915
| 32.925926
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/StaticPutInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface StaticPutInst extends FieldArgInst {
}
| 911
| 32.777778
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/StoreInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Local;
import soot.Type;
public interface StoreInst extends Inst {
public Type getOpType();
public void setOpType(Type opType);
public Local getLocal();
public void setLocal(Local l);
}
| 1,065
| 27.810811
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/SubInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface SubInst extends OpTypeArgInst {
}
| 906
| 32.592593
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/SwapInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Type;
public interface SwapInst extends Inst {
Type getFromType();
void setFromType(Type fromType);
Type getToType();
void setToType(Type toType);
}
| 1,028
| 27.583333
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/SwitchInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.List;
import soot.Unit;
import soot.UnitBox;
public interface SwitchInst extends Inst {
public Unit getDefaultTarget();
public void setDefaultTarget(Unit defTarget);
public UnitBox getDefaultTargetBox();
public int getTargetCount();
public List<Unit> getTargets();
public Unit getTarget(int index);
public void setTarget(int index, Unit target);
public void setTargets(List<Unit> targets);
public UnitBox getTargetBox(int index);
}
| 1,333
| 25.68
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/TableSwitchInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface TableSwitchInst extends SwitchInst {
public int getLowIndex();
public void setLowIndex(int index);
public int getHighIndex();
public void setHighIndex(int index);
}
| 1,049
| 29
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/TargetArgInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.UnitBox;
public interface TargetArgInst extends Inst {
public Unit getTarget();
public UnitBox getTargetBox();
public void setTarget(Unit target);
}
| 1,043
| 28.828571
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/ThrowInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface ThrowInst extends NoArgInst {
}
| 904
| 32.518519
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/UshrInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface UshrInst extends OpTypeArgInst {
}
| 907
| 32.62963
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/VirtualInvokeInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface VirtualInvokeInst extends MethodArgInst {
}
| 916
| 32.962963
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/WordType.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.G;
import soot.Singletons;
import soot.Type;
import soot.util.Switch;
public class WordType extends Type {
public WordType(Singletons.Global g) {
}
public static WordType v() {
return G.v().soot_baf_WordType();
}
@Override
public boolean equals(Object t) {
return this == t;
}
@Override
public int hashCode() {
return 0xB747239F;
}
@Override
public String toString() {
return "word";
}
@Override
public void apply(Switch sw) {
throw new RuntimeException("invalid switch case");
}
}
| 1,408
| 22.881356
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/XorInst.java
|
package soot.baf;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
public interface XorInst extends OpTypeArgInst {
}
| 906
| 32.592593
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/AbstractBranchInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.Collections;
import java.util.List;
import soot.Unit;
import soot.UnitBox;
import soot.UnitPrinter;
public abstract class AbstractBranchInst extends AbstractInst {
UnitBox targetBox;
final List<UnitBox> targetBoxes;
AbstractBranchInst(UnitBox targetBox) {
this.targetBox = targetBox;
this.targetBoxes = Collections.singletonList(targetBox);
}
@Override
public String toString() {
String target;
Unit targetUnit = getTarget();
if (this == targetUnit) {
target = getName();
} else {
target = targetUnit.toString();
}
return getName() + " " + target;
}
@Override
public void toString(UnitPrinter up) {
up.literal(getName());
up.literal(" ");
targetBox.toString(up);
}
public Unit getTarget() {
return targetBox.getUnit();
}
public void setTarget(Unit target) {
targetBox.setUnit(target);
}
public UnitBox getTargetBox() {
return targetBox;
}
@Override
public List<UnitBox> getUnitBoxes() {
return targetBoxes;
}
@Override
public boolean branches() {
return true;
}
}
| 1,976
| 22.819277
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/AbstractInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractUnit;
import soot.UnitPrinter;
import soot.baf.Inst;
public abstract class AbstractInst extends AbstractUnit implements Inst {
public abstract String getName();
@Override
public Object clone() {
throw new RuntimeException("undefined clone for: " + this.toString());
}
@Override
public String toString() {
return getName() + getParameters();
}
@Override
public void toString(UnitPrinter up) {
up.literal(getName());
getParameters(up);
}
@Override
public int getInCount() {
throw new RuntimeException("undefined " + toString() + "!");
}
@Override
public int getOutCount() {
throw new RuntimeException("undefined " + toString() + "!");
}
@Override
public int getNetCount() {
return getOutCount() - getInCount();
}
@Override
public boolean fallsThrough() {
return true;
}
@Override
public boolean branches() {
return false;
}
@Override
public int getInMachineCount() {
throw new RuntimeException("undefined" + toString() + "!");
}
@Override
public int getOutMachineCount() {
throw new RuntimeException("undefined" + toString() + "!");
}
@Override
public int getNetMachineCount() {
return getOutMachineCount() - getInMachineCount();
}
String getParameters() {
return "";
}
protected void getParameters(UnitPrinter up) {
}
@Override
public boolean containsInvokeExpr() {
return false;
}
@Override
public boolean containsArrayRef() {
return false;
}
@Override
public boolean containsFieldRef() {
return false;
}
@Override
public boolean containsNewExpr() {
return false;
}
}
| 2,539
| 20.896552
| 74
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/AbstractInvokeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.SootMethod;
import soot.SootMethodRef;
import soot.Type;
import soot.UnitPrinter;
import soot.VoidType;
public abstract class AbstractInvokeInst extends AbstractInst {
SootMethodRef methodRef;
public SootMethodRef getMethodRef() {
return methodRef;
}
public SootMethod getMethod() {
return methodRef.resolve();
}
public Type getType() {
return methodRef.getReturnType();
}
@Override
public String toString() {
return getName() + getParameters();
}
@Override
abstract public String getName();
@Override
String getParameters() {
return " " + methodRef.getSignature();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
up.methodRef(methodRef);
}
@Override
public int getInCount() {
return getMethodRef().getParameterTypes().size();
}
@Override
public int getOutCount() {
return (getMethodRef().getReturnType() instanceof VoidType) ? 0 : 1;
}
@Override
public int getInMachineCount() {
int count = 0;
for (Type t : getMethodRef().getParameterTypes()) {
count += AbstractJasminClass.sizeOfType(t);
}
return count;
}
@Override
public int getOutMachineCount() {
final Type returnType = getMethodRef().getReturnType();
return (returnType instanceof VoidType) ? 0 : AbstractJasminClass.sizeOfType(returnType);
}
@Override
public boolean containsInvokeExpr() {
return true;
}
}
| 2,353
| 23.268041
| 93
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/AbstractOpTypeBranchInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Type;
import soot.UnitBox;
import soot.UnitPrinter;
import soot.baf.Baf;
public abstract class AbstractOpTypeBranchInst extends AbstractBranchInst {
protected Type opType;
AbstractOpTypeBranchInst(Type opType, UnitBox targetBox) {
super(targetBox);
setOpType(opType);
}
public Type getOpType() {
return this.opType;
}
public void setOpType(Type t) {
this.opType = Baf.getDescriptorTypeOf(t);
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public String toString() {
// do stuff with opType later.
return getName() + "." + Baf.bafDescriptorOf(opType) + " " + getTarget();
}
@Override
public void toString(UnitPrinter up) {
up.literal(getName());
up.literal(".");
up.literal(Baf.bafDescriptorOf(opType));
up.literal(" ");
targetBox.toString(up);
}
}
| 1,785
| 23.805556
| 77
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/AbstractOpTypeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.UnitPrinter;
import soot.baf.Baf;
public abstract class AbstractOpTypeInst extends AbstractInst {
protected Type opType;
protected AbstractOpTypeInst(Type opType) {
setOpType(opType);
}
public Type getOpType() {
return opType;
}
public void setOpType(Type t) {
this.opType = Baf.getDescriptorTypeOf(t);
}
/* override AbstractInst's toString with our own, including types */
@Override
public String toString() {
return getName() + "." + Baf.bafDescriptorOf(opType) + getParameters();
}
@Override
public void toString(UnitPrinter up) {
up.literal(getName());
up.literal(".");
up.literal(Baf.bafDescriptorOf(opType));
getParameters(up);
}
@Override
public int getOutMachineCount() {
return AbstractJasminClass.sizeOfType(getOpType());
}
}
| 1,741
| 25.8
| 75
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/AbstractRefTypeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.RefType;
import soot.Type;
import soot.UnitPrinter;
public abstract class AbstractRefTypeInst extends AbstractInst {
Type opType;
protected AbstractRefTypeInst(RefType opType) {
this.opType = opType;
}
public Type getOpType() {
return opType;
}
public void setOpType(Type t) {
opType = t;
}
public RefType getBaseType() {
return (RefType) opType;
}
public void setBaseType(RefType type) {
this.opType = type;
}
@Override
String getParameters() {
return " " + opType.toString();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
up.type(opType);
}
}
| 1,526
| 22.859375
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/AbstractSwitchInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import soot.Unit;
import soot.UnitBox;
import soot.baf.Baf;
import soot.baf.SwitchInst;
public abstract class AbstractSwitchInst extends AbstractInst implements SwitchInst {
UnitBox defaultTargetBox;
UnitBox[] targetBoxes;
List<UnitBox> unitBoxes;
public AbstractSwitchInst(Unit defaultTarget, List<? extends Unit> targets) {
this.defaultTargetBox = Baf.v().newInstBox(defaultTarget);
// Build up 'targetBoxes'
final int numTargets = targets.size();
UnitBox[] tgts = new UnitBox[numTargets];
for (int i = 0; i < numTargets; i++) {
tgts[i] = Baf.v().newInstBox(targets.get(i));
}
this.targetBoxes = tgts;
// Build up 'unitBoxes'
List<UnitBox> unitBoxes = new ArrayList<UnitBox>(numTargets + 1);
for (UnitBox element : tgts) {
unitBoxes.add(element);
}
unitBoxes.add(defaultTargetBox);
this.unitBoxes = Collections.unmodifiableList(unitBoxes);
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public List<UnitBox> getUnitBoxes() {
return unitBoxes;
}
@Override
public boolean fallsThrough() {
return false;
}
@Override
public boolean branches() {
return true;
}
@Override
public Unit getDefaultTarget() {
return defaultTargetBox.getUnit();
}
@Override
public void setDefaultTarget(Unit defaultTarget) {
defaultTargetBox.setUnit(defaultTarget);
}
@Override
public UnitBox getDefaultTargetBox() {
return defaultTargetBox;
}
@Override
public int getTargetCount() {
return targetBoxes.length;
}
@Override
public Unit getTarget(int index) {
return targetBoxes[index].getUnit();
}
@Override
public void setTarget(int index, Unit target) {
targetBoxes[index].setUnit(target);
}
@Override
public void setTargets(List<Unit> targets) {
final UnitBox[] targetBoxes = this.targetBoxes;
for (int i = 0; i < targets.size(); i++) {
targetBoxes[i].setUnit(targets.get(i));
}
}
@Override
public UnitBox getTargetBox(int index) {
return targetBoxes[index];
}
@Override
public List<Unit> getTargets() {
List<Unit> targets = new ArrayList<Unit>();
for (UnitBox element : targetBoxes) {
targets.add(element.getUnit());
}
return targets;
}
}
| 3,422
| 22.285714
| 85
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BAddInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.AddInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BAddInst extends AbstractOpTypeInst implements AddInst {
public BAddInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BAddInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "add";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseAddInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BAndInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.AndInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BAndInst extends AbstractOpTypeInst implements AndInst {
public BAndInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BAndInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "and";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseAndInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BArrayLengthInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.baf.ArrayLengthInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BArrayLengthInst extends AbstractInst implements ArrayLengthInst {
public BArrayLengthInst() {
}
@Override
public Object clone() {
return new BArrayLengthInst();
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
public final String getName() {
return "arraylength";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseArrayLengthInst(this);
}
}
| 1,574
| 21.826087
| 79
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BArrayReadInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Type;
import soot.baf.ArrayReadInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BArrayReadInst extends AbstractOpTypeInst implements ArrayReadInst {
public BArrayReadInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BArrayReadInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2;
}
@Override
public int getOutCount() {
return 1;
}
@Override
final public String getName() {
return "arrayread";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseArrayReadInst(this);
}
@Override
public boolean containsArrayRef() {
return true;
}
}
| 1,630
| 21.971831
| 81
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BArrayWriteInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.ArrayWriteInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BArrayWriteInst extends AbstractOpTypeInst implements ArrayWriteInst {
public BArrayWriteInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BArrayWriteInst(getOpType());
}
@Override
public int getInCount() {
return 3;
}
@Override
public int getInMachineCount() {
return 2 + AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "arraywrite";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseArrayWriteInst(this);
}
@Override
public boolean containsArrayRef() {
return true;
}
}
| 1,783
| 22.168831
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BCmpInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Type;
import soot.baf.CmpInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BCmpInst extends AbstractOpTypeInst implements CmpInst {
public BCmpInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BCmpInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 4;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
public final String getName() {
return "cmp";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseCmpInst(this);
}
}
| 1,583
| 21.309859
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BCmpgInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.CmpgInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BCmpgInst extends AbstractOpTypeInst implements CmpgInst {
public BCmpgInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BCmpgInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
public final String getName() {
return "cmpg";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseCmpgInst(this);
}
}
| 1,669
| 22.194444
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BCmplInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.CmplInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BCmplInst extends AbstractOpTypeInst implements CmplInst {
public BCmplInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BCmplInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
public final String getName() {
return "cmpl";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseCmplInst(this);
}
}
| 1,669
| 22.194444
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDivInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.DivInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BDivInst extends AbstractOpTypeInst implements DivInst {
public BDivInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BDivInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "div";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseDivInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDup1Inst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.List;
import soot.Type;
import soot.UnitPrinter;
import soot.baf.Baf;
import soot.baf.Dup1Inst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BDup1Inst extends BDupInst implements Dup1Inst {
private final Type mOpType;
public BDup1Inst(Type aOpType) {
this.mOpType = Baf.getDescriptorTypeOf(aOpType);
}
@Override
public Type getOp1Type() {
return mOpType;
}
@Override
public List<Type> getOpTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mOpType);
return res;
}
@Override
public List<Type> getUnderTypes() {
return new ArrayList<Type>();
}
@Override
final public String getName() {
return "dup1";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseDup1Inst(this);
}
@Override
public String toString() {
return "dup1." + Baf.bafDescriptorOf(mOpType);
}
@Override
public void toString(UnitPrinter up) {
up.literal("dup1.");
up.literal(Baf.bafDescriptorOf(mOpType));
}
}
| 1,924
| 23.0625
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDup1_x1Inst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.List;
import soot.Type;
import soot.baf.Baf;
import soot.baf.Dup1_x1Inst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BDup1_x1Inst extends BDupInst implements Dup1_x1Inst {
private final Type mOpType;
private final Type mUnderType;
public BDup1_x1Inst(Type aOpType, Type aUnderType) {
this.mOpType = Baf.getDescriptorTypeOf(aOpType);
this.mUnderType = Baf.getDescriptorTypeOf(aUnderType);
}
@Override
public Type getOp1Type() {
return mOpType;
}
@Override
public Type getUnder1Type() {
return mUnderType;
}
@Override
public List<Type> getOpTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mOpType);
return res;
}
@Override
public List<Type> getUnderTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mUnderType);
return res;
}
@Override
final public String getName() {
return "dup1_x1";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseDup1_x1Inst(this);
}
@Override
public String toString() {
return "dup1_x1." + Baf.bafDescriptorOf(mOpType) + "_" + Baf.bafDescriptorOf(mUnderType);
}
}
| 2,064
| 23.879518
| 93
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDup1_x2Inst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.List;
import soot.Type;
import soot.baf.Baf;
import soot.baf.Dup1_x2Inst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BDup1_x2Inst extends BDupInst implements Dup1_x2Inst {
private final Type mOpType;
private final Type mUnder1Type;
private final Type mUnder2Type;
public BDup1_x2Inst(Type aOpType, Type aUnder1Type, Type aUnder2Type) {
this.mOpType = Baf.getDescriptorTypeOf(aOpType);
this.mUnder1Type = Baf.getDescriptorTypeOf(aUnder1Type);
this.mUnder2Type = Baf.getDescriptorTypeOf(aUnder2Type);
}
@Override
public Type getOp1Type() {
return mOpType;
}
@Override
public Type getUnder1Type() {
return mUnder1Type;
}
@Override
public Type getUnder2Type() {
return mUnder2Type;
}
@Override
public List<Type> getOpTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mOpType);
return res;
}
@Override
public List<Type> getUnderTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mUnder1Type);
res.add(mUnder2Type);
return res;
}
@Override
final public String getName() {
return "dup1_x2";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseDup1_x2Inst(this);
}
@Override
public String toString() {
return "dup1_x2." + Baf.bafDescriptorOf(mOpType) + "_" + Baf.bafDescriptorOf(mUnder1Type) + "."
+ Baf.bafDescriptorOf(mUnder2Type);
}
}
| 2,332
| 24.358696
| 99
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDup2Inst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.List;
import soot.Type;
import soot.baf.Baf;
import soot.baf.Dup2Inst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BDup2Inst extends BDupInst implements Dup2Inst {
private final Type mOp1Type;
private final Type mOp2Type;
public BDup2Inst(Type aOp1Type, Type aOp2Type) {
this.mOp1Type = Baf.getDescriptorTypeOf(aOp1Type);
this.mOp2Type = Baf.getDescriptorTypeOf(aOp2Type);
}
@Override
public Type getOp1Type() {
return mOp1Type;
}
@Override
public Type getOp2Type() {
return mOp2Type;
}
@Override
public List<Type> getOpTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mOp1Type);
res.add(mOp2Type);
return res;
}
@Override
public List<Type> getUnderTypes() {
return new ArrayList<Type>();
}
@Override
final public String getName() {
return "dup2";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseDup2Inst(this);
}
@Override
public String toString() {
return "dup2." + Baf.bafDescriptorOf(mOp1Type) + Baf.bafDescriptorOf(mOp2Type);
}
}
| 2,000
| 23.703704
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDup2_x1Inst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.List;
import soot.Type;
import soot.baf.Baf;
import soot.baf.Dup2_x1Inst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BDup2_x1Inst extends BDupInst implements Dup2_x1Inst {
private final Type mOp1Type;
private final Type mOp2Type;
private final Type mUnderType;
public BDup2_x1Inst(Type aOp1Type, Type aOp2Type, Type aUnderType) {
this.mOp1Type = Baf.getDescriptorTypeOf(aOp1Type);
this.mOp2Type = Baf.getDescriptorTypeOf(aOp2Type);
this.mUnderType = Baf.getDescriptorTypeOf(aUnderType);
}
@Override
public Type getOp1Type() {
return mOp1Type;
}
@Override
public Type getOp2Type() {
return mOp2Type;
}
@Override
public Type getUnder1Type() {
return mUnderType;
}
@Override
public List<Type> getOpTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mOp1Type);
res.add(mOp2Type);
return res;
}
@Override
public List<Type> getUnderTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mUnderType);
return res;
}
@Override
final public String getName() {
return "dup2_x1";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseDup2_x1Inst(this);
}
@Override
public String toString() {
return "dup2_x1." + Baf.bafDescriptorOf(mOp1Type) + "." + Baf.bafDescriptorOf(mOp2Type) + "_"
+ Baf.bafDescriptorOf(mUnderType);
}
}
| 2,308
| 24.097826
| 97
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDup2_x2Inst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.List;
import soot.Type;
import soot.baf.Baf;
import soot.baf.Dup2_x2Inst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BDup2_x2Inst extends BDupInst implements Dup2_x2Inst {
private final Type mOp1Type;
private final Type mOp2Type;
private final Type mUnder1Type;
private final Type mUnder2Type;
public BDup2_x2Inst(Type aOp1Type, Type aOp2Type, Type aUnder1Type, Type aUnder2Type) {
this.mOp1Type = Baf.getDescriptorTypeOf(aOp1Type);
this.mOp2Type = Baf.getDescriptorTypeOf(aOp2Type);
this.mUnder1Type = Baf.getDescriptorTypeOf(aUnder1Type);
this.mUnder2Type = Baf.getDescriptorTypeOf(aUnder2Type);
}
@Override
public Type getOp1Type() {
return mOp1Type;
}
@Override
public Type getOp2Type() {
return mOp2Type;
}
@Override
public Type getUnder1Type() {
return mUnder1Type;
}
@Override
public Type getUnder2Type() {
return mUnder2Type;
}
@Override
public List<Type> getOpTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mOp1Type);
// 07-20-2006 Michael Batchelder
// previously did not handle all types of dup2_x2 Now, will take null as mOp2Type, so don't add to overtypes if it is
// null
if (mOp2Type != null) {
res.add(mOp2Type);
}
return res;
}
@Override
public List<Type> getUnderTypes() {
List<Type> res = new ArrayList<Type>();
res.add(mUnder1Type);
// 07-20-2006 Michael Batchelder
// previously did not handle all types of dup2_x2 Now, will take null as mUnder2Type, so don't add to undertypes if it is
// null
if (mUnder2Type != null) {
res.add(mUnder2Type);
}
return res;
}
@Override
final public String getName() {
return "dup2_x2";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseDup2_x2Inst(this);
}
@Override
public String toString() {
// 07-20-2006 Michael Batchelder
// previously did not handle all types of dup2_x2 Now, will take null as either mOp2Type or null as mUnder2Type to handle
// ALL types of dup2_x2
// old code:
// return "dup2_x2." + Baf.bafDescriptorOf(mOp1Type) + "." + Baf.bafDescriptorOf(mOp2Type) + "_" +
// Baf.bafDescriptorOf(mUnder1Type) + "." +
// Baf.bafDescriptorOf(mUnder2Type);
String optypes = Baf.bafDescriptorOf(mOp1Type);
if (mOp2Type != null) {
optypes += "." + Baf.bafDescriptorOf(mOp2Type);
}
String undertypes = Baf.bafDescriptorOf(mUnder1Type);
if (mUnder2Type != null) {
optypes += "." + Baf.bafDescriptorOf(mUnder2Type);
}
return "dup2_x2." + optypes + "_" + undertypes;
// END 07-20-2006 Michael Batchelder
}
}
| 3,595
| 26.875969
| 125
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDupInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.DupInst;
import soot.util.Switch;
public abstract class BDupInst extends AbstractInst implements DupInst {
@Override
public int getInCount() {
return getUnderTypes().size() + getOpTypes().size();
}
@Override
public int getInMachineCount() {
int count = 0;
for (Type t : getUnderTypes()) {
count += AbstractJasminClass.sizeOfType(t);
}
for (Type t : getOpTypes()) {
count += AbstractJasminClass.sizeOfType(t);
}
return count;
}
@Override
public int getOutCount() {
return getUnderTypes().size() + 2 * getOpTypes().size();
}
@Override
public int getOutMachineCount() {
int count = 0;
for (Type t : getUnderTypes()) {
count += AbstractJasminClass.sizeOfType(t);
}
for (Type t : getOpTypes()) {
count += 2 * AbstractJasminClass.sizeOfType(t);
}
return count;
}
@Override
public void apply(Switch sw) {
throw new RuntimeException();
}
}
| 1,883
| 25.535211
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BDynamicInvokeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
* Copyright (C) 2004 Ondrej Lhotak
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.Iterator;
import java.util.List;
import soot.SootMethod;
import soot.SootMethodRef;
import soot.UnitPrinter;
import soot.Value;
import soot.VoidType;
import soot.baf.DynamicInvokeInst;
import soot.baf.InstSwitch;
import soot.jimple.Jimple;
import soot.util.Switch;
@SuppressWarnings("serial")
public class BDynamicInvokeInst extends AbstractInvokeInst implements DynamicInvokeInst {
protected final SootMethodRef bsmRef;
private final List<Value> bsmArgs;
protected int tag;
public BDynamicInvokeInst(SootMethodRef bsmMethodRef, List<Value> bsmArgs, SootMethodRef methodRef, int tag) {
super.methodRef = methodRef;
this.bsmRef = bsmMethodRef;
this.bsmArgs = bsmArgs;
this.tag = tag;
}
@Override
public Object clone() {
return new BDynamicInvokeInst(bsmRef, bsmArgs, methodRef, tag);
}
@Override
public int getInCount() {
return methodRef.getParameterTypes().size();
}
@Override
public int getOutCount() {
return (methodRef.getReturnType() instanceof VoidType) ? 0 : 1;
}
@Override
public SootMethodRef getBootstrapMethodRef() {
return bsmRef;
}
@Override
public List<Value> getBootstrapArgs() {
return bsmArgs;
}
@Override
public String getName() {
return "dynamicinvoke";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseDynamicInvokeInst(this);
}
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(Jimple.DYNAMICINVOKE + " \"");
buffer.append(methodRef.getName()); // quoted method name (can be any UTF8 string)
buffer.append("\" <");
buffer.append(
SootMethod.getSubSignature(""/* no method name here */, methodRef.getParameterTypes(), methodRef.getReturnType()));
buffer.append('>');
buffer.append(bsmRef.getSignature());
buffer.append('(');
for (Iterator<Value> it = bsmArgs.iterator(); it.hasNext();) {
Value v = it.next();
buffer.append(v.toString());
if (it.hasNext()) {
buffer.append(", ");
}
}
buffer.append(')');
return buffer.toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.DYNAMICINVOKE + " \"");
up.literal(methodRef.getName());
up.literal("\" <");
up.literal(
SootMethod.getSubSignature(""/* no method name here */, methodRef.getParameterTypes(), methodRef.getReturnType()));
up.literal("> ");
up.methodRef(bsmRef);
up.literal("(");
for (Iterator<Value> it = bsmArgs.iterator(); it.hasNext();) {
Value v = it.next();
v.toString(up);
if (it.hasNext()) {
up.literal(", ");
}
}
up.literal(")");
}
@Override
public int getHandleTag() {
return tag;
}
}
| 3,677
| 25.460432
| 123
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BEnterMonitorInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.baf.EnterMonitorInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BEnterMonitorInst extends AbstractInst implements EnterMonitorInst {
public BEnterMonitorInst() {
}
@Override
public Object clone() {
return new BEnterMonitorInst();
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "entermonitor";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseEnterMonitorInst(this);
}
}
| 1,581
| 21.927536
| 81
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BExitMonitorInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.baf.ExitMonitorInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BExitMonitorInst extends AbstractInst implements ExitMonitorInst {
public BExitMonitorInst() {
}
@Override
public Object clone() {
return new BExitMonitorInst();
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "exitmonitor";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseExitMonitorInst(this);
}
}
| 1,574
| 21.826087
| 79
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BFieldGetInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.SootField;
import soot.SootFieldRef;
import soot.UnitPrinter;
import soot.baf.FieldGetInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BFieldGetInst extends AbstractInst implements FieldGetInst {
SootFieldRef fieldRef;
public BFieldGetInst(SootFieldRef fieldRef) {
if (fieldRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
this.fieldRef = fieldRef;
}
@Override
public Object clone() {
return new BFieldGetInst(fieldRef);
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return AbstractJasminClass.sizeOfType(fieldRef.type());
}
@Override
final public String getName() {
return "fieldget";
}
@Override
final String getParameters() {
return " " + fieldRef.getSignature();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
up.fieldRef(fieldRef);
}
@Override
public SootFieldRef getFieldRef() {
return fieldRef;
}
@Override
public SootField getField() {
return fieldRef.resolve();
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseFieldGetInst(this);
}
@Override
public boolean containsFieldRef() {
return true;
}
}
| 2,317
| 21.07619
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BFieldPutInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
* Copyright (C) 2004 Ondrej Lhotak
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.SootField;
import soot.SootFieldRef;
import soot.UnitPrinter;
import soot.baf.FieldPutInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BFieldPutInst extends AbstractInst implements FieldPutInst {
SootFieldRef fieldRef;
public BFieldPutInst(SootFieldRef fieldRef) {
if (fieldRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
this.fieldRef = fieldRef;
}
@Override
public Object clone() {
return new BFieldPutInst(fieldRef);
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(fieldRef.type()) + 1;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "fieldput";
}
@Override
final String getParameters() {
return " " + fieldRef.getSignature();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
up.fieldRef(fieldRef);
}
@Override
public SootFieldRef getFieldRef() {
return fieldRef;
}
@Override
public SootField getField() {
return fieldRef.resolve();
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseFieldPutInst(this);
}
@Override
public boolean containsFieldRef() {
return true;
}
}
| 2,357
| 21.245283
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BGotoInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.GotoInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BGotoInst extends AbstractBranchInst implements GotoInst {
public BGotoInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BGotoInst(getTarget());
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public boolean branches() {
return true;
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "goto";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseGotoInst(this);
}
@Override
public boolean fallsThrough() {
return false;
}
}
| 1,758
| 20.45122
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIdentityInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import soot.UnitPrinter;
import soot.Value;
import soot.ValueBox;
import soot.baf.Baf;
import soot.baf.IdentityInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIdentityInst extends AbstractInst implements IdentityInst {
ValueBox leftBox;
ValueBox rightBox;
List<ValueBox> defBoxes;
protected BIdentityInst(ValueBox localBox, ValueBox identityValueBox) {
this.leftBox = localBox;
this.rightBox = identityValueBox;
this.defBoxes = Collections.singletonList(localBox);
}
public BIdentityInst(Value local, Value identityValue) {
this(Baf.v().newLocalBox(local), Baf.v().newIdentityRefBox(identityValue));
}
@Override
public Object clone() {
return new BIdentityInst(getLeftOp(), getRightOp());
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public Value getLeftOp() {
return leftBox.getValue();
}
@Override
public Value getRightOp() {
return rightBox.getValue();
}
@Override
public ValueBox getLeftOpBox() {
return leftBox;
}
@Override
public ValueBox getRightOpBox() {
return rightBox;
}
@Override
public List<ValueBox> getDefBoxes() {
return defBoxes;
}
@Override
public List<ValueBox> getUseBoxes() {
List<ValueBox> list = new ArrayList<ValueBox>();
list.addAll(rightBox.getValue().getUseBoxes());
list.add(rightBox);
list.addAll(leftBox.getValue().getUseBoxes());
return list;
}
@Override
public String toString() {
return leftBox.getValue().toString() + " := " + rightBox.getValue().toString();
}
@Override
public void toString(UnitPrinter up) {
leftBox.toString(up);
up.literal(" := ");
rightBox.toString(up);
}
@Override
final public String getName() {
return ":=";
}
@Override
public void setLeftOp(Value local) {
leftBox.setValue(local);
}
@Override
public void setRightOp(Value identityRef) {
rightBox.setValue(identityRef);
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIdentityInst(this);
}
}
| 3,210
| 20.993151
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfCmpEqInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfCmpEqInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfCmpEqInst extends AbstractOpTypeBranchInst implements IfCmpEqInst {
public BIfCmpEqInst(Type opType, Unit target) {
super(opType, Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfCmpEqInst(getOpType(), getTarget());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifcmpeq";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfCmpEqInst(this);
}
}
| 1,783
| 23.108108
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfCmpGeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfCmpGeInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfCmpGeInst extends AbstractOpTypeBranchInst implements IfCmpGeInst {
public BIfCmpGeInst(Type opType, Unit target) {
super(opType, Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfCmpGeInst(getOpType(), getTarget());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifcmpge";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfCmpGeInst(this);
}
}
| 1,783
| 23.108108
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfCmpGtInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfCmpGtInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfCmpGtInst extends AbstractOpTypeBranchInst implements IfCmpGtInst {
public BIfCmpGtInst(Type opType, Unit target) {
super(opType, Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfCmpGtInst(getOpType(), getTarget());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifcmpgt";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfCmpGtInst(this);
}
}
| 1,783
| 23.108108
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfCmpLeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfCmpLeInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfCmpLeInst extends AbstractOpTypeBranchInst implements IfCmpLeInst {
public BIfCmpLeInst(Type opType, Unit target) {
super(opType, Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfCmpLeInst(getOpType(), getTarget());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifcmple";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfCmpLeInst(this);
}
}
| 1,783
| 23.108108
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfCmpLtInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfCmpLtInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfCmpLtInst extends AbstractOpTypeBranchInst implements IfCmpLtInst {
public BIfCmpLtInst(Type opType, Unit target) {
super(opType, Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfCmpLtInst(getOpType(), getTarget());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifcmplt";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfCmpLtInst(this);
}
}
| 1,783
| 23.108108
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfCmpNeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfCmpNeInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfCmpNeInst extends AbstractOpTypeBranchInst implements IfCmpNeInst {
public BIfCmpNeInst(Type opType, Unit target) {
super(opType, Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfCmpNeInst(getOpType(), getTarget());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifcmpne";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfCmpNeInst(this);
}
}
| 1,783
| 23.108108
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfEqInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfEqInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfEqInst extends AbstractBranchInst implements IfEqInst {
public BIfEqInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfEqInst(getTarget());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifeq";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfEqInst(this);
}
}
| 1,625
| 21.583333
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfGeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfGeInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfGeInst extends AbstractBranchInst implements IfGeInst {
public BIfGeInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfGeInst(getTarget());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifge";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfGeInst(this);
}
}
| 1,625
| 21.583333
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfGtInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfGtInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfGtInst extends AbstractBranchInst implements IfGtInst {
public BIfGtInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfGtInst(getTarget());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifgt";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfGtInst(this);
}
}
| 1,625
| 21.583333
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfLeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfLeInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfLeInst extends AbstractBranchInst implements IfLeInst {
public BIfLeInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfLeInst(getTarget());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifle";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfLeInst(this);
}
}
| 1,625
| 21.583333
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfLtInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfLtInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfLtInst extends AbstractBranchInst implements IfLtInst {
public BIfLtInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfLtInst(getTarget());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "iflt";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfLtInst(this);
}
}
| 1,625
| 21.583333
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfNeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfNeInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfNeInst extends AbstractBranchInst implements IfNeInst {
public BIfNeInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfNeInst(getTarget());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifne";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfNeInst(this);
}
}
| 1,625
| 21.583333
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfNonNullInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfNonNullInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfNonNullInst extends AbstractBranchInst implements IfNonNullInst {
public BIfNonNullInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfNonNullInst(getTarget());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifnonnull";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfNonNullInst(this);
}
}
| 1,660
| 22.069444
| 81
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIfNullInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.IfNullInst;
import soot.baf.InstSwitch;
import soot.util.Switch;
public class BIfNullInst extends AbstractBranchInst implements IfNullInst {
public BIfNullInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BIfNullInst(getTarget());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public String getName() {
return "ifnull";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIfNullInst(this);
}
}
| 1,639
| 21.777778
| 75
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BIncInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.Collections;
import java.util.List;
import soot.Local;
import soot.UnitPrinter;
import soot.ValueBox;
import soot.baf.IncInst;
import soot.baf.InstSwitch;
import soot.jimple.Constant;
import soot.util.Switch;
public class BIncInst extends AbstractInst implements IncInst {
final ValueBox localBox;
final ValueBox defLocalBox;
final List<ValueBox> useBoxes;
final List<ValueBox> mDefBoxes;
Constant mConstant;
public BIncInst(Local local, Constant constant) {
this.mConstant = constant;
this.localBox = new BafLocalBox(local);
this.useBoxes = Collections.singletonList(localBox);
this.defLocalBox = new BafLocalBox(local);
this.mDefBoxes = Collections.singletonList(defLocalBox);
}
@Override
public Object clone() {
return new BIncInst(getLocal(), getConstant());
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public Constant getConstant() {
return mConstant;
}
@Override
public void setConstant(Constant aConstant) {
this.mConstant = aConstant;
}
@Override
final public String getName() {
return "inc.i";
}
@Override
final String getParameters() {
return " " + localBox.getValue().toString();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
localBox.toString(up);
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseIncInst(this);
}
@Override
public void setLocal(Local l) {
localBox.setValue(l);
}
@Override
public Local getLocal() {
return (Local) localBox.getValue();
}
@Override
public List<ValueBox> getUseBoxes() {
return useBoxes;
}
@Override
public List<ValueBox> getDefBoxes() {
return mDefBoxes;
}
@Override
public String toString() {
return "inc.i " + getLocal() + " " + getConstant();
}
@Override
public void toString(UnitPrinter up) {
up.literal("inc.i ");
localBox.toString(up);
up.literal(" ");
up.constant(mConstant);
}
}
| 3,076
| 20.669014
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BInstanceCastInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.ArrayType;
import soot.RefType;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.InstanceCastInst;
import soot.util.Switch;
public class BInstanceCastInst extends AbstractInst implements InstanceCastInst {
protected Type castType;
public BInstanceCastInst(Type opType) {
if (!(opType instanceof RefType) && !(opType instanceof ArrayType)) {
throw new RuntimeException("invalid InstanceCastInst: " + opType);
}
this.castType = opType;
}
@Override
public Object clone() {
return new BInstanceCastInst(castType);
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
final public String getName() {
return "checkcast";
}
@Override
public Type getCastType() {
return castType;
}
@Override
public void setCastType(Type t) {
castType = t;
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseInstanceCastInst(this);
}
}
| 2,007
| 21.818182
| 81
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BInstanceOfInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.ArrayType;
import soot.RefType;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.InstanceOfInst;
import soot.util.Switch;
public class BInstanceOfInst extends AbstractInst implements InstanceOfInst {
protected Type checkType;
public BInstanceOfInst(Type opType) {
if (!(opType instanceof RefType) && !(opType instanceof ArrayType)) {
throw new RuntimeException("invalid InstanceOfInst: " + opType);
}
this.checkType = opType;
}
@Override
public Object clone() {
return new BInstanceOfInst(checkType);
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
final public String getName() {
return "instanceof";
}
@Override
public Type getCheckType() {
return checkType;
}
@Override
public void setCheckType(Type t) {
checkType = t;
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseInstanceOfInst(this);
}
}
| 2,001
| 21.75
| 77
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BInterfaceInvokeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
* Copyright (C) 2004 Ondrej Lhotak
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.SootMethodRef;
import soot.UnitPrinter;
import soot.baf.InstSwitch;
import soot.baf.InterfaceInvokeInst;
import soot.util.Switch;
public class BInterfaceInvokeInst extends AbstractInvokeInst implements InterfaceInvokeInst {
int argCount;
public BInterfaceInvokeInst(SootMethodRef methodRef, int argCount) {
if (methodRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
super.methodRef = methodRef;
this.argCount = argCount;
}
@Override
public Object clone() {
return new BInterfaceInvokeInst(methodRef, getArgCount());
}
@Override
public int getInCount() {
return methodRef.getParameterTypes().size() + 1;
}
@Override
public int getInMachineCount() {
return super.getInMachineCount() + 1;
}
@Override
final public String getName() {
return "interfaceinvoke";
}
@Override
final String getParameters() {
return super.getParameters() + " " + argCount;
}
@Override
protected void getParameters(UnitPrinter up) {
super.getParameters(up);
up.literal(" ");
up.literal(Integer.toString(argCount));
}
@Override
public int getArgCount() {
return argCount;
}
@Override
public void setArgCount(int x) {
argCount = x;
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseInterfaceInvokeInst(this);
}
}
| 2,268
| 23.934066
| 93
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BJSRInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Unit;
import soot.baf.Baf;
import soot.baf.InstSwitch;
import soot.baf.JSRInst;
import soot.util.Switch;
public class BJSRInst extends AbstractBranchInst implements JSRInst {
public BJSRInst(Unit target) {
super(Baf.v().newInstBox(target));
}
@Override
public Object clone() {
return new BJSRInst(getTarget());
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public boolean branches() {
return true;
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
public String getName() {
return "jsr";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseJSRInst(this);
}
@Override
public boolean fallsThrough() {
return false;
}
}
| 1,750
| 20.617284
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BLoadInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.Collections;
import java.util.List;
import soot.Local;
import soot.Type;
import soot.UnitPrinter;
import soot.ValueBox;
import soot.baf.InstSwitch;
import soot.baf.LoadInst;
import soot.util.Switch;
public class BLoadInst extends AbstractOpTypeInst implements LoadInst {
ValueBox localBox;
List<ValueBox> useBoxes;
public BLoadInst(Type opType, Local local) {
super(opType);
this.localBox = new BafLocalBox(local);
this.useBoxes = Collections.singletonList(localBox);
}
@Override
public Object clone() {
return new BLoadInst(getOpType(), getLocal());
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 1;
}
@Override
final public String getName() {
return "load";
}
@Override
final String getParameters() {
return " " + localBox.getValue().toString();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
localBox.toString(up);
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseLoadInst(this);
}
@Override
public void setLocal(Local l) {
localBox.setValue(l);
}
@Override
public Local getLocal() {
return (Local) localBox.getValue();
}
@Override
public List<ValueBox> getUseBoxes() {
return useBoxes;
}
}
| 2,271
| 21.058252
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BLookupSwitchInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import soot.Unit;
import soot.UnitPrinter;
import soot.baf.InstSwitch;
import soot.baf.LookupSwitchInst;
import soot.jimple.Constant;
import soot.jimple.IntConstant;
import soot.util.Switch;
public class BLookupSwitchInst extends AbstractSwitchInst implements LookupSwitchInst {
List<IntConstant> lookupValues;
public BLookupSwitchInst(Unit defaultTarget, List<IntConstant> lookupValues, List<? extends Unit> targets) {
super(defaultTarget, targets);
setLookupValues(lookupValues);
}
@Override
public Object clone() {
return new BLookupSwitchInst(getDefaultTarget(), lookupValues, getTargets());
}
@Override
public void setLookupValues(List<IntConstant> lookupValues) {
this.lookupValues = new ArrayList<IntConstant>(lookupValues);
}
@Override
public void setLookupValue(int index, int value) {
this.lookupValues.set(index, IntConstant.v(value));
}
@Override
public int getLookupValue(int index) {
return lookupValues.get(index).value;
}
@Override
public List<IntConstant> getLookupValues() {
return Collections.unmodifiableList(lookupValues);
}
@Override
public String getName() {
return "lookupswitch";
}
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
String endOfLine = " ";
buffer.append("lookupswitch").append(endOfLine);
buffer.append("{").append(endOfLine);
for (int i = 0; i < lookupValues.size(); i++) {
buffer.append(" case ").append(lookupValues.get(i)).append(": goto ").append(getTarget(i)).append(";")
.append(endOfLine);
}
buffer.append(" default: goto ").append(getDefaultTarget()).append(";").append(endOfLine);
buffer.append("}");
return buffer.toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal("lookupswitch");
up.newline();
up.literal("{");
up.newline();
for (int i = 0; i < lookupValues.size(); i++) {
up.literal(" case ");
up.constant((Constant) lookupValues.get(i));
up.literal(": goto ");
targetBoxes[i].toString(up);
up.literal(";");
up.newline();
}
up.literal(" default: goto ");
defaultTargetBox.toString(up);
up.literal(";");
up.newline();
up.literal("}");
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseLookupSwitchInst(this);
}
}
| 3,341
| 25.951613
| 111
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BMulInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.MulInst;
import soot.util.Switch;
public class BMulInst extends AbstractOpTypeInst implements MulInst {
public BMulInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BMulInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "mul";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseMulInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BNegInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.NegInst;
import soot.util.Switch;
public class BNegInst extends AbstractOpTypeInst implements NegInst {
public BNegInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BNegInst(getOpType());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutMachineCount() {
return AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "neg";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseNegInst(this);
}
}
| 1,700
| 22.625
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BNewArrayInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.NewArrayInst;
import soot.util.Switch;
public class BNewArrayInst extends AbstractInst implements NewArrayInst {
protected Type baseType;
public BNewArrayInst(Type opType) {
this.baseType = opType;
}
@Override
public Object clone() {
return new BNewArrayInst(baseType);
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
final public String getName() {
return "newarray";
}
@Override
public Type getBaseType() {
return baseType;
}
@Override
public void setBaseType(Type type) {
baseType = type;
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseNewArrayInst(this);
}
@Override
public boolean containsNewExpr() {
return true;
}
}
| 1,862
| 20.170455
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BNewInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.RefType;
import soot.baf.InstSwitch;
import soot.baf.NewInst;
import soot.util.Switch;
public class BNewInst extends AbstractRefTypeInst implements NewInst {
public BNewInst(RefType opType) {
super(opType);
}
@Override
public Object clone() {
return new BNewInst(getBaseType());
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
final public String getName() {
return "new";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseNewInst(this);
}
@Override
public boolean containsNewExpr() {
return true;
}
}
| 1,663
| 20.894737
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BNewMultiArrayInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.ArrayType;
import soot.UnitPrinter;
import soot.baf.InstSwitch;
import soot.baf.NewMultiArrayInst;
import soot.util.Switch;
public class BNewMultiArrayInst extends AbstractInst implements NewMultiArrayInst {
int dimensionCount;
ArrayType baseType;
public BNewMultiArrayInst(ArrayType opType, int dimensionCount) {
this.dimensionCount = dimensionCount;
this.baseType = opType;
}
@Override
public Object clone() {
return new BNewMultiArrayInst(getBaseType(), getDimensionCount());
}
@Override
public int getInCount() {
return dimensionCount;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getInMachineCount() {
return dimensionCount;
}
@Override
public int getOutMachineCount() {
return 1;
}
@Override
final public String getName() {
return "newmultiarray";
}
@Override
final String getParameters() {
return " " + dimensionCount;
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
up.literal(Integer.toString(dimensionCount));
}
@Override
public ArrayType getBaseType() {
return baseType;
}
@Override
public void setBaseType(ArrayType type) {
this.baseType = type;
}
@Override
public int getDimensionCount() {
return dimensionCount;
}
@Override
public void setDimensionCount(int x) {
this.dimensionCount = x;
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseNewMultiArrayInst(this);
}
@Override
public boolean containsNewExpr() {
return true;
}
}
| 2,464
| 21.008929
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BNopInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.baf.InstSwitch;
import soot.baf.NopInst;
import soot.util.Switch;
public class BNopInst extends AbstractInst implements NopInst {
public BNopInst() {
}
@Override
public Object clone() {
return new BNopInst();
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "nop";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseNopInst(this);
}
}
| 1,518
| 21.014493
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BOrInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.OrInst;
import soot.util.Switch;
public class BOrInst extends AbstractOpTypeInst implements OrInst {
public BOrInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BOrInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "or";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseOrInst(this);
}
}
| 1,701
| 22.638889
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BPopInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.PopInst;
import soot.util.Switch;
public class BPopInst extends AbstractInst implements PopInst {
protected Type mType;
public BPopInst(Type aType) {
this.mType = aType;
}
@Override
public Object clone() {
return new BPopInst(mType);
}
@Override
public int getWordCount() {
return getInMachineCount();
}
@Override
public void setWordCount(int count) {
throw new RuntimeException("not implemented");
}
@Override
final public String getName() {
return "pop";
}
@Override
final String getParameters() {
return "";
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(mType);
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).casePopInst(this);
}
public Type getType() {
return mType;
}
}
| 1,970
| 20.193548
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BPrimitiveCastInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.BooleanType;
import soot.ByteType;
import soot.CharType;
import soot.DoubleType;
import soot.FloatType;
import soot.IntType;
import soot.LongType;
import soot.NullType;
import soot.ShortType;
import soot.Type;
import soot.TypeSwitch;
import soot.baf.InstSwitch;
import soot.baf.PrimitiveCastInst;
import soot.util.Switch;
public class BPrimitiveCastInst extends AbstractInst implements PrimitiveCastInst {
Type fromType;
protected Type toType;
public BPrimitiveCastInst(Type fromType, Type toType) {
if (fromType instanceof NullType) {
throw new RuntimeException("invalid fromType " + fromType);
}
this.fromType = fromType;
this.toType = toType;
}
@Override
public Object clone() {
return new BPrimitiveCastInst(getFromType(), toType);
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(fromType);
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return AbstractJasminClass.sizeOfType(toType);
}
// after changing the types, use getName to check validity
@Override
public Type getFromType() {
return fromType;
}
@Override
public void setFromType(Type t) {
this.fromType = t;
}
@Override
public Type getToType() {
return toType;
}
@Override
public void setToType(Type t) {
this.toType = t;
}
@Override
final public String getName() {
TypeSwitch<String> sw = new TypeSwitch<String>() {
@Override
public void defaultCase(Type ty) {
throw new RuntimeException("invalid fromType " + fromType);
}
@Override
public void caseDoubleType(DoubleType ty) {
if (IntType.v().equals(toType)) {
setResult("d2i");
} else if (LongType.v().equals(toType)) {
setResult("d2l");
} else if (FloatType.v().equals(toType)) {
setResult("d2f");
} else {
throw new RuntimeException("invalid toType from double: " + toType);
}
}
@Override
public void caseFloatType(FloatType ty) {
if (IntType.v().equals(toType)) {
setResult("f2i");
} else if (LongType.v().equals(toType)) {
setResult("f2l");
} else if (DoubleType.v().equals(toType)) {
setResult("f2d");
} else {
throw new RuntimeException("invalid toType from float: " + toType);
}
}
@Override
public void caseIntType(IntType ty) {
emitIntToTypeCast();
}
@Override
public void caseBooleanType(BooleanType ty) {
emitIntToTypeCast();
}
@Override
public void caseByteType(ByteType ty) {
emitIntToTypeCast();
}
@Override
public void caseCharType(CharType ty) {
emitIntToTypeCast();
}
@Override
public void caseShortType(ShortType ty) {
emitIntToTypeCast();
}
private void emitIntToTypeCast() {
if (ByteType.v().equals(toType)) {
setResult("i2b");
} else if (CharType.v().equals(toType)) {
setResult("i2c");
} else if (ShortType.v().equals(toType)) {
setResult("i2s");
} else if (FloatType.v().equals(toType)) {
setResult("i2f");
} else if (LongType.v().equals(toType)) {
setResult("i2l");
} else if (DoubleType.v().equals(toType)) {
setResult("i2d");
} else if (IntType.v().equals(toType)) {
setResult(""); // this shouldn't happen?
} else if (BooleanType.v().equals(toType)) {
setResult("");
} else {
throw new RuntimeException("invalid toType from int: " + toType);
}
}
@Override
public void caseLongType(LongType ty) {
if (IntType.v().equals(toType)) {
setResult("l2i");
} else if (FloatType.v().equals(toType)) {
setResult("l2f");
} else if (DoubleType.v().equals(toType)) {
setResult("l2d");
} else {
throw new RuntimeException("invalid toType from long: " + toType);
}
}
};
fromType.apply(sw);
return sw.getResult();
}
/* override toString with our own, *not* including types */
@Override
public String toString() {
return getName() + getParameters();
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).casePrimitiveCastInst(this);
}
}
| 5,431
| 24.622642
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BPushInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.UnitPrinter;
import soot.baf.InstSwitch;
import soot.baf.PushInst;
import soot.jimple.Constant;
import soot.jimple.DoubleConstant;
import soot.jimple.LongConstant;
import soot.util.Switch;
public class BPushInst extends AbstractInst implements PushInst {
private Constant constant;
public BPushInst(Constant c) {
this.constant = c;
}
@Override
public Object clone() {
return new BPushInst(getConstant());
}
@Override
final public String getName() {
return "push";
}
@Override
final String getParameters() {
return " " + constant.toString();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
up.constant(constant);
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
if (constant instanceof LongConstant || constant instanceof DoubleConstant) {
return 2;
} else {
return 1;
}
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).casePushInst(this);
}
@Override
public Constant getConstant() {
return constant;
}
@Override
public void setConstant(Constant c) {
this.constant = c;
}
}
| 2,196
| 20.752475
| 81
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BRemInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.RemInst;
import soot.util.Switch;
public class BRemInst extends AbstractOpTypeInst implements RemInst {
public BRemInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BRemInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "rem";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseRemInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BReturnInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.ReturnInst;
import soot.util.Switch;
public class BReturnInst extends AbstractOpTypeInst implements ReturnInst {
public BReturnInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BReturnInst(getOpType());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType((getOpType()));
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "return";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseReturnInst(this);
}
@Override
public boolean fallsThrough() {
return false;
}
}
| 1,750
| 21.74026
| 75
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BReturnVoidInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.baf.InstSwitch;
import soot.baf.ReturnVoidInst;
import soot.util.Switch;
public class BReturnVoidInst extends AbstractInst implements ReturnVoidInst {
public BReturnVoidInst() {
}
@Override
public Object clone() {
return new BReturnVoidInst();
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "return";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseReturnVoidInst(this);
}
@Override
public boolean fallsThrough() {
return false;
}
}
| 1,632
| 21.067568
| 77
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BShlInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.ShlInst;
import soot.util.Switch;
public class BShlInst extends AbstractOpTypeInst implements ShlInst {
public BShlInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BShlInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(getOpType()) + 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "shl";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseShlInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BShrInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.ShrInst;
import soot.util.Switch;
public class BShrInst extends AbstractOpTypeInst implements ShrInst {
public BShrInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BShrInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(getOpType()) + 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "shr";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseShrInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BSpecialInvokeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
* Copyright (C) 2004 Ondrej Lhotak
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.SootMethodRef;
import soot.baf.InstSwitch;
import soot.baf.SpecialInvokeInst;
import soot.util.Switch;
public class BSpecialInvokeInst extends AbstractInvokeInst implements SpecialInvokeInst {
public BSpecialInvokeInst(SootMethodRef methodRef) {
if (methodRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
super.methodRef = methodRef;
}
@Override
public Object clone() {
return new BSpecialInvokeInst(methodRef);
}
@Override
public int getInCount() {
return super.getInCount() + 1;
}
@Override
public int getInMachineCount() {
return super.getInMachineCount() + 1;
}
@Override
public String getName() {
return "specialinvoke";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseSpecialInvokeInst(this);
}
}
| 1,731
| 25.646154
| 89
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BStaticGetInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.SootField;
import soot.SootFieldRef;
import soot.UnitPrinter;
import soot.baf.InstSwitch;
import soot.baf.StaticGetInst;
import soot.util.Switch;
public class BStaticGetInst extends AbstractInst implements StaticGetInst {
SootFieldRef fieldRef;
public BStaticGetInst(SootFieldRef fieldRef) {
if (!fieldRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
this.fieldRef = fieldRef;
}
@Override
public Object clone() {
return new BStaticGetInst(fieldRef);
}
@Override
public int getInCount() {
return 0;
}
@Override
public int getInMachineCount() {
return 0;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return AbstractJasminClass.sizeOfType(fieldRef.type());
}
@Override
final public String getName() {
return "staticget";
}
@Override
final String getParameters() {
return " " + fieldRef.getSignature();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
up.fieldRef(fieldRef);
}
@Override
public SootFieldRef getFieldRef() {
return fieldRef;
}
@Override
public SootField getField() {
return fieldRef.resolve();
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseStaticGetInst(this);
}
@Override
public boolean containsFieldRef() {
return true;
}
}
| 2,325
| 21.152381
| 75
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BStaticInvokeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
* Copyright (C) 2004 Ondrej Lhotak
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.SootMethodRef;
import soot.VoidType;
import soot.baf.InstSwitch;
import soot.baf.StaticInvokeInst;
import soot.util.Switch;
public class BStaticInvokeInst extends AbstractInvokeInst implements StaticInvokeInst {
public BStaticInvokeInst(SootMethodRef methodRef) {
if (!methodRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
super.methodRef = methodRef;
}
@Override
public Object clone() {
return new BStaticInvokeInst(methodRef);
}
@Override
public int getInCount() {
return methodRef.getParameterTypes().size();
}
@Override
public int getOutCount() {
return (methodRef.getReturnType() instanceof VoidType) ? 0 : 1;
}
@Override
public String getName() {
return "staticinvoke";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseStaticInvokeInst(this);
}
}
| 1,781
| 26
| 87
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BStaticPutInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
* Copyright (C) 2004 Ondrej Lhotak
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.SootField;
import soot.SootFieldRef;
import soot.UnitPrinter;
import soot.baf.InstSwitch;
import soot.baf.StaticPutInst;
import soot.util.Switch;
public class BStaticPutInst extends AbstractInst implements StaticPutInst {
SootFieldRef fieldRef;
public BStaticPutInst(SootFieldRef fieldRef) {
if (!fieldRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
this.fieldRef = fieldRef;
}
@Override
public Object clone() {
return new BStaticPutInst(fieldRef);
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(fieldRef.type());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "staticput";
}
@Override
final String getParameters() {
return " " + fieldRef.getSignature();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
up.fieldRef(fieldRef);
}
@Override
public SootFieldRef getFieldRef() {
return fieldRef;
}
@Override
public SootField getField() {
return fieldRef.resolve();
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseStaticPutInst(this);
}
@Override
public boolean containsFieldRef() {
return true;
}
}
| 2,361
| 21.283019
| 75
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BStoreInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.Collections;
import java.util.List;
import soot.AbstractJasminClass;
import soot.Local;
import soot.Type;
import soot.UnitPrinter;
import soot.ValueBox;
import soot.baf.InstSwitch;
import soot.baf.StoreInst;
import soot.util.Switch;
public class BStoreInst extends AbstractOpTypeInst implements StoreInst {
ValueBox localBox;
List<ValueBox> defBoxes;
public BStoreInst(Type opType, Local local) {
super(opType);
this.localBox = new BafLocalBox(local);
this.defBoxes = Collections.singletonList(localBox);
}
@Override
public Object clone() {
return new BStoreInst(getOpType(), getLocal());
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "store";
}
@Override
final String getParameters() {
return " " + localBox.getValue().toString();
}
@Override
protected void getParameters(UnitPrinter up) {
up.literal(" ");
localBox.toString(up);
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseStoreInst(this);
}
@Override
public void setLocal(Local l) {
localBox.setValue(l);
}
@Override
public Local getLocal() {
return (Local) localBox.getValue();
}
@Override
public List<ValueBox> getDefBoxes() {
return defBoxes;
}
}
| 2,420
| 21.211009
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BSubInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.SubInst;
import soot.util.Switch;
public class BSubInst extends AbstractOpTypeInst implements SubInst {
public BSubInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BSubInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "sub";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseSubInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BSwapInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.DoubleType;
import soot.LongType;
import soot.Type;
import soot.baf.Baf;
import soot.baf.InstSwitch;
import soot.baf.SwapInst;
import soot.util.Switch;
public class BSwapInst extends AbstractInst implements SwapInst {
protected Type mFromType;
protected Type mToType;
public BSwapInst(Type fromType, Type toType) {
if (fromType instanceof LongType || fromType instanceof DoubleType) {
throw new RuntimeException("fromType is LongType or DoubleType !");
}
if (toType instanceof LongType || toType instanceof DoubleType) {
throw new RuntimeException("toType is LongType or DoubleType !");
}
this.mFromType = Baf.getDescriptorTypeOf(fromType);
this.mToType = Baf.getDescriptorTypeOf(toType);
}
@Override
public Type getFromType() {
return mFromType;
}
@Override
public void setFromType(Type fromType) {
mFromType = fromType;
}
@Override
public Type getToType() {
return mToType;
}
@Override
public void setToType(Type toType) {
mToType = toType;
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return 2;
}
@Override
public int getOutCount() {
return 2;
}
@Override
public int getOutMachineCount() {
return 2;
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseSwapInst(this);
}
@Override
public String toString() {
return "swap." + Baf.bafDescriptorOf(mFromType) + Baf.bafDescriptorOf(mToType);
}
@Override
public String getName() {
return "swap";
}
}
| 2,453
| 22.371429
| 83
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BTableSwitchInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.List;
import soot.Unit;
import soot.UnitPrinter;
import soot.baf.InstSwitch;
import soot.baf.TableSwitchInst;
import soot.util.Switch;
public class BTableSwitchInst extends AbstractSwitchInst implements TableSwitchInst {
int lowIndex;
int highIndex;
public BTableSwitchInst(Unit defaultTarget, int lowIndex, int highIndex, List<? extends Unit> targets) {
super(defaultTarget, targets);
this.lowIndex = lowIndex;
this.highIndex = highIndex;
}
@Override
public Object clone() {
return new BTableSwitchInst(getDefaultTarget(), lowIndex, highIndex, getTargets());
}
@Override
public void setLowIndex(int lowIndex) {
this.lowIndex = lowIndex;
}
@Override
public void setHighIndex(int highIndex) {
this.highIndex = highIndex;
}
@Override
public int getLowIndex() {
return lowIndex;
}
@Override
public int getHighIndex() {
return highIndex;
}
@Override
public String getName() {
return "tableswitch";
}
@Override
public String toString() {
final String endOfLine = " ";
StringBuilder buffer = new StringBuilder();
buffer.append("tableswitch").append(endOfLine);
buffer.append('{').append(endOfLine);
// In this for-loop, we cannot use "<=" since 'i' would wrap around.
// The case for "i == highIndex" is handled separately after the loop.
final int low = lowIndex;
final int high = highIndex;
for (int i = low; i < high; i++) {
buffer.append(" case ").append(i).append(": goto ").append(getTarget(i - low)).append(';').append(endOfLine);
}
buffer.append(" case ").append(high).append(": goto ").append(getTarget(high - low)).append(';').append(endOfLine);
buffer.append(" default: goto ").append(getDefaultTarget()).append(';').append(endOfLine);
buffer.append('}');
return buffer.toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal("tableswitch");
up.newline();
up.literal("{");
up.newline();
// In this for-loop, we cannot use "<=" since 'i' would wrap around.
// The case for "i == highIndex" is handled separately after the loop.
for (int i = lowIndex; i < highIndex; i++) {
printCaseTarget(up, i);
}
printCaseTarget(up, highIndex);
up.literal(" default: goto ");
defaultTargetBox.toString(up);
up.literal(";");
up.newline();
up.literal("}");
}
private void printCaseTarget(UnitPrinter up, int targetIndex) {
up.literal(" case ");
up.literal(Integer.toString(targetIndex));
up.literal(": goto ");
targetBoxes[targetIndex - lowIndex].toString(up);
up.literal(";");
up.newline();
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseTableSwitchInst(this);
}
}
| 3,661
| 26.533835
| 122
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BThrowInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.baf.InstSwitch;
import soot.baf.ThrowInst;
import soot.util.Switch;
public class BThrowInst extends AbstractInst implements ThrowInst {
public BThrowInst() {
}
@Override
public Object clone() {
return new BThrowInst();
}
@Override
public int getInCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 1;
}
@Override
public int getOutCount() {
return 0;
}
@Override
public int getOutMachineCount() {
return 0;
}
@Override
final public String getName() {
return "athrow";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseThrowInst(this);
}
@Override
public boolean fallsThrough() {
return false;
}
}
| 1,602
| 20.662162
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BTrap.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractTrap;
import soot.SootClass;
import soot.Unit;
import soot.baf.Baf;
public class BTrap extends AbstractTrap {
public BTrap(SootClass exception, Unit beginStmt, Unit endStmt, Unit handlerStmt) {
super(exception, Baf.v().newInstBox(beginStmt), Baf.v().newInstBox(endStmt), Baf.v().newInstBox(handlerStmt));
}
@Override
public Object clone() {
return new BTrap(exception, getBeginUnit(), getEndUnit(), getHandlerUnit());
}
}
| 1,327
| 31.390244
| 114
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BUshrInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.UshrInst;
import soot.util.Switch;
public class BUshrInst extends AbstractOpTypeInst implements UshrInst {
public BUshrInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BUshrInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getInMachineCount() {
return AbstractJasminClass.sizeOfType(getOpType()) + 1;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "ushr";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseUshrInst(this);
}
}
| 1,715
| 22.833333
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BVirtualInvokeInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
* Copyright (C) 2004 Ondrej Lhotak
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.SootMethodRef;
import soot.baf.InstSwitch;
import soot.baf.VirtualInvokeInst;
import soot.util.Switch;
public class BVirtualInvokeInst extends AbstractInvokeInst implements VirtualInvokeInst {
public BVirtualInvokeInst(SootMethodRef methodRef) {
if (methodRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
super.methodRef = methodRef;
}
@Override
public Object clone() {
return new BVirtualInvokeInst(methodRef);
}
@Override
public int getInMachineCount() {
return super.getInMachineCount() + 1;
}
@Override
public int getInCount() {
return super.getInCount() + 1;
}
@Override
final public String getName() {
return "virtualinvoke";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseVirtualInvokeInst(this);
}
}
| 1,737
| 25.738462
| 89
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BXorInst.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractJasminClass;
import soot.Type;
import soot.baf.InstSwitch;
import soot.baf.XorInst;
import soot.util.Switch;
public class BXorInst extends AbstractOpTypeInst implements XorInst {
public BXorInst(Type opType) {
super(opType);
}
@Override
public Object clone() {
return new BXorInst(getOpType());
}
@Override
public int getInCount() {
return 2;
}
@Override
public int getOutCount() {
return 1;
}
@Override
public int getInMachineCount() {
return 2 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public int getOutMachineCount() {
return 1 * AbstractJasminClass.sizeOfType(getOpType());
}
@Override
public final String getName() {
return "xor";
}
@Override
public void apply(Switch sw) {
((InstSwitch) sw).caseXorInst(this);
}
}
| 1,708
| 22.736111
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BafLocal.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.Collections;
import java.util.List;
import soot.Local;
import soot.Type;
import soot.UnitPrinter;
import soot.ValueBox;
import soot.util.Switch;
public class BafLocal implements Local {
String name;
Type type;
int fixedHashCode;
boolean isHashCodeChosen;
private Local originalLocal;
private int number = 0;
public BafLocal(String name, Type t) {
this.name = name;
this.type = t;
}
@Override
public Object clone() {
BafLocal baf = new BafLocal(name, type);
baf.originalLocal = this.originalLocal;
return baf;
}
/* JimpleLocals are *NOT* equivalent to Baf Locals! */
@Override
public boolean equivTo(Object o) {
return this.equals(o);
}
/** Returns a hash code for this object, consistent with structural equality. */
@Override
public int equivHashCode() {
return name.hashCode() * 101 + type.hashCode() * 17;
}
public Local getOriginalLocal() {
return this.originalLocal;
}
public void setOriginalLocal(Local l) {
this.originalLocal = l;
}
@Override
public String getName() {
return this.name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public Type getType() {
return this.type;
}
@Override
public void setType(Type t) {
this.type = t;
}
@Override
public String toString() {
return getName();
}
@Override
public void toString(UnitPrinter up) {
up.local(this);
}
@Override
public List<ValueBox> getUseBoxes() {
return Collections.emptyList();
}
@Override
public void apply(Switch s) {
throw new RuntimeException("invalid case switch");
}
@Override
public final int getNumber() {
return number;
}
@Override
public final void setNumber(int number) {
this.number = number;
}
@Override
public boolean isStackLocal() {
return true;
}
}
| 2,757
| 20.215385
| 82
|
java
|
soot
|
soot-master/src/main/java/soot/baf/internal/BafLocalBox.java
|
package soot.baf.internal;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.AbstractValueBox;
import soot.Value;
public class BafLocalBox extends AbstractValueBox {
public BafLocalBox(Value value) {
setValue(value);
}
@Override
public boolean canContainValue(Value value) {
return value instanceof BafLocal;
}
}
| 1,133
| 28.076923
| 73
|
java
|
soot
|
soot-master/src/main/java/soot/baf/toolkits/base/ExamplePeephole.java
|
package soot.baf.toolkits.base;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrice Pominville
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.Iterator;
import soot.Body;
import soot.Unit;
import soot.baf.InstanceCastInst;
/**
* Example peephole that remove all checkcast operations. Resulting class will likely not verify.
*/
public class ExamplePeephole implements Peephole {
@Override
public boolean apply(Body b) {
boolean changed = false;
for (Iterator<Unit> it = b.getUnits().iterator(); it.hasNext();) {
Unit u = it.next();
if (u instanceof InstanceCastInst) {
it.remove();
changed = true;
}
}
return changed;
}
}
| 1,392
| 27.428571
| 97
|
java
|
soot
|
soot-master/src/main/java/soot/baf/toolkits/base/LoadStoreOptimizer.java
|
package soot.baf.toolkits.base;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrice Pominville
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
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.Local;
import soot.PhaseOptions;
import soot.Singletons;
import soot.Trap;
import soot.Unit;
import soot.baf.AddInst;
import soot.baf.AndInst;
import soot.baf.ArrayReadInst;
import soot.baf.ArrayWriteInst;
import soot.baf.Baf;
import soot.baf.Dup1Inst;
import soot.baf.DupInst;
import soot.baf.EnterMonitorInst;
import soot.baf.ExitMonitorInst;
import soot.baf.FieldArgInst;
import soot.baf.FieldGetInst;
import soot.baf.FieldPutInst;
import soot.baf.IdentityInst;
import soot.baf.IncInst;
import soot.baf.Inst;
import soot.baf.LoadInst;
import soot.baf.MethodArgInst;
import soot.baf.MulInst;
import soot.baf.NewInst;
import soot.baf.OrInst;
import soot.baf.PushInst;
import soot.baf.StaticGetInst;
import soot.baf.StaticPutInst;
import soot.baf.StoreInst;
import soot.baf.XorInst;
import soot.options.Options;
import soot.toolkits.graph.Block;
import soot.toolkits.graph.BlockGraph;
import soot.toolkits.graph.ZonedBlockGraph;
import soot.toolkits.scalar.LocalDefs;
import soot.toolkits.scalar.LocalUses;
import soot.toolkits.scalar.UnitValueBoxPair;
import soot.util.Chain;
public class LoadStoreOptimizer extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(LoadStoreOptimizer.class);
private static final boolean SKIP_SLOW_ASSERTS = true;
public LoadStoreOptimizer(Singletons.Global g) {
}
public static LoadStoreOptimizer v() {
return G.v().soot_baf_toolkits_base_LoadStoreOptimizer();
}
// constants returned by the stackIndependent function.
final static private int FAILURE = 0;
final static private int SUCCESS = 1;
final static private int MAKE_DUP = 2;
final static private int MAKE_DUP1_X1 = 3;
final static private int SPECIAL_SUCCESS = 4;
final static private int HAS_CHANGED = 5;
final static private int SPECIAL_SUCCESS2 = 6;
final static private int STORE_LOAD_ELIMINATION = 0;
final static private int STORE_LOAD_LOAD_ELIMINATION = -1;
@Override
protected void internalTransform(Body body, String phaseName, Map<String, String> options) {
boolean debug = PhaseOptions.getBoolean(options, "debug");
if (Options.v().verbose()) {
logger.debug("[" + body.getMethod().getName() + "] Performing LoadStore optimizations...");
}
if (debug) {
logger.debug("\n\nOptimizing Method: " + body.getMethod().getName());
}
new Instance(body, options, debug).go();
}
private static class Instance {
// Instance vars.
private final boolean debug;
private final Map<String, String> gOptions;
private final Chain<Unit> mUnits;
private final Body mBody;
private final Map<Unit, Block> mUnitToBlockMap; // maps each Unit to it's containing Block
private LocalDefs mLocalDefs;
private LocalUses mLocalUses;
public Instance(Body b, Map<String, String> options, boolean debug) {
this.mBody = b;
this.mUnits = b.getUnits();
this.gOptions = options;
this.debug = debug;
this.mUnitToBlockMap = new HashMap<>();
}
public void go() {
if (!mUnits.isEmpty()) {
buildUnitToBlockMap();
assert (SKIP_SLOW_ASSERTS || unitToBlockMapIsValid());
if (debug) {
logger.debug("Calling optimizeLoadStore(1)\n");
}
optimizeLoadStores(false);
assert (SKIP_SLOW_ASSERTS || unitToBlockMapIsValid());
if (PhaseOptions.getBoolean(gOptions, "inter")) {
if (debug) {
logger.debug("Calling doInterBlockOptimizations");
}
doInterBlockOptimizations();
assert (SKIP_SLOW_ASSERTS || unitToBlockMapIsValid());
}
if (PhaseOptions.getBoolean(gOptions, "sl2") || PhaseOptions.getBoolean(gOptions, "sll2")) {
if (debug) {
logger.debug("Calling optimizeLoadStore(2)");
}
optimizeLoadStores(true);
assert (SKIP_SLOW_ASSERTS || unitToBlockMapIsValid());
}
}
}
/**
* Computes a map binding each unit in a method to the unique basic block that contains it.
*/
private void buildUnitToBlockMap() {
mUnitToBlockMap.clear();// clear the map in case of rebuilds
BlockGraph blockGraph = new ZonedBlockGraph(mBody);
if (debug) {
logger.debug("Method " + mBody.getMethod().getName() + " Block Graph: ");
logger.debug(blockGraph.toString());
}
for (Block block : blockGraph.getBlocks()) {
for (Unit unit : block) {
mUnitToBlockMap.put(unit, block);
}
}
}
private void computeLocalDefsAndLocalUsesInfo() {
if (mLocalDefs == null) {
mLocalDefs = G.v().soot_toolkits_scalar_LocalDefsFactory().newLocalDefs(mBody);
}
if (mLocalUses == null) {
mLocalUses = LocalUses.Factory.newLocalUses(mBody, mLocalDefs);
}
}
private void clearLocalDefsAndLocalUsesInfo() {
mLocalDefs = null;
mLocalUses = null;
}
/**
* Computes a list of all the stores in mUnits in order of their occurrences therein.
*/
private List<Unit> buildStoreList() {
List<Unit> storeList = new ArrayList<>();
for (Unit unit : mUnits) {
if (unit instanceof StoreInst) {
storeList.add(unit);
}
}
return storeList;
}
/**
* Main optimizing method.
*/
private void optimizeLoadStores(boolean mPass2) {
computeLocalDefsAndLocalUsesInfo();
// build a list of all store units in mUnits
List<Unit> storeList = buildStoreList();
// Eliminate store/load
for (boolean hasChanged = true, hasChangedFlag = false; hasChanged;) {
hasChanged = false;
// Iterate over the storeList
nextUnit: for (Iterator<Unit> unitIt = storeList.iterator(); unitIt.hasNext();) {
final Unit unit = unitIt.next();
List<UnitValueBoxPair> uses = mLocalUses.getUsesOf(unit);
// if uses of a store < 3, attempt some form of store/load elimination
if (uses.size() < 3) {
// check that all uses have only the current store as their definition
for (UnitValueBoxPair pair : uses) {
Unit loadUnit = pair.getUnit();
if (!(loadUnit instanceof LoadInst)) {
continue nextUnit;
}
List<Unit> defs = mLocalDefs.getDefsOfAt((Local) pair.getValueBox().getValue(), loadUnit);
if (defs.size() > 1 || defs.get(0) != unit) {
continue nextUnit;
}
}
// Check that all loads are in the same bb as the store
{
Block storeBlock = mUnitToBlockMap.get(unit);
assert (SKIP_SLOW_ASSERTS || contains(storeBlock, unit));
for (UnitValueBoxPair pair : uses) {
Block useBlock = mUnitToBlockMap.get(pair.getUnit());
assert (SKIP_SLOW_ASSERTS || contains(useBlock, pair.getUnit()));
if (useBlock != storeBlock) {
continue nextUnit;
}
}
}
// Check for stack independance (automatic reordering may be performed by stackIndependent() fcnt)
switch (uses.size()) {
case 0:
/*
* if(Options.getBoolean(gOptions, "s-elimination")) { // replace store by a pop and remove store from store
* list replaceUnit(unit, Baf.v().newPopInst(((StoreInst)unit).getOpType())); unitIt.remove();
*
* hasChanged = true; hasChangedFlag = false; }
*/
break;
case 1:
if (PhaseOptions.getBoolean(gOptions, "sl")) {
if (!mPass2 || PhaseOptions.getBoolean(gOptions, "sl2")) {
// try to eliminate store/load pair
Unit loadUnit = uses.get(0).getUnit();
Block block = mUnitToBlockMap.get(unit);
assert (SKIP_SLOW_ASSERTS || contains(block, unit));
int test = stackIndependent(unit, loadUnit, block, STORE_LOAD_ELIMINATION);
if (test == SUCCESS || test == SPECIAL_SUCCESS) {
block.remove(unit);
mUnitToBlockMap.remove(unit);
block.remove(loadUnit);
mUnitToBlockMap.remove(loadUnit);
unitIt.remove();
hasChanged = true;
hasChangedFlag = false;
if (debug) {
logger.debug("Store/Load elimination occurred case1.");
}
}
}
}
break;
case 2:
if (PhaseOptions.getBoolean(gOptions, "sll")) {
if (!mPass2 || PhaseOptions.getBoolean(gOptions, "sll2")) {
// try to replace store/load/load trio by a flavor of the dup unit
Unit firstLoad = uses.get(0).getUnit();
Unit secondLoad = uses.get(1).getUnit();
// xxx try to optimize this
if (mUnits.follows(firstLoad, secondLoad)) {
Unit temp = secondLoad;
secondLoad = firstLoad;
firstLoad = temp;
}
Block block = mUnitToBlockMap.get(unit);
assert (SKIP_SLOW_ASSERTS || contains(block, unit));
int result = stackIndependent(unit, firstLoad, block, STORE_LOAD_ELIMINATION);
if (result == SUCCESS) {
// move the first load just after its defining store.
block.remove(firstLoad);
block.insertAfter(firstLoad, unit);
int res = stackIndependent(unit, secondLoad, block, STORE_LOAD_LOAD_ELIMINATION);
if (res == MAKE_DUP) {
// replace store by dup, drop both loads
Dup1Inst dup = Baf.v().newDup1Inst(((LoadInst) secondLoad).getOpType());
dup.addAllTagsOf(unit);
replaceUnit(unit, dup);
unitIt.remove(); // remove store from store list
block.remove(firstLoad);
mUnitToBlockMap.remove(firstLoad);
block.remove(secondLoad);
mUnitToBlockMap.remove(secondLoad);
hasChanged = true;
hasChangedFlag = false;
}
} else if (result == SPECIAL_SUCCESS || result == HAS_CHANGED || result == SPECIAL_SUCCESS2) {
if (!hasChangedFlag) {
hasChangedFlag = true;
hasChanged = true;
}
}
}
}
}
}
}
}
}
/**
* Checks if the units occurring between [from, to] consume . stack items not produced by these interval units. (ie if
* the stack height ever goes negative between from and to, assuming the stack height is set to 0 upon executing the
* instruction following 'from'.
*/
private boolean isRequiredByFollowingUnits(Unit from, Unit to) {
if (from != to) {
int stackHeight = 0;
Iterator<Unit> it = mUnits.iterator(from, to);
// advance past the 'from' unit
it.next();
while (it.hasNext()) {
Unit currentInst = it.next();
if (currentInst == to) {
break;
}
stackHeight -= ((Inst) currentInst).getInCount();
if (stackHeight < 0) {
return true;
}
stackHeight += ((Inst) currentInst).getOutCount();
}
}
return false;
}
private int pushStoreToLoad(final Unit from, final Unit to, final Block block) {
final Unit storePred = block.getPredOf(from);
if (storePred == null || ((Inst) storePred).getOutCount() != 1) {
if (debug) {
if (storePred == null) {
logger.debug("xxx: failed due: cannot move past block tail ");
} else {
logger.debug("xxx: failed due: pred out-count != 1 ");
}
}
return FAILURE;
}
Set<Unit> unitsToMove = new HashSet<>();
unitsToMove.add(storePred);
unitsToMove.add(from);
int h = ((Inst) storePred).getInCount();
Unit currentUnit = storePred;
if (h != 0) {
currentUnit = block.getPredOf(storePred);
while (currentUnit != null) {
h -= ((Inst) currentUnit).getOutCount();
if (h < 0) { // xxx could be more flexible here?
if (debug) {
logger.debug("xxx: negative");
}
return FAILURE;
}
h += ((Inst) currentUnit).getInCount();
unitsToMove.add(currentUnit);
if (h == 0) {
break;
}
currentUnit = block.getPredOf(currentUnit);
}
}
if (currentUnit == null) {
if (debug) {
logger.debug("xxx: null");
}
return FAILURE;
}
for (Unit uu = block.getSuccOf(from); uu != to; uu = block.getSuccOf(uu)) {
for (Unit nu : unitsToMove) {
if (!canMoveUnitOver(nu, uu)) {
if (debug) {
logger.debug("xxx: failure cannot move " + nu + " over " + uu);
}
return FAILURE;
}
if (debug) {
logger.debug("can move " + nu + " over " + uu);
}
}
}
// if we get here it means we can move all the units in the
// set past the units in between [to, from]
for (Unit unitToMove = currentUnit; unitToMove != from;) {
Unit succ = block.getSuccOf(unitToMove);
if (debug) {
logger.debug("moving " + unitToMove);
}
block.remove(unitToMove);
block.insertBefore(unitToMove, to);
unitToMove = succ;
}
block.remove(from);
block.insertBefore(from, to);
if (debug) {
logger.debug("xxx: success pushing forward stuff.");
}
return SPECIAL_SUCCESS;
}
/**
* @return FAILURE when store load elimination is not possible in any form.
* @return SUCCESS when a load in a store load pair can be moved IMMEDIATELY after it's defining store.
* @return MAKE_DUP when a store/load/load trio can be replaced by a dup unit.
* @return MAKE_DUP_X1 when store/load/load trio can be replaced by a dup1_x1 unit.
* @return SPECIAL_SUCCESS when a store/load pair can AND must be immediately annihilated.
* @return HAS_CHANGED when store load elimination is not possible in any form, but some unit reordering has occurred.
*/
private int stackIndependent(Unit from, Unit to, Block block, int aContext) {
assert (aContext == STORE_LOAD_ELIMINATION || aContext == STORE_LOAD_LOAD_ELIMINATION);
if (debug) {
logger.debug("Trying: " + from + "/" + to + " in block " + block.getIndexInMethod() + ":");
logger.debug(
"context: " + (aContext == STORE_LOAD_ELIMINATION ? "STORE_LOAD_ELIMINATION" : "STORE_LOAD_LOAD_ELIMINATION"));
}
int minStackHeightAttained = 0; // records the min stack height attained between [from, to]
int stackHeight = 0; // records the stack height when similating the effects on the stack
{
Iterator<Unit> it = mUnits.iterator(mUnits.getSuccOf(from));
Unit currentInst = it.next(); // get unit following the store
if (aContext == STORE_LOAD_LOAD_ELIMINATION) {
currentInst = it.next(); // jump after first load
}
// find minStackHeightAttained
while (currentInst != to && it.hasNext()) {
stackHeight -= ((Inst) currentInst).getInCount();
if (stackHeight < minStackHeightAttained) {
minStackHeightAttained = stackHeight;
}
stackHeight += ((Inst) currentInst).getOutCount();
currentInst = it.next();
}
}
// note: now stackHeight contains the delta height of the stack
// after executing the units contained in [from, to] non-inclusive.
if (debug) {
logger.debug("nshv = " + stackHeight);
logger.debug("mshv = " + minStackHeightAttained);
}
// Iterate until an elimination clause is taken or no reordering of the code occurs
for (boolean hasChanged = true; hasChanged;) {
hasChanged = false;
if (aContext == STORE_LOAD_LOAD_ELIMINATION) {
// check for possible sll elimination
if (stackHeight == 0 && minStackHeightAttained == 0) {
if (debug) {
logger.debug("xxx: succ: -1, makedup ");
}
return MAKE_DUP;
} else if (stackHeight == -1 && minStackHeightAttained == -1) {
if (debug) {
logger.debug("xxx: succ: -1, makedup , -1");
}
return MAKE_DUP;
} else if (stackHeight == -2 && minStackHeightAttained == -2) {
if (debug) {
logger.debug("xxx: succ -1 , make dupx1 ");
}
return MAKE_DUP1_X1;
} else if (minStackHeightAttained < -2) {
if (debug) {
logger.debug("xxx: failed due: minStackHeightAttained < -2 ");
}
return FAILURE;
}
} else if (aContext == STORE_LOAD_ELIMINATION) {
// check for possible sl elimination
if (stackHeight == 0 && minStackHeightAttained == 0) {
if (debug) {
logger.debug("xxx: success due: 0, SUCCESS");
}
return SUCCESS;
}
/*
* xxx broken data depensie problem. else if (minStackHeightAttained == -1 && stackHeight == -1) { // try to make
* it more generic Unit u = (Unit) block.getPredOf(from); if(u instanceof FieldGetInst) if(block.getPredOf(u)
* instanceof Dup1Inst) { block.remove(u); block.insertBefore(u, to); block.remove(from); block.insertBefore(from,
* to); if(debug) { logger.debug("xxx: success due to 1, SPECIAL_SUCCESS2");} return SPECIAL_SUCCESS2; } }
*/
else if (minStackHeightAttained < 0) {
return pushStoreToLoad(from, to, block);
}
}
Iterator<Unit> it = mUnits.iterator(mUnits.getSuccOf(from), to);
Unit u = it.next();
if (aContext == STORE_LOAD_LOAD_ELIMINATION) {
u = it.next();
}
// find a candidate to move before the store/load/(load) group
for (; u != to; u = it.next()) {
Unit unitToMove = null;
if (((Inst) u).getNetCount() == 1) {
// xxx remove this check
if (u instanceof LoadInst || u instanceof PushInst || u instanceof NewInst || u instanceof StaticGetInst
|| u instanceof Dup1Inst) {
// verify that unitToMove is not required by following units (until the 'to' unit)
if (!isRequiredByFollowingUnits(u, to)) {
unitToMove = u;
}
} else if (debug) {
logger.debug("(LoadStoreOptimizer@stackIndependent): found unknown unit w/ getNetCount == 1: " + u);
}
}
if (unitToMove != null) {
if (tryToMoveUnit(unitToMove, block, from, to, 0)) {
if (stackHeight > -2 && minStackHeightAttained == -2) {
if (debug) {
logger.debug("xxx: has changed ");
}
return HAS_CHANGED;
}
stackHeight--;
if (stackHeight < minStackHeightAttained) {
minStackHeightAttained = stackHeight;
}
hasChanged = true;
break;
}
}
}
}
if (isCommutativeBinOp(block.getSuccOf(to))) {
if (aContext == STORE_LOAD_ELIMINATION && stackHeight == 1 && minStackHeightAttained == 0) {
if (debug) {
logger.debug("xxx: commutative ");
}
return SPECIAL_SUCCESS;
}
Inst toAsInst = (Inst) to;
if (toAsInst.getOutCount() == 1 && toAsInst.getInCount() == 0) {
Inst toPred = (Inst) mUnits.getPredOf(to);
if (toPred.getOutCount() == 1 && toPred.getInCount() == 0) {
block.remove(toPred);
block.insertAfter(toPred, to);
if (debug) {
logger.debug("xxx: (commutative) has changed ");
}
return HAS_CHANGED;
}
}
if (debug) {
logger.debug("xxx: (commutative) failed due: ??? ");
}
return FAILURE;
}
if (aContext == STORE_LOAD_ELIMINATION) {
return pushStoreToLoad(from, to, block);
}
if (debug) {
logger.debug("xxx: failed due: ??? ");
}
return FAILURE;
}
/**
* @return true if aUnit perform a non-local read or write. false otherwise.
*/
private boolean isNonLocalReadOrWrite(Unit aUnit) {
return (aUnit instanceof FieldArgInst) || (aUnit instanceof ArrayReadInst) || (aUnit instanceof ArrayWriteInst);
}
/**
* When reordering bytecode, check if it is safe to move aUnitToMove past aUnitToGoOver.
*
* @return true if aUnitToMove can be moved past aUnitToGoOver.
*/
private boolean canMoveUnitOver(Unit aUnitToMove, Unit aUnitToGoOver) { // xxx missing cases
// can't change method call order or change fieldargInst and method call order
if ((aUnitToGoOver instanceof MethodArgInst && aUnitToMove instanceof MethodArgInst)
|| (aUnitToGoOver instanceof MethodArgInst && isNonLocalReadOrWrite(aUnitToMove))
|| (isNonLocalReadOrWrite(aUnitToGoOver) && aUnitToMove instanceof MethodArgInst)
|| (aUnitToGoOver instanceof ArrayReadInst && aUnitToMove instanceof ArrayWriteInst)
|| (aUnitToGoOver instanceof ArrayWriteInst && aUnitToMove instanceof ArrayReadInst)
|| (aUnitToGoOver instanceof ArrayWriteInst && aUnitToMove instanceof ArrayWriteInst)
|| (aUnitToGoOver instanceof FieldPutInst && aUnitToMove instanceof FieldGetInst
&& ((FieldArgInst) aUnitToGoOver).getField() == ((FieldArgInst) aUnitToMove).getField())
|| (aUnitToGoOver instanceof FieldGetInst && aUnitToMove instanceof FieldPutInst
&& ((FieldArgInst) aUnitToGoOver).getField() == ((FieldArgInst) aUnitToMove).getField())
|| (aUnitToGoOver instanceof FieldPutInst && aUnitToMove instanceof FieldPutInst
&& ((FieldArgInst) aUnitToGoOver).getField() == ((FieldArgInst) aUnitToMove).getField())
|| (aUnitToGoOver instanceof StaticPutInst && aUnitToMove instanceof StaticGetInst
&& ((FieldArgInst) aUnitToGoOver).getField() == ((FieldArgInst) aUnitToMove).getField())
|| (aUnitToGoOver instanceof StaticGetInst && aUnitToMove instanceof StaticPutInst
&& ((FieldArgInst) aUnitToGoOver).getField() == ((FieldArgInst) aUnitToMove).getField())
|| (aUnitToGoOver instanceof StaticPutInst && aUnitToMove instanceof StaticPutInst
&& ((FieldArgInst) aUnitToGoOver).getField() == ((FieldArgInst) aUnitToMove).getField())) {
return false;
}
// xxx to be safe don't mess w/ monitors. These rules could be relaxed. ? Maybe.
if (aUnitToGoOver instanceof EnterMonitorInst || aUnitToGoOver instanceof ExitMonitorInst) {
return false;
}
if (aUnitToMove instanceof EnterMonitorInst || aUnitToGoOver instanceof ExitMonitorInst) {
return false;
}
if (aUnitToGoOver instanceof IdentityInst || aUnitToMove instanceof IdentityInst) {
return false;
}
if (aUnitToMove instanceof LoadInst) {
if (aUnitToGoOver instanceof StoreInst) {
if (((StoreInst) aUnitToGoOver).getLocal() == ((LoadInst) aUnitToMove).getLocal()) {
return false;
}
} else if (aUnitToGoOver instanceof IncInst) {
if (((IncInst) aUnitToGoOver).getLocal() == ((LoadInst) aUnitToMove).getLocal()) {
return false;
}
}
}
// don't move def of load pass it.
if (aUnitToMove instanceof StoreInst) {
if (aUnitToGoOver instanceof LoadInst) {
if (((LoadInst) aUnitToGoOver).getLocal() == ((StoreInst) aUnitToMove).getLocal()) {
return false;
}
} else if (aUnitToGoOver instanceof IncInst) {
if (((IncInst) aUnitToGoOver).getLocal() == ((StoreInst) aUnitToMove).getLocal()) {
return false;
}
}
}
if (aUnitToMove instanceof IncInst) {
if (aUnitToGoOver instanceof StoreInst) {
if (((StoreInst) aUnitToGoOver).getLocal() == ((IncInst) aUnitToMove).getLocal()) {
return false;
}
} else if (aUnitToGoOver instanceof LoadInst) {
if (((LoadInst) aUnitToGoOver).getLocal() == ((IncInst) aUnitToMove).getLocal()) {
return false;
}
}
}
return true;
}
private boolean tryToMoveUnit(Unit unitToMove, Block block, Unit from, Unit to, int flag) {
if (debug) {
logger.debug("[tryToMoveUnit]: trying to move:" + unitToMove);
}
if (unitToMove == null) {
return false;
}
int h = 0;
boolean reachedStore = false;
boolean reorderingOccurred = false;
for (Unit current = unitToMove; current != block.getHead();) { // do not go past basic block limit
current = mUnits.getPredOf(current);
if (!canMoveUnitOver(current, unitToMove)) {
return false;
}
if (current == from) {
reachedStore = true;
}
h -= ((Inst) current).getOutCount();
if (h < 0) {
if (debug) {
logger.debug("(LoadStoreOptimizer@stackIndependent): Stack went negative while trying to reorder code.");
}
if (flag == 1 && current instanceof DupInst) {
block.remove(unitToMove);
block.insertAfter(unitToMove, current);
// block.insertAfter(new BSwapInst( ), unitToMove);
}
return false;
}
h += ((Inst) current).getInCount();
if (h == 0 && reachedStore == true) {
if (!isRequiredByFollowingUnits(unitToMove, to)) {
if (debug) {
logger.debug(
"(LoadStoreOptimizer@stackIndependent): reordering bytecode move: " + unitToMove + " before: " + current);
}
block.remove(unitToMove);
block.insertBefore(unitToMove, current);
reorderingOccurred = true;
break;
}
}
}
if (debug) {
if (reorderingOccurred) {
logger.debug("reordering occurred");
} else {
logger.debug("(LoadStoreOptimizer@stackIndependent):failed to find a new slot for unit to move");
}
}
return reorderingOccurred;
}
/**
* Replace 1 or 2 units by a third unit in a block. Both units to replace should be in the same block. The map
* 'mUnitToBlockMap' is updated. The replacement unit is inserted in the position, of the aToReplace2 if not null,
* otherwise in aToReplace1's slot.
*
* @param aToReplace1
* Unit to replace. (shouldn't be null)
* @param aToReplace2
* Second Unit to replace (can be null)
* @param aReplacement
* Unit that replaces the 2 previous units (shouldn't be null)
*/
private void replaceUnit(Unit aToReplace1, Unit aToReplace2, Unit aReplacement) {
Block block = mUnitToBlockMap.get(aToReplace1);
assert (SKIP_SLOW_ASSERTS || contains(block, aToReplace1));
if (aToReplace2 != null) {
block.insertAfter(aReplacement, aToReplace2);
block.remove(aToReplace2);
mUnitToBlockMap.remove(aToReplace2);
} else {
block.insertAfter(aReplacement, aToReplace1);
}
block.remove(aToReplace1);
mUnitToBlockMap.remove(aToReplace1);
// add the new unit the block map
mUnitToBlockMap.put(aReplacement, block);
}
private void replaceUnit(Unit aToReplace, Unit aReplacement) {
replaceUnit(aToReplace, null, aReplacement);
}
/**
* @return true if the Block is an exception handler.
*/
private boolean isExceptionHandlerBlock(Block aBlock) {
Unit blockHead = aBlock.getHead();
for (Trap trap : mBody.getTraps()) {
if (trap.getHandlerUnit() == blockHead) {
return true;
}
}
return false;
}
// not a save function :: goes over block boundries
private int getDeltaStackHeightFromTo(Unit aFrom, Unit aTo) {
int h = 0;
for (Iterator<Unit> it = mUnits.iterator(aFrom, aTo); it.hasNext();) {
Unit next = it.next();
h += ((Inst) next).getNetCount();
}
return h;
}
// not a save function :: goes over block boundries
private boolean isZeroStackDeltaWithoutClobbering(Unit aFrom, Unit aTo) {
int h = 0;
for (Iterator<Unit> it = mUnits.iterator(aFrom, aTo); it.hasNext();) {
Inst next = (Inst) it.next();
// detect use of the top stack value at 'aFrom'
if (next.getInCount() > h) {
return false;
}
h += next.getNetCount();
// detect removal of the top stack value at 'aFrom'
if (h < 0) {
return false;
}
}
return h == 0;
}
/**
* Performs 2 simple inter-block optimizations in order to keep some variables on the stack between blocks. Both are
* intended to catch 'if' like constructs where the control flow branches temporarily into two paths that join up at a
* later point.
*/
private void doInterBlockOptimizations() {
for (boolean hasChanged = true; hasChanged;) {
// Ensure LocalDefs and LocalUses are computed
computeLocalDefsAndLocalUsesInfo();
hasChanged = false;
if (debug) {
logger.debug("[doInterBlockOptimizations] begin pass...");
}
for (Unit u : new ArrayList<>(mUnits)) {
if (u instanceof LoadInst) {
if (debug) {
logger.debug("interopt trying: " + u);
}
final Block loadBlock = mUnitToBlockMap.get(u);
assert (SKIP_SLOW_ASSERTS || contains(loadBlock, u));
final List<Unit> defs = mLocalDefs.getDefsOfAt(((LoadInst) u).getLocal(), u);
if (debug) {
logger.debug(" loadBlock: " + loadBlock);
logger.debug(" defs: " + defs);
}
if (defs.size() == 1) { // first optimization
final Unit def = defs.get(0);
final Block defBlock = mUnitToBlockMap.get(def);
assert (SKIP_SLOW_ASSERTS || contains(defBlock, def));
if (defBlock != loadBlock && !isExceptionHandlerBlock(loadBlock)) {
if (def instanceof StoreInst) {
List<UnitValueBoxPair> uses = mLocalUses.getUsesOf(def);
if (uses.size() == 1 && allSuccesorsOfAreThePredecessorsOf(defBlock, loadBlock)) {
if (isZeroStackDeltaWithoutClobbering(defBlock.getSuccOf(def), defBlock.getTail())) {
boolean res = true;
for (Block b : defBlock.getSuccs()) {
if (getDeltaStackHeightFromTo(b.getHead(), b.getTail()) != 0 || b.getPreds().size() != 1
|| b.getSuccs().size() != 1) {
res = false;
break;
}
}
if (debug) {
logger.debug(defBlock.toString() + loadBlock.toString());
}
if (res) {
defBlock.remove(def);
mUnitToBlockMap.put(def, loadBlock);
loadBlock.insertBefore(def, loadBlock.getHead());
hasChanged = true;
if (debug) {
logger.debug("inter-block opt 1 occurred " + def + " " + u);
}
if (debug) {
logger.debug(defBlock.toString() + loadBlock.toString());
}
}
}
}
}
}
} else if (defs.size() == 2) { // second optimization
final Unit def0 = defs.get(0);
final Block defBlock0 = mUnitToBlockMap.get(def0);
assert (SKIP_SLOW_ASSERTS || contains(defBlock0, def0));
final Unit def1 = defs.get(1);
final Block defBlock1 = mUnitToBlockMap.get(def1);
assert (SKIP_SLOW_ASSERTS || contains(defBlock1, def1));
if (defBlock0 != loadBlock && defBlock1 != loadBlock && defBlock0 != defBlock1
&& !(isExceptionHandlerBlock(loadBlock))) {
if (mLocalUses.getUsesOf(def0).size() == 1 && mLocalUses.getUsesOf(def1).size() == 1) {
List<Block> def0Succs = defBlock0.getSuccs();
List<Block> def1Succs = defBlock1.getSuccs();
if (def0Succs.size() == 1 && def1Succs.size() == 1) {
if (def0Succs.get(0) == loadBlock && def1Succs.get(0) == loadBlock) {
if (loadBlock.getPreds().size() == 2) {
final Unit tailB0 = defBlock0.getTail();
final Unit tailB1 = defBlock1.getTail();
if ((def0 == tailB0 || isZeroStackDeltaWithoutClobbering(defBlock0.getSuccOf(def0), tailB0))
&& (def1 == tailB1 || isZeroStackDeltaWithoutClobbering(defBlock1.getSuccOf(def1), tailB1))) {
defBlock0.remove(def0);
defBlock1.remove(def1);
loadBlock.insertBefore(def0, loadBlock.getHead());
mUnitToBlockMap.put(def0, loadBlock);
mUnitToBlockMap.remove(def1);
hasChanged = true;
if (debug) {
logger.debug("inter-block opt 2 occurred " + def0);
}
} else if (debug) {
logger.debug("failed: inter: unacceptable stack offset");
}
} else if (debug) {
logger.debug("failed: inter: 'loadBlock' #preds != 2");
}
} else if (debug) {
logger.debug("failed: inter: successor is not 'loadBlock'");
}
} else if (debug) {
logger.debug("failed: inter: #successors != 1");
}
} else if (debug) {
logger.debug("failed: inter: #defs != 1");
}
} else if (debug) {
logger.debug("failed: inter: unacceptable blocks");
}
}
}
}
if (debug) {
logger.debug("[doInterBlockOptimizations] completed pass. changed? " + hasChanged);
}
if (hasChanged) {
// Clear the use/def sets so they will be recomputed if running another
// iteration or if running optimizeLoadStores() again. Otherwise, their
// stale information could cause incomplete or incorrect optimization.
clearLocalDefsAndLocalUsesInfo();
}
}
}
/**
* Given 2 blocks, checks whether all the successors of the first block are the predecessors of the second block.
*/
private boolean allSuccesorsOfAreThePredecessorsOf(Block aFirstBlock, Block aSecondBlock) {
List<Block> preds = aSecondBlock.getPreds();
for (Block next : aFirstBlock.getSuccs()) {
if (!preds.contains(next)) {
return false;
}
}
return aFirstBlock.getSuccs().size() == preds.size();
}
/**
* @return true if the Unit is a commutative binary operator
*/
private boolean isCommutativeBinOp(Unit aUnit) {
return aUnit instanceof AddInst || aUnit instanceof MulInst || aUnit instanceof AndInst || aUnit instanceof OrInst
|| aUnit instanceof XorInst;
}
// For assertions
private boolean unitToBlockMapIsValid() {
// Ensure every Unit in the body is mapped
for (Unit u : mUnits) {
assert (mUnitToBlockMap.containsKey(u));
}
HashSet<Block> blocks = new HashSet<Block>();
for (Map.Entry<Unit, Block> e : mUnitToBlockMap.entrySet()) {
blocks.add(e.getValue());
// Ensure the Unit is mapped to the correct Block
assert (contains(e.getValue(), e.getKey()));
}
// Ensure that every Unit in the Block is mapped to the Block
for (Block b : blocks) {
final Unit t = b.getTail();
assert (mUnitToBlockMap.get(t) == b);
for (Unit u2 = b.getHead(); u2 != t; u2 = b.getSuccOf(u2)) {
assert (mUnitToBlockMap.get(u2) == b);
}
}
return true;
}
// For assertions
private static boolean contains(Block b, Unit u) {
final Unit t = b.getTail();
if (u == t) {
return true;
}
for (Unit u2 = b.getHead(); u2 != t; u2 = b.getSuccOf(u2)) {
if (u == u2) {
return true;
}
}
return false;
}
}
}
| 39,159
| 37.354554
| 124
|
java
|
soot
|
soot-master/src/main/java/soot/baf/toolkits/base/OpStackCalculator.java
|
package soot.baf.toolkits.base;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 - 2021 Raja Vallee-Rai and others
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import soot.DoubleType;
import soot.FloatType;
import soot.IntType;
import soot.IntegerType;
import soot.LongType;
import soot.PatchingChain;
import soot.RefLikeType;
import soot.RefType;
import soot.SootMethod;
import soot.StmtAddressType;
import soot.Trap;
import soot.Type;
import soot.Unit;
import soot.VoidType;
import soot.baf.AddInst;
import soot.baf.AndInst;
import soot.baf.ArrayLengthInst;
import soot.baf.ArrayReadInst;
import soot.baf.ArrayWriteInst;
import soot.baf.BafBody;
import soot.baf.CmpInst;
import soot.baf.CmpgInst;
import soot.baf.CmplInst;
import soot.baf.DivInst;
import soot.baf.Dup1Inst;
import soot.baf.Dup1_x1Inst;
import soot.baf.Dup1_x2Inst;
import soot.baf.Dup2Inst;
import soot.baf.Dup2_x1Inst;
import soot.baf.Dup2_x2Inst;
import soot.baf.DynamicInvokeInst;
import soot.baf.EnterMonitorInst;
import soot.baf.ExitMonitorInst;
import soot.baf.FieldGetInst;
import soot.baf.FieldPutInst;
import soot.baf.GotoInst;
import soot.baf.IdentityInst;
import soot.baf.IfCmpEqInst;
import soot.baf.IfCmpGeInst;
import soot.baf.IfCmpGtInst;
import soot.baf.IfCmpLeInst;
import soot.baf.IfCmpLtInst;
import soot.baf.IfCmpNeInst;
import soot.baf.IfEqInst;
import soot.baf.IfGeInst;
import soot.baf.IfGtInst;
import soot.baf.IfLeInst;
import soot.baf.IfLtInst;
import soot.baf.IfNeInst;
import soot.baf.IfNonNullInst;
import soot.baf.IfNullInst;
import soot.baf.IncInst;
import soot.baf.Inst;
import soot.baf.InstSwitch;
import soot.baf.InstanceCastInst;
import soot.baf.InstanceOfInst;
import soot.baf.InterfaceInvokeInst;
import soot.baf.JSRInst;
import soot.baf.LoadInst;
import soot.baf.LookupSwitchInst;
import soot.baf.MethodArgInst;
import soot.baf.MulInst;
import soot.baf.NegInst;
import soot.baf.NewArrayInst;
import soot.baf.NewInst;
import soot.baf.NewMultiArrayInst;
import soot.baf.NopInst;
import soot.baf.OpTypeArgInst;
import soot.baf.OrInst;
import soot.baf.PopInst;
import soot.baf.PrimitiveCastInst;
import soot.baf.PushInst;
import soot.baf.RemInst;
import soot.baf.ReturnInst;
import soot.baf.ReturnVoidInst;
import soot.baf.ShlInst;
import soot.baf.ShrInst;
import soot.baf.SpecialInvokeInst;
import soot.baf.StaticGetInst;
import soot.baf.StaticInvokeInst;
import soot.baf.StaticPutInst;
import soot.baf.StoreInst;
import soot.baf.SubInst;
import soot.baf.SwapInst;
import soot.baf.TableSwitchInst;
import soot.baf.TargetArgInst;
import soot.baf.ThrowInst;
import soot.baf.UshrInst;
import soot.baf.VirtualInvokeInst;
import soot.baf.XorInst;
import soot.baf.internal.AbstractOpTypeInst;
import soot.toolkits.graph.BriefUnitGraph;
import soot.util.Chain;
/**
* Emulates the operation of the JVM stack to compute the expected types of the objects on the stack at each {@link Unit} in
* a {@link BafBody}.
*
* @author Michael Batchelder
* @author Timothy Hoffman
*/
public class OpStackCalculator {
private static final Logger logger = LoggerFactory.getLogger(OpStackCalculator.class);
private static class StackEffectSwitch implements InstSwitch {
public boolean shouldThrow = true;
// Types popped from the stack by the instruction
public Type[] remove_types = null;
// Types pushed to the stack by the instruction
public Type[] add_types = null;
private static RefLikeType arrayRefType() {
// RefType replaces the arraytype
return RefType.v();
}
@Override
public void caseReturnInst(ReturnInst i) {
remove_types = new Type[] { i.getOpType() };
add_types = null;
}
@Override
public void caseReturnVoidInst(ReturnVoidInst i) {
remove_types = null;
add_types = null;
}
@Override
public void caseNopInst(NopInst i) {
remove_types = null;
add_types = null;
}
@Override
public void caseGotoInst(GotoInst i) {
remove_types = null;
add_types = null;
}
@Override
public void caseJSRInst(JSRInst i) {
remove_types = null;
add_types = new Type[] { StmtAddressType.v() };
}
@Override
public void casePushInst(PushInst i) {
remove_types = null;
add_types = new Type[] { i.getConstant().getType() };
}
@Override
public void casePopInst(PopInst i) {
remove_types = new Type[] { ((soot.baf.internal.BPopInst) i).getType() };
add_types = null;
}
@Override
public void caseIdentityInst(IdentityInst i) {
remove_types = null;
add_types = null;
}
@Override
public void caseStoreInst(StoreInst i) {
remove_types = new Type[] { ((AbstractOpTypeInst) i).getOpType() };
add_types = null;
}
@Override
public void caseLoadInst(LoadInst i) {
remove_types = null;
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseArrayWriteInst(ArrayWriteInst i) {
remove_types = new Type[] { arrayRefType(), IntType.v(), i.getOpType() };
add_types = null;
}
@Override
public void caseArrayReadInst(ArrayReadInst i) {
remove_types = new Type[] { arrayRefType(), IntType.v() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseIfNullInst(IfNullInst i) {
remove_types = new Type[] { RefType.v("java.lang.Object") };
add_types = null;
}
@Override
public void caseIfNonNullInst(IfNonNullInst i) {
remove_types = new Type[] { RefType.v("java.lang.Object") };
add_types = null;
}
@Override
public void caseIfEqInst(IfEqInst i) {
remove_types = new Type[] { IntType.v() };
add_types = null;
}
@Override
public void caseIfNeInst(IfNeInst i) {
remove_types = new Type[] { IntType.v() };
add_types = null;
}
@Override
public void caseIfGtInst(IfGtInst i) {
remove_types = new Type[] { IntType.v() };
add_types = null;
}
@Override
public void caseIfGeInst(IfGeInst i) {
remove_types = new Type[] { IntType.v() };
add_types = null;
}
@Override
public void caseIfLtInst(IfLtInst i) {
remove_types = new Type[] { IntType.v() };
add_types = null;
}
@Override
public void caseIfLeInst(IfLeInst i) {
remove_types = new Type[] { IntType.v() };
add_types = null;
}
@Override
public void caseIfCmpEqInst(IfCmpEqInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = null;
}
@Override
public void caseIfCmpNeInst(IfCmpNeInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = null;
}
@Override
public void caseIfCmpGtInst(IfCmpGtInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = null;
}
@Override
public void caseIfCmpGeInst(IfCmpGeInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = null;
}
@Override
public void caseIfCmpLtInst(IfCmpLtInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = null;
}
@Override
public void caseIfCmpLeInst(IfCmpLeInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = null;
}
@Override
public void caseStaticGetInst(StaticGetInst i) {
remove_types = null;
add_types = new Type[] { i.getField().getType() };
}
@Override
public void caseStaticPutInst(StaticPutInst i) {
remove_types = new Type[] { i.getField().getType() };
add_types = null;
}
@Override
public void caseFieldGetInst(FieldGetInst i) {
remove_types = new Type[] { i.getField().getDeclaringClass().getType() };
add_types = new Type[] { i.getField().getType() };
}
@Override
public void caseFieldPutInst(FieldPutInst i) {
remove_types = new Type[] { i.getField().getDeclaringClass().getType(), i.getField().getType() };
add_types = null;
}
@Override
public void caseInstanceCastInst(InstanceCastInst i) {
remove_types = new Type[] { RefType.v("java.lang.Object") };
add_types = new Type[] { i.getCastType() };
}
@Override
public void caseInstanceOfInst(InstanceOfInst i) {
remove_types = new Type[] { RefType.v("java.lang.Object") };
add_types = new Type[] { IntType.v() };
}
@Override
public void casePrimitiveCastInst(PrimitiveCastInst i) {
remove_types = new Type[] { i.getFromType() };
add_types = new Type[] { i.getToType() };
}
private void staticinvoke(MethodArgInst i) {
SootMethod m = i.getMethod();
final int len = m.getParameterCount();
remove_types = new Type[len];
System.arraycopy(m.getParameterTypes().toArray(), 0, remove_types, 0, len);
Type retTy = m.getReturnType();
add_types = (retTy instanceof VoidType) ? null : new Type[] { retTy };
}
private void instanceinvoke(MethodArgInst i) {
SootMethod m = i.getMethod();
final int len = m.getParameterCount();
remove_types = new Type[len + 1];
remove_types[0] = RefType.v("java.lang.Object");
System.arraycopy(m.getParameterTypes().toArray(), 0, remove_types, 1, len);
Type retTy = m.getReturnType();
add_types = (retTy instanceof VoidType) ? null : new Type[] { retTy };
}
@Override
public void caseDynamicInvokeInst(DynamicInvokeInst i) {
staticinvoke(i);
}
@Override
public void caseStaticInvokeInst(StaticInvokeInst i) {
staticinvoke(i);
}
@Override
public void caseVirtualInvokeInst(VirtualInvokeInst i) {
instanceinvoke(i);
}
@Override
public void caseInterfaceInvokeInst(InterfaceInvokeInst i) {
instanceinvoke(i);
}
@Override
public void caseSpecialInvokeInst(SpecialInvokeInst i) {
instanceinvoke(i);
}
@Override
public void caseThrowInst(ThrowInst i) {
remove_types = new Type[] { RefType.v("java.lang.Throwable") };
add_types = null;
}
@Override
public void caseAddInst(AddInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { i.getOpType() };
}
private void bitOps(OpTypeArgInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseAndInst(AndInst i) {
bitOps(i);
}
@Override
public void caseOrInst(OrInst i) {
bitOps(i);
}
@Override
public void caseXorInst(XorInst i) {
bitOps(i);
}
@Override
public void caseArrayLengthInst(ArrayLengthInst i) {
remove_types = new Type[] { arrayRefType() };
add_types = new Type[] { IntType.v() };
}
@Override
public void caseCmpInst(CmpInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { IntType.v() };
}
@Override
public void caseCmpgInst(CmpgInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { IntType.v() };
}
@Override
public void caseCmplInst(CmplInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { IntType.v() };
}
@Override
public void caseDivInst(DivInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseIncInst(IncInst i) {
remove_types = null;
add_types = null;
}
@Override
public void caseMulInst(MulInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseRemInst(RemInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseSubInst(SubInst i) {
remove_types = new Type[] { i.getOpType(), i.getOpType() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseShlInst(ShlInst i) {
remove_types = new Type[] { i.getOpType(), IntType.v() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseShrInst(ShrInst i) {
remove_types = new Type[] { i.getOpType(), IntType.v() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseUshrInst(UshrInst i) {
remove_types = new Type[] { i.getOpType(), IntType.v() };
add_types = new Type[] { i.getOpType() };
}
@Override
public void caseNewInst(NewInst i) {
remove_types = null;
add_types = new Type[] { i.getBaseType() };
}
@Override
public void caseNegInst(NegInst i) {
remove_types = null;
add_types = null;
}
@Override
public void caseSwapInst(SwapInst i) {
remove_types = new Type[] { i.getFromType(), i.getToType() };
add_types = new Type[] { i.getToType(), i.getFromType() };
}
@Override
public void caseDup1Inst(Dup1Inst i) {
remove_types = new Type[] { i.getOp1Type() };
add_types = new Type[] { i.getOp1Type(), i.getOp1Type() };
}
@Override
public void caseDup2Inst(Dup2Inst i) {
if (!(i.getOp1Type() instanceof DoubleType || i.getOp1Type() instanceof LongType)) {
add_types = new Type[] { i.getOp2Type(), i.getOp1Type() };
remove_types = null;
} else {
add_types = new Type[] { i.getOp1Type() };
remove_types = null;
}
}
@Override
public void caseDup1_x1Inst(Dup1_x1Inst i) {
remove_types = new Type[] { i.getUnder1Type(), i.getOp1Type() };
add_types = new Type[] { i.getOp1Type(), i.getUnder1Type(), i.getOp1Type() };
}
@Override
public void caseDup1_x2Inst(Dup1_x2Inst i) {
Type u1 = i.getUnder1Type();
if (u1 instanceof DoubleType || u1 instanceof LongType) {
remove_types = new Type[] { u1, i.getOp1Type() };
add_types = new Type[] { i.getOp1Type(), u1, i.getOp1Type() };
} else {
remove_types = new Type[] { i.getUnder2Type(), u1, i.getOp1Type() };
add_types = new Type[] { i.getOp1Type(), i.getUnder2Type(), u1, i.getOp1Type() };
}
}
@Override
public void caseDup2_x1Inst(Dup2_x1Inst i) {
Type ot = i.getOp1Type();
if (ot instanceof DoubleType || ot instanceof LongType) {
remove_types = new Type[] { i.getUnder1Type(), ot };
add_types = new Type[] { ot, i.getUnder1Type(), ot };
} else {
remove_types = new Type[] { i.getUnder1Type(), i.getOp2Type(), ot };
add_types = new Type[] { i.getOp2Type(), ot, i.getUnder1Type(), i.getOp2Type(), ot };
}
}
@Override
public void caseDup2_x2Inst(Dup2_x2Inst i) {
Type u1 = i.getUnder1Type();
Type o1 = i.getOp1Type();
if (u1 instanceof DoubleType || u1 instanceof LongType) {
if (o1 instanceof DoubleType || o1 instanceof LongType) {
remove_types = new Type[] { u1, o1 };
add_types = new Type[] { o1, u1, o1 };
} else {
remove_types = new Type[] { u1, i.getOp2Type(), o1 };
add_types = new Type[] { i.getOp2Type(), o1, u1, i.getOp2Type(), o1 };
}
} else if (o1 instanceof DoubleType || o1 instanceof LongType) {
remove_types = new Type[] { i.getUnder2Type(), u1, o1 };
add_types = new Type[] { o1, i.getUnder2Type(), u1, o1 };
} else {
remove_types = new Type[] { i.getUnder2Type(), u1, i.getOp2Type(), o1 };
add_types = new Type[] { i.getOp2Type(), o1, i.getUnder2Type(), u1, i.getOp2Type(), o1 };
}
}
@Override
public void caseNewArrayInst(NewArrayInst i) {
remove_types = new Type[] { IntType.v() };
add_types = new Type[] { arrayRefType() };
}
@Override
public void caseNewMultiArrayInst(NewMultiArrayInst i) {
int size = i.getDimensionCount();
remove_types = new Type[size];
Arrays.fill(remove_types, 0, size, IntType.v());
add_types = new Type[] { arrayRefType() };
}
@Override
public void caseLookupSwitchInst(LookupSwitchInst i) {
remove_types = new Type[] { IntType.v() };
add_types = null;
}
@Override
public void caseTableSwitchInst(TableSwitchInst i) {
remove_types = new Type[] { IntType.v() };
add_types = null;
}
@Override
public void caseEnterMonitorInst(EnterMonitorInst i) {
remove_types = new Type[] { RefType.v("java.lang.Object") };
add_types = null;
}
@Override
public void caseExitMonitorInst(ExitMonitorInst i) {
remove_types = new Type[] { RefType.v("java.lang.Object") };
add_types = null;
}
}
/**
* @param b
* @return {@link Map} of each {@link Unit} to the VM operand stack types prior to executing the {@link Unit}
*/
public static Map<Unit, Stack<Type>> calculateStacks(BafBody b) {
Map<Unit, Stack<Type>> results = new IdentityHashMap<>();
final StackEffectSwitch sw = new StackEffectSwitch();
final BriefUnitGraph bug = new BriefUnitGraph(b);
for (Unit h : bug.getHeads()) {
RefType handlerExc = isHandlerUnit(b.getTraps(), h);
Stack<Type> stack = results.get(h);
if (stack == null) {
stack = new Stack<>();
if (handlerExc != null) {
stack.push(handlerExc);
}
results.put(h, stack);
List<Unit> worklist = new ArrayList<>();
worklist.add(h);
while (!worklist.isEmpty()) {
Inst inst = (Inst) worklist.remove(0);
inst.apply(sw);
stack = updateStack(sw, results.get(inst));
for (Unit next : bug.getSuccsOf(inst)) {
Stack<Type> nxtStck = results.get(next);
if (nxtStck != null) {
if (nxtStck.size() != stack.size()) {
printStack(sw, b.getUnits(), results);
throw new java.lang.RuntimeException(
"Problem with stack height at: " + next + "\n\rHas Stack " + nxtStck + " but is expecting " + stack);
}
continue;
}
results.put(next, stack);
worklist.add(next);
}
}
} else {
if (stack.size() != (handlerExc != null ? 1 : 0)) {
throw new java.lang.RuntimeException("Problem with stack height - head expects 0 (or 1 if exception handler)");
}
}
}
return results;
}
private static Stack<Type> updateStack(StackEffectSwitch sw, Stack<Type> st) {
@SuppressWarnings("unchecked")
Stack<Type> clone = (Stack<Type>) st.clone();
final Type[] remove_types = sw.remove_types;
if (remove_types != null) {
if (remove_types.length > clone.size()) {
StringBuilder exc = new StringBuilder();
exc.append("Expecting values on stack: ");
for (Type element : remove_types) {
String type = element.toString();
if (type.trim().isEmpty()) {
type = element instanceof RefLikeType ? "L" : "U";
}
exc.append(type).append(" ");
}
exc.append("\n\tbut only found: ");
for (Type element : clone) {
String type = element.toString();
if (type.trim().isEmpty()) {
type = element instanceof RefLikeType ? "L" : "U";
}
exc.append(type).append(" ");
}
if (sw.shouldThrow) {
throw new RuntimeException(exc.toString());
} else {
logger.debug(exc.toString());
}
}
for (int i = remove_types.length - 1; i >= 0; i--) {
try {
Type t = clone.pop();
assert (typesAreCompatible(t, remove_types[i])); // ensure consistency
} catch (Exception exc) {
return null;
}
}
}
if (sw.add_types != null) {
for (Type element : sw.add_types) {
clone.push(element);
}
}
return clone;
}
private static boolean typesAreCompatible(Type t1, Type t2) {
if (t1 == t2) {
return true;
}
if (t1 instanceof RefLikeType && t2 instanceof RefLikeType) {
return true;
}
if (t1 instanceof IntegerType && t2 instanceof IntegerType) {
return true;
}
if (t1 instanceof LongType && t2 instanceof LongType) {
return true;
}
if (t1 instanceof DoubleType && t2 instanceof DoubleType) {
return true;
}
if (t1 instanceof FloatType && t2 instanceof FloatType) {
return true;
}
return false;
}
private static RefType isHandlerUnit(Chain<Trap> traps, Unit h) {
for (Trap t : traps) {
if (t.getHandlerUnit() == h) {
return t.getException().getType();
}
}
return null;
}
private static void printStack(StackEffectSwitch sw, PatchingChain<Unit> units, Map<Unit, Stack<Type>> stacks) {
try {
sw.shouldThrow = false;
Map<Unit, Integer> indexes = new HashMap<>();
{
int count = 0;
for (Iterator<Unit> it = units.snapshotIterator(); it.hasNext();) {
indexes.put(it.next(), count++);
}
}
for (Iterator<Unit> it = units.snapshotIterator(); it.hasNext();) {
Unit unit = it.next();
StringBuilder s = new StringBuilder();
try {
s.append(indexes.get(unit)).append(' ').append(unit).append(" ");
} catch (Exception e) {
logger.debug("Error in OpStackCalculator trying to find index of unit");
}
if (unit instanceof TargetArgInst) {
s.append(indexes.get(((TargetArgInst) unit).getTarget()));
} else if (unit instanceof TableSwitchInst) {
TableSwitchInst tswi = (TableSwitchInst) unit;
s.append("\r\tdefault: ").append(tswi.getDefaultTarget());
s.append(" ").append(indexes.get(tswi.getDefaultTarget()));
int index = 0;
for (int x = tswi.getLowIndex(), e = tswi.getHighIndex(); x <= e; x++) {
s.append("\r\t ").append(x).append(": ").append(tswi.getTarget(index));
s.append(" ").append(indexes.get(tswi.getTarget(index++)));
}
}
s.append(" [");
Stack<Type> stack = stacks.get(unit);
if (stack != null) {
unit.apply(sw);
stack = updateStack(sw, stack);
if (stack == null) {
printUnits(units, " StackTypeHeightCalc failed");
return;
}
for (int i = 0, e = stack.size(); i < e; i++) {
s.append(printType(stack.get(i)));
}
} else {
s.append("***missing***");
}
s.append(']');
System.out.println(s);
}
} finally {
sw.shouldThrow = true;
}
}
private static String printType(Type t) {
if (t instanceof IntegerType) {
return "I";
} else if (t instanceof FloatType) {
return "F";
} else if (t instanceof DoubleType) {
return "D";
} else if (t instanceof LongType) {
return "J";
} else if (t instanceof RefLikeType) {
return "L" + t.toString();
} else {
return "U(" + t.getClass().toString() + ")";
}
}
private static void printUnits(PatchingChain<Unit> u, String msg) {
System.out.println("\r\r*********** " + msg);
HashMap<Unit, Integer> numbers = new HashMap<>();
{
int i = 0;
for (Iterator<Unit> it = u.snapshotIterator(); it.hasNext();) {
numbers.put(it.next(), i++);
}
}
for (Iterator<Unit> udit = u.snapshotIterator(); udit.hasNext();) {
final Unit unit = udit.next();
final Integer numb = numbers.get(unit);
if (unit instanceof TargetArgInst) {
TargetArgInst ti = (TargetArgInst) unit;
if (ti.getTarget() == null) {
System.out.println(unit + " null null null null null null null null null");
continue;
}
System.out.println(numb + " " + unit + " #" + numbers.get(ti.getTarget()));
continue;
} else if (unit instanceof TableSwitchInst) {
TableSwitchInst tswi = (TableSwitchInst) unit;
System.out.println(numb + " SWITCH:");
System.out.println("\tdefault: " + tswi.getDefaultTarget() + " " + numbers.get(tswi.getDefaultTarget()));
int idx = 0;
for (int x = tswi.getLowIndex(), e = tswi.getHighIndex(); x <= e; x++) {
System.out.println("\t " + x + ": " + tswi.getTarget(idx) + " " + numbers.get(tswi.getTarget(idx++)));
}
continue;
}
System.out.println(numb + " " + unit);
}
}
private OpStackCalculator() {
}
}
| 25,830
| 28.588774
| 124
|
java
|
soot
|
soot-master/src/main/java/soot/baf/toolkits/base/Peephole.java
|
package soot.baf.toolkits.base;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1999 Patrice Pominville
* %%
* 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
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
import soot.Body;
/**
* Interface to be implemented by peepholes acting on the Baf IR.
*
* @see PeepholeOptimizer
* @see ExamplePeephole
*/
public interface Peephole {
/**
* Entry point for a peephole. This method is repeatedly called by the peephole driver, until a fixed-point is reached over
* all peepholes.
*
* @param b
* Body to apply peephole to.
* @return true if the peephole changed in any way the Body it acted on. false otherwise.
*/
boolean apply(Body b);
}
| 1,348
| 28.977778
| 125
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.