|
From: <ac...@us...> - 2010-03-30 21:26:45
|
Revision: 23
http://clibinutils.svn.sourceforge.net/clibinutils/?rev=23&view=rev
Author: aco
Date: 2010-03-30 21:26:37 +0000 (Tue, 30 Mar 2010)
Log Message:
-----------
finish refactoring CFile classes structure
Modified Paths:
--------------
mono-based-binutils/branches/aco-dev/tools/gcc4cli/nm/Driver.cs
mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFile.cs
mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFileBuilder.cs
mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFileModifier.cs
mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CStaticLibrary.cs
mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ICFile.cs
mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ICFileNames.cs
mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ReferenceGetters.cs
Modified: mono-based-binutils/branches/aco-dev/tools/gcc4cli/nm/Driver.cs
===================================================================
--- mono-based-binutils/branches/aco-dev/tools/gcc4cli/nm/Driver.cs 2010-03-30 21:23:51 UTC (rev 22)
+++ mono-based-binutils/branches/aco-dev/tools/gcc4cli/nm/Driver.cs 2010-03-30 21:26:37 UTC (rev 23)
@@ -101,7 +101,7 @@
dump (obj.Name, obj);
}
} else {
- dump (filename, (CFile)myfile);
+ dump (filename, (ICFileNames)myfile);
}
} catch (CFileException e) {
Console.WriteLine ("Error : {0}", e.Message);
@@ -141,10 +141,10 @@
Environment.Exit (1);
}
- void dump (string filename, CFile obj)
+ void dump (string filename, ICFileNames obj)
{
if (printDef) {
- foreach (string name in obj.DefinedSymbols ()) {
+ foreach (string name in obj.DefinedMethods ()) {
switch (name) {
case ".start":
case ".init":
@@ -154,16 +154,14 @@
}
break;
default:
- IMemberDefinition member = obj.GetDefMember (name);
- if (member is MethodDefinition) {
- printLine (0, "T", name);
- } else if (member is FieldDefinition) {
- printLine (0, "D", name);
- }
+ printLine (0, "T", name);
break;
}
}
- foreach (string name in obj.PrivateSymbols ()) {
+ foreach (string name in obj.DefinedFields ()) {
+ printLine (0, "D", name);
+ }
+ foreach (string name in obj.PrivateMethods ()) {
switch (name) {
case "COBJ?init":
if (printSpecial) {
@@ -171,15 +169,13 @@
}
break;
default:
- IMemberDefinition member = obj.GetDefMember (name);
- if (member is MethodDefinition) {
- printLine (0, "T", name);
- } else if (member is FieldDefinition) {
- printLine (0, "D", name);
- }
+ printLine (0, "T", name);
break;
}
}
+ foreach (string name in obj.PrivateFields ()) {
+ printLine (0, "D", name);
+ }
}
if (printUndef) {
foreach (string name in obj.UndefinedSymbols ()) {
Modified: mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFile.cs
===================================================================
--- mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFile.cs 2010-03-30 21:23:51 UTC (rev 22)
+++ mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFile.cs 2010-03-30 21:26:37 UTC (rev 23)
@@ -7,7 +7,7 @@
namespace gcc4cli.util {
- public abstract class CFile : ICFile, ICFileNames {
+ public abstract class CFile : ICFile {
public static readonly string ExternalAssemblyName = "ExternalAssembly";
public static readonly string ExternalTypeName = "ExternalAssembly";
@@ -37,168 +37,6 @@
protected set { mainType = value; }
}
- protected Hashtable def_symbols = new Hashtable (); //Dictionary<string,IMemberDefinition>
- protected Hashtable undef_symbols = new Hashtable (); //Dictionary<string,IMemberReference>
- protected Hashtable private_symbols = new Hashtable (); //Dictionary<string,IMemberDefinition>
-
- protected Hashtable def_types = new Hashtable (); //Dictionary<string,TypeDefinition>
- protected Hashtable undef_types = new Hashtable (); //Dictionary<string,TypeReference>
- protected Hashtable incomplete_types = new Hashtable (); //Dictionary<string,TypeDefinition>
-
- protected Hashtable ref_types = new Hashtable (); //Dictionary<string,TypeReference>
- protected Hashtable ref_symbols = new Hashtable (); //Dictionary<string,IMemberReference>
-
- internal Hashtable DefinedSymbolsTable {
- get { return def_symbols; }
- }
-
- internal Hashtable PrivateSymbolsTable {
- get { return private_symbols; }
- }
-
-
- void DumpHashtable (string title, string prefix, Hashtable ht)
- {
- Console.WriteLine (title);
- foreach (string name in ht.Keys) {
- Console.WriteLine ("{0}{1} \t{2}", prefix, name, ht[name]);
- }
- }
-
- protected void DumpTables ()
- {
- DumpHashtable ("++++ def_types", " ", def_types);
- DumpHashtable ("++++ ref_types", " ", ref_types);
- DumpHashtable ("++++ incomplete_types", " ", incomplete_types);
- DumpHashtable ("++++ undef_types", " ", undef_types);
- DumpHashtable ("++++ def_symbols", " ", def_symbols);
- DumpHashtable ("++++ undef_symbols", " ", undef_symbols);
- DumpHashtable ("++++ private_symbols", " ", private_symbols);
- DumpHashtable ("++++ ref_symbols", " ", ref_symbols);
- }
-
- public ICollection DefinedSymbols ()
- {
- return def_symbols.Keys;
- }
-
- public ICollection DefinedTypes ()
- {
- return def_types.Keys;
- }
-
- public ICollection UndefinedSymbols ()
- {
- return undef_symbols.Keys;
- }
-
- public ICollection UndefinedTypes ()
- {
- return undef_types.Keys;
- }
-
- public ICollection IncompleteTypes ()
- {
- return incomplete_types.Keys;
- }
-
- public ICollection PrivateSymbols ()
- {
- return private_symbols.Keys;
- }
-
- public ICollection RefSymbols ()
- {
- return ref_symbols.Keys;
- }
-
- public TypeDefinition GetDefType (string name)
- {
- if (!def_types.Contains (name))
- throw new NotFoundException ("Can't find type '" + name + "' in assembly " + Name, name);
- return (TypeDefinition)def_types[name];
- }
-
- public IMemberDefinition GetDefMember (string name)
- {
- if (def_symbols.Contains (name))
- return (IMemberDefinition)def_symbols[name];
- if (private_symbols.Contains (name))
- return (IMemberDefinition)private_symbols[name];
- throw new NotFoundException ("Can't find member '" + name + "' in assembly " + Name, name);
- }
-
- protected void FillTables ()
- {
- Module.FullLoad ();
- LoadTables ();
- }
-
- public void ReloadTables ()
- {
- ClearTables ();
- LoadTables ();
- if (Tracer.TraceAtLevel (10))
- DumpTables ();
- }
-
- protected void ClearTables ()
- {
- def_symbols.Clear ();
- undef_symbols.Clear ();
- private_symbols.Clear ();
-
- def_types.Clear ();
- undef_types.Clear ();
- incomplete_types.Clear ();
-
- ref_types.Clear ();
- ref_symbols.Clear ();
- }
-
- protected void LoadTables ()
- {
- foreach (TypeDefinition type in Module.Types) {
- if (type != MainType) {
- if (type.DeclaringType != null)
- throw new NotSupportedException("Error Nested Types not supported");
- if (CFileAttributes.TypeDefIsIncomplete(type))
- incomplete_types [type.Name] = type;
- else
- def_types [type.Name] = type;
- }
- }
-
- foreach (MethodDefinition method in MainType.Methods) {
- if (method.IsPublic)
- def_symbols [method.Name] = method;
- else
- private_symbols [method.Name] = method;
- }
-
- foreach (FieldDefinition field in MainType.Fields) {
- if (field.IsPublic)
- def_symbols [field.Name] = field;
- else
- private_symbols [field.Name] = field;
- }
-
- foreach (TypeReference type in Module.TypeReferences) {
- if (type.Name != CFile.ExternalTypeName)
- ref_types [type.FullName] = type;
- else if (type.Module.Assembly.Name.Name == CFile.ExternalAssemblyName)
- undef_types [type.Name] = type;
- }
-
- foreach (MemberReference member in Module.MemberReferences) {
- if (member.DeclaringType.Name == CFile.ExternalTypeName)
- undef_symbols [member.Name] = member;
- else
- ref_symbols [member.ToString ()] = member;
- }
-
- }
-
protected CFile (string name, AssemblyKind kind, AssemblyResolver asm_resolver, string attrname)
{
Name = name;
Modified: mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFileBuilder.cs
===================================================================
--- mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFileBuilder.cs 2010-03-30 21:23:51 UTC (rev 22)
+++ mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFileBuilder.cs 2010-03-30 21:26:37 UTC (rev 23)
@@ -32,6 +32,22 @@
keepIncompleteTypes = _keepIncompleteTypes;
}
+ internal TypeDefinition GetDefType (string name)
+ {
+ if (!def_types.Contains (name))
+ throw new NotFoundException ("Can't find type '" + name + "' in assembly " + Name, name);
+ return (TypeDefinition)def_types[name];
+ }
+
+ internal IMemberDefinition GetDefMember (string name)
+ {
+ if (def_symbols.Contains (name))
+ return (IMemberDefinition)def_symbols[name];
+ if (private_symbols.Contains (name))
+ return (IMemberDefinition)private_symbols[name];
+ throw new NotFoundException ("Can't find member '" + name + "' in assembly " + Name, name);
+ }
+
public bool Building {
get { return building; }
}
Modified: mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFileModifier.cs
===================================================================
--- mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFileModifier.cs 2010-03-30 21:23:51 UTC (rev 22)
+++ mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CFileModifier.cs 2010-03-30 21:26:37 UTC (rev 23)
@@ -7,7 +7,7 @@
namespace gcc4cli.util {
- public abstract class CFileModifier : CFile, ICFileModifier {
+ public abstract class CFileModifier : CFile, ICFileModifier, ICFileNames {
protected CFileModifier (string name, AssemblyKind kind, AssemblyResolver asm_resolver, string attrname)
@@ -20,6 +20,117 @@
{
}
+ protected Hashtable def_symbols = new Hashtable (); //Dictionary<string,IMemberDefinition>
+ protected Hashtable undef_symbols = new Hashtable (); //Dictionary<string,IMemberReference>
+ protected Hashtable private_symbols = new Hashtable (); //Dictionary<string,IMemberDefinition>
+
+ protected Hashtable def_types = new Hashtable (); //Dictionary<string,TypeDefinition>
+ protected Hashtable undef_types = new Hashtable (); //Dictionary<string,TypeReference>
+ protected Hashtable incomplete_types = new Hashtable (); //Dictionary<string,TypeDefinition>
+
+ protected Hashtable ref_types = new Hashtable (); //Dictionary<string,TypeReference>
+ protected Hashtable ref_symbols = new Hashtable (); //Dictionary<string,IMemberReference>
+
+ internal Hashtable DefinedSymbolsTable {
+ get { return def_symbols; }
+ }
+
+ internal Hashtable PrivateSymbolsTable {
+ get { return private_symbols; }
+ }
+
+ void DumpHashtable (string title, string prefix, Hashtable ht)
+ {
+ Console.WriteLine (title);
+ foreach (string name in ht.Keys) {
+ Console.WriteLine ("{0}{1} \t{2}", prefix, name, ht[name]);
+ }
+ }
+
+ protected void DumpTables ()
+ {
+ DumpHashtable ("++++ def_types", " ", def_types);
+ DumpHashtable ("++++ ref_types", " ", ref_types);
+ DumpHashtable ("++++ incomplete_types", " ", incomplete_types);
+ DumpHashtable ("++++ undef_types", " ", undef_types);
+ DumpHashtable ("++++ def_symbols", " ", def_symbols);
+ DumpHashtable ("++++ undef_symbols", " ", undef_symbols);
+ DumpHashtable ("++++ private_symbols", " ", private_symbols);
+ DumpHashtable ("++++ ref_symbols", " ", ref_symbols);
+ }
+
+
+ protected void FillTables ()
+ {
+ Module.FullLoad ();
+ LoadTables ();
+ }
+
+ public void ReloadTables ()
+ {
+ ClearTables ();
+ LoadTables ();
+ if (Tracer.TraceAtLevel (10))
+ DumpTables ();
+ }
+
+ protected void ClearTables ()
+ {
+ def_symbols.Clear ();
+ undef_symbols.Clear ();
+ private_symbols.Clear ();
+
+ def_types.Clear ();
+ undef_types.Clear ();
+ incomplete_types.Clear ();
+
+ ref_types.Clear ();
+ ref_symbols.Clear ();
+ }
+
+ protected void LoadTables ()
+ {
+ foreach (TypeDefinition type in Module.Types) {
+ if (type != MainType) {
+ if (type.DeclaringType != null)
+ throw new NotSupportedException("Error Nested Types not supported");
+ if (CFileAttributes.TypeDefIsIncomplete(type))
+ incomplete_types [type.Name] = type;
+ else
+ def_types [type.Name] = type;
+ }
+ }
+
+ foreach (MethodDefinition method in MainType.Methods) {
+ if (method.IsPublic)
+ def_symbols [method.Name] = method;
+ else
+ private_symbols [method.Name] = method;
+ }
+
+ foreach (FieldDefinition field in MainType.Fields) {
+ if (field.IsPublic)
+ def_symbols [field.Name] = field;
+ else
+ private_symbols [field.Name] = field;
+ }
+
+ foreach (TypeReference type in Module.TypeReferences) {
+ if (type.Name != CFile.ExternalTypeName)
+ ref_types [type.FullName] = type;
+ else if (type.Module.Assembly.Name.Name == CFile.ExternalAssemblyName)
+ undef_types [type.Name] = type;
+ }
+
+ foreach (MemberReference member in Module.MemberReferences) {
+ if (member.DeclaringType.Name == CFile.ExternalTypeName)
+ undef_symbols [member.Name] = member;
+ else
+ ref_symbols [member.ToString ()] = member;
+ }
+
+ }
+
public void AddSymbolPrefix (string prefix)
{
if (prefix == null || prefix == "")
@@ -112,6 +223,121 @@
}
}
+ public ICollection DefinedTypes ()
+ {
+ return new Set(def_types.Keys);
+ }
+
+ public ICollection UndefinedTypes ()
+ {
+ return new Set(undef_types.Keys);
+ }
+
+ public ICollection IncompleteTypes ()
+ {
+ return new Set(incomplete_types.Keys);
+ }
+
+ public ICollection DefinedSymbols ()
+ {
+ return new Set(def_symbols.Keys);
+ }
+
+ public ICollection UndefinedSymbols ()
+ {
+ return new Set(undef_symbols.Keys);
+ }
+
+ public ICollection PrivateSymbols ()
+ {
+ return new Set(private_symbols.Keys);
+ }
+
+ public ICollection RefSymbols ()
+ {
+ return new Set(ref_symbols.Keys);
+ }
+
+ public ICollection DefinedMethods ()
+ {
+ Set result = new Set();
+ foreach (string member in def_symbols.Keys) {
+ if (def_symbols[member] is MethodReference)
+ result.Add (member);
+ }
+ return result;
+ }
+
+ public ICollection UndefinedMethods ()
+ {
+ Set result = new Set();
+ foreach (string member in undef_symbols.Keys) {
+ if (def_symbols[member] is MethodReference)
+ result.Add (member);
+ }
+ return result;
+ }
+
+ public ICollection PrivateMethods ()
+ {
+ Set result = new Set();
+ foreach (string member in private_symbols.Keys) {
+ if (def_symbols[member] is MethodReference)
+ result.Add (member);
+ }
+ return result;
+ }
+
+ public ICollection RefMethods ()
+ {
+ Set result = new Set();
+ foreach (string member in ref_symbols.Keys) {
+ if (def_symbols[member] is MethodReference)
+ result.Add (member);
+ }
+ return result;
+ }
+
+ public ICollection DefinedFields ()
+ {
+ Set result = new Set();
+ foreach (string member in def_symbols.Keys) {
+ if (def_symbols[member] is FieldReference)
+ result.Add (member);
+ }
+ return result;
+ }
+
+ public ICollection UndefinedFields ()
+ {
+ Set result = new Set();
+ foreach (string member in undef_symbols.Keys) {
+ if (def_symbols[member] is FieldReference)
+ result.Add (member);
+ }
+ return result;
+ }
+
+ public ICollection PrivateFields ()
+ {
+ Set result = new Set();
+ foreach (string member in private_symbols.Keys) {
+ if (def_symbols[member] is FieldReference)
+ result.Add (member);
+ }
+ return result;
+ }
+
+ public ICollection RefFields ()
+ {
+ Set result = new Set();
+ foreach (string member in ref_symbols.Keys) {
+ if (def_symbols[member] is FieldReference)
+ result.Add (member);
+ }
+ return result;
+ }
+
}
}
Modified: mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CStaticLibrary.cs
===================================================================
--- mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CStaticLibrary.cs 2010-03-30 21:23:51 UTC (rev 22)
+++ mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/CStaticLibrary.cs 2010-03-30 21:26:37 UTC (rev 23)
@@ -15,8 +15,6 @@
Hashtable types = new Hashtable (); //Dictionary<string,string>
Hashtable symbols = new Hashtable (); //Dictionary<string,string>
- static readonly object marker = new object ();
-
public ICollection Objects {
get { return objects.Values; }
}
@@ -78,7 +76,6 @@
void ClearMaps ()
{
- ClearTables ();
types.Clear ();
symbols.Clear ();
}
@@ -88,8 +85,6 @@
string name = obj.Name;
foreach (string tname in obj.DefinedTypes ()) {
types[tname] = name;
-// def_types[tname] = obj.GetDefType (tname);
- def_types[tname] = marker;
}
foreach (string sname in obj.DefinedSymbols ()) {
if (warn && symbols.Contains (sname)) {
@@ -97,8 +92,6 @@
Console.WriteLine (" First definition in " + symbols[sname]);
}
symbols[sname] = name;
-// def_symbols[sname] = obj.GetDefMember (sname);
- def_symbols[sname] = marker;
}
}
Modified: mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ICFile.cs
===================================================================
--- mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ICFile.cs 2010-03-30 21:23:51 UTC (rev 22)
+++ mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ICFile.cs 2010-03-30 21:26:37 UTC (rev 23)
@@ -16,9 +16,6 @@
TypeDefinition MainType { get; }
- TypeDefinition GetDefType (string name);
- IMemberDefinition GetDefMember (string name);
-
void Save (string filename);
}
Modified: mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ICFileNames.cs
===================================================================
--- mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ICFileNames.cs 2010-03-30 21:23:51 UTC (rev 22)
+++ mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ICFileNames.cs 2010-03-30 21:26:37 UTC (rev 23)
@@ -8,14 +8,25 @@
public interface ICFileNames {
- ICollection DefinedSymbols ();
ICollection DefinedTypes ();
- ICollection UndefinedSymbols ();
ICollection UndefinedTypes ();
ICollection IncompleteTypes ();
+
+ ICollection DefinedSymbols ();
+ ICollection UndefinedSymbols ();
ICollection PrivateSymbols ();
ICollection RefSymbols ();
+ ICollection DefinedMethods ();
+ ICollection UndefinedMethods ();
+ ICollection PrivateMethods ();
+ ICollection RefMethods ();
+
+ ICollection DefinedFields ();
+ ICollection UndefinedFields ();
+ ICollection PrivateFields ();
+ ICollection RefFields ();
+
}
}
Modified: mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ReferenceGetters.cs
===================================================================
--- mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ReferenceGetters.cs 2010-03-30 21:23:51 UTC (rev 22)
+++ mono-based-binutils/branches/aco-dev/tools/gcc4cli/utils/ReferenceGetters.cs 2010-03-30 21:26:37 UTC (rev 23)
@@ -11,7 +11,7 @@
public class ReferenceGetters : IReferenceGetters
{
- CFile m_cfile;
+ CFileModifier m_cfile;
ModuleDefinition m_module;
@@ -20,14 +20,14 @@
readonly string ExternalAssemblyName = CFile.ExternalAssemblyName;
readonly string ExternalTypeName = CFile.ExternalTypeName;
- ReferenceGetters (CFile cfile, ModuleDefinition module, bool allowExternalAssembly)
+ ReferenceGetters (CFileModifier cfile, ModuleDefinition module, bool allowExternalAssembly)
{
m_cfile = cfile;
m_module = module;
m_aea = allowExternalAssembly;
}
- public ReferenceGetters (CFile cfile, bool allowExternalAssembly)
+ public ReferenceGetters (CFileModifier cfile, bool allowExternalAssembly)
: this (cfile, cfile.Module, allowExternalAssembly)
{
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|