Package cuchaz.enigma.mapping

Examples of cuchaz.enigma.mapping.ClassEntry


    Map<ClassEntry,ClassEntry> map = Maps.newHashMap();
    for( ClassEntry classEntry : ClassRenamer.getAllClassEntries( c ) )
    {
      if( classEntry.isInDefaultPackage() )
      {
        map.put( classEntry, new ClassEntry( newPackageName + "/" + classEntry.getName() ) );
      }
    }
    ClassRenamer.renameClasses( c, map );
   
    // TEMP
    for( ClassEntry classEntry : ClassRenamer.getAllClassEntries( c ) )
    {
      if( classEntry.isInDefaultPackage() )
      {
        throw new Error( "!!! " + classEntry );
      }
    }
   
    // TEMP
    for( CtBehavior behavior : c.getDeclaredBehaviors() )
    {
      if( behavior.getSignature() == null )
      {
        continue;
      }
     
      SignatureUpdater.update( behavior.getSignature(), new ClassNameUpdater( )
      {
        @Override
        public String update( String className )
        {
          ClassEntry classEntry = new ClassEntry( className );
          if( classEntry.isInDefaultPackage() )
          {
            throw new Error( "!!! " + className );
          }
          return className;
        }
View Full Code Here


  }
 
  public void writeMethodArguments( CtClass c )
  {
    // Procyon will read method arguments from the "MethodParameters" attribute, so write those
    ClassEntry classEntry = new ClassEntry( Descriptor.toJvmName( c.getName() ) );
    for( CtBehavior behavior : c.getDeclaredBehaviors() )
    {
      int numParams = Descriptor.numOfParameters( behavior.getMethodInfo().getDescriptor() );
      if( numParams <= 0 )
      {
View Full Code Here

      {
        case ConstPool.CONST_Fieldref:
        {
          // translate the name
          FieldEntry entry = new FieldEntry(
            new ClassEntry( Descriptor.toJvmName( constants.getFieldrefClassName( i ) ) ),
            constants.getFieldrefName( i )
          );
          FieldEntry translatedEntry = m_translator.translateEntry( entry );
         
          // translate the type
          String type = constants.getFieldrefType( i );
          String translatedType = m_translator.translateSignature( type );
         
          if( !entry.equals( translatedEntry ) || !type.equals( translatedType ) )
          {
            editor.changeMemberrefNameAndType( i, translatedEntry.getName(), translatedType );
          }
        }
        break;
       
        case ConstPool.CONST_Methodref:
        case ConstPool.CONST_InterfaceMethodref:
        {
          // translate the name and type
          BehaviorEntry entry = BehaviorEntryFactory.create(
            Descriptor.toJvmName( editor.getMemberrefClassname( i ) ),
            editor.getMemberrefName( i ),
            editor.getMemberrefType( i )
          );
          BehaviorEntry translatedEntry = m_translator.translateEntry( entry );
         
          if( !entry.getName().equals( translatedEntry.getName() ) || !entry.getSignature().equals( translatedEntry.getSignature() ) )
          {
            editor.changeMemberrefNameAndType( i, translatedEntry.getName(), translatedEntry.getSignature() );
          }
        }
        break;
      }
    }
   
    ClassEntry classEntry = new ClassEntry( Descriptor.toJvmName( c.getName() ) );
   
    // translate all the fields
    for( CtField field : c.getDeclaredFields() )
    {
      // translate the name
      FieldEntry entry = new FieldEntry( classEntry, field.getName() );
      String translatedName = m_translator.translate( entry );
      if( translatedName != null )
      {
        field.setName( translatedName );
      }
     
      // translate the type
      String translatedType = m_translator.translateSignature( field.getFieldInfo().getDescriptor() );
      field.getFieldInfo().setDescriptor( translatedType );
    }
   
    // translate all the methods and constructors
    for( CtBehavior behavior : c.getDeclaredBehaviors() )
    {
      if( behavior instanceof CtMethod )
      {
        CtMethod method = (CtMethod)behavior;
       
        // translate the name
        MethodEntry entry = new MethodEntry( classEntry, method.getName(), method.getSignature() );
        String translatedName = m_translator.translate( entry );
        if( translatedName != null )
        {
          method.setName( translatedName );
        }
      }

      // translate the type
      String translatedSignature = m_translator.translateSignature( behavior.getMethodInfo().getDescriptor() );
      behavior.getMethodInfo().setDescriptor( translatedSignature );
    }
   
    // translate all the class names referenced in the code
    // the above code only changed method/field/reference names and types, but not the class names themselves
    Map<ClassEntry,ClassEntry> map = Maps.newHashMap();
    for( ClassEntry obfClassEntry : ClassRenamer.getAllClassEntries( c ) )
    {
      ClassEntry deobfClassEntry = m_translator.translateEntry( obfClassEntry );
      if( !obfClassEntry.equals( deobfClassEntry ) )
      {
        map.put( obfClassEntry, deobfClassEntry );
      }
    }
View Full Code Here

TOP

Related Classes of cuchaz.enigma.mapping.ClassEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.