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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// GenericInstanceType.cs
3
3
//
4
4
// Author:
5
 
//      Martin Baulig  <martin@ximian.com>
6
 
//  Jb Evain  <jbevain@gmail.com>
 
5
//   Jb Evain (jbevain@gmail.com)
7
6
//
8
 
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 
7
// Copyright (c) 2008 - 2010 Jb Evain
9
8
//
10
9
// Permission is hereby granted, free of charge, to any person obtaining
11
10
// a copy of this software and associated documentation files (the
27
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
27
//
29
28
 
 
29
using System;
 
30
using System.Text;
 
31
 
 
32
using Mono.Collections.Generic;
 
33
 
 
34
using MD = Mono.Cecil.Metadata;
 
35
 
30
36
namespace Mono.Cecil {
31
37
 
32
 
        using System.Text;
33
 
 
34
 
        public sealed class GenericInstanceType : TypeSpecification, IGenericInstance {
35
 
 
36
 
                private GenericArgumentCollection m_genArgs;
37
 
 
38
 
                public GenericArgumentCollection GenericArguments {
39
 
                        get {
40
 
                                if (m_genArgs == null)
41
 
                                        m_genArgs = new GenericArgumentCollection (this);
42
 
                                return m_genArgs;
43
 
                        }
44
 
                }
 
38
        public sealed class GenericInstanceType : TypeSpecification, IGenericInstance, IGenericContext {
 
39
 
 
40
                Collection<TypeReference> arguments;
45
41
 
46
42
                public bool HasGenericArguments {
47
 
                        get { return m_genArgs == null ? false : m_genArgs.Count > 0; }
48
 
                }
49
 
 
50
 
                public override bool IsValueType {
51
 
                        get { return m_isValueType; }
52
 
                        set { m_isValueType = value; }
 
43
                        get { return !arguments.IsNullOrEmpty (); }
 
44
                }
 
45
 
 
46
                public Collection<TypeReference> GenericArguments {
 
47
                        get {
 
48
                                if (arguments == null)
 
49
                                        arguments = new Collection<TypeReference> ();
 
50
 
 
51
                                return arguments;
 
52
                        }
 
53
                }
 
54
 
 
55
                public override TypeReference DeclaringType {
 
56
                        get { return ElementType.DeclaringType; }
 
57
                        set { throw new NotSupportedException (); }
53
58
                }
54
59
 
55
60
                public override string FullName {
56
61
                        get {
57
 
                                StringBuilder sb = new StringBuilder ();
58
 
                                sb.Append (base.FullName);
59
 
                                sb.Append ("<");
60
 
                                for (int i = 0; i < this.GenericArguments.Count; i++) {
61
 
                                        if (i > 0)
62
 
                                                sb.Append (",");
63
 
                                        sb.Append (this.GenericArguments [i].FullName);
64
 
                                }
65
 
                                sb.Append (">");
66
 
                                return sb.ToString ();
 
62
                                var name = new StringBuilder ();
 
63
                                name.Append (base.FullName);
 
64
                                this.GenericInstanceFullName (name);
 
65
                                return name.ToString ();
67
66
                        }
68
67
                }
69
68
 
70
 
                public GenericInstanceType (TypeReference elementType) : base (elementType)
 
69
                public override bool IsGenericInstance {
 
70
                        get { return true; }
 
71
                }
 
72
 
 
73
                internal override bool ContainsGenericParameter {
 
74
                        get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; }
 
75
                }
 
76
 
 
77
                IGenericParameterProvider IGenericContext.Type {
 
78
                        get { return ElementType; }
 
79
                }
 
80
 
 
81
                public GenericInstanceType (TypeReference type)
 
82
                        : base (type)
71
83
                {
72
 
                        m_isValueType = elementType.IsValueType;
 
84
                        base.IsValueType = type.IsValueType;
 
85
                        this.etype = MD.ElementType.GenericInst;
73
86
                }
74
87
        }
75
88
}