Skip to content

Commit

Permalink
Merge branch 'develop' into arrayFix
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenArzt authored Dec 8, 2021
2 parents 49521db + 92bf5b8 commit 645db2c
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 9 deletions.
14 changes: 13 additions & 1 deletion src/main/java/soot/BooleanType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
@SuppressWarnings("serial")
public class BooleanType extends PrimType implements IntegerType {

public static final int HASHCODE = 0x1C4585DA;

public BooleanType(Singletons.Global g) {
}

Expand All @@ -44,7 +46,7 @@ public boolean equals(Object t) {

@Override
public int hashCode() {
return 0x1C4585DA;
return HASHCODE;
}

@Override
Expand All @@ -61,4 +63,14 @@ public void apply(Switch sw) {
public RefType boxedType() {
return RefType.v("java.lang.Boolean");
}

@Override
public Class<?> getJavaBoxedType() {
return Boolean.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return boolean.class;
}
}
14 changes: 13 additions & 1 deletion src/main/java/soot/ByteType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
@SuppressWarnings("serial")
public class ByteType extends PrimType implements IntegerType {

public static final int HASHCODE = 0x813D1329;

public ByteType(Singletons.Global g) {
}

Expand All @@ -39,7 +41,7 @@ public static ByteType v() {

@Override
public int hashCode() {
return 0x813D1329;
return HASHCODE;
}

@Override
Expand All @@ -61,4 +63,14 @@ public void apply(Switch sw) {
public RefType boxedType() {
return RefType.v("java.lang.Byte");
}

@Override
public Class<?> getJavaBoxedType() {
return Byte.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return byte.class;
}
}
14 changes: 13 additions & 1 deletion src/main/java/soot/CharType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
@SuppressWarnings("serial")
public class CharType extends PrimType implements IntegerType {

public static final int HASHCODE = 0x739EA474;

public CharType(Singletons.Global g) {
}

Expand All @@ -49,7 +51,7 @@ public String toString() {

@Override
public int hashCode() {
return 0x739EA474;
return HASHCODE;
}

@Override
Expand All @@ -61,4 +63,14 @@ public void apply(Switch sw) {
public RefType boxedType() {
return RefType.v("java.lang.Character");
}

@Override
public Class<?> getJavaBoxedType() {
return Character.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return char.class;
}
}
14 changes: 13 additions & 1 deletion src/main/java/soot/DoubleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
@SuppressWarnings("serial")
public class DoubleType extends PrimType {

public static final int HASHCODE = 0x4B9D7242;

public DoubleType(Singletons.Global g) {
}

Expand All @@ -44,7 +46,7 @@ public boolean equals(Object t) {

@Override
public int hashCode() {
return 0x4B9D7242;
return HASHCODE;
}

@Override
Expand All @@ -61,4 +63,14 @@ public void apply(Switch sw) {
public RefType boxedType() {
return RefType.v("java.lang.Double");
}

@Override
public Class<?> getJavaBoxedType() {
return Double.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return double.class;
}
}
14 changes: 13 additions & 1 deletion src/main/java/soot/FloatType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
@SuppressWarnings("serial")
public class FloatType extends PrimType {

public static final int HASHCODE = 0xA84373FA;

public FloatType(Singletons.Global g) {
}

Expand All @@ -44,7 +46,7 @@ public boolean equals(Object t) {

@Override
public int hashCode() {
return 0xA84373FA;
return HASHCODE;
}

@Override
Expand All @@ -61,4 +63,14 @@ public void apply(Switch sw) {
public RefType boxedType() {
return RefType.v("java.lang.Float");
}

@Override
public Class<?> getJavaBoxedType() {
return Float.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return float.class;
}
}
15 changes: 14 additions & 1 deletion src/main/java/soot/IntType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
@SuppressWarnings("serial")
public class IntType extends PrimType implements IntegerType {

public static final int HASHCODE = 0xB747239F;

public IntType(Singletons.Global g) {
}

Expand All @@ -44,7 +46,7 @@ public boolean equals(Object t) {

@Override
public int hashCode() {
return 0xB747239F;
return HASHCODE;
}

@Override
Expand All @@ -61,4 +63,15 @@ public void apply(Switch sw) {
public RefType boxedType() {
return RefType.v("java.lang.Integer");
}

@Override
public Class<?> getJavaBoxedType() {
return Integer.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return int.class;
}

}
15 changes: 14 additions & 1 deletion src/main/java/soot/LongType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
@SuppressWarnings("serial")
public class LongType extends PrimType {

public static final int HASHCODE = 0x023DA077;

public LongType(Singletons.Global g) {
}

Expand All @@ -44,7 +46,7 @@ public boolean equals(Object t) {

@Override
public int hashCode() {
return 0x023DA077;
return HASHCODE;
}

@Override
Expand All @@ -61,4 +63,15 @@ public void apply(Switch sw) {
public RefType boxedType() {
return RefType.v("java.lang.Long");
}

@Override
public Class<?> getJavaBoxedType() {
return Long.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return long.class;
}

}
4 changes: 4 additions & 0 deletions src/main/java/soot/PrimType.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public abstract class PrimType extends Type {

public abstract RefType boxedType();

public abstract Class<?> getJavaBoxedType();

public abstract Class<?> getJavaPrimitiveType();

@Override
public boolean isAllowedInFinalCode() {
return true;
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/soot/ShortType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
@SuppressWarnings("serial")
public class ShortType extends PrimType implements IntegerType {

public static final int HASHCODE = 0x8B817DD3;

public ShortType(Singletons.Global g) {
}

Expand All @@ -39,7 +41,7 @@ public static ShortType v() {

@Override
public int hashCode() {
return 0x8B817DD3;
return HASHCODE;
}

@Override
Expand All @@ -61,4 +63,15 @@ public void apply(Switch sw) {
public RefType boxedType() {
return RefType.v("java.lang.Short");
}

@Override
public Class<?> getJavaBoxedType() {
return Short.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return short.class;
}

}
1 change: 0 additions & 1 deletion src/main/java/soot/SootMethodRefImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import soot.javaToJimple.DefaultLocalGenerator;
import soot.jimple.AssignStmt;
import soot.jimple.InvokeStmt;
import soot.jimple.Jimple;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/soot/jimple/toolkits/typing/fast/Integer127Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,14 @@ public Type getDefaultFinalType() {
return ByteType.v();
}

@Override
public Class<?> getJavaBoxedType() {
return Integer.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return int.class;
}

}
10 changes: 10 additions & 0 deletions src/main/java/soot/jimple/toolkits/typing/fast/Integer1Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,14 @@ public Type getDefaultFinalType() {
return BooleanType.v();
}

@Override
public Class<?> getJavaBoxedType() {
return Integer.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return int.class;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,14 @@ public Type getDefaultFinalType() {
return ShortType.v();
}

@Override
public Class<?> getJavaBoxedType() {
return Integer.class;
}

@Override
public Class<?> getJavaPrimitiveType() {
return int.class;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
import heros.solver.Pair;

import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -294,9 +296,14 @@ public void caseAssignStmt(AssignStmt stmt) {
// First, we check the definitions. If we can see the definitions and know the array type
// that way, we are safe.
ArrayDeque<Pair<Unit, Local>> worklist = new ArrayDeque<Pair<Unit, Local>>();
Set<Pair<Unit, Local>> seen = new HashSet<>();
worklist.add(new Pair<>(stmt, (Local) ((ArrayRef) rhs).getBase()));
while (!worklist.isEmpty()) {
Pair<Unit, Local> r = worklist.removeFirst();
if (!seen.add(r)) {
// Make sure we only process each entry once
continue;
}

List<Unit> d = defs.getDefsOfAt(r.getO2(), r.getO1());
if (d.isEmpty()) {
Expand Down

0 comments on commit 645db2c

Please sign in to comment.