Пример #1
0
 private void AppendDefinitionType(TextBuffer buffer)
 {
     if (DecompilerContext.GetOption(IFernflowerPreferences.Use_Debug_Var_Names))
     {
         MethodWrapper method = (MethodWrapper)DecompilerContext.GetProperty(DecompilerContext
                                                                             .Current_Method_Wrapper);
         if (method != null)
         {
             int?originalIndex = null;
             if (processor != null)
             {
                 originalIndex = processor.GetVarOriginalIndex(index);
             }
             if (originalIndex != null)
             {
                 // first try from signature
                 if (DecompilerContext.GetOption(IFernflowerPreferences.Decompile_Generic_Signatures
                                                 ))
                 {
                     StructLocalVariableTypeTableAttribute attr = method.methodStruct.GetAttribute(StructGeneralAttribute
                                                                                                   .Attribute_Local_Variable_Type_Table);
                     if (attr != null)
                     {
                         string signature = attr.GetSignature(originalIndex, visibleOffset);
                         if (signature != null)
                         {
                             GenericFieldDescriptor descriptor = GenericMain.ParseFieldSignature(signature);
                             if (descriptor != null)
                             {
                                 buffer.Append(GenericMain.GetGenericCastTypeName(descriptor.type));
                                 return;
                             }
                         }
                     }
                 }
                 // then try from descriptor
                 StructLocalVariableTableAttribute attr_1 = method.methodStruct.GetLocalVariableAttr
                                                                ();
                 if (attr_1 != null)
                 {
                     string descriptor = attr_1.GetDescriptor(originalIndex, visibleOffset);
                     if (descriptor != null)
                     {
                         buffer.Append(ExprProcessor.GetCastTypeName(new VarType(descriptor)));
                         return;
                     }
                 }
             }
         }
     }
     buffer.Append(ExprProcessor.GetCastTypeName(GetVarType()));
 }
Пример #2
0
        /// <exception cref="System.IO.IOException"/>
        protected internal virtual Dictionary <string, StructGeneralAttribute> ReadAttributes
            (DataInputFullStream @in, ConstantPool pool)
        {
            int length = @in.ReadUnsignedShort();
            Dictionary <string, StructGeneralAttribute> attributes = new Dictionary <string, StructGeneralAttribute
                                                                                     >(length);

            for (int i = 0; i < length; i++)
            {
                int    nameIndex = @in.ReadUnsignedShort();
                string name      = pool.GetPrimitiveConstant(nameIndex).GetString();
                StructGeneralAttribute attribute = ReadAttribute(@in, pool, name);
                if (attribute != null)
                {
                    if (StructGeneralAttribute.Attribute_Local_Variable_Table.GetName().Equals(name) &&
                        attributes.ContainsKey(name))
                    {
                        // merge all variable tables
                        StructLocalVariableTableAttribute table = (StructLocalVariableTableAttribute)attributes
                                                                  .GetOrNull(name);
                        table.Add((StructLocalVariableTableAttribute)attribute);
                    }
                    else if (StructGeneralAttribute.Attribute_Local_Variable_Type_Table.GetName().Equals
                                 (name) && attributes.ContainsKey(name))
                    {
                        // merge all variable tables
                        StructLocalVariableTypeTableAttribute table = (StructLocalVariableTypeTableAttribute
                                                                       )attributes.GetOrNull(name);
                        table.Add((StructLocalVariableTypeTableAttribute)attribute);
                    }
                    else
                    {
                        Sharpen.Collections.Put(attributes, attribute.GetName(), attribute);
                    }
                }
            }
            return(attributes);
        }