[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: soot.baf.RetInst
> 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)
It seems RetInst is not used anywhere. For JSR/RET instructions, Soot
eliminates them in COFFI. So you wan't see JSR/RET in jimple, baf anymore.
> 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.
I think Singleton prevents you from creating more than one instance of one
class. For example, you only have one instance of Scene.
But soot.RefType seems different from singleton pattern, I am not sure
what's the suitable name for it.
I have tried something very similar to your following code.
Unfortunately, it fialed on type system. If you can pass that,
please let me know. Also if we can ensuring only one instance of RefType
for a class name, then the hashCode and equals can be made much simple.
> 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
>