janlukes / smali

Automatically exported from code.google.com/p/smali
0 stars 0 forks source link

improvement: Implement "this" object. #213

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Would be great if you will implement this operator while (de)compilation like 
in C/C++. It will reduce Lblah/blah/blah; overhead, will make text easier to 
read and easier to transfer to other classes.

This can be optional, enabled through commandline switch.

Original issue reported on code.google.com by pour.gar...@gmail.com on 14 May 2014 at 5:22

GoogleCodeExporter commented 9 years ago
You're talking about two different concepts here. "this" in c++/java is an 
object reference. However, Lblah/blah/blah; is a class reference.

Do you mean something like:

invoke-virtual {p0, v0, v1}, this->someMethod()V

I'm not opposed to that in principle, although I'm not sure "this" is the 
correct keyword for this. It might even make sense to allow omitting the class 
altogether, for methods (or fields) in the current class.

As far as recompilation goes, I don't see any particular reason to make it an 
optional feature in smali. And then for disassembling it could be optional, and 
maybe even default to enabled.

But, one of the main problems during disassembly is that it doesn't always have 
the full classpath available, and methods may be referenced using different 
class names. I.e. if a class overrides some method blah(), both 
Lbase/class;->blah() and Lsub/class;->blah() reference the same method. But 
without the full classpath, you may not know that Lsub/class; extends 
Lbase/class;, so you wouldn't know to remove the class reference when the 
method is referenced using Lbase/class;

Original comment by jesusfreke@jesusfreke.com on 14 May 2014 at 5:42

GoogleCodeExporter commented 9 years ago
Yes, i mean this:
invoke-virtual {p0, v0, v1}, this->someMethod()V

or even this:
invoke-virtual {p0, v0, v1}, someMethod()V

The basic idea is to make smali more readable.
Some decompiled smali have very long string of class reference, so i have to 
scroll the text horizontally just to find it references to the same class.

I don't know, if such form will allow to compile back 1:1 to original, but if 
you are able to sort it out, then it would be good.

Original comment by pour.gar...@gmail.com on 14 May 2014 at 9:54

GoogleCodeExporter commented 9 years ago
I don't like change, can I suggest making this an option? I don't care which is 
default.

Original comment by jc...@cunninglogic.com on 22 Jun 2014 at 3:49

GoogleCodeExporter commented 9 years ago
Old people hate change.

Original comment by jc...@cunninglogic.com on 22 Jun 2014 at 3:49

GoogleCodeExporter commented 9 years ago
This has implemented for fields and methods, using the 2nd syntax, where there 
is nothing before the member name. E.g.
invoke-virtual {p0, v0, v1}, someMethod()V

https://code.google.com/p/smali/source/detail?r=ce7f93cd79fc2263794f02f5fca3ff65
ab3d243f 

https://code.google.com/p/smali/source/detail?r=d33fd6773cc3e527b4dbb79245796d55
6b7facde

It is enabled by default in baksmali, but can be disabled with the -t option.

Original comment by jesusfreke@jesusfreke.com on 20 Jul 2014 at 3:36