Skip to content

Commit

Permalink
fix compiler error by perv commit
Browse files Browse the repository at this point in the history
--HG--
branch : 2.x
  • Loading branch information
pxb1988 committed Jun 13, 2015
1 parent 05dcb84 commit 21eadfa
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,8 @@ f1x : op=('move-result'|'move-result-wide'|'move-result-object'
| 'monitor-enter' | 'monitor-exit' ) r1=REGISTER
;
fconst
: op=('const/4'|'const/16'|CONST|'const/high16'|'const-wide/16'|'const-wide/32'|'const-wide/high16')
r1=REGISTER ',' cst=INT
| op='const-wide' r1=REGISTER ',' cst=(INT|LONG)
: op=('const/4'|'const/16'|CONST|'const/high16'|'const-wide/16'|'const-wide/32'|'const-wide/high16'|'const-wide')
r1=REGISTER ',' cst=(INT|LONG)
| op=('const-string'|'const-string/jumbo') r1=REGISTER ',' cst=STRING
| op=('const-class'|'check-cast'|'new-instance') r1=REGISTER ',' cst=(OBJECT_TYPE|ARRAY_TYPE)
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public Object visitFconst(SmaliParser.FconstContext ctx) {
scv.visitTypeStmt(op, r, 0, unEscapeId(cst.getText()));
break;
case CONST_WIDE:
scv.visitConstStmt(op, r, cst.getType() == SmaliLexer.INT ? ((long) parseInt(ctx.getText())) : parseLong(cst.getText()));
scv.visitConstStmt(op, r, cst.getType() == SmaliLexer.INT ? ((long) parseInt(cst.getText())) : parseLong(cst.getText()));
break;
case CONST_WIDE_16: {
long v;
Expand Down
42 changes: 42 additions & 0 deletions d2j-smali/src/test/java/a/BaksmaliTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package a;

import com.googlecode.d2j.smali.Baksmali;
import com.googlecode.d2j.smali.BaksmaliDexFileVisitor;
import com.googlecode.d2j.smali.BaksmaliDumper;
import com.googlecode.d2j.smali.Smali;
import com.googlecode.dex2jar.tools.BaseCmd;
import org.junit.Test;

import java.io.File;
import java.nio.file.FileSystem;
import java.nio.file.Path;

public class BaksmaliTest {


@Test
public void t() throws Exception {
File dir = new File("../dex-translator/src/test/resources/dexes");
File[] fs = dir.listFiles();
if (fs != null) {
for (File f : fs) {
if (f.getName().endsWith(".dex") || f.getName().endsWith(".apk")) {
dotest(f.toPath());
}
}
}
}

private void dotest(Path f) throws Exception {
Path smali0 = new File("target/" + f.getFileName() + "-smali0.zip").toPath();
try (FileSystem fs0 = BaseCmd.createZip(smali0)) {
Baksmali.from(f).to(fs0.getPath("/"));
}
Path smali1 = new File("target/" + f.getFileName() + "-smali1.zip").toPath();
try (FileSystem fs0 = BaseCmd.openZip(smali0); FileSystem fs1 = BaseCmd.createZip(smali1)) {
BaksmaliDumper baksmaliDumper = new BaksmaliDumper();
BaksmaliDexFileVisitor v = new BaksmaliDexFileVisitor(fs1.getPath("/"), baksmaliDumper);
Smali.smali(fs0.getPath("/"), v);
}
}
}
17 changes: 14 additions & 3 deletions d2j-smali/src/test/java/a/SmaliTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void test() throws IOException {
}
}

Map<String, DexClassNode> readDex(String path) throws IOException {
DexFileReader dexFileReader = new DexFileReader(ZipUtil.readDex(new File(path)));
Map<String, DexClassNode> readDex(File path) throws IOException {
DexFileReader dexFileReader = new DexFileReader(ZipUtil.readDex(path));
DexFileNode dexFileNode = new DexFileNode();
dexFileReader.accept(dexFileNode);
Map<String, DexClassNode> map = new HashMap<>();
Expand All @@ -49,7 +49,18 @@ Map<String, DexClassNode> readDex(String path) throws IOException {

@Test
public void test2() throws IOException {
String dexFile = "../dex-translator/src/test/resources/dexes/i_jetty.dex";
File dir=new File( "../dex-translator/src/test/resources/dexes");
File[]fs=dir.listFiles();
if(fs!=null) {
for (File f : fs) {
if (f.getName().endsWith(".dex") || f.getName().endsWith(".apk")) {
dotest(f);
}
}
}
}

private void dotest(File dexFile) throws IOException {
DexBackedDexFile dex = DexFileFactory.loadDexFile(dexFile, 14, false);
Map<String, DexClassNode> map = readDex(dexFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ public void testB() throws IOException, RecognitionException {
}

private void test0(DexWeaver iw, String prefix) throws IOException, RecognitionException {

Smali s = new Smali();

DexClassNode before = s.smaliFile2Node(prefix + "-before.smali", getClass()
DexClassNode before = Smali.smaliFile2Node(prefix + "-before.smali", getClass()
.getResourceAsStream("/weave/smali/" + prefix + "-before.smali"));
DexClassNode expectedAfter = s.smaliFile2Node(prefix + "-after.smali", getClass()
DexClassNode expectedAfter = Smali.smaliFile2Node(prefix + "-after.smali", getClass()
.getResourceAsStream("/weave/smali/" + prefix + "-after.smali"));

DexFileNode dfn = new DexFileNode();
Expand All @@ -58,7 +55,7 @@ private void test0(DexWeaver iw, String prefix) throws IOException, RecognitionE

assertEqual(expectedAfter, dfn.clzs.get(0));

DexClassNode expectedGen = s.smaliFile2Node(prefix + "-gen.j", getClass()
DexClassNode expectedGen = Smali.smaliFile2Node(prefix + "-gen.j", getClass()
.getResourceAsStream("/weave/smali/" + prefix + "-gen.smali"));

dfn.clzs.clear();
Expand Down

This file was deleted.

8 changes: 0 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,11 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerId>eclipse</compilerId>
<source>1.7</source>
<target>1.7</target>
<optimize>true</optimize>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down

0 comments on commit 21eadfa

Please sign in to comment.