2 // IMetaDataProvider.cs
5 // Alexander Chebaturkin (chebaturkin@gmail.com)
7 // Copyright (C) 2011 Alexander Chebaturkin
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections.Generic;
30 using Mono.CodeContracts.Static.AST;
31 using Mono.CodeContracts.Static.AST.Visitors;
32 using Mono.CodeContracts.Static.DataStructures;
34 namespace Mono.CodeContracts.Static.Providers {
35 interface IMetaDataProvider {
36 TypeNode System_Int32 { get; }
37 TypeNode System_String { get; }
38 TypeNode System_Boolean { get; }
39 TypeNode System_IntPtr { get; }
40 TypeNode System_UIntPtr { get; }
41 TypeNode System_Void { get; }
42 TypeNode System_Array { get; }
43 TypeNode System_Object { get; }
44 TypeNode System_Int8 { get; }
45 TypeNode System_Int64 { get; }
46 TypeNode System_Int16 { get; }
47 TypeNode System_UInt8 { get; }
48 TypeNode System_UInt64 { get; }
49 TypeNode System_UInt32 { get; }
50 TypeNode System_UInt16 { get; }
52 Result AccessMethodBody<Data, Result> (Method method, IMethodCodeConsumer<Data, Result> consumer, Data data);
54 IEnumerable<Method> Methods (AssemblyNode assembly);
55 IEnumerable<Property> Properties (TypeNode type);
56 IEnumerable<Field> Fields (TypeNode type);
57 IEnumerable<TypeNode> Interfaces (TypeNode type);
58 IIndexable<Local> Locals (Method method);
59 IIndexable<Parameter> Parameters (Method method);
61 IEnumerable<Method> ImplementedMethods (Method method);
62 IEnumerable<Method> OverridenAndImplementedMethods (Method method);
64 Parameter This (Method method);
66 string Name (Local local);
67 string Name (Method method);
68 string Name (Field field);
69 string Name (TypeNode type);
71 string FullName (Method method);
72 string FullName (TypeNode type);
74 TypeNode FieldType (Field field);
75 TypeNode ParameterType (Parameter parameter);
76 TypeNode LocalType (Local local);
77 TypeNode ReturnType (Method method);
78 TypeNode ManagedPointer (TypeNode type);
79 TypeNode ElementType (TypeNode type);
80 TypeNode ArrayType (TypeNode type, int rank);
83 TypeNode DeclaringType (Method method);
84 TypeNode DeclaringType (Field field);
86 bool Equal (Method thisMethod, Method thatMethod);
88 bool IsMain (Method method);
90 bool IsStatic (Method method);
91 bool IsStatic (Field field);
92 bool IsStatic (Property property);
94 bool IsPrivate (Method method);
96 bool IsProtected (Method method);
97 bool IsProtected (Field field);
99 bool IsPublic (Method method);
100 bool IsPublic (Field field);
102 bool IsVirtual (Method method);
103 bool IsNewSlot (Method method);
104 bool IsOverride (Method method);
105 bool IsFinal (Method method);
106 bool IsConstructor (Method method);
107 bool IsAbstract (Method method);
108 bool IsCompilerGenerated (Field field);
109 bool IsCompilerGenerated (Method method);
111 bool IsAutoPropertyMember (Method method);
112 bool IsPropertySetter (Method method, out Property property);
113 bool IsPropertyGetter (Method method, out Property property);
114 bool HasSetter (Property property, out Method method);
115 bool HasGetter (Property property, out Method method);
117 bool HasBody (Method method);
118 bool DerivesFrom (TypeNode sub, TypeNode type);
119 bool Equal (TypeNode type, TypeNode otherType);
121 bool TryGetImplementingMethod (TypeNode type, Method calledMethod, out Method implementingMethod);
122 bool TryGetRootMethod (Method method, out Method rootMethod);
124 Field Unspecialized (Field field);
125 Method Unspecialized (Method method);
126 TypeNode Unspecialized (TypeNode type);
128 Method DeclaringMethod (Parameter parameter);
130 int ParameterIndex (Parameter parameter);
131 int ParameterStackIndex (Parameter parameter);
133 bool TryLoadAssembly (string filename, out AssemblyNode assembly, out string reasonOnFailure);
135 string Name (Parameter parameter);
137 bool IsReferenceType (TypeNode type);
138 bool IsManagedPointer (TypeNode value);
139 bool IsStruct (TypeNode type);
140 bool IsInterface (TypeNode type);
141 bool IsArray (TypeNode type);
142 bool IsVoid (TypeNode type);
143 bool IsReadonly (Field value);
144 bool IsFinalizer (Method method);
145 bool IsDispose (Method method);
146 bool IsVoidMethod (Method method);
147 bool IsOut (Parameter p);
148 bool IsPrimitive (TypeNode type);
149 bool IsClass (TypeNode type);
151 bool IsAsVisibleAs (Field value, Method method);
152 bool IsAsVisibleAs (Method value, Method method);
153 bool IsVisibleFrom (Field field, TypeNode declaringType);
154 bool IsVisibleFrom (Method value, TypeNode declaringType);
155 bool IsVisibleFrom (TypeNode type, TypeNode fromType);
157 bool TryGetSystemType (string fullName, out TypeNode type);
159 bool HasValueRepresentation (TypeNode type);
161 void IsSpecialized (Method calledMethod, ref IImmutableMap<TypeNode, TypeNode> specialization);
162 bool IsSpecialized (Method method);
164 bool IsFormalTypeParameter (TypeNode type);
165 bool IsMethodFormalTypeParameter (TypeNode type);
167 int TypeSize (TypeNode type);