2002-05-24 Martin Baulig <martin@gnome.org>
authorMartin Baulig <martin@novell.com>
Fri, 24 May 2002 13:20:52 +0000 (13:20 -0000)
committerMartin Baulig <martin@novell.com>
Fri, 24 May 2002 13:20:52 +0000 (13:20 -0000)
* ModuleBuilder.cs (symwriter_define_local): New private variable.
(GetSymbolWriter): Look for a custom version of "DefineLocalVariable"
and store it in `symwriter_define_local'.
(SymWriter_DefineLocalVariable): New internal method to call the
symbol writer's custom DefineLocalVariable() method.  It is safe to
call this method if there's no symbol writer.

* LocalBuilder.cs (SetLocalSymInfo): Use the MethodBuilder'snew
SymWriter_DefineLocalVariable().

* MethodBuilder.cs (GetParameters): Implemented.

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

mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs
mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs

index ad0e2f38b908a50fae581ec9a2409b24baa5bdd4..1deb7101f2c023d92eea2091cece69221e32d222 100644 (file)
@@ -1,3 +1,17 @@
+2002-05-24  Martin Baulig  <martin@gnome.org>
+
+       * ModuleBuilder.cs (symwriter_define_local): New private variable.
+       (GetSymbolWriter): Look for a custom version of "DefineLocalVariable"
+       and store it in `symwriter_define_local'.
+       (SymWriter_DefineLocalVariable): New internal method to call the
+       symbol writer's custom DefineLocalVariable() method.  It is safe to
+       call this method if there's no symbol writer.
+
+       * LocalBuilder.cs (SetLocalSymInfo): Use the MethodBuilder'snew
+       SymWriter_DefineLocalVariable().
+
+       * MethodBuilder.cs (GetParameters): Implemented.
+
 2002-05-22  Martin Baulig  <martin@gnome.org>
 
        * ModuleBuilder.cs (GetSymbolWriter): Pass the this pointer to the
index 6e21ae2cca7a89e99f020aac46ab98287a8739d6..db7f05c30ec24a51570c9b6c2eae9447a38f12ed 100755 (executable)
@@ -40,22 +40,10 @@ namespace System.Reflection.Emit {
                }
                public void SetLocalSymInfo (string lname, int startOffset, int endOffset)
                {
-                       ISymbolWriter symbol_writer = module.GetSymWriter ();
-                       name = lname;
+                       this.name = lname;
 
-                       if (symbol_writer == null)
-                               return;
-
-                       SignatureHelper sig_helper = SignatureHelper.GetLocalVarSigHelper (module);
-
-                       sig_helper.AddArgument (type);
-
-                       byte[] signature = sig_helper.GetSignature ();
-
-                       symbol_writer.DefineLocalVariable (name, FieldAttributes.Private,
-                                                          signature, SymAddressKind.ILOffset,
-                                                          (int)position, 0, 0,
-                                                          startOffset, endOffset);
+                       module.SymWriter_DefineLocalVariable (lname, this, FieldAttributes.Private,
+                                                             (int) position, startOffset, endOffset);
                }
 
                public void SetLocalSymInfo (string lname)
