* CodeGen.cs: Add method to add data
authorJackson Harper <jackson@novell.com>
Sun, 20 Apr 2003 09:05:29 +0000 (09:05 -0000)
committerJackson Harper <jackson@novell.com>
Sun, 20 Apr 2003 09:05:29 +0000 (09:05 -0000)
* FieldDef.cs: Add method to set a fields value
* TypeDef.cs: Add method to add data
* DataDef.cs: New file - Definition of a data constant

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

mcs/ilasm/codegen/ChangeLog
mcs/ilasm/codegen/CodeGen.cs
mcs/ilasm/codegen/DataDef.cs [new file with mode: 0644]
mcs/ilasm/codegen/FieldDef.cs

index 5566513953e2cd159a848d849e78e94b29a6dd5f..6c36a9bdcbc2b4fefaa9e3af4a23d2103f38578e 100644 (file)
@@ -1,3 +1,10 @@
+2003-04-20 Jackson Harper <jackson@latitudegeo.com>
+
+       * CodeGen.cs: Add method to add data
+       * FieldDef.cs: Add method to set a fields value
+       * TypeDef.cs: Add method to add data
+       * DataDef.cs: New file - Definition of a data constant
+               
 2003-04-18 Jackson Harper <jackson@latitudegeo.com>
 
        * FieldDef.cs: Change peapi fielddef name.
index abcbe6657e31f660d9a24b1bf726f981b946dc43..5038ce186523e2029f36b77623a5aa1e54eb7088 100644 (file)
@@ -30,6 +30,7 @@ namespace Mono.ILASM {
                 private ExternTable extern_table;\r
                 private ArrayList global_field_list;\r
                 private ArrayList global_method_list;\r
+                private ArrayList global_data_list;\r
 \r
                 public CodeGen (string output_file, bool is_dll, bool is_assembly)\r
                 {\r
@@ -39,6 +40,7 @@ namespace Mono.ILASM {
                         typedef_stack = new Stack ();\r
                         global_field_list = new ArrayList ();\r
                         global_method_list = new ArrayList ();\r
+                        global_data_list = new ArrayList ();\r
                 }\r
 \r
                 public PEFile PEFile {\r
@@ -98,6 +100,15 @@ namespace Mono.ILASM {
                         }\r
                 }\r
 \r
+                public void AddDataDef (DataDef datadef)\r
+                {\r
+                        if (current_typedef != null) {\r
+                                current_typedef.AddDataDef (datadef);\r
+                        } else {\r
+                                global_data_list.Add (datadef);\r
+                        }\r
+                }\r
+\r
                 public void BeginMethodDef (MethodDef methoddef)\r
                 {\r
                         if (current_typedef != null) {\r
diff --git a/mcs/ilasm/codegen/DataDef.cs b/mcs/ilasm/codegen/DataDef.cs
new file mode 100644 (file)
index 0000000..b415296
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// Mono.ILASM.DataDef
+//
+// Author(s):
+//  Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+        public class DataDef {
+
+                private string name;
+                private bool is_tls;
+
+                private PEAPI.Constant constant;
+
+                public DataDef (string name, bool is_tls)
+                {
+                        this.name = name;
+                        this.is_tls = is_tls;
+                }
+
+                public PEAPI.Constant PeapiConstant {
+                        get { return constant; }
+                        set { constant = value; }
+                }
+
+        }
+
+}
+
index 1512f7485555e2b2279356ce867a9e7e86348398..e8e2207a5a3182220c072d1779a7037e462494c5 100644 (file)
@@ -24,6 +24,7 @@ namespace Mono.ILASM {
                 private bool value_set;
 
                 private uint offset;
+                private PEAPI.Constant constant;
 
                 public FieldDef (PEAPI.FieldAttr attr, string name,
                                 ITypeRef type)
@@ -45,11 +46,18 @@ namespace Mono.ILASM {
                         get { return field_def; }
                 }
 
-                public void SetOffset (uint val) {
+                public void SetOffset (uint val)
+                {
                         offset_set = true;
                         offset = val;
                 }
 
+                public void SetValue (PEAPI.Constant constant)
+                {
+                        value_set = true;
+                        this.constant = constant;
+                }
+
                 /// <summary>
                 ///  Define a global field
                 /// </summary>
@@ -61,7 +69,10 @@ namespace Mono.ILASM {
 
                         if (offset_set) {
                                 field_def.SetOffset (offset);
+                        }
 
+                        if (value_set) {
+                                field_def.AddValue (constant);
                         }
                 }