Permalink
Browse files

fix compiler error by perv commit

--HG--
branch : 2.x
  • Loading branch information...
1 parent 05dcb84 commit 21eadfaab96338c62f80c78ba075a79cd9972660 @pxb1988 committed Jun 13, 2015
@@ -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)
;
@@ -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;
@@ -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);
+ }
+ }
+}
@@ -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<>();
@@ -49,7 +49,18 @@ public void test() 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);
@@ -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();
@@ -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();
@@ -1,37 +0,0 @@
-package com.googlecode.dex2jar.test;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.util.List;
-
-import com.googlecode.dex2jar.tools.BaseCmd;
-import org.antlr.runtime.RecognitionException;
-import org.junit.Test;
-
-import com.googlecode.d2j.smali.Baksmali;
-import com.googlecode.d2j.smali.BaksmaliDexFileVisitor;
-import com.googlecode.d2j.smali.BaksmaliDumper;
-import com.googlecode.d2j.smali.Smali;
-
-public class BaksmaliTest {
- @Test
- public void t() throws IOException, RecognitionException {
-
- List<Path> files = TestUtils.listTestDexFiles();
-
- for (Path f : files) {
- 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);
- new Smali().smali(fs0.getPath("/"), v);
- }
- }
- }
-}
View
@@ -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>

0 comments on commit 21eadfa

Please sign in to comment.