~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to contrib/Mono.Cecil/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
                        if (t.HasElementType) {
75
75
                                if (t.IsPointer)
76
76
                                        return string.Concat (GetTypeSignature (t.GetElementType ()), "*");
77
 
                                else if (t.IsArray) // deal with complex arrays
78
 
                                        return string.Concat (GetTypeSignature (t.GetElementType ()), "[]");
79
 
                                else if (t.IsByRef)
80
 
                                        return string.Concat (GetTypeSignature (t.GetElementType ()), "&");
 
77
                                else if (t.IsArray) {
 
78
                                        int rank = t.GetArrayRank ();
 
79
                                        if (rank == 1)
 
80
                                                return string.Concat (GetTypeSignature (t.GetElementType ()), "[]");
 
81
 
 
82
                                        StringBuilder sb = new StringBuilder ();
 
83
                                        sb.Append ('[');
 
84
                                        for (int i = 1; i < rank; i++)
 
85
                                                sb.Append (',');
 
86
                                        sb.Append (']');
 
87
 
 
88
                                        return string.Concat (GetTypeSignature (t.GetElementType ()), sb.ToString ());
 
89
                                } else if (t.IsByRef)
 
90
                                        return string.Concat(GetTypeSignature(t.GetElementType()), "&");
81
91
                        }
82
92
 
83
93
                        if (IsGenericTypeSpec (t)) {
186
196
                                t = (Type) s.Pop ();
187
197
                                if (t.IsPointer)
188
198
                                        elementType = new PointerType (elementType);
189
 
                                else if (t.IsArray) // deal with complex arrays
190
 
                                        elementType = new ArrayType (elementType);
 
199
                                else if (t.IsArray)
 
200
                                        elementType = new ArrayType (elementType, t.GetArrayRank ());
191
201
                                else if (t.IsByRef)
192
202
                                        elementType = new ReferenceType (elementType);
193
203
                                else if (IsGenericTypeSpec (t))
216
226
                        }
217
227
 
218
228
                        AssemblyNameReference asm = ImportAssembly (t.Assembly);
219
 
                        type = new TypeReference (t.Name, t.Namespace, asm, t.IsValueType);
 
229
                        if (t.DeclaringType != null) {
 
230
                                type = new TypeReference (t.Name, string.Empty, asm, t.IsValueType);
 
231
                                type.DeclaringType = ImportSystemType (t.DeclaringType, context);
 
232
                        } else
 
233
                                type = new TypeReference (t.Name, t.Namespace, asm, t.IsValueType);
220
234
 
221
235
                        if (IsGenericTypeDefinition (t))
222
236
                                foreach (Type genParam in GetGenericArguments (t))
250
264
                        SR.ParameterInfo [] parameters = meth.GetParameters ();
251
265
                        for (int i = 0; i < parameters.Length; i++) {
252
266
                                if (i > 0)
253
 
                                        sb.Append (", ");
 
267
                                        sb.Append (",");
254
268
                                sb.Append (GetTypeSignature (parameters [i].ParameterType));
255
269
                        }
256
270
                        sb.Append (")");
332
346
                                foreach (Type genParam in GetGenericArguments (mb as SR.MethodInfo))
333
347
                                        meth.GenericParameters.Add (new GenericParameter (genParam.Name, meth));
334
348
 
 
349
                        TypeReference contextType = context.GenericContext.Type;
 
350
                        MethodReference contextMethod = context.GenericContext.Method;
 
351
 
335
352
                        context.GenericContext.Method = meth;
336
353
                        context.GenericContext.Type = ImportSystemType (declaringTypeDef, context);
337
354
 
342
359
                                meth.Parameters.Add (new ParameterDefinition (
343
360
                                        ImportSystemType (parameters [i].ParameterType, context)));
344
361
 
 
362
                        context.GenericContext.Type = contextType;
 
363
                        context.GenericContext.Method = contextMethod;
 
364
 
345
365
                        m_module.MemberReferences.Add (meth);
346
366
                        return meth;
347
367
                }