This repository was archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathMetadataInterfaces.cs
More file actions
4969 lines (4117 loc) · 166 KB
/
MetadataInterfaces.cs
File metadata and controls
4969 lines (4117 loc) · 166 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Research.DataStructures;
using StackTemp = System.Int32;
namespace Microsoft.Research.CodeAnalysis
{
using System.Diagnostics.Contracts;
#region Delegate types
/// <summary>
/// Prints data on given output where each line is prefixed by prefix
///
/// </summary>
/// <param name="tw">Output stream</param>
/// <param name="prefix">Prefix to be printed on each new line</param>
public delegate void Printer<Data>(TextWriter writer, string prefix, Data data);
/// <summary>
/// Generates a textual representation of code at label (none if label is a skip instruction)
/// </summary>
/// <param name="tw">Output stream</param>
/// <param name="prefix">Prefix to be printed on each new line</param>
/// <param name="lab">Label of code to be printed</param>
public delegate void ILPrinter<Label>(Label label, string prefix, TextWriter writer);
/// <summary>
/// Used to print extra info associated with the end of control flow blocks.
/// </summary>
public delegate void BlockInfoPrinter<Label>(Label at, string prefix, TextWriter writer);
/// <summary>
/// Used to find the current location of a source file's path, e.g. from PDB
/// </summary>
public delegate string SourceFileLocator(string originalSourceFilePath);
#endregion
#region IL visitor data types
/// <summary>
/// The binary branch operators
/// </summary>
public enum BranchOperator
{
Beq,
Bge,
Bge_un,
Bgt,
Bgt_un,
Ble,
Ble_un,
Blt,
Blt_un,
Bne_un,
}
/// <summary>
/// Slightly uniformized version of unary operations in IL
/// </summary>
[Serializable]
public enum UnaryOperator
{
Conv_i,
Conv_i1,
Conv_i2,
Conv_i4,
Conv_i8,
Conv_r4,
Conv_r8,
Conv_u,
Conv_u1,
Conv_u2,
Conv_u4,
Conv_u8,
Conv_r_un,
Neg,
Not,
/// <summary>
/// A unary operator on pointers to express contracts about the writeable region extending forward from the pointer.
/// The argument is of pointer type, the result type ulong.
/// </summary>
WritableBytes,
/// <summary>
/// A synthetic conversion to Decimal. We insert this instead of Decimal constructors.
/// </summary>
Conv_dec,
}
/// <summary>
/// Slightly uniformized version of binary operations in IL
/// </summary>
[Serializable]
public enum BinaryOperator
{
Add,
Add_Ovf,
Add_Ovf_Un,
And,
Ceq,
Cobjeq, // corresponds to Object.Equals, which behaves differently for some values from Ceq (NaN)
Cne_Un, // for semantics, consult Ceq in part III ECMA and negate condition
Cge, // for semantics, consult Bge in part III ECMA
Cge_Un, // for semantics, consult Bge_un in part III ECMA
Cgt,
Cgt_Un,
Cle, // for semantics, consult Ble in part III ECMA
Cle_Un, // for semantics, consult Ble_un in part III ECMA
Clt,
Clt_Un,
Div,
Div_Un,
LogicalAnd, // F: I've added those two for use in the refinement of expression involving boolean connectors
LogicalOr,
Mul,
Mul_Ovf,
Mul_Ovf_Un,
Or,
Rem,
Rem_Un,
Shl,
Shr,
Shr_Un,
Sub,
Sub_Ovf,
Sub_Ovf_Un,
Xor,
}
public static class OperatorExtensions
{
public static string ToCodeString(this BinaryOperator bop)
{
switch (bop)
{
case BinaryOperator.Add:
case BinaryOperator.Add_Ovf:
case BinaryOperator.Add_Ovf_Un:
return "+";
case BinaryOperator.And:
return "&";
case BinaryOperator.Cobjeq:
return "=="; // TODO: eventually need something else here.
case BinaryOperator.Ceq:
return "==";
case BinaryOperator.Cge:
case BinaryOperator.Cge_Un:
return ">=";
case BinaryOperator.Cgt:
case BinaryOperator.Cgt_Un:
return ">";
case BinaryOperator.Cle:
case BinaryOperator.Cle_Un:
return "<=";
case BinaryOperator.Clt:
case BinaryOperator.Clt_Un:
return "<";
case BinaryOperator.Cne_Un:
return "!=";
case BinaryOperator.Div:
case BinaryOperator.Div_Un:
return "/";
case BinaryOperator.LogicalAnd:
return "&&";
case BinaryOperator.LogicalOr:
return "||";
case BinaryOperator.Mul:
case BinaryOperator.Mul_Ovf:
case BinaryOperator.Mul_Ovf_Un:
return "*";
case BinaryOperator.Or:
return "|";
case BinaryOperator.Rem:
case BinaryOperator.Rem_Un:
return "%";
case BinaryOperator.Shl:
return "<<";
case BinaryOperator.Shr:
case BinaryOperator.Shr_Un:
return ">>";
case BinaryOperator.Sub:
case BinaryOperator.Sub_Ovf:
case BinaryOperator.Sub_Ovf_Un:
return "-";
case BinaryOperator.Xor:
return "^";
default:
throw new InvalidOperationException("Unknown binary operator");
}
}
public static string ToCodeString(this UnaryOperator op)
{
switch (op)
{
case UnaryOperator.Conv_i:
return "(UIntPtr)";
case UnaryOperator.Conv_i1:
return "(sbyte)";
case UnaryOperator.Conv_i2:
return "(short)";
case UnaryOperator.Conv_i4:
return "(int)";
case UnaryOperator.Conv_i8:
return "(long)";
case UnaryOperator.Conv_r_un:
return "(double)";
case UnaryOperator.Conv_r4:
return "(float)";
case UnaryOperator.Conv_r8:
return "(double)";
case UnaryOperator.Conv_u:
return "(UIntPtr)";
case UnaryOperator.Conv_u1:
return "(byte)";
case UnaryOperator.Conv_u2:
return "(ushort)";
case UnaryOperator.Conv_u4:
return "(uint)";
case UnaryOperator.Conv_u8:
return "(ulong)";
case UnaryOperator.Neg:
return "-";
case UnaryOperator.Not:
return "!";
case UnaryOperator.WritableBytes:
return "Contracts.WritableBytes";
case UnaryOperator.Conv_dec:
return "new Decimal";
default:
throw new InvalidOperationException("Unknown unary op");
}
}
[Pure]
public static bool IsComparisonBinaryOperator(this BinaryOperator op)
{
switch (op)
{
case BinaryOperator.Ceq:
case BinaryOperator.Cge:
case BinaryOperator.Cge_Un:
case BinaryOperator.Cgt:
case BinaryOperator.Cgt_Un:
case BinaryOperator.Cle:
case BinaryOperator.Cle_Un:
case BinaryOperator.Clt:
case BinaryOperator.Clt_Un:
case BinaryOperator.Cne_Un:
case BinaryOperator.Cobjeq:
return true;
default:
return false;
}
}
[Pure]
public static bool IsEqualityOrDisequality(this BinaryOperator bop)
{
return bop == BinaryOperator.Ceq || bop == BinaryOperator.Cne_Un;
}
public static bool IsBooleanBinaryOperator(this BinaryOperator op)
{
switch (op)
{
case BinaryOperator.LogicalAnd:
case BinaryOperator.LogicalOr:
return true;
default:
return false;
}
}
public static bool IsBitwiseBinaryOperator(this BinaryOperator op)
{
switch (op)
{
case BinaryOperator.And:
case BinaryOperator.Or:
case BinaryOperator.Xor:
return true;
default:
return false;
}
}
public static bool IsArithmeticBinaryOperator(this BinaryOperator op)
{
switch (op)
{
case BinaryOperator.Add:
case BinaryOperator.Add_Ovf:
case BinaryOperator.Add_Ovf_Un:
case BinaryOperator.Div:
case BinaryOperator.Div_Un:
case BinaryOperator.Mul:
case BinaryOperator.Mul_Ovf:
case BinaryOperator.Mul_Ovf_Un:
case BinaryOperator.Rem:
case BinaryOperator.Rem_Un:
case BinaryOperator.Sub:
case BinaryOperator.Sub_Ovf:
case BinaryOperator.Sub_Ovf_Un:
{
return true;
}
default:
{
return false;
}
}
}
public static bool IsOverflowChecked(this BinaryOperator op)
{
return op == BinaryOperator.Add_Ovf || op == BinaryOperator.Add_Ovf_Un ||
op == BinaryOperator.Sub_Ovf || op == BinaryOperator.Sub_Ovf_Un ||
op == BinaryOperator.Mul_Ovf || op == BinaryOperator.Mul_Ovf_Un;
}
public static bool TryNegate(this BinaryOperator op, out BinaryOperator negated)
{
switch (op)
{
case BinaryOperator.Ceq:
{
negated = BinaryOperator.Cne_Un;
return true;
}
case BinaryOperator.Cge:
{
negated = BinaryOperator.Clt;
return true;
}
case BinaryOperator.Cge_Un:
{
negated = BinaryOperator.Clt_Un;
return true;
}
case BinaryOperator.Cgt:
{
negated = BinaryOperator.Cle;
return true;
}
case BinaryOperator.Cgt_Un:
{
negated = BinaryOperator.Cle_Un;
return true;
}
case BinaryOperator.Cle:
{
negated = BinaryOperator.Cgt;
return true;
}
case BinaryOperator.Cle_Un:
{
negated = BinaryOperator.Cgt_Un;
return true;
}
case BinaryOperator.Clt:
{
negated = BinaryOperator.Cge;
return true;
}
case BinaryOperator.Clt_Un:
{
negated = BinaryOperator.Cge_Un;
return true;
}
case BinaryOperator.Cne_Un:
{
negated = BinaryOperator.Ceq;
return true;
}
default:
{
negated = BinaryOperator.Add;
return false;
}
}
}
public static bool TryInvert(this BinaryOperator op, out BinaryOperator inverted)
{
switch (op)
{
case BinaryOperator.Ceq:
{
inverted = BinaryOperator.Ceq;
return true;
}
case BinaryOperator.Cge:
{
inverted = BinaryOperator.Cle;
return true;
}
case BinaryOperator.Cge_Un:
{
inverted = BinaryOperator.Cle_Un;
return true;
}
case BinaryOperator.Cgt:
{
inverted = BinaryOperator.Clt;
return true;
}
case BinaryOperator.Cgt_Un:
{
inverted = BinaryOperator.Clt_Un;
return true;
}
case BinaryOperator.Cle:
{
inverted = BinaryOperator.Cge;
return true;
}
case BinaryOperator.Cle_Un:
{
inverted = BinaryOperator.Cge_Un;
return true;
}
case BinaryOperator.Clt:
{
inverted = BinaryOperator.Cgt;
return true;
}
case BinaryOperator.Clt_Un:
{
inverted = BinaryOperator.Cgt_Un;
return true;
}
case BinaryOperator.Cne_Un:
{
inverted = BinaryOperator.Cne_Un;
return true;
}
default:
{
inverted = default(BinaryOperator);
return false;
}
}
}
public static bool IsConversionOperator(this UnaryOperator op)
{
switch (op)
{
case UnaryOperator.Conv_i:
case UnaryOperator.Conv_i1:
case UnaryOperator.Conv_i2:
case UnaryOperator.Conv_i4:
case UnaryOperator.Conv_i8:
case UnaryOperator.Conv_r4:
case UnaryOperator.Conv_r8:
case UnaryOperator.Conv_u:
case UnaryOperator.Conv_u1:
case UnaryOperator.Conv_u2:
case UnaryOperator.Conv_u4:
case UnaryOperator.Conv_u8:
case UnaryOperator.Conv_r_un:
return true;
default:
return false;
}
}
}
#endregion
#region IDecodeMethods contract binding
[ContractClass(typeof(IDecodeMethodsContract<>))]
public partial interface IDecodeMethods<Method>
{
/// <summary>
/// Short name of method without namespace and outer types
/// </summary>
[Pure]
string Name(Method method);
/// <summary>
/// Full name of method including namespace and outer types
/// </summary>
[Pure]
string FullName(Method method);
/// <summary>
/// Obtain the Documentation Id for the method
/// </summary>
[Pure]
string DocumentationId(Method method);
/// <summary>
/// Get the canonical name of the member associated with this method.
/// A member can be a method, an event or a property.
/// This name is aimed at beeing created by the visual studio package
/// </summary>
[Pure]
string DeclaringMemberCanonicalName(Method method);
/// <summary>
/// True iff method is the entry point of an executable
/// </summary>
[Pure]
bool IsMain(Method method);
/// <summary>
/// True if method is static.
/// </summary>
[Pure]
bool IsStatic(Method method);
/// <summary>
/// True if method is private
/// </summary>
[Pure]
bool IsPrivate(Method method);
/// <summary>
/// True if method is protected
/// </summary>
[Pure]
bool IsProtected(Method method);
/// <summary>
/// True if method is public
/// </summary>
[Pure]
bool IsPublic(Method method);
/// <summary>
/// True if method is virtual
/// </summary>
[Pure]
bool IsVirtual(Method method);
/// <summary>
/// True if method is declared as "new"
/// </summary>
[Pure]
bool IsNewSlot(Method method);
/// <summary>
/// True if method is "override"
/// </summary>
[Pure]
bool IsOverride(Method method);
/// <summary>
/// True if method is sealed
/// </summary>
[Pure]
bool IsSealed(Method method);
/// <summary>
/// True if the return type of the method is void
/// </summary>
[Pure]
bool IsVoidMethod(Method method);
/// <summary>
/// Returns true if the method is an instance constructor
/// </summary>
[Pure]
bool IsConstructor(Method method);
/// <summary>
/// Returns true if the method is a finalizer
/// </summary>
[Pure]
bool IsFinalizer(Method method);
/// <summary>
/// Returns true if the method is a Dispose implementation
/// </summary>
[Pure]
bool IsDispose(Method method);
/// <summary>
/// Returns true if the method is internal
/// </summary>
[Pure]
bool IsInternal(Method method);
/// <summary>
/// True if method is visible outside assembly within which it is declared
/// E.g., public methods, or protected methods of publicly visible types, etc.
/// </summary>
[Pure]
bool IsVisibleOutsideAssembly(Method method);
/// <summary>
/// True if method is abstract and has no body
/// </summary>
[Pure]
bool IsAbstract(Method method);
/// <summary>
/// True if method is declared extern and has no body
/// </summary>
[Pure]
bool IsExtern(Method method);
/// <summary>
/// Returns true if the method is a property setter
/// </summary>
[Pure]
bool IsPropertySetter(Method method);
/// <summary>
/// Returns true if the method is a property getter
/// </summary>
[Pure]
bool IsPropertyGetter(Method method);
/// <summary>
/// For an async generated MoveNext methods, returns true
/// </summary>
[Pure]
bool IsAsyncMoveNext(Method method);
/// <summary>
/// For a MoveNext method from async or iterators, returns the start state (-1 or 0). Otherwise returns null.
/// </summary>
[Pure]
int? MoveNextStartState(Method method);
}
[ContractClassFor(typeof(IDecodeMethods<>))]
internal abstract class IDecodeMethodsContract<Method> : IDecodeMethods<Method>
{
public string Name(Method method)
{
Contract.Ensures(Contract.Result<string>() != null);
return null;
}
public string FullName(Method method)
{
Contract.Ensures(Contract.Result<string>() != null);
return null;
}
public string DocumentationId(Method method)
{
Contract.Ensures(Contract.Result<string>() != null);
return null;
}
public string DeclaringMemberCanonicalName(Method method)
{
Contract.Ensures(Contract.Result<string>() != null);
throw new NotImplementedException();
}
public bool IsMain(Method method)
{
throw new NotImplementedException();
}
public bool IsStatic(Method method)
{
throw new NotImplementedException();
}
public bool IsPrivate(Method method)
{
throw new NotImplementedException();
}
public bool IsProtected(Method method)
{
throw new NotImplementedException();
}
public bool IsPublic(Method method)
{
throw new NotImplementedException();
}
public bool IsVirtual(Method method)
{
throw new NotImplementedException();
}
public bool IsNewSlot(Method method)
{
throw new NotImplementedException();
}
public bool IsOverride(Method method)
{
throw new NotImplementedException();
}
public bool IsSealed(Method method)
{
throw new NotImplementedException();
}
public bool IsVoidMethod(Method method)
{
throw new NotImplementedException();
}
public bool IsConstructor(Method method)
{
throw new NotImplementedException();
}
public bool IsFinalizer(Method method)
{
throw new NotImplementedException();
}
public bool IsDispose(Method method)
{
throw new NotImplementedException();
}
public bool IsInternal(Method method)
{
throw new NotImplementedException();
}
public bool IsVisibleOutsideAssembly(Method method)
{
throw new NotImplementedException();
}
public bool IsAbstract(Method method)
{
throw new NotImplementedException();
}
public bool IsExtern(Method method)
{
throw new NotImplementedException();
}
public bool IsPropertySetter(Method method)
{
throw new NotImplementedException();
}
public bool IsPropertyGetter(Method method)
{
throw new NotImplementedException();
}
#region IDecodeMethods<Method> Members
public bool IsAsyncMoveNext(Method method)
{
throw new NotImplementedException();
}
public int? MoveNextStartState(Method method)
{
throw new NotImplementedException();
}
#endregion
}
#endregion
[ContractClass(typeof(IDecodeMetaDataContracts<,,,,,,,,>))]
public partial interface IDecodeMetaData<Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> : IDecodeMethods<Method>
{
#region Methods
/// <summary>
/// Returns the return type of a method
/// </summary>
[Pure]
Type ReturnType(Method method);
/// <summary>
/// Returns the parameters of a method, NOT including "this" (even if the method is an instance method)
/// </summary>
[Pure]
IIndexable<Parameter> Parameters(Method method);
/// <summary>
/// For non-static methods, returns a parameter corresponding to "this or arg0".
/// Can throw if the method is static.
/// </summary>
[Pure]
Parameter This(Method method);
/// <summary>
/// True if property is visible outside assembly within which it is declared
/// </summary>
[Pure]
bool IsVisibleOutsideAssembly(Property property);
/// <summary>
/// True if event is visible outside assembly within which it is declared
/// </summary>
[Pure]
bool IsVisibleOutsideAssembly(Event @event);
/// <summary>
/// True if field is visible outside assembly within which it is declared
/// </summary>
[Pure]
bool IsVisibleOutsideAssembly(Field field);
/// <summary>
/// Returns the property containing the getter/setter if the method is actually a getter/setter.
/// </summary>
/// <param name="method"></param>
/// <returns></returns>
[Pure]
Property GetPropertyFromAccessor(Method method);
/// <summary>
/// Returns true if the method is compiler generated
/// </summary>
[Pure]
bool IsCompilerGenerated(Method method);
/// <summary>
/// Returns true if the method is marked with the DebuggerNonUserCode attribute
/// </summary>
[Pure]
bool IsDebuggerNonUserCode(Method method);
/// <summary>
/// Returns true if the type is marked with the DebuggerNonUserCode attribute
/// </summary>
[Pure]
bool IsDebuggerNonUserCode(Type t);
/// <summary>
/// Returns true if the method is an auto property getter or setter
/// </summary>
[Pure]
bool IsAutoPropertyMember(Method method);
/// <summary>
/// Returns true if the method is an auto property setter
/// </summary>
[Pure]
bool IsAutoPropertySetter(Method method, out Field backingField);
/// <summary>
/// Returns true if the type is compiler generated
/// </summary>
[Pure]
bool IsCompilerGenerated(Type type);
/// <summary>
/// Returns true if the type was generated from C++
/// </summary>
[Pure]
bool IsNativeCpp(Type type);
/// <summary>
/// Returns the declaring type containing this method
/// </summary>
[Pure]
Type DeclaringType(Method method);
/// <summary>
/// Returns the declaring assembly containing this method
/// </summary>
[Pure]
Assembly DeclaringAssembly(Method method);
/// <summary>
/// Returns the method def/ref token of the method if possible.
/// </summary>
[Pure]
int MethodToken(Method method);
/// <summary>
/// Returns true if this method reference is specialized w.r.t. type parameters, either
/// because the method is generic and instantiated, or because a declaring/parent type is
/// instantiated.
/// </summary>
[Pure]
bool IsSpecialized(Method method);
/// <summary>
/// Returns true if this method reference is specialized w.r.t. type parameters, either
/// because the method is generic and instantiated, or because a declaring/parent type is
/// instantiated.
/// </summary>
/// <param name="specialization">the map is updated with all the specializations
/// (mapping formal type arguments to actuals)</param>
[Pure]
bool IsSpecialized(Method method, ref IFunctionalMap<Type, Type> specialization);
/// <summary>
/// Returns true if this method reference is specialized w.r.t. type parameters, either
/// because the method is generic and instantiated, or because a declaring/parent type is
/// instantiated.
/// </summary>
[Pure]
bool IsSpecialized(Method method, out Method genericMethod, out IIndexable<Type> methodTypeArguments);
/// <summary>
/// Returns true if method is a template method with formal type arguments.
/// NOTE: only the method type parameter of the given method are reported, no type parameters of
/// enclosing types.
/// </summary>
[Pure]
bool IsGeneric(Method method, out IIndexable<Type> formals);
/// <summary>
/// For specialized methods, this returns the original template method, otherwise identity
/// </summary>
[Pure]
Method Unspecialized(Method method);
/// <summary>
/// Specializes a generic method with the given type arguments
/// </summary>
[Pure]
Method Specialize(Method method, Type[] methodTypeArguments);
/// <summary>
/// Returns the set of methods that are immediately overridden from a base class (no intermediate override)
/// </summary>
[Pure]
IEnumerable<Method> OverriddenMethods(Method method);
/// <summary>
/// Returns the set of methods that are interface methods implemented explicitly or implicitly by this method
/// </summary>
[Pure]
IEnumerable<Method> ImplementedMethods(Method method);
/// <summary>
/// Returns the set of methods that are either
/// - immediately overridden from a base class (no intermediate override)
/// - interface methods implemented explicitly or implicitly by this method
/// </summary>
[Pure]
IEnumerable<Method> OverriddenAndImplementedMethods(Method method);
/// <summary>
/// Returns true if method implements a method from an interface implicitly (as opposed to explict implementations)
/// </summary>
[Pure]
bool IsImplicitImplementation(Method method);
/// <summary>
/// Returns true if the method has a body and Entry(method) can be called.
/// </summary>
[Pure]
bool HasBody(Method method);
/// <summary>
/// Provides access to a method body (if HasBody returned true), existentially abstracting the
/// internal code representation of Labels and Handlers.
/// </summary>
[Pure]
Result AccessMethodBody<Data, Result>(Method method, IMethodCodeConsumer<Local, Parameter, Method, Field, Type, Data, Result> consumer, Data data);
/// <summary>
/// Equality between methods
/// </summary>
[Pure]
bool Equal(Method m1, Method m2);
/// <summary>
/// Returns true if two types, type1 and type2, are equivalent types, as interpreted by the underlying
/// object model.
/// </summary>
/// <param name="type1"></param>
/// <param name="type2"></param>
/// <returns></returns>
[Pure]
bool Equal(Type type1, Type type2);
/// <summary>
/// Returns true if any context that can see m2 can also see m1
/// </summary>
[Pure]
bool IsAsVisibleAs(Method m1, Method m2);
/// <summary>