[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

soot.baf.RetInst




2 things

1)
What's the use of RetInst?
If it represents the ret instruction
then it is useless unless a jsr is
implemented.
(I have to implement the jsr and ret for my project)

2)
I'm not that familiar about the singleton model.
For me it would mean a single instance of an object and
object representing the same, immutable, data share
the same instance.

If you consider soot.RefType though, a new instance
is returned every time v is invoked even if the
the same class name is provided.  It shouldn't make a difference
in practice, but if you rename class name (for space
saving) then you get into trouble.

Also, types used a lot like String could lead to a lot
of memory used.


current implementation:

    public static RefType v(String className)
    {
        return new RefType(className);
    }


my implementation:

I map names to instances.  And keep a single instance for
each type.

    public static RefType v(String className)
    {

      //return new RefType(className);
      
      if (nameToRefType.containsKey(className)) {
        //System.out.println("Getting an already created type: " +
className);
        return (RefType) nameToRefType.get(className);
      } else {
        //System.out.println("Creating a new type: " + className);
        RefType type = new RefType(className);
        nameToRefType.put(className, type);
        return type;
      }
      
    }



David

---

David Bélanger
Graduate Student
School of Computer Science
McGill University
Office: MC226

PGP public key:
  http://www.cs.mcgill.ca/~dbelan2/public_key.pgp