public DecompilerContext(Dictionary <string, object> properties, IFernflowerLogger logger, StructContext structContext, ClassesProcessor classProcessor, PoolInterceptor interceptor) { this.properties = properties; this.logger = logger; this.structContext = structContext; this.classProcessor = classProcessor; this.poolInterceptor = interceptor; this.counterContainer = new CounterContainer(); }
public Fernflower(IIBytecodeProvider provider, IIResultSaver saver, Dictionary <string , object> customProperties, IFernflowerLogger logger) { Dictionary <string, object> properties = new Dictionary <string, object>(IFernflowerPreferences.Defaults); if (customProperties != null) { Sharpen.Collections.PutAll(properties, customProperties); } string level = (string)properties.GetOrNull(IFernflowerPreferences.Log_Level); if (level != null) { try { logger.SetSeverity(IFernflowerLogger.Severity.ValueOf(level.ToUpper())); } catch (ArgumentException) { } } structContext = new StructContext(saver, this, new LazyLoader(provider)); classProcessor = new ClassesProcessor(structContext); PoolInterceptor interceptor = null; if ("1".Equals(properties.GetOrNull(IFernflowerPreferences.Rename_Entities))) { helper = LoadHelper((string)properties.GetOrNull(IFernflowerPreferences.User_Renamer_Class ), logger); interceptor = new PoolInterceptor(); converter = new IdentifierConverter(structContext, helper, interceptor); } else { helper = null; converter = null; } DecompilerContext context = new DecompilerContext(properties, logger, structContext , classProcessor, interceptor); DecompilerContext.SetCurrentContext(context); }
/// <exception cref="IOException"/> public ConstantPool(DataInputStream @in) { int size = @in.ReadUnsignedShort(); pool = new List <PooledConstant>(size); BitSet[] nextPass = new BitSet[] { new BitSet(size), new BitSet(size), new BitSet (size) }; // first dummy constant pool.Add(null); // first pass: read the elements for (int i = 1; i < size; i++) { byte tag = unchecked ((byte)@in.ReadUnsignedByte()); switch (tag) { case ICodeConstants.CONSTANT_Utf8: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Utf8, @in.ReadUTF())); break; } case ICodeConstants.CONSTANT_Integer: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Integer, (@in.ReadInt ()))); break; } case ICodeConstants.CONSTANT_Float: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Float, @in.ReadFloat())); break; } case ICodeConstants.CONSTANT_Long: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Long, @in.ReadLong())); pool.Add(null); i++; break; } case ICodeConstants.CONSTANT_Double: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Double, @in.ReadDouble())); pool.Add(null); i++; break; } case ICodeConstants.CONSTANT_Class: case ICodeConstants.CONSTANT_String: case ICodeConstants.CONSTANT_MethodType: { pool.Add(new PrimitiveConstant(tag, @in.ReadUnsignedShort())); nextPass[0].Set(i); break; } case ICodeConstants.CONSTANT_NameAndType: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedShort(), @in.ReadUnsignedShort())); nextPass[0].Set(i); break; } case ICodeConstants.CONSTANT_Fieldref: case ICodeConstants.CONSTANT_Methodref: case ICodeConstants.CONSTANT_InterfaceMethodref: case ICodeConstants.CONSTANT_InvokeDynamic: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedShort(), @in.ReadUnsignedShort())); nextPass[1].Set(i); break; } case ICodeConstants.CONSTANT_MethodHandle: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedByte(), @in.ReadUnsignedShort())); nextPass[2].Set(i); break; } } } // resolving complex pool elements foreach (BitSet pass in nextPass) { int idx = 0; while ((idx = pass.NextSetBit(idx + 1)) > 0) { pool[idx].ResolveConstant(this); } } // get global constant pool interceptor instance, if any available interceptor = DecompilerContext.GetPoolInterceptor(); }