index e2953b2a67ac44e42e8f950bd4e1c6764b87cc79..175e91e05211476c0ab862170c073a1c2ec6e7c2 100755 (executable)
@@ -90,7 +90,18 @@ namespace System.Reflection.Emit {
                        return iattrs;
                }
                public override ParameterInfo[] GetParameters() {
-                       return null;
+                       if ((parameters == null) || (pinfo == null))
+                               return null;
+
+                       ParameterInfo[] retval = new ParameterInfo [parameters.Length - 1];
+                       for (int i = 1; i < parameters.Length; i++) {
+                               if (pinfo [i] == null)
+                                       return null;
+
+                               retval [i - 1] = new ParameterInfo (pinfo [i], parameters [i - 1], this);
+                       }
+
+                       return retval;
                }
                
                public void CreateMethodBody( byte[] il, int count) {
index 49509112b41f8bb6d1459ecc17b43b8fdb1b53b6..d3d844506b502f753d132e0a6cdbcd747a95f097 100644 (file)
@@ -24,6 +24,7 @@ namespace System.Reflection.Emit {
                private int table_idx;
                private AssemblyBuilder assemblyb;
                private ISymbolWriter symbol_writer;
+               private MethodInfo symwriter_define_local;
                Hashtable name_cache;
 
                internal ModuleBuilder (AssemblyBuilder assb, string name, string fullyqname, bool emitSymbolInfo) {
@@ -35,43 +36,80 @@ namespace System.Reflection.Emit {
                        name_cache = new Hashtable ();
 
                        if (emitSymbolInfo)
-                               symbol_writer = GetSymbolWriter (fullyqname);
+                               GetSymbolWriter (fullyqname);
                }
 
-               internal ISymbolWriter GetSymbolWriter (string filename)
+               internal void GetSymbolWriter (string filename)
                {
                        Assembly assembly;
                        try {
                                assembly = Assembly.Load ("Mono.CSharp.Debugger");
                        } catch (FileNotFoundException) {
-                               return null;
+                               return;
                        }
 
                        Type type = assembly.GetType ("Mono.CSharp.Debugger.MonoSymbolWriter");
                        if (type == null)
-                               return null;
+                               return;
 
-                       Type[] arg_types = new Type [2];
-                       arg_types [0] = typeof (ModuleBuilder);
-                       arg_types [1] = typeof (string);
-                       ConstructorInfo constructor = type.GetConstructor (arg_types);
+                       // First get the constructor.
+                       {
+                               Type[] arg_types = new Type [2];
+                               arg_types [0] = typeof (ModuleBuilder);
+                               arg_types [1] = typeof (string);
+                               ConstructorInfo constructor = type.GetConstructor (arg_types);
 
-                       object[] args = new object [2];
-                       args [0] = this;
-                       args [1] = filename;
+                               object[] args = new object [2];
+                               args [0] = this;
+                               args [1] = filename;
 
-                       if (constructor == null)
-                               return null;
+                               if (constructor == null)
+                                       return;
 
-                       Object instance = constructor.Invoke (args);
-                       if (instance == null)
-                               return null;
+                               Object instance = constructor.Invoke (args);
+                               if (instance == null)
+                                       return;
 
-                       if (!(instance is ISymbolWriter))
-                               return null;
+                               if (!(instance is ISymbolWriter))
+                                       return;
 
-                       return (ISymbolWriter) instance;
+                               symbol_writer = (ISymbolWriter) instance;
+                       }
+
+                       // Get the DefineLocalVariable method.
+                       {
+                               Type[] arg_types = new Type [6];
+                               arg_types [0] = typeof (string);
+                               arg_types [1] = typeof (LocalBuilder);
+                               arg_types [2] = typeof (FieldAttributes);
+                               arg_types [3] = typeof (int);
+                               arg_types [4] = typeof (int);
+                               arg_types [5] = typeof (int);
+
+                               symwriter_define_local = type.GetMethod ("DefineLocalVariable", arg_types);
+
+                               if (symwriter_define_local == null)
+                                       throw new NotSupportedException ();
+                       }
                }
+
+               internal void SymWriter_DefineLocalVariable (string name, LocalBuilder local,
+                                                            FieldAttributes attributes,
+                                                            int position, int startOffset, int endOffset)
+               {
+                       if ((symbol_writer == null) || (symwriter_define_local == null))
+                               return;
+
+                       object[] args = new object [6];
+                       args [0] = name;
+                       args [1] = local;
+                       args [2] = attributes;
+                       args [3] = position;
+                       args [4] = startOffset;
+                       args [5] = endOffset;
+
+                       symwriter_define_local.Invoke (symbol_writer, args);
+               }                                                            
        
                public override string FullyQualifiedName {get { return fqname;}}