* MethodTable.cs: Add method to Check if all methods have been defined, set reference...
authorJackson Harper <jackson@novell.com>
Tue, 18 Mar 2003 07:56:00 +0000 (07:56 -0000)
committerJackson Harper <jackson@novell.com>
Tue, 18 Mar 2003 07:56:00 +0000 (07:56 -0000)
* FieldTable.cs: Add method to check if all fields have been defined, set referenced fields properties when defining them
* ClassTable.cs: Make sure all methods and fields are defined.

svn path=/trunk/mcs/; revision=12648

mcs/ilasm/codegen/ChangeLog
mcs/ilasm/codegen/ClassTable.cs
mcs/ilasm/codegen/FieldTable.cs
mcs/ilasm/codegen/MethodTable.cs

index 76e2845898552344d1a7e2473416f2e8759fb71d..ab6b0ecd3e82d80ca00c4f8e748413da750a20e2 100644 (file)
@@ -1,3 +1,11 @@
+2003-03-17 Jackson Harper <jackson@latitudegeo.com>
+
+       * MethodTable.cs: Add method to Check if all methods have been defined, set referenced methods properties
+       when defining them
+       * FieldTable.cs: Add method to check if all fields have been defined, set referenced fields properties
+       when defining them
+       * ClassTable.cs: Make sure all methods and fields are defined.
+
 2003-03-16 Jackson Harper <jackson@latitudegeo.com>
 
        * MethodTable.cs: Fire events when methods are defined and referenced
index c630c9eba5e9ab6f3a5ab48b0c3ebdc1c0d2e2a5..e8cdf8063f5678edebecb35184f54769d21c9c17 100644 (file)
@@ -46,6 +46,20 @@ namespace Mono.ILASM {
                                }
                        }
 
+                       public bool CheckDefined ()
+                       {
+                               if (!Defined)
+                                       return false;
+                               
+                               if (!FieldTable.CheckDefined ())
+                                       return false;
+                               
+                               if (!MethodTable.CheckDefined ())
+                                       return false;
+                               
+                               return true;
+                       }
+
                        public MethodTable MethodTable {
                                get { return method_table; }
                        }
@@ -152,7 +166,7 @@ namespace Mono.ILASM {
                {
                        foreach (DictionaryEntry dic_entry in table) {
                                ClassTableItem table_item = (ClassTableItem) dic_entry.Value;
-                               if (table_item.Defined)
+                               if (table_item.CheckDefined ())
                                        continue;
                                throw new Exception (String.Format ("Type: {0} is not defined.", dic_entry.Key));
                        }
index a108c46c2c4069da6b1650dc26d908fa52233dbb..a4a2c9625be3741911edc6cd655a871bd8f5dc09 100644 (file)
@@ -23,9 +23,9 @@ namespace Mono.ILASM {
                        private int flags;
 
                        public ArrayList LocationList;
-                       public Field Field;
+                       public FieldDef Field;
 
-                       public FieldTableItem (Field field, Location location)
+                       public FieldTableItem (FieldDef field, Location location)
                        {
                                flags = 0;
                                Field = field;
@@ -71,12 +71,29 @@ namespace Mono.ILASM {
                public FieldDef AddDefinition (FieldAttr field_attr, string name, 
                        TypeRef type, Location location) 
                {
-                       CheckExists (name);
-
-                       FieldDef field = parent_class.AddField (field_attr, name, type.Type);
-                       AddDefined (name, field, location);
+                       FieldTableItem item = (FieldTableItem) table[name];
                        
-                       return field;
+                       if (item == null) {
+                               FieldDef field = parent_class.AddField (field_attr, name, type.Type);
+                               AddDefined (name, field, location);
+                               return field;
+                       }
+                       
+                       item.Field.AddFieldAttr (field_attr);
+                       item.Defined = true;
+                       
+                       return item.Field;
+               }
+
+               public bool CheckDefined ()
+               {
+                       foreach (DictionaryEntry dic_entry in table) {
+                               FieldTableItem table_item = (FieldTableItem) dic_entry.Value;
+                               if (table_item.Defined)
+                                       continue;
+                               throw new Exception (String.Format ("Field: {0} is not defined.", dic_entry.Key));
+                       }
+                       return true;
                }
                        
                protected void AddDefined (string signature, FieldDef field, Location location)
@@ -90,7 +107,7 @@ namespace Mono.ILASM {
                        table[signature] = item;
                }
 
-               protected void AddReferenced (string signature, Field field, Location location)
+               protected void AddReferenced (string signature, FieldDef field, Location location)
                {
                        FieldTableItem item = new FieldTableItem (field, location);
                        
index ddd2202c2c1856e650d87e630af23905cca04a77..4c17eb84c8aa8470566ea24ba677a6f3b66c1530 100644 (file)
@@ -74,9 +74,9 @@ namespace Mono.ILASM {
                        private int flags;
 
                        public ArrayList LocationList;
-                       public Method Method;
+                       public MethodDef Method;
 
-                       public MethodTableItem (Method method, Location location)
+                       public MethodTableItem (MethodDef method, Location location)
                        {
                                flags = 0;
                                Method = method;
@@ -142,16 +142,35 @@ namespace Mono.ILASM {
                                        return_type, param_list, table.Contains (signature), method_attr, 
                                        impl_attr, call_conv));
 
-                       CheckExists (signature);
-
-                       MethodDef method = parent_class.AddMethod (method_attr, impl_attr, name, 
-                               return_type.Type, param_list);
-                       method.AddCallConv (call_conv);
-                       AddDefined (signature, method, location);
+                       MethodTableItem item = (MethodTableItem) table[signature];
                        
-                       return method;
-               }
+                       if (item == null) {
+                               MethodDef method = parent_class.AddMethod (method_attr, impl_attr, name, 
+                                       return_type.Type, param_list);
+                               method.AddCallConv (call_conv);
+                               AddDefined (signature, method, location);
+                               return method;
+                       }
                        
+                       item.Method.AddMethAttribute (method_attr);
+                       item.Method.AddImplAttribute (impl_attr);
+                       item.Method.AddCallConv (call_conv);
+                       item.Defined = true;
+               
+                       return item.Method;
+               }
+
+               public bool CheckDefined ()
+               {
+                       foreach (DictionaryEntry dic_entry in table) {
+                               MethodTableItem table_item = (MethodTableItem) dic_entry.Value;
+                               if (table_item.Defined)
+                                       continue;
+                               throw new Exception (String.Format ("Method: {0} is not defined.", dic_entry.Key));
+                       }
+                       return true;
+               }
+                                       
                protected string GetSignature (string name, TypeRef return_type, 
                        TypeRef[] param_list)
                {
@@ -184,7 +203,7 @@ namespace Mono.ILASM {
                        table[signature] = item;
                }
 
-               protected void AddReferenced (string signature, Method method, Location location)
+               protected void AddReferenced (string signature, MethodDef method, Location location)
                {
                        MethodTableItem item = new MethodTableItem (method, location);