Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
9e811d95
Commit
9e811d95
authored
Aug 16, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: add method for print line numbers
parent
957d5394
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
13 deletions
+32
-13
CodeWriter.java
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
+25
-0
InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+2
-5
MethodGen.java
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
+2
-2
RegionGen.java
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
+3
-6
No files found.
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
View file @
9e811d95
...
...
@@ -22,6 +22,8 @@ public class CodeWriter {
public
static
final
String
NL
=
System
.
getProperty
(
"line.separator"
);
public
static
final
String
INDENT
=
" "
;
private
static
final
boolean
ADD_LINE_NUMBERS
=
false
;
private
static
final
String
[]
INDENT_CACHE
=
{
""
,
INDENT
,
...
...
@@ -43,6 +45,9 @@ public class CodeWriter {
public
CodeWriter
()
{
this
.
indent
=
0
;
this
.
indentStr
=
""
;
if
(
ADD_LINE_NUMBERS
)
{
incIndent
(
2
);
}
}
public
CodeWriter
startLine
()
{
...
...
@@ -65,6 +70,26 @@ public class CodeWriter {
return
this
;
}
public
CodeWriter
startLineWithNum
(
int
sourceLine
)
{
if
(
sourceLine
==
0
)
{
startLine
();
return
this
;
}
if
(
ADD_LINE_NUMBERS
)
{
newLine
();
attachSourceLine
(
sourceLine
);
String
ln
=
"/* "
+
sourceLine
+
" */ "
;
add
(
ln
);
if
(
indentStr
.
length
()
>
ln
.
length
())
{
add
(
indentStr
.
substring
(
ln
.
length
()));
}
}
else
{
startLine
();
attachSourceLine
(
sourceLine
);
}
return
this
;
}
public
CodeWriter
add
(
String
str
)
{
buf
.
append
(
str
);
offset
+=
str
.
length
();
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
View file @
9e811d95
...
...
@@ -196,10 +196,7 @@ public class InsnGen {
state
.
add
(
flag
);
makeInsnBody
(
code
,
insn
,
state
);
}
else
{
code
.
startLine
();
if
(
insn
.
getSourceLine
()
!=
0
)
{
code
.
attachSourceLine
(
insn
.
getSourceLine
());
}
code
.
startLineWithNum
(
insn
.
getSourceLine
());
if
(
insn
.
getResult
()
!=
null
&&
insn
.
getType
()
!=
InsnType
.
ARITH_ONEARG
)
{
assignVar
(
code
,
insn
);
code
.
add
(
" = "
);
...
...
@@ -304,7 +301,7 @@ public class InsnGen {
addArg
(
code
,
insn
.
getArg
(
0
));
code
.
add
(
" == "
);
addArg
(
code
,
insn
.
getArg
(
1
));
code
.
add
(
"? 0 : -1))"
);
code
.
add
(
"
? 0 : -1))"
);
break
;
case
INSTANCE_OF:
{
...
...
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
View file @
9e811d95
...
...
@@ -78,8 +78,8 @@ public class MethodGen {
if
(
clsAccFlags
.
isAnnotation
())
{
ai
=
ai
.
remove
(
AccessFlags
.
ACC_PUBLIC
);
}
code
.
startLine
(
ai
.
makeString
());
code
.
a
ttachSourceLine
(
mth
.
getSourceLine
());
code
.
startLine
WithNum
(
mth
.
getSourceLine
());
code
.
a
dd
(
ai
.
makeString
());
if
(
classGen
.
addGenericMap
(
code
,
mth
.
getGenericMap
()))
{
code
.
add
(
' '
);
...
...
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
View file @
9e811d95
...
...
@@ -101,14 +101,11 @@ public class RegionGen extends InsnGen {
}
private
void
makeIf
(
IfRegion
region
,
CodeWriter
code
,
boolean
newLine
)
throws
CodegenException
{
if
(
region
.
getTernRegion
()
!=
null
)
{
makeSimpleBlock
(
region
.
getTernRegion
().
getBlock
(),
code
);
return
;
}
if
(
newLine
)
{
code
.
startLine
();
code
.
startLineWithNum
(
region
.
getSourceLine
());
}
else
{
code
.
attachSourceLine
(
region
.
getSourceLine
());
}
code
.
attachSourceLine
(
region
.
getSourceLine
());
code
.
add
(
"if ("
);
new
ConditionGen
(
this
).
add
(
code
,
region
.
getCondition
());
code
.
add
(
") {"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment