You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
4
external/ikdasm/Program.cs
vendored
4
external/ikdasm/Program.cs
vendored
@@ -49,6 +49,8 @@ namespace Ildasm
|
||||
{ "assembly", v =>tableToDump = MetadataTableIndex.Assembly },
|
||||
{ "assemblyref", v =>tableToDump = MetadataTableIndex.AssemblyRef },
|
||||
{ "moduleref", v =>tableToDump = MetadataTableIndex.ModuleRef },
|
||||
{ "exported", v =>tableToDump = MetadataTableIndex.ExportedType },
|
||||
{ "customattr", v =>tableToDump = MetadataTableIndex.CustomAttribute },
|
||||
};
|
||||
args = p.Parse (args).ToArray ();
|
||||
if (printUsage) {
|
||||
@@ -200,6 +202,8 @@ namespace Ildasm
|
||||
Console.WriteLine (" -assembly Dumps the contents of the Assembly table");
|
||||
Console.WriteLine (" -assemblyref Dumps the contents of the AssemblyRef table");
|
||||
Console.WriteLine (" -moduleref Dumps the contents of the ModuleRef table");
|
||||
Console.WriteLine (" -exported Dumps the contents of the ExportedType table");
|
||||
Console.WriteLine (" -customattr Dumps the contents of the CustomAttribute table");
|
||||
} else {
|
||||
Console.WriteLine(" /OUT=<file name> Direct output to file rather than to stdout.");
|
||||
Console.WriteLine(" /COMPAT=<version> Match ildasm behavior. (<version> = 2.0 | 4.0 | 4.5)");
|
||||
|
||||
120
external/ikdasm/TableDumper.cs
vendored
120
external/ikdasm/TableDumper.cs
vendored
@@ -27,13 +27,16 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using IKVM.Reflection;
|
||||
using IKVM.Reflection.Metadata;
|
||||
|
||||
namespace Ildasm
|
||||
{
|
||||
enum MetadataTableIndex {
|
||||
CustomAttribute = 0xc,
|
||||
ModuleRef = 0x1a,
|
||||
Assembly = 0x20,
|
||||
AssemblyRef = 0x23,
|
||||
ExportedType = 0x27,
|
||||
}
|
||||
|
||||
class TableDumper
|
||||
@@ -70,6 +73,12 @@ namespace Ildasm
|
||||
case MetadataTableIndex.ModuleRef:
|
||||
DumpModuleRefTable (w);
|
||||
break;
|
||||
case MetadataTableIndex.ExportedType:
|
||||
DumpExportedTypeTable (w);
|
||||
break;
|
||||
case MetadataTableIndex.CustomAttribute:
|
||||
DumpCustomAttributeTable (w);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
@@ -138,5 +147,116 @@ namespace Ildasm
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
|
||||
string GetManifestImpl (int idx) {
|
||||
if (idx == 0)
|
||||
return "current module";
|
||||
uint table = (uint)idx >> 24;
|
||||
uint row = (uint)idx & 0xffffff;
|
||||
switch (table) {
|
||||
case FileTable.Index:
|
||||
return "file " + row;
|
||||
case (uint)AssemblyRefTable.Index:
|
||||
return "assemblyref " + row;
|
||||
case (uint)ExportedTypeTable.Index:
|
||||
return "exportedtype " + row;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void DumpExportedTypeTable (TextWriter w) {
|
||||
var t = module.ExportedType;
|
||||
w.WriteLine ("ExportedType Table (1.." + t.RowCount + ")");
|
||||
int rowIndex = 1;
|
||||
foreach (var r in t.records) {
|
||||
string name = module.GetString (r.TypeName);
|
||||
string nspace = module.GetString (r.TypeNamespace);
|
||||
w.WriteLine (String.Format ("{0}: {1}{2}{3} is in {4}, index={5:x}, flags=0x{6:x}", rowIndex, nspace, nspace != "" ? "." : "", name, GetManifestImpl (r.Implementation), r.TypeDefId, r.Flags));
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
|
||||
string StringifyCattrValue (object val) {
|
||||
if (val.GetType () == typeof (string))
|
||||
return String.Format ("\"{0}\"", val);
|
||||
else if (val == null)
|
||||
return "null";
|
||||
else
|
||||
return val.ToString ();
|
||||
}
|
||||
|
||||
void DumpCustomAttributeTable (TextWriter w) {
|
||||
var t = module.CustomAttribute;
|
||||
w.WriteLine ("CustomAttribute Table (1.." + t.RowCount + ")");
|
||||
int rowIndex = 1;
|
||||
foreach (var r in t.records) {
|
||||
}
|
||||
|
||||
Dictionary<int, string> table_names = new Dictionary<int, string> () {
|
||||
{ MethodDefTable.Index, "MethodDef" },
|
||||
{ FieldTable.Index, "FieldDef" },
|
||||
{ TypeRefTable.Index, "TypeRef" },
|
||||
{ TypeDefTable.Index, "TypeDef" },
|
||||
{ ParamTable.Index, "Param" },
|
||||
{ InterfaceImplTable.Index, "InterfaceImpl" },
|
||||
{ MemberRefTable.Index, "MemberRef" },
|
||||
{ AssemblyTable.Index, "Assembly" },
|
||||
{ ModuleTable.Index, "Module" },
|
||||
{ PropertyTable.Index, "Property" },
|
||||
{ EventTable.Index, "Event" },
|
||||
{ StandAloneSigTable.Index, "StandAloneSignature" },
|
||||
{ ModuleRefTable.Index, "ModuleRef" },
|
||||
{ TypeSpecTable.Index, "TypeSpec" },
|
||||
{ AssemblyRefTable.Index, "AssemblyRef" },
|
||||
{ FileTable.Index, "File" },
|
||||
{ ExportedTypeTable.Index, "ExportedType" },
|
||||
{ ManifestResourceTable.Index, "Manifest" },
|
||||
{ GenericParamTable.Index, "GenericParam" }
|
||||
};
|
||||
|
||||
foreach (var cattr in module.__EnumerateCustomAttributeTable ()) {
|
||||
//Console.WriteLine (cattr);
|
||||
|
||||
int parent_token = cattr.__Parent;
|
||||
|
||||
string parent;
|
||||
int table_idx = parent_token >> 24;
|
||||
int row = parent_token & 0xffffff;
|
||||
if (!table_names.TryGetValue (table_idx, out parent))
|
||||
parent = "Unknown";
|
||||
|
||||
var args = new StringBuilder ();
|
||||
args.Append ("[");
|
||||
var sep = "";
|
||||
foreach (var arg in cattr.ConstructorArguments) {
|
||||
args.Append (sep).Append (StringifyCattrValue (arg.Value));
|
||||
sep = ", ";
|
||||
}
|
||||
foreach (var named_arg in cattr.NamedArguments) {
|
||||
args.Append (sep);
|
||||
args.Append ("{");
|
||||
args.Append (String.Format ("{0} = {1}", named_arg.MemberName, StringifyCattrValue (named_arg.TypedValue.Value)));
|
||||
args.Append ("}");
|
||||
sep = ", ";
|
||||
}
|
||||
args.Append ("]");
|
||||
|
||||
var ctor = cattr.Constructor;
|
||||
var method = new StringBuilder ();
|
||||
method.Append ("instance void class ");
|
||||
method.Append (String.Format ("[{0}]{1}", ctor.DeclaringType.Assembly.GetName ().Name, ctor.DeclaringType.ToString ()));
|
||||
method.Append ("::'.ctor'(");
|
||||
sep = "";
|
||||
foreach (var arg in ctor.GetParameters ()) {
|
||||
method.Append (sep).Append (arg.ParameterType);
|
||||
sep = ", ";
|
||||
}
|
||||
method.Append (")");
|
||||
|
||||
w.WriteLine (String.Format ("{0}: {1}: {2} {3} {4}", rowIndex, parent, row, method, args));
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user