dex-translator-0.0.9.11

16:35:22.699 INFO  jd.cli.Main - Decompiling dex-translator-0.0.9.11.jar
package com.googlecode.dex2jar;

public class Annotation$Item
{
  public String name;
  public Object value;
  
  public Annotation$Item(String name, Object value)
  {
    this.name = name;
    this.value = value;
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.Annotation.Item
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar;

import java.util.ArrayList;
import java.util.List;

public class Annotation
{
  public static class Item
  {
    public String name;
    public Object value;
    
    public Item(String name, Object value)
    {
      this.name = name;
      this.value = value;
    }
  }
  
  public List<Item> items = new ArrayList();
  public String type;
  public boolean visible;
  
  public Annotation(String type, boolean visible)
  {
    this.type = type;
    this.visible = visible;
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.Annotation
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Method;
import com.googlecode.dex2jar.util.ASMifierCodeV;
import com.googlecode.dex2jar.util.Escape;
import com.googlecode.dex2jar.util.Out;
import com.googlecode.dex2jar.visitors.DexCodeVisitor;
import com.googlecode.dex2jar.visitors.EmptyVisitor;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

class DexExceptionHandlerImpl$2$1$1
  extends EmptyVisitor
{
  DexExceptionHandlerImpl$2$1$1(DexExceptionHandlerImpl.2.1 param1, Method paramMethod, int paramInt) {}
  
  public DexCodeVisitor visitCode()
  {
    try
    {
      int tmp37_36 = 0; int[] tmp37_33 = this$2.this$1.val$count; int tmp39_38 = tmp37_33[tmp37_36];tmp37_33[tmp37_36] = (tmp39_38 + 1);this$2.this$1.val$errorZipOutputStream.putNextEntry(new ZipEntry("t" + tmp39_38 + ".txt"));
    }
    catch (IOException e)
    {
      throw new RuntimeException(e);
    }
    Exception exception = (Exception)DexExceptionHandlerImpl.access$000(this$2.this$1.this$0).get(val$method);
    exception.printStackTrace(this$2.this$1.val$fw);
    this$2.this$1.val$out.s("");
    this$2.this$1.val$out.s("DexMethodVisitor mv=cv.visitMethod(%s, %s);", new Object[] { Escape.methodAcc(val$accessFlags), Escape.v(val$method) });
    
    this$2.this$1.val$out.s("DexCodeVisitor code = mv.visitCode();");
    return new ASMifierCodeV(this$2.this$1.val$out);
  }
  
  public void visitEnd()
  {
    this$2.this$1.val$out.s("mv.visitEnd();");
    this$2.this$1.val$fw.flush();
    try
    {
      this$2.this$1.val$errorZipOutputStream.closeEntry();
    }
    catch (IOException e)
    {
      throw new RuntimeException(e);
    }
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.DexExceptionHandlerImpl.2.1.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Method;
import com.googlecode.dex2jar.ir.IrMethod;
import org.objectweb.asm.tree.MethodNode;

public abstract interface DexExceptionHandler
{
  public abstract void handleFileException(Exception paramException);
  
  public abstract void handleMethodTranslateException(Method paramMethod, IrMethod paramIrMethod, MethodNode paramMethodNode, Exception paramException);
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.DexExceptionHandler
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Annotation;
import com.googlecode.dex2jar.Annotation.Item;
import com.googlecode.dex2jar.Field;
import com.googlecode.dex2jar.visitors.DexAnnotationVisitor;
import com.googlecode.dex2jar.visitors.DexFieldVisitor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;

public class V3FieldAdapter
  implements DexFieldVisitor
{
  protected List<Annotation> anns = new ArrayList();
  protected boolean build = false;
  protected ClassVisitor cv;
  protected Field field;
  protected FieldVisitor fv;
  protected Object value;
  protected int accessFlags;
  
  protected void build()
  {
    if (!build)
    {
      String signature = null;
      for (Iterator<Annotation> it = anns.iterator(); it.hasNext();)
      {
        Annotation ann = (Annotation)it.next();
        if ("Ldalvik/annotation/Signature;".equals(type))
        {
          it.remove();
          for (Annotation.Item item : items) {
            if (name.equals("value"))
            {
              Annotation values = (Annotation)value;
              StringBuilder sb = new StringBuilder();
              for (Annotation.Item i : items) {
                sb.append(value.toString());
              }
              signature = sb.toString();
            }
          }
        }
      }
      FieldVisitor fv = cv.visitField(accessFlags, field.getName(), field.getType(), signature, value);
      if (fv != null) {
        for (Annotation ann : anns)
        {
          AnnotationVisitor av = fv.visitAnnotation(type, visible);
          V3AnnAdapter.accept(items, av);
          av.visitEnd();
        }
      }
      this.fv = fv;
      build = true;
    }
  }
  
  public DexAnnotationVisitor visitAnnotation(String name, boolean visible)
  {
    Annotation ann = new Annotation(name, visible);
    anns.add(ann);
    return new V3AnnAdapter(ann);
  }
  
  public V3FieldAdapter(ClassVisitor cv, int accessFlags, Field field, Object value)
  {
    this.cv = cv;
    this.field = field;
    this.value = value;
    this.accessFlags = accessFlags;
  }
  
  public void visitEnd()
  {
    build();
    if (fv != null) {
      fv.visitEnd();
    }
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.V3FieldAdapter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Field;
import com.googlecode.dex2jar.visitors.DexAnnotationVisitor;
import com.googlecode.dex2jar.visitors.EmptyVisitor;
import java.util.HashMap;
import java.util.Map;

class V3ClassAdapter$1
  extends EmptyVisitor
{
  V3ClassAdapter$1(V3ClassAdapter paramV3ClassAdapter) {}
  
  public DexAnnotationVisitor visitAnnotation(String name, String desc)
  {
    new EmptyVisitor()
    {
      private void putDefault(String name, Object value)
      {
        if (this$0.annotationDefaults == null) {
          this$0.annotationDefaults = new HashMap();
        }
        this$0.annotationDefaults.put(name, value);
      }
      
      public void visit(String name, Object value)
      {
        putDefault(name, value);
      }
      
      public void visitEnum(String name, String desc, String value)
      {
        putDefault(name, new Field(desc, value, desc));
      }
    };
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.V3ClassAdapter.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Method;
import com.googlecode.dex2jar.ir.Constant;
import com.googlecode.dex2jar.ir.ET;
import com.googlecode.dex2jar.ir.IrMethod;
import com.googlecode.dex2jar.ir.Value;
import com.googlecode.dex2jar.ir.expr.Exprs;
import com.googlecode.dex2jar.ir.stmt.StmtList;
import com.googlecode.dex2jar.ir.stmt.Stmts;
import com.googlecode.dex2jar.reader.DexFileReader;
import com.googlecode.dex2jar.util.ASMifierCodeV;
import com.googlecode.dex2jar.util.Escape;
import com.googlecode.dex2jar.util.Out;
import com.googlecode.dex2jar.visitors.DexClassVisitor;
import com.googlecode.dex2jar.visitors.DexCodeVisitor;
import com.googlecode.dex2jar.visitors.DexMethodVisitor;
import com.googlecode.dex2jar.visitors.EmptyVisitor;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.FileUtils;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodNode;

public class DexExceptionHandlerImpl
  implements DexExceptionHandler
{
  private int readerConfig = 1;
  private Map<Method, Exception> exceptions = new HashMap();
  
  public Map<Method, Exception> getExceptions()
  {
    return exceptions;
  }
  
  public void handleFileException(Exception e)
  {
    e.printStackTrace(System.err);
  }
  
  public void handleMethodTranslateException(Method method, IrMethod irMethod, MethodNode methodNode, Exception e)
  {
    exceptions.put(method, e);
    
    StringWriter s = new StringWriter();
    e.printStackTrace(new PrintWriter(s));
    String msg = s.toString();
    instructions.clear();
    tryCatchBlocks.clear();
    traps.clear();
    stmts.clear();
    stmts.add(Stmts.nThrow(Exprs.nInvokeNew(new Value[] { Constant.nString("Generated by Dex2jar, and Some Exception Caught :" + msg) }, new Type[] { Type.getType(String.class) }, Type.getType(RuntimeException.class))));
    
    new IrMethod2AsmMethod().convert(irMethod, methodNode);
  }
  
  public static String getVersionString()
  {
    return "version: reader-" + DexFileReader.class.getPackage().getImplementationVersion() + ", translator-" + Main.class.getPackage().getImplementationVersion() + ", ir-" + ET.class.getPackage().getImplementationVersion();
  }
  
  public DexExceptionHandlerImpl skipDebug(boolean b)
  {
    if (b) {
      readerConfig |= 0x1;
    } else {
      readerConfig &= 0xFFFFFFFE;
    }
    return this;
  }
  
  public DexExceptionHandlerImpl skipDebug()
  {
    readerConfig |= 0x1;
    return this;
  }
  
  public void dumpException(DexFileReader reader, File errorFile)
    throws IOException
  {
    for (Map.Entry<Method, Exception> e : exceptions.entrySet()) {
      System.err.println("Error:" + ((Method)e.getKey()).toString() + "->" + ((Exception)e.getValue()).getMessage());
    }
    final ZipOutputStream errorZipOutputStream = new ZipOutputStream(FileUtils.openOutputStream(errorFile));
    errorZipOutputStream.putNextEntry(new ZipEntry("summary.txt"));
    final PrintWriter fw = new PrintWriter(new OutputStreamWriter(errorZipOutputStream, "UTF-8"));
    fw.println(getVersionString());
    fw.println("there are " + exceptions.size() + " error methods");
    fw.print("options: ");
    if ((readerConfig & 0x1) == 0) {
      fw.print(" -d");
    }
    fw.println();
    fw.flush();
    errorZipOutputStream.closeEntry();
    final Out out = new Out()
    {
      public void pop() {}
      
      public void push() {}
      
      public void s(String s)
      {
        fw.println(s);
      }
      
      public void s(String format, Object... arg)
      {
        fw.println(String.format(format, arg));
      }
    };
    final int[] count = { 0 };
    reader.accept(new EmptyVisitor()
    {
      public DexClassVisitor visit(int accessFlags, String className, String superClass, String[] interfaceNames)
      {
        new EmptyVisitor()
        {
          public DexMethodVisitor visitMethod(final int accessFlags, final Method method)
          {
            if (exceptions.containsKey(method)) {
              new EmptyVisitor()
              {
                public DexCodeVisitor visitCode()
                {
                  try
                  {
                    int tmp37_36 = 0; int[] tmp37_33 = val$count; int tmp39_38 = tmp37_33[tmp37_36];tmp37_33[tmp37_36] = (tmp39_38 + 1);val$errorZipOutputStream.putNextEntry(new ZipEntry("t" + tmp39_38 + ".txt"));
                  }
                  catch (IOException e)
                  {
                    throw new RuntimeException(e);
                  }
                  Exception exception = (Exception)exceptions.get(method);
                  exception.printStackTrace(val$fw);
                  val$out.s("");
                  val$out.s("DexMethodVisitor mv=cv.visitMethod(%s, %s);", new Object[] { Escape.methodAcc(accessFlags), Escape.v(method) });
                  
                  val$out.s("DexCodeVisitor code = mv.visitCode();");
                  return new ASMifierCodeV(val$out);
                }
                
                public void visitEnd()
                {
                  val$out.s("mv.visitEnd();");
                  val$fw.flush();
                  try
                  {
                    val$errorZipOutputStream.closeEntry();
                  }
                  catch (IOException e)
                  {
                    throw new RuntimeException(e);
                  }
                }
              };
            }
            return null;
          }
        };
      }
    }, readerConfig);
    
    errorZipOutputStream.close();
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.DexExceptionHandlerImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.ir.ts.LiveAnalyze.Phi;
import java.util.Comparator;
import java.util.Set;

class IrMethod2AsmMethod$1
  implements Comparator<LiveAnalyze.Phi>
{
  IrMethod2AsmMethod$1(IrMethod2AsmMethod paramIrMethod2AsmMethod) {}
  
  public int compare(LiveAnalyze.Phi o1, LiveAnalyze.Phi o2)
  {
    int r = sets.size() - sets.size();
    return r == 0 ? IrMethod2AsmMethod.access$000(o2) - IrMethod2AsmMethod.access$000(o1) : r;
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.IrMethod2AsmMethod.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import java.io.IOException;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;

class Dex2jar$1
  implements ClassVisitorFactory
{
  Dex2jar$1(Dex2jar paramDex2jar, Object paramObject) {}
  
  public ClassVisitor create(final String name)
  {
    new ClassWriter(1)
    {
      public void visitEnd()
      {
        super.visitEnd();
        try
        {
          byte[] data = toByteArray();
          Dex2jar.access$000(this$0, data, name, val$dist);
        }
        catch (IOException e)
        {
          e.printStackTrace(System.err);
        }
      }
    };
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.Dex2jar.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Annotation;
import com.googlecode.dex2jar.Annotation.Item;
import com.googlecode.dex2jar.Method;
import com.googlecode.dex2jar.visitors.DexAnnotationVisitor;
import com.googlecode.dex2jar.visitors.DexClassVisitor;
import com.googlecode.dex2jar.visitors.DexFileVisitor;
import com.googlecode.dex2jar.visitors.EmptyVisitor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.objectweb.asm.Type;

public class V3InnerClzGather
  implements DexFileVisitor
{
  public static class Clz
  {
    public int access;
    public Clz enclosingClass;
    public Method enclosingMethod;
    public String innerName;
    public Set<Clz> inners = null;
    public final String name;
    
    public Clz(String name)
    {
      this.name = name;
    }
    
    void addInner(Clz clz)
    {
      if (inners == null) {
        inners = new HashSet();
      }
      inners.add(clz);
    }
    
    public boolean equals(Object obj)
    {
      if (this == obj) {
        return true;
      }
      if (obj == null) {
        return false;
      }
      if (getClass() != obj.getClass()) {
        return false;
      }
      Clz other = (Clz)obj;
      if (name == null)
      {
        if (name != null) {
          return false;
        }
      }
      else if (!name.equals(name)) {
        return false;
      }
      return true;
    }
    
    public int hashCode()
    {
      int prime = 31;
      int result = 1;
      result = 31 * result + (name == null ? 0 : name.hashCode());
      return result;
    }
    
    public String toString()
    {
      return "" + name;
    }
  }
  
  private Map<String, Clz> classes = new HashMap();
  private static final int ACC_INTERFACE_ABSTRACT = 1536;
  
  private Clz get(String name)
  {
    Clz clz = (Clz)classes.get(name);
    if (clz == null)
    {
      clz = new Clz(name);
      classes.put(name, clz);
    }
    return clz;
  }
  
  public Map<String, Clz> getClasses()
  {
    return classes;
  }
  
  public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames)
  {
    final Clz clz = get(className);
    
    access = (access & 0xF9FF | access_flags);
    
    new EmptyVisitor()
    {
      protected List<Annotation> anns = new ArrayList();
      
      public DexAnnotationVisitor visitAnnotation(String name, boolean visible)
      {
        Annotation ann = new Annotation(name, visible);
        anns.add(ann);
        return new V3AnnAdapter(ann);
      }
      
      public void visitEnd()
      {
        for (Annotation ann : anns) {
          if (type.equals("Ldalvik/annotation/EnclosingClass;")) {
            for (Annotation.Item i : items) {
              if (name.equals("value"))
              {
                clzenclosingClass = V3InnerClzGather.this.get(value.toString());
                clzenclosingClass.addInner(clz);
              }
            }
          } else if (type.equals("Ldalvik/annotation/EnclosingMethod;")) {
            for (Annotation.Item i : items) {
              if ("value".equals(name))
              {
                Method m = (Method)value;
                if (m != null)
                {
                  clzenclosingMethod = m;
                  clzenclosingClass = V3InnerClzGather.this.get(clzenclosingMethod.getOwner());
                  clzenclosingClass.addInner(clz);
                }
              }
            }
          } else if ("Ldalvik/annotation/InnerClass;".equals(type)) {
            for (Annotation.Item it : items) {
              if ("accessFlags".equals(name)) {
                clzaccess |= ((Integer)value).intValue() & 0xF9FF;
              } else if ("name".equals(name)) {
                clzinnerName = ((String)value);
              }
            }
          } else if ("Ldalvik/annotation/MemberClasses;".equals(type)) {
            for (Annotation.Item it : items) {
              if ("value".equals(name))
              {
                Annotation v = (Annotation)value;
                for (Annotation.Item item : items)
                {
                  Type type = (Type)value;
                  V3InnerClzGather.Clz inner = V3InnerClzGather.this.get(type.getDescriptor());
                  clz.addInner(inner);
                  enclosingClass = clz;
                }
              }
            }
          }
        }
      }
    };
  }
  
  public void visitEnd() {}
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.V3InnerClzGather
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Annotation;
import com.googlecode.dex2jar.Annotation.Item;
import com.googlecode.dex2jar.Method;
import com.googlecode.dex2jar.visitors.DexAnnotationVisitor;
import com.googlecode.dex2jar.visitors.EmptyVisitor;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.Type;

class V3InnerClzGather$1
  extends EmptyVisitor
{
  protected List<Annotation> anns = new ArrayList();
  
  V3InnerClzGather$1(V3InnerClzGather paramV3InnerClzGather, V3InnerClzGather.Clz paramClz) {}
  
  public DexAnnotationVisitor visitAnnotation(String name, boolean visible)
  {
    Annotation ann = new Annotation(name, visible);
    anns.add(ann);
    return new V3AnnAdapter(ann);
  }
  
  public void visitEnd()
  {
    for (Annotation ann : anns) {
      if (type.equals("Ldalvik/annotation/EnclosingClass;")) {
        for (Annotation.Item i : items) {
          if (name.equals("value"))
          {
            val$clz.enclosingClass = V3InnerClzGather.access$000(this$0, value.toString());
            val$clz.enclosingClass.addInner(val$clz);
          }
        }
      } else if (type.equals("Ldalvik/annotation/EnclosingMethod;")) {
        for (Annotation.Item i : items) {
          if ("value".equals(name))
          {
            Method m = (Method)value;
            if (m != null)
            {
              val$clz.enclosingMethod = m;
              val$clz.enclosingClass = V3InnerClzGather.access$000(this$0, val$clz.enclosingMethod.getOwner());
              val$clz.enclosingClass.addInner(val$clz);
            }
          }
        }
      } else if ("Ldalvik/annotation/InnerClass;".equals(type)) {
        for (Annotation.Item it : items) {
          if ("accessFlags".equals(name)) {
            val$clz.access |= ((Integer)value).intValue() & 0xF9FF;
          } else if ("name".equals(name)) {
            val$clz.innerName = ((String)value);
          }
        }
      } else if ("Ldalvik/annotation/MemberClasses;".equals(type)) {
        for (Annotation.Item it : items) {
          if ("value".equals(name))
          {
            Annotation v = (Annotation)value;
            for (Annotation.Item item : items)
            {
              Type type = (Type)value;
              V3InnerClzGather.Clz inner = V3InnerClzGather.access$000(this$0, type.getDescriptor());
              val$clz.addInner(inner);
              enclosingClass = val$clz;
            }
          }
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.V3InnerClzGather.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Method;
import java.util.HashSet;
import java.util.Set;

public class V3InnerClzGather$Clz
{
  public int access;
  public Clz enclosingClass;
  public Method enclosingMethod;
  public String innerName;
  public Set<Clz> inners = null;
  public final String name;
  
  public V3InnerClzGather$Clz(String name)
  {
    this.name = name;
  }
  
  void addInner(Clz clz)
  {
    if (inners == null) {
      inners = new HashSet();
    }
    inners.add(clz);
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    Clz other = (Clz)obj;
    if (name == null)
    {
      if (name != null) {
        return false;
      }
    }
    else if (!name.equals(name)) {
      return false;
    }
    return true;
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = 1;
    result = 31 * result + (name == null ? 0 : name.hashCode());
    return result;
  }
  
  public String toString()
  {
    return "" + name;
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.V3InnerClzGather.Clz
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.Method;
import com.googlecode.dex2jar.util.ASMifierCodeV;
import com.googlecode.dex2jar.util.Escape;
import com.googlecode.dex2jar.util.Out;
import com.googlecode.dex2jar.visitors.DexCodeVisitor;
import com.googlecode.dex2jar.visitors.DexMethodVisitor;
import com.googlecode.dex2jar.visitors.EmptyVisitor;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

class DexExceptionHandlerImpl$2$1
  extends EmptyVisitor
{
  DexExceptionHandlerImpl$2$1(DexExceptionHandlerImpl.2 param2) {}
  
  public DexMethodVisitor visitMethod(final int accessFlags, final Method method)
  {
    if (DexExceptionHandlerImpl.access$000(this$1.this$0).containsKey(method)) {
      new EmptyVisitor()
      {
        public DexCodeVisitor visitCode()
        {
          try
          {
            int tmp37_36 = 0; int[] tmp37_33 = this$1.val$count; int tmp39_38 = tmp37_33[tmp37_36];tmp37_33[tmp37_36] = (tmp39_38 + 1);this$1.val$errorZipOutputStream.putNextEntry(new ZipEntry("t" + tmp39_38 + ".txt"));
          }
          catch (IOException e)
          {
            throw new RuntimeException(e);
          }
          Exception exception = (Exception)DexExceptionHandlerImpl.access$000(this$1.this$0).get(method);
          exception.printStackTrace(this$1.val$fw);
          this$1.val$out.s("");
          this$1.val$out.s("DexMethodVisitor mv=cv.visitMethod(%s, %s);", new Object[] { Escape.methodAcc(accessFlags), Escape.v(method) });
          
          this$1.val$out.s("DexCodeVisitor code = mv.visitCode();");
          return new ASMifierCodeV(this$1.val$out);
        }
        
        public void visitEnd()
        {
          this$1.val$out.s("mv.visitEnd();");
          this$1.val$fw.flush();
          try
          {
            this$1.val$errorZipOutputStream.closeEntry();
          }
          catch (IOException e)
          {
            throw new RuntimeException(e);
          }
        }
      };
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.DexExceptionHandlerImpl.2.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.DexType;
import com.googlecode.dex2jar.Field;
import com.googlecode.dex2jar.Method;
import java.util.Map;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.MethodNode;

class V3ClassAdapter$2
  extends V3MethodAdapter
{
  V3ClassAdapter$2(V3ClassAdapter paramV3ClassAdapter, int x0, Method x1, DexExceptionHandler x2, int x3)
  {
    super(x0, x1, x2, x3);
  }
  
  public void visitEnd()
  {
    super.visitEnd();
    if (this$0.annotationDefaults != null)
    {
      Object value = this$0.annotationDefaults.get(method.getName());
      if (value != null)
      {
        AnnotationVisitor av = methodNode.visitAnnotationDefault();
        if (av != null)
        {
          if ((value instanceof Field))
          {
            Field field = (Field)value;
            av.visitEnum(null, field.getOwner(), field.getName());
          }
          else
          {
            if ((value instanceof DexType)) {
              value = Type.getType(desc);
            }
            av.visit(null, value);
          }
          av.visitEnd();
        }
      }
    }
    methodNode.accept(this$0.cv);
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.V3ClassAdapter.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import java.io.IOException;
import org.objectweb.asm.ClassWriter;

class Dex2jar$1$1
  extends ClassWriter
{
  Dex2jar$1$1(Dex2jar.1 param1, int x0, String paramString)
  {
    super(x0);
  }
  
  public void visitEnd()
  {
    super.visitEnd();
    try
    {
      byte[] data = toByteArray();
      Dex2jar.access$000(this$1.this$0, data, val$name, this$1.val$dist);
    }
    catch (IOException e)
    {
      e.printStackTrace(System.err);
    }
  }
}

/* Location:
 * Qualified Name:     com.googlecode.dex2jar.v3.Dex2jar.1.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.googlecode.dex2jar.v3;

import com.googlecode.dex2jar.DexException;
import com.googlecode.dex2jar.ir.Constant;
import com.googlecode.dex2jar.ir.IrMethod;
import com.googlecode.dex2jar.ir.Local;
import com.googlecode.dex2jar.ir.LocalVar;
import com.googlecode.dex2jar.ir.Trap;
import com.googlecode.dex2jar.ir.Value;
import com.googlecode.dex2jar.ir.Value.E1Expr;
import com.googlecode.dex2jar.ir.Value.E2Expr;
import com.googlecode.dex2jar.ir.Value.EnExpr;
import com.googlecode.dex2jar.ir.Value.VT;
import com.googlecode.dex2jar.ir.ValueBox;
import com.googlecode.dex2jar.ir.expr.ArrayExpr;
import com.googlecode.dex2jar.ir.expr.CastExpr;
import com.googlecode.dex2jar.ir.expr.Exprs;
import com.googlecode.dex2jar.ir.expr.FieldExpr;
import com.googlecode.dex2jar.ir.expr.FilledArrayExpr;
import com.googlecode.dex2jar.ir.expr.InvokeExpr;
import com.googlecode.dex2jar.ir.expr.NewExpr;
import com.googlecode.dex2jar.ir.expr.NewMutiArrayExpr;
import com.googlecode.dex2jar.ir.expr.RefExpr;
import com.googlecode.dex2jar.ir.expr.TypeExpr;
import com.googlecode.dex2jar.ir.stmt.AssignStmt;
import com.googlecode.dex2jar.ir.stmt.JumpStmt;
import com.googlecode.dex2jar.ir.stmt.LabelStmt;
import com.googlecode.dex2jar.ir.stmt.LookupSwitchStmt;
import com.googlecode.dex2jar.ir.stmt.Stmt;
import com.googlecode.dex2jar.ir.stmt.Stmt.E2Stmt;
import com.googlecode.dex2jar.ir.stmt.Stmt.ST;
import com.googlecode.dex2jar.ir.stmt.StmtList;
import com.googlecode.dex2jar.ir.stmt.TableSwitchStmt;
import com.googlecode.dex2jar.ir.stmt.UnopStmt;
import com.googlecode.dex2jar.ir.ts.Cfg;
import com.googlecode.dex2jar.ir.ts.Cfg.StmtVisitor;
import com.googlecode.dex2jar.ir.ts.LiveAnalyze;
import com.googlecode.dex2jar.ir.ts.LiveAnalyze.Phi;
import com.googlecode.dex2jar.ir.ts.LocalType;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

public class IrMethod2AsmMethod
  implements Opcodes
{
  private boolean reuseReg = false;
  private boolean optimizeSynchronized = false;
  
  public IrMethod2AsmMethod() {}
  
  /**
   * @deprecated
   */
  public IrMethod2AsmMethod(boolean reuseReg)
  {
    this.reuseReg = reuseReg;
  }
  
  public IrMethod2AsmMethod(int config)
  {
    reuseReg = (0 != (config & 0x1));
    optimizeSynchronized = (0 != (config & 0x8));
  }
  
  private void reIndexLocalReuseReg(IrMethod ir)
  {
    LiveAnalyze la = new LiveAnalyze(ir);
    List<LiveAnalyze.Phi> phis = la.analyze();
    
    int index = 0;
    if ((access & 0x8) == 0) {
      index++;
    }
    int localSize = locals.size();
    int[] parameterIdx = new int[args.length];
    for (int i = 0; i < args.length; i++)
    {
      parameterIdx[i] = index;
      index += args[i].getSize();
    }
    int[] maps = new int[localSize];
    for (int i = 0; i < localSize; i++) {
      maps[i] = -1;
    }
    Local _thisLocal = null;
    Local[] _parameterLocals = new Local[args.length];
    for (Stmt stmt = stmts.getFirst(); stmt != null; stmt = stmt.getNext()) {
      if ((st == Stmt.ST.IDENTITY) || (st == Stmt.ST.ASSIGN))
      {
        Stmt.E2Stmt e2 = (Stmt.E2Stmt)stmt;
        switch (op2.value.vt)
        {
        case THIS_REF: 
          Local local = (Local)op1.value;
          maps[_ls_index] = 0;
          _thisLocal = local;
          
          break;
        case PARAMETER_REF: 
          Local local = (Local)op1.value;
          int i = op2.value).parameterIndex;
          maps[_ls_index] = parameterIdx[i];
          _parameterLocals[i] = local;
        }
      }
    }
    createGraph(ir, phis.size());
    if (((access & 0x8) == 0) && (_thisLocal != null)) {
      markPhiNeverReuse(phis, _thisLocal);
    }
    for (Local local : _parameterLocals) {
      if (local != null) {
        markPhiNeverReuse(phis, local);
      }
    }
    gradyColoring(phis, maps);
    for (Local local : locals) {
      _ls_index = maps[_ls_index];
    }
  }
  
  private void markPhiNeverReuse(List<LiveAnalyze.Phi> phis, Local local)
  {
    LiveAnalyze.Phi nPhi = null;
    for (LiveAnalyze.Phi phi : phis) {
      if (local == local)
      {
        nPhi = phi;
        break;
      }
    }
    if (nPhi == null)
    {
      nPhi = new LiveAnalyze.Phi();
      local = local;
    }
    for (LiveAnalyze.Phi phi : phis) {
      if (phi != nPhi)
      {
        sets.add(nPhi);
        sets.add(phi);
      }
    }
  }
  
  private int findNextColor(LiveAnalyze.Phi v, int n, int max, int[] maps)
  {
    BitSet bs = new BitSet(max);
    bs.set(0, max);
    for (LiveAnalyze.Phi one : sets)
    {
      int x = maps[local._ls_index];
      if (x >= 0)
      {
        bs.clear(x);
        if (sizeOf(one) > 1) {
          bs.clear(x + 1);
        }
      }
    }
    boolean wide = sizeOf(v) > 1;
    for (int i = bs.nextSetBit(n); i >= 0; i = bs.nextSetBit(i + 1)) {
      if (wide)
      {
        if ((i + 1 < bs.length()) && (bs.get(i + 1))) {
          return i;
        }
      }
      else {
        return i;
      }
    }
    return -1;
  }
  
  private void gradyColoring(List<LiveAnalyze.Phi> phis, int[] maps)
  {
    if (phis.size() <= 0) {
      return;
    }
    Collections.sort(phis, new Comparator()
    {
      public int compare(LiveAnalyze.Phi o1, LiveAnalyze.Phi o2)
      {
        int r = sets.size() - sets.size();
        return r == 0 ? IrMethod2AsmMethod.sizeOf(o2) - IrMethod2AsmMethod.sizeOf(o1) : r;
      }
    });
    LiveAnalyze.Phi first = (LiveAnalyze.Phi)phis.get(0);
    int size = sizeOf(first);
    for (LiveAnalyze.Phi p : sets) {
      size += sizeOf(p);
    }
    BitSet toColor = new BitSet(phis.size());
    for (int i = 0; i < phis.size(); i++)
    {
      LiveAnalyze.Phi p = (LiveAnalyze.Phi)phis.get(i);
      if (maps[local._ls_index] < 0) {
        toColor.set(i);
      }
    }
    while (!doColor(0, toColor, phis, size, maps)) {
      size++;
    }
  }
  
  private boolean doColor(int idx, BitSet toColor, List<LiveAnalyze.Phi> phis, int size, int[] maps)
  {
    int x = toColor.nextSetBit(idx);
    if (x < 0) {
      return true;
    }
    LiveAnalyze.Phi phi = (LiveAnalyze.Phi)phis.get(x);
    for (int i = findNextColor(phi, 0, size, maps); i >= 0; i = findNextColor(phi, i + 1, size, maps))
    {
      maps[local._ls_index] = i;
      if (doColor(x + 1, toColor, phis, size, maps)) {
        return true;
      }
      maps[local._ls_index] = -1;
    }
    return false;
  }
  
  private static int sizeOf(LiveAnalyze.Phi p)
  {
    return LocalType.typeOf(local).getSize();
  }
  
  private void createGraph(IrMethod ir, int localSize)
  {
    List<LiveAnalyze.Phi> tmp = new ArrayList(localSize);
    for (Stmt p = stmts.getFirst(); p != null; p = p.getNext())
    {
      tmp.clear();
      
      LiveAnalyze.Phi[] frame = (LiveAnalyze.Phi[])_ls_forward_frame;
      _ls_forward_frame = null;
      if (frame != null) {
        for (LiveAnalyze.Phi r : frame) {
          if (r != null) {
            tmp.add(r);
          }
        }
      }
      for (int i = 0; i < tmp.size() - 1; i++)
      {
        LiveAnalyze.Phi a = (LiveAnalyze.Phi)tmp.get(i);
        for (int j = i + 1; j < tmp.size(); j++)
        {
          LiveAnalyze.Phi b = (LiveAnalyze.Phi)tmp.get(j);
          if (a != b)
          {
            sets.add(b);
            sets.add(a);
          }
        }
      }
    }
  }
  
  private void reIndexLocal(IrMethod ir)
  {
    if (reuseReg) {
      reIndexLocalReuseReg(ir);
    } else {
      reIndexLocalDirect(ir);
    }
  }
  
  private void reIndexLocalDirect(IrMethod ir)
  {
    int index = 0;
    if ((access & 0x8) == 0) {
      index++;
    }
    final int[] ids = new int[args.length];
    for (int i = 0; i < args.length; i++)
    {
      ids[i] = index;
      index += args[i].getSize();
    }
    for (Local local : locals) {
      _ls_index = -1;
    }
    final int[] indexHolder = { index };
    Cfg.createCFG(ir);
    Cfg.Forward(ir, new Cfg.StmtVisitor()
    {
      public Object exec(Stmt stmt)
      {
        switch (IrMethod2AsmMethod.4.$SwitchMap$com$googlecode$dex2jar$ir$stmt$Stmt$ST[st.ordinal()])
        {
        case 1: 
        case 2: 
          if (op1.value.vt == Value.VT.LOCAL)
          {
            Local local = (Local)op1.value;
            if (_ls_index == -1)
            {
              Type localType = LocalType.typeOf(local);
              if (!Type.VOID_TYPE.equals(localType))
              {
                Value ref = op2.value;
                switch (IrMethod2AsmMethod.4.$SwitchMap$com$googlecode$dex2jar$ir$Value$VT[vt.ordinal()])
                {
                case 1: 
                  _ls_index = 0;
                  break;
                case 2: 
                  _ls_index = ids[parameterIndex];
                  break;
                case 3: 
                  int tmp178_177 = 0; int[] tmp178_174 = indexHolder; int tmp180_179 = tmp178_174[tmp178_177];tmp178_174[tmp178_177] = (tmp180_179 + 1);_ls_index = tmp180_179;
                  break;
                default: 
                  _ls_index = indexHolder[0];
                  indexHolder[0] += LocalType.typeOf(ref).getSize();
                }
              }
            }
          }
          break;
        }
        return null;
      }
    });
  }
  
  public void convert(IrMethod ir, MethodVisitor asm)
  {
    reIndexLocal(ir);
    reIndexStmts(ir);
    reBuildInstructions(ir, asm);
    reBuildTryCatchBlocks(ir, asm);
    reBuildLocalVar(ir, asm);
  }
  
  private void reBuildTryCatchBlocks(IrMethod ir, MethodVisitor asm)
  {
    for (Trap trap : traps)
    {
      boolean needAdd = false;
      for (Stmt p = start.getNext(); (p != null) && (p != end); p = p.getNext()) {
        if (st != Stmt.ST.LABEL)
        {
          needAdd = true;
          break;
        }
      }
      if (needAdd) {
        asm.visitTryCatchBlock(start.label, end.label, handler.label, type == null ? null : type.getInternalName());
      }
    }
  }
  
  private void reIndexStmts(IrMethod ir)
  {
    int count = 0;
    for (Stmt st : stmts)
    {
      id = count;
      count++;
    }
  }
  
  private void reBuildInstructions(IrMethod ir, MethodVisitor asm)
  {
    Map<String, Integer> lockMap = new HashMap();
    int maxLocalIndex;
    int maxLocalIndex;
    if (locals.size() == 0)
    {
      maxLocalIndex = 0;
    }
    else
    {
      Local maxLoale = (Local)Collections.max(locals, new Comparator()
      {
        public int compare(Local o1, Local o2)
        {
          int i = _ls_index - _ls_index;
          if (i != 0) {
            return i;
          }
          Type t1 = LocalType.typeOf(o1);
          if (t1 == null) {
            return -1;
          }
          Type t2 = LocalType.typeOf(o2);
          if (t2 == null) {
            return 1;
          }
          return t1.getSize() - t2.getSize();
        }
      });
      int maxLocalIndex;
      if ((maxLoale == null) || (_ls_index < 0)) {
        maxLocalIndex = 0;
      } else {
        maxLocalIndex = _ls_index + LocalType.typeOf(maxLoale).getSize() - 1;
      }
    }
    for (Stmt st : stmts) {
      switch (st)
      {
      case LABEL: 
        LabelStmt labelStmt = (LabelStmt)st;
        asm.visitLabel(label);
        if (lineNumber >= 0) {
          asm.visitLineNumber(lineNumber, label);
        }
        break;
      case ASSIGN: 
        Stmt.E2Stmt e2 = (Stmt.E2Stmt)st;
        Value v1 = op1.value;
        Value v2 = op2.value;
        switch (vt)
        {
        case LOCAL: 
          Local local = (Local)v1;
          int i = _ls_index;
          
          boolean skipOrg = false;
          if (LocalType.typeOf(v1).equals(Type.INT_TYPE)) {
            if (vt == Value.VT.ADD)
            {
              Value.E2Expr e = (Value.E2Expr)v2;
              if (((op1.value == local) && (op2.value.vt == Value.VT.CONSTANT)) || ((op2.value == local) && (op1.value.vt == Value.VT.CONSTANT)))
              {
                int increment = ((Integer)op1.value == local ? op2.value : op1.value)).value).intValue();
                asm.visitIincInsn(i, increment);
                skipOrg = true;
              }
            }
            else if (vt == Value.VT.SUB)
            {
              Value.E2Expr e = (Value.E2Expr)v2;
     
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd