Skip to content

Commit

Permalink
Merge pull request soot-oss#762 from MarcMil/develop-marc
Browse files Browse the repository at this point in the history
Allowing subclasses to change the name of JimpleLocals directly
  • Loading branch information
mbenz89 committed Aug 9, 2017
2 parents cc9c4bc + 068758b commit fc5563e
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions src/soot/jimple/internal/JimpleLocal.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@

package soot.jimple.internal;

import soot.*;
import soot.jimple.*;
import soot.baf.*;
import soot.util.*;

import java.util.*;
import java.util.Collections;
import java.util.List;

import soot.Local;
import soot.Scene;
import soot.Type;
import soot.Unit;
import soot.UnitPrinter;
import soot.ValueBox;
import soot.baf.Baf;
import soot.jimple.ConvertToBaf;
import soot.jimple.JimpleToBafContext;
import soot.jimple.JimpleValueSwitch;
import soot.util.Switch;

public class JimpleLocal implements Local, ConvertToBaf {
String name;
protected String name;
Type type;

/** Constructs a JimpleLocal of the given name and type. */
Expand All @@ -44,13 +52,15 @@ public JimpleLocal(String name, Type type) {
}

/** Returns true if the given object is structurally equal to this one. */
@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() {
final int prime = 31;
int result = 1;
Expand All @@ -60,6 +70,7 @@ public int equivHashCode() {
}

/** Returns a clone of the current JimpleLocal. */
@Override
public Object clone() {
// do not intern the name again
JimpleLocal local = new JimpleLocal(null, type);
Expand All @@ -68,29 +79,35 @@ public Object clone() {
}

/** Returns the name of this object. */
@Override
public String getName() {
return name;
}

/** Sets the name of this object as given. */
@Override
public void setName(String name) {
this.name = (name == null) ? null : name.intern();
}

/** Returns the type of this local. */
@Override
public Type getType() {
return type;
}

/** Sets the type of this local. */
@Override
public void setType(Type t) {
this.type = t;
}

@Override
public String toString() {
return getName();
}

@Override
public void toString(UnitPrinter up) {
up.local(this);
}
Expand All @@ -100,21 +117,25 @@ public final List<ValueBox> getUseBoxes() {
return Collections.emptyList();
}

@Override
public void apply(Switch sw) {
((JimpleValueSwitch) sw).caseLocal(this);
}

@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
Unit u = Baf.v().newLoadInst(getType(),
context.getBafLocalOfJimpleLocal(this));
u.addAllTagsOf(context.getCurrentUnit());
out.add(u);
}

@Override
public final int getNumber() {
return number;
}

@Override
public final void setNumber(int number) {
this.number = number;
}
Expand Down

0 comments on commit fc5563e

Please sign in to comment.