il.fsi 70.6 KB
Newer Older
1
// Copyright (c) Microsoft Corporation.  All Rights Reserved.  See License.txt in the project root for license information.
L
latkin 已提交
2

3
/// The "unlinked" view of .NET metadata and code.  Central to the Abstract IL library
D
Don Syme 已提交
4
module public FSharp.Compiler.AbstractIL.IL 
L
latkin 已提交
5

6
open FSharp.Compiler.AbstractIL.Internal
L
latkin 已提交
7
open System.Collections.Generic
A
Avi Avni 已提交
8
open System.Reflection
L
latkin 已提交
9

10
[<RequireQualifiedAccess>]
D
desco 已提交
11 12
type PrimaryAssembly = 
    | Mscorlib
13 14
    | System_Runtime
    | NetStandard
D
desco 已提交
15 16

    member Name: string
L
latkin 已提交
17

18
/// Represents guids 
D
Don Syme 已提交
19
type ILGuid = byte[]
L
latkin 已提交
20 21 22 23 24 25 26 27 28 29 30

[<StructuralEquality; StructuralComparison>]
type ILPlatform = 
    | X86
    | AMD64
    | IA64

/// Debug info.  Values of type "source" can be attached at sequence 
/// points and some other locations. 
[<Sealed>]
type ILSourceDocument =
D
Don Syme 已提交
31
    static member Create: language: ILGuid option * vendor: ILGuid option * documentType: ILGuid option * file: string -> ILSourceDocument
D
Don Syme 已提交
32 33 34
    member Language: ILGuid option
    member Vendor: ILGuid option
    member DocumentType: ILGuid option
L
latkin 已提交
35 36 37 38 39
    member File: string


[<Sealed>]
type ILSourceMarker =
D
Don Syme 已提交
40
    static member Create: document: ILSourceDocument * line: int * column: int * endLine:int * endColumn: int-> ILSourceMarker
L
latkin 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54
    member Document: ILSourceDocument
    member Line: int
    member Column: int
    member EndLine: int
    member EndColumn: int

[<StructuralEquality; StructuralComparison>]
type PublicKey = 
    | PublicKey of byte[]
    | PublicKeyToken of byte[]
    member IsKey: bool
    member IsKeyToken: bool
    member Key: byte[]
    member KeyToken: byte[]
D
Don Syme 已提交
55
    static member KeyAsToken: byte[] -> PublicKey 
L
latkin 已提交
56

57 58 59 60 61 62 63 64 65
[<Struct>]
type ILVersionInfo =

    val Major: uint16
    val Minor: uint16
    val Build: uint16
    val Revision: uint16

    new : major: uint16 * minor: uint16 * build: uint16 * revision: uint16 -> ILVersionInfo
L
latkin 已提交
66 67 68

[<Sealed>]
type ILAssemblyRef =
D
Don Syme 已提交
69 70
    static member Create: name: string * hash: byte[] option * publicKey: PublicKey option * retargetable: bool * version: ILVersionInfo option * locale: string option -> ILAssemblyRef
    static member FromAssemblyName: System.Reflection.AssemblyName -> ILAssemblyRef
D
Don Syme 已提交
71
    member Name: string
72

L
latkin 已提交
73
    /// The fully qualified name of the assembly reference, e.g. mscorlib, Version=1.0.3705 etc.
D
Don Syme 已提交
74 75 76
    member QualifiedName: string 
    member Hash: byte[] option
    member PublicKey: PublicKey option
77

L
latkin 已提交
78
    /// CLI says this indicates if the assembly can be retargeted (at runtime) to be from a different publisher. 
D
Don Syme 已提交
79 80
    member Retargetable: bool
    member Version: ILVersionInfo option
L
latkin 已提交
81 82 83 84 85
    member Locale: string option
    interface System.IComparable

[<Sealed>]
type ILModuleRef =
D
Don Syme 已提交
86
    static member Create: name: string * hasMetadata: bool * hash: byte[] option -> ILModuleRef
L
latkin 已提交
87 88 89 90 91 92
    member Name: string
    member HasMetadata: bool
    member Hash: byte[] option
    interface System.IComparable

// Scope references
93
[<StructuralEquality; StructuralComparison; RequireQualifiedAccess>]
L
latkin 已提交
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
type ILScopeRef = 
    /// A reference to the type in the current module
    | Local 
    /// A reference to a type in a module in the same assembly
    | Module of ILModuleRef   
    /// A reference to a type in another assembly
    | Assembly of ILAssemblyRef  
    member IsLocalRef: bool
    member QualifiedName: string

// Calling conventions.  
//
// For nearly all purposes you simply want to use ILArgConvention.Default combined
// with ILThisConvention.Instance or ILThisConvention.Static, i.e.
//   ILCallingConv.Instance == Callconv(ILThisConvention.Instance, ILArgConvention.Default): for an instance method
//   ILCallingConv.Static   == Callconv(ILThisConvention.Static, ILArgConvention.Default): for a static method
//
// ILThisConvention.InstanceExplicit is only used by Managed C++, and indicates 
// that the 'this' pointer is actually explicit in the signature. 
[<StructuralEquality; StructuralComparison; RequireQualifiedAccess>]
type ILArgConvention = 
    | Default
    | CDecl 
    | StdCall 
    | ThisCall 
    | FastCall 
    | VarArg
      
[<StructuralEquality; StructuralComparison; RequireQualifiedAccess>]
type ILThisConvention =
    /// accepts an implicit 'this' pointer 
    | Instance           
    /// accepts an explicit 'this' pointer 
    | InstanceExplicit  
    /// no 'this' pointer is passed
    | Static             

[<StructuralEquality; StructuralComparison>]
type ILCallingConv =
    | Callconv of ILThisConvention * ILArgConvention
134

D
Don Syme 已提交
135 136 137 138 139
    member IsInstance: bool
    member IsInstanceExplicit: bool
    member IsStatic: bool
    member ThisConv: ILThisConvention
    member BasicConv: ILArgConvention
140

D
Don Syme 已提交
141 142
    static member Instance: ILCallingConv
    static member Static  : ILCallingConv
L
latkin 已提交
143

144
/// Array shapes. For most purposes the rank is the only thing that matters. 
L
latkin 已提交
145
type ILArrayBound = int32 option 
146 147

/// Lower-bound/size pairs 
L
latkin 已提交
148 149 150
type ILArrayBounds = ILArrayBound * ILArrayBound

type ILArrayShape =
151 152
    | ILArrayShape of ILArrayBounds list 

D
Don Syme 已提交
153
    member Rank: int
154

L
latkin 已提交
155 156
    /// Bounds for a single dimensional, zero based array 
    static member SingleDimensional: ILArrayShape
D
Don Syme 已提交
157
    static member FromRank: int -> ILArrayShape
L
latkin 已提交
158 159 160 161 162 163 164 165 166 167 168 169 170

type ILBoxity = 
    | AsObject
    | AsValue

type ILGenericVariance = 
    | NonVariant            
    | CoVariant             
    | ContraVariant         

/// Type refs, i.e. references to types in some .NET assembly
[<Sealed>]
type ILTypeRef =
171

W
WilliamBerryiii 已提交
172
    /// Create a ILTypeRef.
D
Don Syme 已提交
173
    static member Create: scope: ILScopeRef * enclosing: string list * name: string -> ILTypeRef
L
latkin 已提交
174 175 176

    /// Where is the type, i.e. is it in this module, in another module in this assembly or in another assembly? 
    member Scope: ILScopeRef
177

L
latkin 已提交
178 179
    /// The list of enclosing type names for a nested type. If non-nil then the first of these also contains the namespace.
    member Enclosing: string list
180

W
WilliamBerryiii 已提交
181
    /// The name of the type. This also contains the namespace if Enclosing is empty.
L
latkin 已提交
182
    member Name: string
183

W
WilliamBerryiii 已提交
184
    /// The name of the type in the assembly using the '.' notation for nested types.
L
latkin 已提交
185
    member FullName: string
186

W
WilliamBerryiii 已提交
187
    /// The name of the type in the assembly using the '+' notation for nested types.
D
Don Syme 已提交
188
    member BasicQualifiedName: string
189

L
latkin 已提交
190
    member QualifiedName: string
191

L
latkin 已提交
192 193 194 195 196
    interface System.IComparable
    
/// Type specs and types.  
[<Sealed>]
type ILTypeSpec =
197
    /// Create an ILTypeSpec.
D
Don Syme 已提交
198
    static member Create: typeRef:ILTypeRef * instantiation:ILGenericArgs -> ILTypeSpec
L
latkin 已提交
199 200 201

    /// Which type is being referred to?
    member TypeRef: ILTypeRef
202

L
latkin 已提交
203 204
    /// The type instantiation if the type is generic, otherwise empty
    member GenericArgs: ILGenericArgs
205 206
    
    /// Where is the type, i.e. is it in this module, in another module in this assembly or in another assembly? 
L
latkin 已提交
207
    member Scope: ILScopeRef
208 209
    
    /// The list of enclosing type names for a nested type. If non-nil then the first of these also contains the namespace.
L
latkin 已提交
210
    member Enclosing: string list
211 212
    
    /// The name of the type. This also contains the namespace if Enclosing is empty.
L
latkin 已提交
213
    member Name: string
214 215
    
    /// The name of the type in the assembly using the '.' notation for nested types.
L
latkin 已提交
216
    member FullName: string
217
    
L
latkin 已提交
218 219 220 221 222
    interface System.IComparable

and 
    [<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
    ILType =
223

L
latkin 已提交
224 225
    /// Used only in return and pointer types.
    | Void                   
226

L
latkin 已提交
227 228
    /// Array types 
    | Array of ILArrayShape * ILType 
229

L
latkin 已提交
230 231
    /// Unboxed types, including builtin types.
    | Value of ILTypeSpec     
232

L
latkin 已提交
233 234
    /// Reference types.  Also may be used for parents of members even if for members in value types. 
    | Boxed of ILTypeSpec     
235

L
latkin 已提交
236 237
    /// Unmanaged pointers.  Nb. the type is used by tools and for binding only, not by the verifier.
    | Ptr of ILType             
238

L
latkin 已提交
239 240
    /// Managed pointers.
    | Byref of ILType           
241

L
latkin 已提交
242 243
    /// ILCode pointers. 
    | FunctionPointer of ILCallingSignature        
244

L
latkin 已提交
245 246
    /// Reference a generic arg. 
    | TypeVar of uint16           
247

L
latkin 已提交
248 249
    /// Custom modifiers. 
    | Modified of            
W
WilliamBerryiii 已提交
250
          /// True if modifier is "required". 
L
latkin 已提交
251 252 253 254 255
          bool *                  
          /// The class of the custom modifier. 
          ILTypeRef *                   
          /// The type being modified. 
          ILType                     
256

D
Don Syme 已提交
257
    member TypeSpec: ILTypeSpec
258

D
Don Syme 已提交
259
    member Boxity: ILBoxity
260

D
Don Syme 已提交
261
    member TypeRef: ILTypeRef
262

D
Don Syme 已提交
263
    member IsNominal: bool
264

D
Don Syme 已提交
265
    member GenericArgs: ILGenericArgs
266

D
Don Syme 已提交
267
    member IsTyvar: bool
268

D
Don Syme 已提交
269
    member BasicQualifiedName: string
270 271

    member QualifiedName: string
L
latkin 已提交
272 273 274

and [<StructuralEquality; StructuralComparison>]
    ILCallingSignature =  
D
Don Syme 已提交
275 276
    { CallingConv: ILCallingConv
      ArgTypes: ILTypes
L
latkin 已提交
277 278 279
      ReturnType: ILType }

/// Actual generic parameters are  always types.  
280
and ILGenericArgs = ILType list
L
latkin 已提交
281

282
and ILTypes = ILType list
L
latkin 已提交
283

284
/// Formal identities of methods.  
L
latkin 已提交
285 286
[<Sealed>]
type ILMethodRef =
287 288

     /// Functional creation
D
Don Syme 已提交
289
     static member Create: enclosingTypeRef: ILTypeRef * callingConv: ILCallingConv * name: string * genericArity: int * argTypes: ILTypes * returnType: ILType -> ILMethodRef
290

291
     member DeclaringTypeRef: ILTypeRef
292

L
latkin 已提交
293
     member CallingConv: ILCallingConv
294

L
latkin 已提交
295
     member Name: string
296

L
latkin 已提交
297
     member GenericArity: int
298

L
latkin 已提交
299
     member ArgCount: int
300

L
latkin 已提交
301
     member ArgTypes: ILTypes
302

L
latkin 已提交
303
     member ReturnType: ILType
304

L
latkin 已提交
305
     member CallingSignature: ILCallingSignature
306

L
latkin 已提交
307 308
     interface System.IComparable
     
309
/// Formal identities of fields. 
L
latkin 已提交
310 311
[<StructuralEquality; StructuralComparison>]
type ILFieldRef = 
D
Don Syme 已提交
312 313
    { DeclaringTypeRef: ILTypeRef
      Name: string
L
latkin 已提交
314 315 316 317 318
      Type: ILType }

/// The information at the callsite of a method
[<Sealed>]
type ILMethodSpec =
319 320

     /// Functional creation
D
Don Syme 已提交
321
     static member Create: ILType * ILMethodRef * ILGenericArgs -> ILMethodSpec
322

L
latkin 已提交
323
     member MethodRef: ILMethodRef
324

325
     member DeclaringType: ILType 
326

L
latkin 已提交
327
     member GenericArgs: ILGenericArgs
328

L
latkin 已提交
329
     member CallingConv: ILCallingConv
330

L
latkin 已提交
331
     member GenericArity: int
332

L
latkin 已提交
333
     member Name: string
334

L
latkin 已提交
335
     member FormalArgTypes: ILTypes
336

L
latkin 已提交
337
     member FormalReturnType: ILType
338

L
latkin 已提交
339 340 341 342 343
     interface System.IComparable
      
/// Field specs.  The data given for a ldfld, stfld etc. instruction.
[<StructuralEquality; StructuralComparison>]    
type ILFieldSpec =
D
Don Syme 已提交
344
    { FieldRef: ILFieldRef
345
      DeclaringType: ILType }    
346

347
    member DeclaringTypeRef: ILTypeRef
348

L
latkin 已提交
349
    member Name: string
350

L
latkin 已提交
351 352
    member FormalType: ILType

D
Don Syme 已提交
353
    member ActualType: ILType
L
latkin 已提交
354

355
/// ILCode labels.  In structured code each code label refers to a basic block somewhere in the code of the method.
L
latkin 已提交
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
type ILCodeLabel = int

[<StructuralEquality; StructuralComparison>]
type ILBasicType =
    | DT_R
    | DT_I1
    | DT_U1
    | DT_I2
    | DT_U2
    | DT_I4
    | DT_U4
    | DT_I8
    | DT_U8
    | DT_R4
    | DT_R8
    | DT_I
    | DT_U
    | DT_REF

[<StructuralEquality; StructuralComparison; RequireQualifiedAccess>]
type ILToken = 
    | ILType of ILType 
    | ILMethod of ILMethodSpec 
    | ILField of ILFieldSpec

[<StructuralEquality; StructuralComparison; RequireQualifiedAccess>]
type ILConst = 
    | I4 of int32
    | I8 of int64
    | R4 of single
    | R8 of double

type ILTailcall = 
    | Tailcall
    | Normalcall

type ILAlignment = 
    | Aligned
    | Unaligned1
    | Unaligned2
    | Unaligned4

type ILVolatility = 
    | Volatile
    | Nonvolatile

type ILReadonly = 
    | ReadonlyAddress
    | NormalAddress

type ILVarArgs = ILTypes option

[<StructuralEquality; StructuralComparison>]
type ILComparisonInstr = 
    | BI_beq        
    | BI_bge        
    | BI_bge_un     
    | BI_bgt        
    | BI_bgt_un        
    | BI_ble        
    | BI_ble_un        
    | BI_blt        
    | BI_blt_un 
    | BI_bne_un 
    | BI_brfalse 
    | BI_brtrue 

/// The instruction set.                                                     
[<StructuralEquality; NoComparison>]
type ILInstr = 
    | AI_add    
    | AI_add_ovf
    | AI_add_ovf_un
    | AI_and    
    | AI_div   
    | AI_div_un
    | AI_ceq      
    | AI_cgt      
    | AI_cgt_un   
    | AI_clt     
    | AI_clt_un  
    | AI_conv      of ILBasicType
    | AI_conv_ovf  of ILBasicType
    | AI_conv_ovf_un  of ILBasicType
    | AI_mul       
    | AI_mul_ovf   
    | AI_mul_ovf_un
    | AI_rem       
    | AI_rem_un       
    | AI_shl       
    | AI_shr       
    | AI_shr_un
    | AI_sub       
    | AI_sub_ovf   
    | AI_sub_ovf_un   
    | AI_xor       
    | AI_or        
    | AI_neg       
    | AI_not       
    | AI_ldnull    
    | AI_dup       
    | AI_pop
    | AI_ckfinite 
    | AI_nop
    | AI_ldc       of ILBasicType * ILConst
    | I_ldarg     of uint16
    | I_ldarga    of uint16
    | I_ldind     of ILAlignment * ILVolatility * ILBasicType
    | I_ldloc     of uint16
    | I_ldloca    of uint16
    | I_starg     of uint16
    | I_stind     of  ILAlignment * ILVolatility * ILBasicType
    | I_stloc     of uint16

    // Control transfer 
    | I_br    of  ILCodeLabel
    | I_jmp   of ILMethodSpec
D
Don Syme 已提交
473 474
    | I_brcmp of ILComparisonInstr * ILCodeLabel 
    | I_switch    of ILCodeLabel list 
L
latkin 已提交
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
    | I_ret 

     // Method call 
    | I_call     of ILTailcall * ILMethodSpec * ILVarArgs
    | I_callvirt of ILTailcall * ILMethodSpec * ILVarArgs
    | I_callconstraint of ILTailcall * ILType * ILMethodSpec * ILVarArgs
    | I_calli    of ILTailcall * ILCallingSignature * ILVarArgs
    | I_ldftn    of ILMethodSpec
    | I_newobj   of ILMethodSpec  * ILVarArgs
    
    // Exceptions 
    | I_throw
    | I_endfinally
    | I_endfilter
    | I_leave     of  ILCodeLabel
    | I_rethrow

    // Object instructions 
    | I_ldsfld      of ILVolatility * ILFieldSpec
    | I_ldfld       of ILAlignment * ILVolatility * ILFieldSpec
    | I_ldsflda     of ILFieldSpec
    | I_ldflda      of ILFieldSpec 
    | I_stsfld      of ILVolatility  *  ILFieldSpec
    | I_stfld       of ILAlignment * ILVolatility * ILFieldSpec
    | I_ldstr       of string
    | I_isinst      of ILType
    | I_castclass   of ILType
    | I_ldtoken     of ILToken
    | I_ldvirtftn   of ILMethodSpec

    // Value type instructions 
    | I_cpobj       of ILType
    | I_initobj     of ILType
    | I_ldobj       of ILAlignment * ILVolatility * ILType
    | I_stobj       of ILAlignment * ILVolatility * ILType
    | I_box         of ILType
    | I_unbox       of ILType
    | I_unbox_any   of ILType
    | I_sizeof      of ILType

    // Generalized array instructions. In AbsIL these instructions include 
    // both the single-dimensional variants (with ILArrayShape == ILArrayShape.SingleDimensional) 
W
WilliamBerryiii 已提交
517
    // and calls to the "special" multi-dimensional "methods" such as: 
L
latkin 已提交
518 519 520 521
    //   newobj void string[,]::.ctor(int32, int32) 
    //   call string string[,]::Get(int32, int32) 
    //   call string& string[,]::Address(int32, int32) 
    //   call void string[,]::Set(int32, int32,string) 
W
WilliamBerryiii 已提交
522
    //
L
latkin 已提交
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
    // The IL reader transforms calls of this form to the corresponding 
    // generalized instruction with the corresponding ILArrayShape 
    // argument. This is done to simplify the IL and make it more uniform. 
    // The IL writer then reverses this when emitting the binary. 
    | I_ldelem      of ILBasicType
    | I_stelem      of ILBasicType
    | I_ldelema     of ILReadonly * bool * ILArrayShape * ILType (* ILArrayShape = ILArrayShape.SingleDimensional for single dimensional arrays *)
    | I_ldelem_any  of ILArrayShape * ILType (* ILArrayShape = ILArrayShape.SingleDimensional for single dimensional arrays *)
    | I_stelem_any  of ILArrayShape * ILType (* ILArrayShape = ILArrayShape.SingleDimensional for single dimensional arrays *)
    | I_newarr      of ILArrayShape * ILType (* ILArrayShape = ILArrayShape.SingleDimensional for single dimensional arrays *)
    | I_ldlen

    // "System.TypedReference" related instructions: almost 
    // no languages produce these, though they do occur in mscorlib.dll 
    // System.TypedReference represents a pair of a type and a byref-pointer
    // to a value of that type. 
    | I_mkrefany    of ILType
    | I_refanytype  
    | I_refanyval   of ILType
    
    // Debug-specific 
    // I_seqpoint is a fake instruction to represent a sequence point: 
    // the next instruction starts the execution of the 
    // statement covered by the given range - this is a 
    // dummy instruction and is not emitted 
    | I_break 
    | I_seqpoint of ILSourceMarker 

    // Varargs - C++ only 
    | I_arglist  

D
Don Syme 已提交
554
    // Local aggregates, i.e. stack allocated data (alloca): C++ only 
L
latkin 已提交
555 556 557 558
    | I_localloc
    | I_cpblk of ILAlignment * ILVolatility
    | I_initblk of ILAlignment  * ILVolatility

559
    // EXTENSIONS
L
latkin 已提交
560 561 562
    | EI_ilzero of ILType
    | EI_ldlen_multi      of int32 * int32

D
Don Syme 已提交
563 564 565 566 567 568
[<RequireQualifiedAccess>]
type ILExceptionClause = 
    | Finally of (ILCodeLabel * ILCodeLabel)
    | Fault  of (ILCodeLabel * ILCodeLabel)
    | FilterCatch of (ILCodeLabel * ILCodeLabel) * (ILCodeLabel * ILCodeLabel)
    | TypeCatch of ILType * (ILCodeLabel * ILCodeLabel)
L
latkin 已提交
569

D
Don Syme 已提交
570 571
[<RequireQualifiedAccess; NoEquality; NoComparison>]
type ILExceptionSpec = 
D
Don Syme 已提交
572
    { Range: (ILCodeLabel * ILCodeLabel)
D
Don Syme 已提交
573
      Clause: ILExceptionClause }
L
latkin 已提交
574 575

/// Indicates that a particular local variable has a particular source 
D
Don Syme 已提交
576
/// language name within a given set of ranges. This does not effect local 
L
latkin 已提交
577
/// variable numbering, which is global over the whole method. 
D
Don Syme 已提交
578 579
[<RequireQualifiedAccess; NoEquality; NoComparison>]
type ILLocalDebugMapping =
D
Don Syme 已提交
580 581
    { LocalIndex: int
      LocalName: string }
L
latkin 已提交
582

D
Don Syme 已提交
583 584 585 586
[<RequireQualifiedAccess; NoEquality; NoComparison>]
type ILLocalDebugInfo = 
    { Range: (ILCodeLabel * ILCodeLabel);
      DebugMappings: ILLocalDebugMapping list }
L
latkin 已提交
587

D
Don Syme 已提交
588 589 590 591 592 593
[<RequireQualifiedAccess; NoEquality; NoComparison>]
type ILCode = 
    { Labels: Dictionary<ILCodeLabel,int> 
      Instrs:ILInstr[] 
      Exceptions: ILExceptionSpec list 
      Locals: ILLocalDebugInfo list }
L
latkin 已提交
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612

/// Field Init
[<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
type ILFieldInit = 
    | String of string
    | Bool of bool
    | Char of uint16
    | Int8 of sbyte
    | Int16 of int16
    | Int32 of int32
    | Int64 of int64
    | UInt8 of byte
    | UInt16 of uint16
    | UInt32 of uint32
    | UInt64 of uint64
    | Single of single
    | Double of double
    | Null

D
Don Syme 已提交
613
[<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
L
latkin 已提交
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
type ILNativeVariant = 
    | Empty
    | Null
    | Variant
    | Currency
    | Decimal               
    | Date               
    | BSTR               
    | LPSTR               
    | LPWSTR               
    | IUnknown               
    | IDispatch               
    | SafeArray               
    | Error               
    | HRESULT               
    | CArray               
    | UserDefined               
    | Record               
    | FileTime
    | Blob               
    | Stream               
    | Storage               
    | StreamedObject               
    | StoredObject               
    | BlobObject               
    | CF                
    | CLSID
    | Void 
    | Bool
    | Int8
    | Int16                
    | Int32                
    | Int64                
    | Single                
    | Double                
    | UInt8                
    | UInt16                
    | UInt32                
    | UInt64                
    | PTR                
    | Array of ILNativeVariant                
    | Vector of ILNativeVariant                
    | Byref of ILNativeVariant                
    | Int                
    | UInt                

/// Native Types, for marshalling to the native C interface.
/// These are taken directly from the ILASM syntax, see ECMA Spec (Partition II, 7.4).  
[<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
type ILNativeType = 
    | Empty
D
Don Syme 已提交
665
    | Custom of ILGuid * string * string * byte[] (* guid,nativeTypeName,custMarshallerName,cookieString *)
L
latkin 已提交
666 667 668 669 670 671
    | FixedSysString of int32
    | FixedArray of int32
    | Currency
    | LPSTR
    | LPWSTR
    | LPTSTR
672
    | LPUTF8STR
L
latkin 已提交
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
    | ByValStr
    | TBSTR
    | LPSTRUCT
    | Struct
    | Void
    | Bool
    | Int8
    | Int16
    | Int32
    | Int64
    | Single
    | Double
    | Byte
    | UInt16
    | UInt32
    | UInt64
689 690
    ///  optional idx of parameter giving size plus optional additive i.e. num elems 
    | Array of ILNativeType option * (int32 * int32 option) option 
L
latkin 已提交
691 692 693 694 695 696 697 698 699 700 701 702 703 704
    | Int
    | UInt
    | Method
    | AsAny
    | BSTR
    | IUnknown
    | IDispatch
    | Interface
    | Error               
    | SafeArray of ILNativeVariant * string option 
    | ANSIBSTR
    | VariantBool

/// Local variables
D
Don Syme 已提交
705
[<RequireQualifiedAccess; NoComparison; NoEquality>]
L
latkin 已提交
706
type ILLocal = 
D
Don Syme 已提交
707 708
    { Type: ILType
      IsPinned: bool
L
latkin 已提交
709
      DebugInfo: (string * int * int) option }
L
latkin 已提交
710
     
711
type ILLocals = list<ILLocal>
L
latkin 已提交
712 713

/// IL method bodies
D
Don Syme 已提交
714
[<RequireQualifiedAccess; NoComparison; NoEquality>]
L
latkin 已提交
715
type ILMethodBody = 
D
Don Syme 已提交
716 717 718 719 720 721
    { IsZeroInit: bool
      MaxStack: int32 
      NoInlining: bool
      AggressiveInlining: bool
      Locals: ILLocals
      Code: ILCode
L
latkin 已提交
722 723 724 725 726 727
      SourceMarker: ILSourceMarker option }

/// Member Access
[<RequireQualifiedAccess>]
type ILMemberAccess = 
    | Assembly
728
    | CompilerControlled
L
latkin 已提交
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
    | FamilyAndAssembly
    | FamilyOrAssembly
    | Family
    | Private 
    | Public 

[<RequireQualifiedAccess>]
type ILAttribElem = 
    /// Represents a custom attribute parameter of type 'string'. These may be null, in which case they are encoded in a special
    /// way as indicated by Ecma-335 Partition II.
    | String of string  option 
    | Bool of bool
    | Char of char
    | SByte of sbyte
    | Int16 of int16
    | Int32 of int32
    | Int64 of int64
    | Byte of byte
    | UInt16 of uint16
    | UInt32 of uint32
    | UInt64 of uint64
    | Single of single
    | Double of double
    | Null 
    | Type of ILType option
    | TypeRef of ILTypeRef option
    | Array of ILType * ILAttribElem list

W
WilliamBerryiii 已提交
757
/// Named args: values and flags indicating if they are fields or properties.
L
latkin 已提交
758 759
type ILAttributeNamedArg = string * ILType * bool * ILAttribElem

760
/// Custom attribute.
L
latkin 已提交
761
type ILAttribute =
762 763 764 765 766 767 768 769 770 771 772 773 774 775
    /// Attribute with args encoded to a binary blob according to ECMA-335 II.21 and II.23.3.
    /// 'decodeILAttribData' is used to parse the byte[] blob to ILAttribElem's as best as possible.
    | Encoded of method: ILMethodSpec * data: byte[] * elements: ILAttribElem list

    /// Attribute with args in decoded form.
    | Decoded of method: ILMethodSpec * fixedArgs: ILAttribElem list * namedArgs: ILAttributeNamedArg list

    /// Attribute instance constructor.
    member Method: ILMethodSpec

    /// Decoded arguments. May be empty in encoded attribute form.
    member Elements: ILAttribElem list

    member WithMethod: method: ILMethodSpec -> ILAttribute
L
latkin 已提交
776

777
[<NoEquality; NoComparison; Struct>]
L
latkin 已提交
778
type ILAttributes =
D
Don Syme 已提交
779 780
    member AsArray: ILAttribute []
    member AsList: ILAttribute list
L
latkin 已提交
781

782 783 784
/// Represents the efficiency-oriented storage of ILAttributes in another item.
[<NoEquality; NoComparison>]
type ILAttributesStored
L
latkin 已提交
785

786
/// Method parameters and return values.
D
Don Syme 已提交
787
[<RequireQualifiedAccess; NoEquality; NoComparison>]
L
latkin 已提交
788
type ILParameter = 
D
Don Syme 已提交
789 790 791
    { Name: string option
      Type: ILType
      Default: ILFieldInit option  
L
latkin 已提交
792
      /// Marshalling map for parameters. COM Interop only. 
D
Don Syme 已提交
793 794 795 796
      Marshal: ILNativeType option 
      IsIn: bool
      IsOut: bool
      IsOptional: bool
797 798 799
      CustomAttrsStored: ILAttributesStored
      MetadataIndex: int32 }
    member CustomAttrs: ILAttributes
L
latkin 已提交
800

801
type ILParameters = list<ILParameter>
L
latkin 已提交
802

D
Don Syme 已提交
803
val typesOfILParams: ILParameters -> ILType list
L
latkin 已提交
804

W
WilliamBerryiii 已提交
805
/// Method return values.
D
Don Syme 已提交
806
[<RequireQualifiedAccess; NoEquality; NoComparison>]
L
latkin 已提交
807
type ILReturn = 
D
Don Syme 已提交
808 809
    { Marshal: ILNativeType option
      Type: ILType 
810 811 812 813
      CustomAttrsStored: ILAttributesStored
      MetadataIndex: int32  }

    member CustomAttrs: ILAttributes
L
latkin 已提交
814

815 816
    member WithCustomAttrs: customAttrs: ILAttributes -> ILReturn

L
latkin 已提交
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837
[<RequireQualifiedAccess>]
type ILSecurityAction = 
    | Request 
    | Demand
    | Assert
    | Deny
    | PermitOnly
    | LinkCheck 
    | InheritCheck
    | ReqMin
    | ReqOpt
    | ReqRefuse
    | PreJitGrant
    | PreJitDeny
    | NonCasDemand
    | NonCasLinkDemand
    | NonCasInheritance
    | LinkDemandChoice
    | InheritanceDemandChoice
    | DemandChoice

D
Don Syme 已提交
838 839
type ILSecurityDecl =
    | ILSecurityDecl of ILSecurityAction * byte[]
L
latkin 已提交
840

D
Don Syme 已提交
841
/// Abstract type equivalent to ILSecurityDecl list - use helpers 
W
WilliamBerryiii 已提交
842
/// below to construct/destruct these.
843
[<NoComparison; NoEquality; Struct>]
D
Don Syme 已提交
844 845
type ILSecurityDecls =
    member AsList: ILSecurityDecl list
L
latkin 已提交
846

847 848 849
/// Represents the efficiency-oriented storage of ILSecurityDecls in another item.
[<NoEquality; NoComparison>]
type ILSecurityDeclsStored
L
latkin 已提交
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

/// PInvoke attributes.
[<RequireQualifiedAccess>]
type PInvokeCallingConvention =
    | None
    | Cdecl
    | Stdcall
    | Thiscall
    | Fastcall
    | WinApi

[<RequireQualifiedAccess>]
type PInvokeCharEncoding =
    | None
    | Ansi
    | Unicode
    | Auto

[<RequireQualifiedAccess>]
type PInvokeCharBestFit =
    | UseAssembly
    | Enabled
    | Disabled

[<RequireQualifiedAccess>]
type PInvokeThrowOnUnmappableChar =
    | UseAssembly
    | Enabled
    | Disabled

D
Don Syme 已提交
880
[<RequireQualifiedAccess; NoComparison; NoEquality>]
L
latkin 已提交
881
type PInvokeMethod =
D
Don Syme 已提交
882 883 884 885 886 887 888
    { Where: ILModuleRef
      Name: string
      CallingConv: PInvokeCallingConvention
      CharEncoding: PInvokeCharEncoding
      NoMangle: bool
      LastError: bool
      ThrowOnUnmappableChar: PInvokeThrowOnUnmappableChar
L
latkin 已提交
889 890 891
      CharBestFit: PInvokeCharBestFit }


892
/// [OverridesSpec] - refer to a method declaration in a superclass or interface. 
L
latkin 已提交
893 894 895
type ILOverridesSpec =
    | OverridesSpec of ILMethodRef * ILType
    member MethodRef: ILMethodRef
896
    member DeclaringType: ILType 
L
latkin 已提交
897 898

type ILMethodVirtualInfo =
D
Don Syme 已提交
899 900 901 902
    { IsFinal: bool 
      IsNewSlot: bool 
      IsCheckAccessOnOverride: bool
      IsAbstract: bool }
L
latkin 已提交
903 904 905 906 907 908 909 910 911 912 913 914

[<RequireQualifiedAccess>]
type MethodKind =
    | Static 
    | Cctor 
    | Ctor 
    | NonVirtual 
    | Virtual of ILMethodVirtualInfo

[<RequireQualifiedAccess>]
type MethodBody =
    | IL of ILMethodBody
915
    | PInvoke of PInvokeMethod 
L
latkin 已提交
916 917
    | Abstract
    | Native
918
    | NotAvailable
L
latkin 已提交
919 920 921 922 923 924 925

[<RequireQualifiedAccess>]
type MethodCodeKind =
    | IL
    | Native
    | Runtime

926
/// Generic parameters.  Formal generic parameter declarations may include the bounds, if any, on the generic parameter.
L
latkin 已提交
927
type ILGenericParameterDef =
D
Don Syme 已提交
928
    { Name: string
D
Don Syme 已提交
929 930

      /// At most one is the parent type, the others are interface types.
D
Don Syme 已提交
931
      Constraints: ILTypes 
D
Don Syme 已提交
932

W
WilliamBerryiii 已提交
933
      /// Variance of type parameters, only applicable to generic parameters for generic interfaces and delegates.
D
Don Syme 已提交
934
      Variance: ILGenericVariance 
D
Don Syme 已提交
935

W
WilliamBerryiii 已提交
936
      /// Indicates the type argument must be a reference type.
D
Don Syme 已提交
937
      HasReferenceTypeConstraint: bool     
D
Don Syme 已提交
938

W
WilliamBerryiii 已提交
939
      /// Indicates the type argument must be a value type, but not Nullable.
D
Don Syme 已提交
940
      HasNotNullableValueTypeConstraint: bool  
D
Don Syme 已提交
941

W
WilliamBerryiii 已提交
942
      /// Indicates the type argument must have a public nullary constructor.
943 944 945 946 947 948 949
      HasDefaultConstructorConstraint: bool 
      
      /// Do not use this
      CustomAttrsStored: ILAttributesStored

      /// Do not use this
      MetadataIndex: int32 }
L
latkin 已提交
950

951
    member CustomAttrs: ILAttributes 
L
latkin 已提交
952 953 954 955 956

type ILGenericParameterDefs = ILGenericParameterDef list

[<NoComparison; NoEquality; Sealed>]
type ILLazyMethodBody = 
D
Don Syme 已提交
957
    member Contents: MethodBody 
L
latkin 已提交
958

D
Don Syme 已提交
959
/// IL Method definitions. 
L
latkin 已提交
960 961
[<NoComparison; NoEquality>]
type ILMethodDef = 
D
Don Syme 已提交
962

963 964 965 966 967 968 969 970 971
    /// Functional creation of a value, with delayed reading of some elements via a metadata index
    new: name: string * attributes: MethodAttributes * implAttributes: MethodImplAttributes * callingConv: ILCallingConv * 
         parameters: ILParameters * ret: ILReturn * body: ILLazyMethodBody * isEntryPoint:bool * genericParams: ILGenericParameterDefs * 
         securityDeclsStored: ILSecurityDeclsStored * customAttrsStored: ILAttributesStored * metadataIndex: int32 -> ILMethodDef

    /// Functional creation of a value, immediate
    new: name: string * attributes: MethodAttributes * implAttributes: MethodImplAttributes * callingConv: ILCallingConv * 
         parameters: ILParameters * ret: ILReturn * body: ILLazyMethodBody * isEntryPoint:bool * genericParams: ILGenericParameterDefs * 
         securityDecls: ILSecurityDecls * customAttrs: ILAttributes -> ILMethodDef
L
latkin 已提交
972
      
D
Don Syme 已提交
973 974 975 976 977 978 979 980 981 982 983
    member Name: string
    member Attributes: MethodAttributes
    member ImplAttributes: MethodImplAttributes
    member CallingConv: ILCallingConv
    member Parameters: ILParameters
    member Return: ILReturn
    member Body: ILLazyMethodBody
    member SecurityDecls: ILSecurityDecls
    member IsEntryPoint:bool
    member GenericParams: ILGenericParameterDefs
    member CustomAttrs: ILAttributes 
D
Don Syme 已提交
984
    member ParameterTypes: ILTypes
D
Don Syme 已提交
985 986 987 988 989
    member IsIL: bool
    member Code: ILCode option
    member Locals: ILLocals
    member MaxStack: int32
    member IsZeroInit: bool
L
latkin 已提交
990
    
D
Don Syme 已提交
991
    /// Indicates a .cctor method.
L
latkin 已提交
992
    member IsClassInitializer: bool
D
Don Syme 已提交
993 994

    /// Indicates a .ctor method.
L
latkin 已提交
995
    member IsConstructor: bool
D
Don Syme 已提交
996 997

    /// Indicates a static method.
L
latkin 已提交
998
    member IsStatic: bool
D
Don Syme 已提交
999 1000

    /// Indicates this is an instance methods that is not virtual.
L
latkin 已提交
1001
    member IsNonVirtualInstance: bool
D
Don Syme 已提交
1002 1003

    /// Indicates an instance methods that is virtual or abstract or implements an interface slot.  
L
latkin 已提交
1004 1005 1006 1007
    member IsVirtual: bool
    
    member IsFinal: bool
    member IsNewSlot: bool
A
Avi Avni 已提交
1008
    member IsCheckAccessOnOverride: bool
L
latkin 已提交
1009
    member IsAbstract: bool
A
Avi Avni 已提交
1010
    member MethodBody: ILMethodBody
L
latkin 已提交
1011
    member CallingSignature: ILCallingSignature
A
Avi Avni 已提交
1012 1013 1014
    member Access: ILMemberAccess
    member IsHideBySig: bool
    member IsSpecialName: bool
D
Don Syme 已提交
1015

A
Avi Avni 已提交
1016 1017 1018
    /// The method is exported to unmanaged code using COM interop.
    member IsUnmanagedExport: bool
    member IsReqSecObj: bool
D
Don Syme 已提交
1019

A
Avi Avni 已提交
1020 1021 1022 1023 1024 1025 1026 1027 1028
    /// Some methods are marked "HasSecurity" even if there are no permissions attached, e.g. if they use SuppressUnmanagedCodeSecurityAttribute 
    member HasSecurity: bool
    member IsManaged: bool
    member IsForwardRef: bool
    member IsInternalCall: bool
    member IsPreserveSig: bool
    member IsSynchronized: bool
    member IsNoInline: bool
    member IsAggressiveInline: bool
D
Don Syme 已提交
1029 1030

    /// SafeHandle finalizer must be run.
A
Avi Avni 已提交
1031 1032
    member IsMustRun: bool
    
D
Don Syme 已提交
1033
    /// Functional update of the value
1034 1035 1036
    member With: ?name: string * ?attributes: MethodAttributes * ?implAttributes: MethodImplAttributes * ?callingConv: ILCallingConv * 
                 ?parameters: ILParameters * ?ret: ILReturn * ?body: ILLazyMethodBody * ?securityDecls: ILSecurityDecls * ?isEntryPoint:bool * 
                 ?genericParams: ILGenericParameterDefs * ?customAttrs: ILAttributes -> ILMethodDef
A
Avi Avni 已提交
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
    member WithSpecialName: ILMethodDef
    member WithHideBySig: unit -> ILMethodDef
    member WithHideBySig: bool -> ILMethodDef
    member WithFinal: bool -> ILMethodDef
    member WithAbstract: bool -> ILMethodDef
    member WithAccess: ILMemberAccess -> ILMethodDef
    member WithNewSlot: ILMethodDef
    member WithSecurity: bool -> ILMethodDef
    member WithPInvoke: bool -> ILMethodDef
    member WithPreserveSig: bool -> ILMethodDef
    member WithSynchronized: bool -> ILMethodDef
    member WithNoInlining: bool -> ILMethodDef
    member WithAggressiveInlining: bool -> ILMethodDef
    member WithRuntime: bool -> ILMethodDef
L
latkin 已提交
1051 1052 1053 1054 1055 1056 1057

/// Tables of methods.  Logically equivalent to a list of methods but
/// the table is kept in a form optimized for looking up methods by 
/// name and arity.
[<NoEquality; NoComparison; Sealed>]
type ILMethodDefs =
    interface IEnumerable<ILMethodDef>
D
Don Syme 已提交
1058 1059 1060
    member AsArray: ILMethodDef[]
    member AsList: ILMethodDef list
    member FindByName: string -> ILMethodDef list
L
latkin 已提交
1061

W
WilliamBerryiii 已提交
1062
/// Field definitions.
L
latkin 已提交
1063 1064
[<NoComparison; NoEquality>]
type ILFieldDef = 
D
Don Syme 已提交
1065

1066 1067 1068 1069 1070 1071 1072 1073 1074
    /// Functional creation of a value using delayed reading via a metadata index
    new: name: string * fieldType: ILType * attributes: FieldAttributes * data: byte[] option * 
         literalValue: ILFieldInit option * offset:  int32 option * marshal: ILNativeType option * 
         customAttrsStored: ILAttributesStored * metadataIndex: int32 -> ILFieldDef

    /// Functional creation of a value, immediate
    new: name: string * fieldType: ILType * attributes: FieldAttributes * data: byte[] option * 
         literalValue: ILFieldInit option * offset:  int32 option * marshal: ILNativeType option * 
         customAttrs: ILAttributes -> ILFieldDef
D
Don Syme 已提交
1075

D
Don Syme 已提交
1076 1077 1078 1079 1080
    member Name: string
    member FieldType: ILType
    member Attributes: FieldAttributes
    member Data:  byte[] option
    member LiteralValue: ILFieldInit option  
D
Don Syme 已提交
1081

D
Don Syme 已提交
1082 1083 1084
    /// The explicit offset in bytes when explicit layout is used.
    member Offset:  int32 option 
    member Marshal: ILNativeType option 
1085
    member CustomAttrs: ILAttributes
D
Don Syme 已提交
1086 1087 1088 1089 1090 1091
    member IsStatic: bool
    member IsSpecialName: bool
    member IsLiteral: bool
    member NotSerialized: bool
    member IsInitOnly: bool
    member Access: ILMemberAccess
D
Don Syme 已提交
1092 1093

    /// Functional update of the value
1094 1095
    member With: ?name: string * ?fieldType: ILType * ?attributes: FieldAttributes * ?data: byte[] option * ?literalValue: ILFieldInit option * 
                 ?offset:  int32 option * ?marshal: ILNativeType option * ?customAttrs: ILAttributes -> ILFieldDef
D
Don Syme 已提交
1096 1097 1098 1099 1100 1101 1102
    member WithAccess: ILMemberAccess -> ILFieldDef
    member WithInitOnly: bool -> ILFieldDef
    member WithStatic: bool -> ILFieldDef
    member WithSpecialName: bool -> ILFieldDef
    member WithNotSerialized: bool -> ILFieldDef
    member WithLiteralDefaultValue: ILFieldInit option -> ILFieldDef
    member WithFieldMarshal: ILNativeType option -> ILFieldDef
L
latkin 已提交
1103

1104 1105
/// Tables of fields.  Logically equivalent to a list of fields but the table is kept in 
/// a form to allow efficient looking up fields by name.
L
latkin 已提交
1106 1107
[<NoEquality; NoComparison; Sealed>]
type ILFieldDefs =
D
Don Syme 已提交
1108 1109
    member AsList: ILFieldDef list
    member LookupByName: string -> ILFieldDef list
L
latkin 已提交
1110

W
WilliamBerryiii 已提交
1111
/// Event definitions.
L
latkin 已提交
1112 1113
[<NoComparison; NoEquality>]
type ILEventDef =
D
Don Syme 已提交
1114

1115 1116 1117 1118 1119 1120 1121 1122 1123
    /// Functional creation of a value, using delayed reading via a metadata index, for ilread.fs
    new: eventType: ILType option * name: string * attributes: EventAttributes * addMethod: ILMethodRef * 
         removeMethod: ILMethodRef * fireMethod: ILMethodRef option * otherMethods: ILMethodRef list * 
         customAttrsStored: ILAttributesStored * metadataIndex: int32 -> ILEventDef

    /// Functional creation of a value, immediate
    new: eventType: ILType option * name: string * attributes: EventAttributes * addMethod: ILMethodRef * 
         removeMethod: ILMethodRef * fireMethod: ILMethodRef option * otherMethods: ILMethodRef list * 
         customAttrs: ILAttributes -> ILEventDef
D
Don Syme 已提交
1124

D
Don Syme 已提交
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134
    member EventType: ILType option
    member Name: string
    member Attributes: EventAttributes
    member AddMethod: ILMethodRef 
    member RemoveMethod: ILMethodRef
    member FireMethod: ILMethodRef option
    member OtherMethods: ILMethodRef list
    member CustomAttrs: ILAttributes
    member IsSpecialName: bool
    member IsRTSpecialName: bool
L
latkin 已提交
1135

D
Don Syme 已提交
1136
    /// Functional update of the value
1137 1138 1139
    member With: ?eventType: ILType option * ?name: string * ?attributes: EventAttributes * ?addMethod: ILMethodRef * 
                 ?removeMethod: ILMethodRef * ?fireMethod: ILMethodRef option * ?otherMethods: ILMethodRef list * 
                 ?customAttrs: ILAttributes -> ILEventDef
L
latkin 已提交
1140 1141 1142 1143

/// Table of those events in a type definition.
[<NoEquality; NoComparison; Sealed>]
type ILEventDefs =
D
Don Syme 已提交
1144 1145
    member AsList: ILEventDef list
    member LookupByName: string -> ILEventDef list
L
latkin 已提交
1146

D
Don Syme 已提交
1147
/// Property definitions
L
latkin 已提交
1148 1149
[<NoComparison; NoEquality>]
type ILPropertyDef =
D
Don Syme 已提交
1150

1151 1152 1153 1154
    /// Functional creation of a value, using delayed reading via a metadata index, for ilread.fs
    new: name: string * attributes: PropertyAttributes * setMethod: ILMethodRef option * getMethod: ILMethodRef option * 
         callingConv: ILThisConvention * propertyType: ILType * init: ILFieldInit option * args: ILTypes * 
         customAttrsStored: ILAttributesStored * metadataIndex: int32 -> ILPropertyDef
D
Don Syme 已提交
1155

1156 1157 1158 1159
    /// Functional creation of a value, immediate
    new: name: string * attributes: PropertyAttributes * setMethod: ILMethodRef option * getMethod: ILMethodRef option * 
         callingConv: ILThisConvention * propertyType: ILType * init: ILFieldInit option * args: ILTypes * 
         customAttrs: ILAttributes -> ILPropertyDef
D
Don Syme 已提交
1160

D
Don Syme 已提交
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
    member Name: string
    member Attributes: PropertyAttributes
    member SetMethod: ILMethodRef option
    member GetMethod: ILMethodRef option
    member CallingConv: ILThisConvention
    member PropertyType: ILType          
    member Init: ILFieldInit option
    member Args: ILTypes
    member CustomAttrs: ILAttributes
    member IsSpecialName: bool
    member IsRTSpecialName: bool
L
latkin 已提交
1172

1173 1174 1175 1176 1177
    /// Functional update of the value
    member With: ?name: string * ?attributes: PropertyAttributes * ?setMethod: ILMethodRef option * ?getMethod: ILMethodRef option * 
                 ?callingConv: ILThisConvention * ?propertyType: ILType * ?init: ILFieldInit option * ?args: ILTypes * 
                 ?customAttrs: ILAttributes -> ILPropertyDef

D
Don Syme 已提交
1178
/// Table of properties in an IL type definition.
L
latkin 已提交
1179 1180 1181
[<NoEquality; NoComparison>]
[<Sealed>]
type ILPropertyDefs =
D
Don Syme 已提交
1182 1183
    member AsList: ILPropertyDef list
    member LookupByName: string -> ILPropertyDef list
L
latkin 已提交
1184 1185 1186

/// Method Impls
type ILMethodImplDef =
D
Don Syme 已提交
1187
    { Overrides: ILOverridesSpec
L
latkin 已提交
1188 1189 1190 1191
      OverrideBy: ILMethodSpec }

[<NoEquality; NoComparison; Sealed>]
type ILMethodImplDefs =
D
Don Syme 已提交
1192
    member AsList: ILMethodImplDef list
L
latkin 已提交
1193

W
WilliamBerryiii 已提交
1194
/// Type Layout information.
L
latkin 已提交
1195 1196 1197 1198 1199 1200 1201
[<RequireQualifiedAccess>]
type ILTypeDefLayout =
    | Auto
    | Sequential of ILTypeDefLayoutInfo
    | Explicit of ILTypeDefLayoutInfo 

and ILTypeDefLayoutInfo =
D
Don Syme 已提交
1202
    { Size: int32 option
L
latkin 已提交
1203 1204
      Pack: uint16 option } 

W
WilliamBerryiii 已提交
1205
/// Indicate the initialization semantics of a type.
L
latkin 已提交
1206 1207 1208 1209 1210
[<RequireQualifiedAccess>]
type ILTypeInit =
    | BeforeField
    | OnAny

W
WilliamBerryiii 已提交
1211
/// Default Unicode encoding for P/Invoke  within a type.
L
latkin 已提交
1212 1213 1214 1215 1216 1217
[<RequireQualifiedAccess>]
type ILDefaultPInvokeEncoding =
    | Ansi
    | Auto
    | Unicode

W
WilliamBerryiii 已提交
1218
/// Type Access.
L
latkin 已提交
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
[<RequireQualifiedAccess>]
type ILTypeDefAccess =
    | Public 
    | Private
    | Nested of ILMemberAccess 

/// A categorization of type definitions into "kinds"
[<RequireQualifiedAccess>]
type ILTypeDefKind =
    | Class
    | ValueType
    | Interface
    | Enum 
    | Delegate 

1234 1235
/// Tables of named type definitions.  
[<NoEquality; NoComparison; Sealed>]
L
latkin 已提交
1236 1237
type ILTypeDefs =
    interface IEnumerable<ILTypeDef>
D
Don Syme 已提交
1238 1239 1240 1241

    member AsArray: ILTypeDef[]

    member AsList: ILTypeDef list
L
latkin 已提交
1242

W
WilliamBerryiii 已提交
1243
    /// Get some information about the type defs, but do not force the read of the type defs themselves.
1244
    member AsArrayOfPreTypeDefs: ILPreTypeDef[]
L
latkin 已提交
1245

W
WilliamBerryiii 已提交
1246
    /// Calls to <c>FindByName</c> will result in any laziness in the overall 
L
latkin 已提交
1247 1248 1249
    /// set of ILTypeDefs being read in in addition 
    /// to the details for the type found, but the remaining individual 
    /// type definitions will not be read. 
D
Don Syme 已提交
1250
    member FindByName: string -> ILTypeDef
L
latkin 已提交
1251

D
Don Syme 已提交
1252
/// Represents IL Type Definitions. 
L
latkin 已提交
1253 1254
and [<NoComparison; NoEquality>]
    ILTypeDef =  
D
Don Syme 已提交
1255

1256
    /// Functional creation of a value, using delayed reading via a metadata index, for ilread.fs
D
Don Syme 已提交
1257 1258
    new: name: string * attributes: TypeAttributes * layout: ILTypeDefLayout * implements: ILTypes * genericParams: ILGenericParameterDefs * 
          extends: ILType option * methods: ILMethodDefs * nestedTypes: ILTypeDefs * fields: ILFieldDefs * methodImpls: ILMethodImplDefs * 
1259
          events: ILEventDefs * properties: ILPropertyDefs * securityDeclsStored: ILSecurityDeclsStored * customAttrsStored: ILAttributesStored * metadataIndex: int32 -> ILTypeDef
D
Don Syme 已提交
1260

1261 1262 1263 1264
    /// Functional creation of a value, immediate
    new: name: string * attributes: TypeAttributes * layout: ILTypeDefLayout * implements: ILTypes * genericParams: ILGenericParameterDefs * 
          extends: ILType option * methods: ILMethodDefs * nestedTypes: ILTypeDefs * fields: ILFieldDefs * methodImpls: ILMethodImplDefs * 
          events: ILEventDefs * properties: ILPropertyDefs * securityDecls: ILSecurityDecls * customAttrs: ILAttributes -> ILTypeDef
D
Don Syme 已提交
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279

    member Name: string  
    member Attributes: TypeAttributes
    member GenericParams: ILGenericParameterDefs
    member Layout: ILTypeDefLayout
    member NestedTypes: ILTypeDefs
    member Implements: ILTypes
    member Extends: ILType option
    member Methods: ILMethodDefs
    member SecurityDecls: ILSecurityDecls
    member Fields: ILFieldDefs
    member MethodImpls: ILMethodImplDefs
    member Events: ILEventDefs
    member Properties: ILPropertyDefs
    member CustomAttrs: ILAttributes
D
Don Syme 已提交
1280 1281 1282 1283 1284 1285
    member IsClass: bool
    member IsStruct: bool
    member IsInterface: bool
    member IsEnum: bool
    member IsDelegate: bool
    member IsStructOrEnum: bool
A
Avi Avni 已提交
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295
    member Access: ILTypeDefAccess
    member IsAbstract: bool
    member IsSealed: bool
    member IsSerializable: bool
    /// Class or interface generated for COM interop. 
    member IsComInterop: bool
    member IsSpecialName: bool
    /// Some classes are marked "HasSecurity" even if there are no permissions attached, 
    /// e.g. if they use SuppressUnmanagedCodeSecurityAttribute 
    member HasSecurity: bool
D
Don Syme 已提交
1296
    member Encoding: ILDefaultPInvokeEncoding
D
Don Syme 已提交
1297

A
Avi Avni 已提交
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
    member WithAccess: ILTypeDefAccess -> ILTypeDef
    member WithNestedAccess: ILMemberAccess -> ILTypeDef
    member WithSealed: bool -> ILTypeDef
    member WithSerializable: bool -> ILTypeDef
    member WithAbstract: bool -> ILTypeDef
    member WithImport: bool -> ILTypeDef
    member WithHasSecurity: bool -> ILTypeDef
    member WithLayout: ILTypeDefLayout -> ILTypeDef
    member WithKind: ILTypeDefKind -> ILTypeDef
    member WithEncoding: ILDefaultPInvokeEncoding -> ILTypeDef
    member WithSpecialName: bool -> ILTypeDef
    member WithInitSemantics: ILTypeInit -> ILTypeDef
L
latkin 已提交
1310

1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321
    /// Functional update
    member With: ?name: string * ?attributes: TypeAttributes * ?layout: ILTypeDefLayout *  ?implements: ILTypes * 
                 ?genericParams:ILGenericParameterDefs * ?extends:ILType option * ?methods:ILMethodDefs * 
                 ?nestedTypes:ILTypeDefs * ?fields: ILFieldDefs * ?methodImpls:ILMethodImplDefs * ?events:ILEventDefs * 
                 ?properties:ILPropertyDefs * ?customAttrs:ILAttributes * ?securityDecls: ILSecurityDecls -> ILTypeDef

/// Represents a prefix of information for ILTypeDef.
///
/// The information is enough to perform name resolution for the F# compiler, probe attributes
/// for ExtensionAttribute  etc.  This is key to the on-demand exploration of .NET metadata.
/// This information has to be "Goldilocks" - not too much, not too little, just right.
1322 1323 1324
and [<NoEquality; NoComparison>] ILPreTypeDef = 
    abstract Namespace: string list
    abstract Name: string
1325
    /// Realise the actual full typedef
1326 1327 1328 1329 1330 1331
    abstract GetTypeDef : unit -> ILTypeDef


and [<NoEquality; NoComparison; Sealed>] ILPreTypeDefImpl =
    interface ILPreTypeDef

1332 1333 1334 1335 1336 1337 1338 1339 1340

and [<Sealed>] ILTypeDefStored 

val mkILPreTypeDef : ILTypeDef -> ILPreTypeDef
val mkILPreTypeDefComputed : string list * string * (unit -> ILTypeDef) -> ILPreTypeDef
val mkILPreTypeDefRead : string list * string * int32 * ILTypeDefStored -> ILPreTypeDef
val mkILTypeDefReader: (int32 -> ILTypeDef) -> ILTypeDefStored

[<NoEquality; NoComparison; Sealed>]
L
latkin 已提交
1341
type ILNestedExportedTypes =
D
Don Syme 已提交
1342
    member AsList: ILNestedExportedType  list
L
latkin 已提交
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371

/// "Classes Elsewhere" - classes in auxiliary modules.
///
/// Manifests include declarations for all the classes in an 
/// assembly, regardless of which module they are in.
///
/// The ".class extern" construct describes so-called exported types -- 
/// these are public classes defined in the auxiliary modules of this assembly,
/// i.e. modules other than the manifest-carrying module. 
/// 
/// For example, if you have a two-module 
/// assembly (A.DLL and B.DLL), and the manifest resides in the A.DLL, 
/// then in the manifest all the public classes declared in B.DLL should
/// be defined as exported types, i.e., as ".class extern". The public classes 
/// defined in A.DLL should not be defined as ".class extern" -- they are 
/// already available in the manifest-carrying module. The union of all 
/// public classes defined in the manifest-carrying module and all 
/// exported types defined there is the set of all classes exposed by 
/// this assembly. Thus, by analysing the metadata of the manifest-carrying 
/// module of an assembly, you can identify all the classes exposed by 
/// this assembly, and where to find them.
///
/// Nested classes found in external modules should also be located in 
/// this table, suitably nested inside another "ILExportedTypeOrForwarder"
/// definition.

/// these are only found in the "Nested" field of ILExportedTypeOrForwarder objects 
// REVIEW: fold this into ILExportedTypeOrForwarder. There's not much value in keeping these distinct
and ILNestedExportedType =
D
Don Syme 已提交
1372 1373 1374
    { Name: string
      Access: ILMemberAccess
      Nested: ILNestedExportedTypes
1375 1376 1377
      CustomAttrsStored: ILAttributesStored
      MetadataIndex: int32 } 
    member CustomAttrs: ILAttributes
L
latkin 已提交
1378 1379 1380 1381

/// these are only found in the ILExportedTypesAndForwarders table in the manifest 
[<NoComparison; NoEquality>]
type ILExportedTypeOrForwarder =
D
Don Syme 已提交
1382
    { ScopeRef: ILScopeRef
L
latkin 已提交
1383
      /// [Namespace.]Name
D
Don Syme 已提交
1384
      Name: string
A
Avi Avni 已提交
1385
      Attributes: TypeAttributes
D
Don Syme 已提交
1386
      Nested: ILNestedExportedTypes
1387 1388
      CustomAttrsStored: ILAttributesStored
      MetadataIndex: int32 }
A
Avi Avni 已提交
1389 1390
    member Access: ILTypeDefAccess
    member IsForwarder: bool
1391
    member CustomAttrs: ILAttributes
L
latkin 已提交
1392 1393 1394 1395

[<NoEquality; NoComparison>]
[<Sealed>]
type ILExportedTypesAndForwarders =
D
Don Syme 已提交
1396
    member AsList: ILExportedTypeOrForwarder  list
L
latkin 已提交
1397 1398 1399 1400 1401 1402 1403 1404

[<RequireQualifiedAccess>]
type ILResourceAccess = 
    | Public 
    | Private 

[<RequireQualifiedAccess>]
type ILResourceLocation = 
1405 1406 1407
    internal
    /// Represents a manifest resource that can be read or written to a PE file
    | Local of ReadOnlyByteMemory
1408 1409

    /// Represents a manifest resource in an associated file
L
latkin 已提交
1410
    | File of ILModuleRef * int32
1411 1412

    /// Represents a manifest resource in a different assembly
L
latkin 已提交
1413 1414 1415
    | Assembly of ILAssemblyRef

/// "Manifest ILResources" are chunks of resource data, being one of:
W
WilliamBerryiii 已提交
1416 1417
///   - the data section of the current module (byte[] of resource given directly).
///   - in an external file in this assembly (offset given in the ILResourceLocation field). 
L
latkin 已提交
1418 1419
///   - as a resources in another assembly of the same name.  
type ILResource =
D
Don Syme 已提交
1420 1421 1422
    { Name: string
      Location: ILResourceLocation
      Access: ILResourceAccess
1423 1424
      CustomAttrsStored: ILAttributesStored
      MetadataIndex: int32 }
1425 1426

    /// Read the bytes from a resource local to an assembly. Will fail for non-local resources.
1427
    member internal GetBytes : unit -> ReadOnlyByteMemory
L
latkin 已提交
1428

1429
    member CustomAttrs: ILAttributes
L
latkin 已提交
1430

W
WilliamBerryiii 已提交
1431
/// Table of resources in a module.
L
latkin 已提交
1432 1433 1434
[<NoEquality; NoComparison>]
[<Sealed>]
type ILResources =
D
Don Syme 已提交
1435
    member AsList: ILResource  list
L
latkin 已提交
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447


[<RequireQualifiedAccess>]
type ILAssemblyLongevity =
    | Unspecified
    | Library
    | PlatformAppDomain
    | PlatformProcess
    | PlatformSystem

/// The main module of an assembly is a module plus some manifest information.
type ILAssemblyManifest = 
D
Don Syme 已提交
1448
    { Name: string
W
WilliamBerryiii 已提交
1449
      /// This is the ID of the algorithm used for the hashes of auxiliary 
L
latkin 已提交
1450
      /// files in the assembly.   These hashes are stored in the 
W
WilliamBerryiii 已提交
1451 1452 1453
      /// <c>ILModuleRef.Hash</c> fields of this assembly. These are not 
      /// cryptographic hashes: they are simple file hashes. The algorithm 
      /// is normally <c>0x00008004</c> indicating the SHA1 hash algorithm.  
D
Don Syme 已提交
1454
      AuxModuleHashAlgorithm: int32 
1455
      SecurityDeclsStored: ILSecurityDeclsStored
L
latkin 已提交
1456 1457 1458 1459 1460
      /// This is the public key used to sign this 
      /// assembly (the signature itself is stored elsewhere: see the 
      /// binary format, and may not have been written if delay signing 
      /// is used).  (member Name, member PublicKey) forms the full 
      /// public name of the assembly.  
D
Don Syme 已提交
1461 1462 1463
      PublicKey: byte[] option  
      Version: ILVersionInfo option
      Locale: string option
1464
      CustomAttrsStored: ILAttributesStored
D
Don Syme 已提交
1465 1466 1467 1468 1469
      AssemblyLongevity: ILAssemblyLongevity 
      DisableJitOptimizations: bool
      JitTracking: bool
      IgnoreSymbolStoreSequencePoints: bool
      Retargetable: bool
1470
      /// Records the types implemented by this assembly in auxiliary 
L
latkin 已提交
1471
      /// modules. 
D
Don Syme 已提交
1472
      ExportedTypes: ILExportedTypesAndForwarders
L
latkin 已提交
1473
      /// Records whether the entrypoint resides in another module. 
D
Don Syme 已提交
1474
      EntrypointElsewhere: ILModuleRef option
1475
      MetadataIndex: int32
L
latkin 已提交
1476
    } 
1477 1478
    member CustomAttrs: ILAttributes
    member SecurityDecls: ILSecurityDecls
L
latkin 已提交
1479
    
1480 1481 1482 1483 1484 1485 1486 1487 1488

[<RequireQualifiedAccess>]
type ILNativeResource = 
    /// Represents a native resource to be read from the PE file
    | In of fileName: string * linkedResourceBase: int * linkedResourceStart: int * linkedResourceLength: int

    /// Represents a native resource to be written in an output file
    | Out of unlinkedResource: byte[]

L
latkin 已提交
1489 1490 1491 1492 1493 1494
/// One module in the "current" assembly, either a main-module or
/// an auxiliary module.  The main module will have a manifest.
///
/// An assembly is built by joining together a "main" module plus 
/// several auxiliary modules. 
type ILModuleDef = 
D
Don Syme 已提交
1495 1496 1497
    { Manifest: ILAssemblyManifest option
      Name: string
      TypeDefs: ILTypeDefs
D
Don Syme 已提交
1498 1499
      SubsystemVersion: int * int
      UseHighEntropyVA: bool
D
Don Syme 已提交
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511
      SubSystemFlags: int32
      IsDLL: bool
      IsILOnly: bool
      Platform: ILPlatform option
      StackReserveSize: int32 option
      Is32Bit: bool
      Is32BitPreferred: bool
      Is64Bit: bool
      VirtualAlignment: int32
      PhysicalAlignment: int32
      ImageBase: int32
      MetadataVersion: string
1512
      Resources: ILResources 
1513
      /// e.g. win86 resources, as the exact contents of a .res or .obj file. Must be unlinked manually.
1514 1515 1516
      NativeResources: ILNativeResource list
      CustomAttrsStored: ILAttributesStored
      MetadataIndex: int32 }
L
latkin 已提交
1517
    member ManifestOfAssembly: ILAssemblyManifest 
D
Don Syme 已提交
1518
    member HasManifest: bool
1519
    member CustomAttrs: ILAttributes
L
latkin 已提交
1520 1521 1522 1523 1524 1525

/// Find the method definition corresponding to the given property or 
/// event operation. These are always in the same class as the property 
/// or event. This is useful especially if your code is not using the Ilbind 
/// API to bind references. 
val resolveILMethodRef: ILTypeDef -> ILMethodRef -> ILMethodDef
1526
val resolveILMethodRefWithRescope: (ILType -> ILType) -> ILTypeDef -> ILMethodRef -> ILMethodDef
L
latkin 已提交
1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542

// ------------------------------------------------------------------ 
// Type Names
//
// The name of a type stored in the Name field is as follows:
//   - For outer types it is, for example, System.String, i.e.
//     the namespace followed by the type name.
//   - For nested types, it is simply the type name.  The namespace
//     must be gleaned from the context in which the nested type
//     lies.
// ------------------------------------------------------------------ 

val splitNamespace: string -> string list

val splitNamespaceToArray: string -> string[]

W
WilliamBerryiii 已提交
1543
/// The <c>splitILTypeName</c> utility helps you split a string representing
L
latkin 已提交
1544 1545 1546 1547 1548 1549 1550 1551
/// a type name into the leading namespace elements (if any), the
/// names of any nested types and the type name itself.  This function
/// memoizes and interns the splitting of the namespace portion of
/// the type name. 
val splitILTypeName: string -> string list * string

val splitILTypeNameWithPossibleStaticArguments: string -> string[] * string

W
WilliamBerryiii 已提交
1552
/// <c>splitTypeNameRight</c> is like <c>splitILTypeName</c> except the 
L
latkin 已提交
1553 1554 1555 1556
/// namespace is kept as a whole string, rather than split at dots.
val splitTypeNameRight: string -> string option * string

val typeNameForGlobalFunctions: string
1557

L
latkin 已提交
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567
val isTypeNameForGlobalFunctions: string -> bool

// ====================================================================
// PART 2
// 
// Making metadata.  Where no explicit constructor
// is given, you should create the concrete datatype directly, 
// e.g. by filling in all appropriate record fields.
// ==================================================================== *)

1568
/// A table of common references to items in primary assembly (System.Runtime or mscorlib).
W
WilliamBerryiii 已提交
1569 1570
/// If a particular version of System.Runtime.dll has been loaded then you should 
/// reference items from it via an ILGlobals for that specific version built using mkILGlobals. 
1571
[<NoEquality; NoComparison; Class>]
L
latkin 已提交
1572
type ILGlobals = 
D
Don Syme 已提交
1573 1574
    member primaryAssemblyScopeRef: ILScopeRef
    member primaryAssemblyName: string
1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597
    member typ_Object: ILType
    member typ_String: ILType
    member typ_Type: ILType
    member typ_Array: ILType
    member typ_IntPtr: ILType
    member typ_UIntPtr: ILType
    member typ_Byte: ILType
    member typ_Int16: ILType
    member typ_Int32: ILType
    member typ_Int64: ILType
    member typ_SByte: ILType
    member typ_UInt16: ILType
    member typ_UInt32: ILType
    member typ_UInt64: ILType
    member typ_Single: ILType
    member typ_Double: ILType
    member typ_Bool: ILType
    member typ_Char: ILType


/// Build the table of commonly used references given functions to find types in system assemblies
val mkILGlobals: ILScopeRef -> ILGlobals

D
Don Syme 已提交
1598
val EcmaMscorlibILGlobals: ILGlobals
L
latkin 已提交
1599 1600

/// When writing a binary the fake "toplevel" type definition (called <Module>)
W
WilliamBerryiii 已提交
1601 1602
/// must come first. This function puts it first, and creates it in the returned 
/// list as an empty typedef if it doesn't already exist.
L
latkin 已提交
1603 1604
val destTypeDefsWithGlobalFunctionsFirst: ILGlobals -> ILTypeDefs -> ILTypeDef list

W
WilliamBerryiii 已提交
1605
/// Not all custom attribute data can be decoded without binding types.  In particular 
L
latkin 已提交
1606 1607 1608 1609 1610 1611 1612 1613
/// enums must be bound in order to discover the size of the underlying integer. 
/// The following assumes enums have size int32. 
val decodeILAttribData: 
    ILGlobals -> 
    ILAttribute -> 
      ILAttribElem list *  (* fixed args *)
      ILAttributeNamedArg list (* named args: values and flags indicating if they are fields or properties *) 

W
WilliamBerryiii 已提交
1614
/// Generate simple references to assemblies and modules.
1615
val mkSimpleAssemblyRef: string -> ILAssemblyRef
1616

L
latkin 已提交
1617 1618 1619 1620
val mkSimpleModRef: string -> ILModuleRef

val mkILTyvarTy: uint16 -> ILType

W
WilliamBerryiii 已提交
1621
/// Make type refs.
L
latkin 已提交
1622 1623 1624 1625 1626
val mkILNestedTyRef: ILScopeRef * string list * string -> ILTypeRef
val mkILTyRef: ILScopeRef * string -> ILTypeRef
val mkILTyRefInTyRef: ILTypeRef * string -> ILTypeRef

type ILGenericArgsList = ILType list
1627

W
WilliamBerryiii 已提交
1628
/// Make type specs.
L
latkin 已提交
1629 1630 1631
val mkILNonGenericTySpec: ILTypeRef -> ILTypeSpec
val mkILTySpec: ILTypeRef * ILGenericArgsList -> ILTypeSpec

W
WilliamBerryiii 已提交
1632
/// Make types.
L
latkin 已提交
1633 1634 1635 1636 1637 1638 1639 1640 1641 1642
val mkILTy: ILBoxity -> ILTypeSpec -> ILType
val mkILNamedTy: ILBoxity -> ILTypeRef -> ILGenericArgsList -> ILType
val mkILBoxedTy: ILTypeRef -> ILGenericArgsList -> ILType
val mkILValueTy: ILTypeRef -> ILGenericArgsList -> ILType
val mkILNonGenericBoxedTy: ILTypeRef -> ILType
val mkILNonGenericValueTy: ILTypeRef -> ILType
val mkILArrTy: ILType * ILArrayShape -> ILType
val mkILArr1DTy: ILType -> ILType
val isILArrTy: ILType -> bool
val destILArrTy: ILType -> ILArrayShape * ILType 
D
Don Syme 已提交
1643
val mkILBoxedType: ILTypeSpec -> ILType
L
latkin 已提交
1644

W
WilliamBerryiii 已提交
1645
/// Make method references and specs.
L
latkin 已提交
1646 1647 1648 1649 1650
val mkILMethRef: ILTypeRef * ILCallingConv * string * int * ILType list * ILType -> ILMethodRef
val mkILMethSpec: ILMethodRef * ILBoxity * ILGenericArgsList * ILGenericArgsList -> ILMethodSpec
val mkILMethSpecForMethRefInTy: ILMethodRef * ILType * ILGenericArgsList -> ILMethodSpec
val mkILMethSpecInTy: ILType * ILCallingConv * string * ILType list * ILType * ILGenericArgsList -> ILMethodSpec

W
WilliamBerryiii 已提交
1651
/// Construct references to methods on a given type .
L
latkin 已提交
1652 1653
val mkILNonGenericMethSpecInTy: ILType * ILCallingConv * string * ILType list * ILType -> ILMethodSpec

W
WilliamBerryiii 已提交
1654
/// Construct references to instance methods.
L
latkin 已提交
1655 1656
val mkILInstanceMethSpecInTy: ILType * string * ILType list * ILType * ILGenericArgsList -> ILMethodSpec

W
WilliamBerryiii 已提交
1657
/// Construct references to instance methods.
L
latkin 已提交
1658 1659
val mkILNonGenericInstanceMethSpecInTy: ILType * string * ILType list * ILType -> ILMethodSpec

W
WilliamBerryiii 已提交
1660
/// Construct references to static methods.
L
latkin 已提交
1661 1662
val mkILStaticMethSpecInTy: ILType * string * ILType list * ILType * ILGenericArgsList -> ILMethodSpec

W
WilliamBerryiii 已提交
1663
/// Construct references to static, non-generic methods.
L
latkin 已提交
1664 1665
val mkILNonGenericStaticMethSpecInTy: ILType * string * ILType list * ILType -> ILMethodSpec

W
WilliamBerryiii 已提交
1666
/// Construct references to constructors.
L
latkin 已提交
1667 1668
val mkILCtorMethSpecForTy: ILType * ILType list -> ILMethodSpec

W
WilliamBerryiii 已提交
1669
/// Construct references to fields.
L
latkin 已提交
1670 1671 1672 1673 1674 1675
val mkILFieldRef: ILTypeRef * string * ILType -> ILFieldRef
val mkILFieldSpec: ILFieldRef * ILType -> ILFieldSpec
val mkILFieldSpecInTy: ILType * string * ILType -> ILFieldSpec

val mkILCallSig: ILCallingConv * ILType list * ILType -> ILCallingSignature

1676
/// Make generalized versions of possibly-generic types, e.g. Given the ILTypeDef for List, return the type "List<T>".
L
latkin 已提交
1677
val mkILFormalBoxedTy: ILTypeRef -> ILGenericParameterDef list -> ILType
D
Don Syme 已提交
1678
val mkILFormalNamedTy: ILBoxity -> ILTypeRef -> ILGenericParameterDef list -> ILType
L
latkin 已提交
1679 1680

val mkILFormalTypars: ILType list -> ILGenericParameterDefs
1681
val mkILFormalGenericArgs: int -> ILGenericParameterDefs -> ILGenericArgsList
D
Don Syme 已提交
1682
val mkILSimpleTypar: string -> ILGenericParameterDef
1683

W
WilliamBerryiii 已提交
1684
/// Make custom attributes.
L
latkin 已提交
1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698
val mkILCustomAttribMethRef: 
    ILGlobals 
    -> ILMethodSpec 
       * ILAttribElem list (* fixed args: values and implicit types *) 
       * ILAttributeNamedArg list (* named args: values and flags indicating if they are fields or properties *) 
      -> ILAttribute

val mkILCustomAttribute: 
    ILGlobals 
    -> ILTypeRef * ILType list * 
       ILAttribElem list (* fixed args: values and implicit types *) * 
       ILAttributeNamedArg list (* named args: values and flags indicating if they are fields or properties *) 
         -> ILAttribute

1699 1700
val getCustomAttrData: ILGlobals -> ILAttribute -> byte[]

D
Don Syme 已提交
1701
val mkPermissionSet: ILGlobals -> ILSecurityAction * (ILTypeRef * (string * ILType * ILAttribElem) list) list -> ILSecurityDecl
L
latkin 已提交
1702 1703 1704

/// Making code.
val generateCodeLabel: unit -> ILCodeLabel
D
Don Syme 已提交
1705
val formatCodeLabel: ILCodeLabel -> string
L
latkin 已提交
1706 1707

/// Make some code that is a straight line sequence of instructions. 
W
WilliamBerryiii 已提交
1708
/// The function will add a "return" if the last instruction is not an exiting instruction.
L
latkin 已提交
1709 1710 1711 1712
val nonBranchingInstrsToCode: ILInstr list -> ILCode 

/// Helpers for codegen: scopes for allocating new temporary variables.
type ILLocalsAllocator =
D
Don Syme 已提交
1713 1714 1715
    new: preAlloc: int -> ILLocalsAllocator
    member AllocLocal: ILLocal -> uint16
    member Close: unit -> ILLocal list
L
latkin 已提交
1716

W
WilliamBerryiii 已提交
1717
/// Derived functions for making some common patterns of instructions.
L
latkin 已提交
1718 1719 1720 1721
val mkNormalCall: ILMethodSpec -> ILInstr
val mkNormalCallvirt: ILMethodSpec -> ILInstr
val mkNormalCallconstraint: ILType * ILMethodSpec -> ILInstr
val mkNormalNewobj: ILMethodSpec -> ILInstr
D
Don Syme 已提交
1722
val mkCallBaseConstructor: ILType * ILType list -> ILInstr list
L
latkin 已提交
1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743
val mkNormalStfld: ILFieldSpec -> ILInstr
val mkNormalStsfld: ILFieldSpec -> ILInstr
val mkNormalLdsfld: ILFieldSpec -> ILInstr
val mkNormalLdfld: ILFieldSpec -> ILInstr
val mkNormalLdflda: ILFieldSpec -> ILInstr
val mkNormalLdobj: ILType -> ILInstr
val mkNormalStobj: ILType -> ILInstr 
val mkLdcInt32: int32 -> ILInstr
val mkLdarg0: ILInstr
val mkLdloc: uint16 -> ILInstr
val mkStloc: uint16 -> ILInstr
val mkLdarg: uint16 -> ILInstr

val andTailness: ILTailcall -> bool -> ILTailcall

/// Derived functions for making return, parameter and local variable
/// objects for use in method definitions.
val mkILParam: string option * ILType -> ILParameter
val mkILParamAnon: ILType -> ILParameter
val mkILParamNamed: string * ILType -> ILParameter
val mkILReturn: ILType -> ILReturn
L
latkin 已提交
1744
val mkILLocal: ILType -> (string * int * int) option -> ILLocal
L
latkin 已提交
1745

W
WilliamBerryiii 已提交
1746
/// Make a formal generic parameters.
L
latkin 已提交
1747 1748
val mkILEmptyGenericParams: ILGenericParameterDefs

W
WilliamBerryiii 已提交
1749
/// Make method definitions.
L
latkin 已提交
1750 1751
val mkILMethodBody: initlocals:bool * ILLocals * int * ILCode * ILSourceMarker option -> ILMethodBody
val mkMethodBody: bool * ILLocals * int * ILCode * ILSourceMarker option -> MethodBody
1752 1753 1754
val methBodyNotAvailable: ILLazyMethodBody 
val methBodyAbstract: ILLazyMethodBody 
val methBodyNative: ILLazyMethodBody 
L
latkin 已提交
1755 1756 1757 1758 1759 1760

val mkILCtor: ILMemberAccess * ILParameter list * MethodBody -> ILMethodDef
val mkILClassCtor: MethodBody -> ILMethodDef
val mkILNonGenericEmptyCtor: ILSourceMarker option -> ILType -> ILMethodDef
val mkILStaticMethod: ILGenericParameterDefs * string * ILMemberAccess * ILParameter list * ILReturn * MethodBody -> ILMethodDef
val mkILNonGenericStaticMethod: string * ILMemberAccess * ILParameter list * ILReturn * MethodBody -> ILMethodDef
A
Avi Avni 已提交
1761 1762
val mkILGenericVirtualMethod: string * ILMemberAccess  * ILGenericParameterDefs * ILParameter list * ILReturn * MethodBody -> ILMethodDef
val mkILGenericNonVirtualMethod: string * ILMemberAccess  * ILGenericParameterDefs * ILParameter list * ILReturn * MethodBody -> ILMethodDef
L
latkin 已提交
1763
val mkILNonGenericVirtualMethod: string * ILMemberAccess * ILParameter list * ILReturn * MethodBody -> ILMethodDef
A
Avi Avni 已提交
1764
val mkILNonGenericInstanceMethod: string * ILMemberAccess  * ILParameter list * ILReturn * MethodBody -> ILMethodDef
L
latkin 已提交
1765 1766


W
WilliamBerryiii 已提交
1767
/// Make field definitions.
L
latkin 已提交
1768 1769 1770 1771
val mkILInstanceField: string * ILType * ILFieldInit option * ILMemberAccess -> ILFieldDef
val mkILStaticField: string * ILType * ILFieldInit option * byte[] option * ILMemberAccess -> ILFieldDef
val mkILLiteralField: string * ILType * ILFieldInit * byte[] option * ILMemberAccess -> ILFieldDef

W
WilliamBerryiii 已提交
1772
/// Make a type definition.
L
latkin 已提交
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782
val mkILGenericClass: string * ILTypeDefAccess * ILGenericParameterDefs * ILType * ILType list * ILMethodDefs * ILFieldDefs * ILTypeDefs * ILPropertyDefs * ILEventDefs * ILAttributes * ILTypeInit -> ILTypeDef
val mkILSimpleClass: ILGlobals -> string * ILTypeDefAccess * ILMethodDefs * ILFieldDefs * ILTypeDefs * ILPropertyDefs * ILEventDefs * ILAttributes * ILTypeInit  -> ILTypeDef
val mkILTypeDefForGlobalFunctions: ILGlobals -> ILMethodDefs * ILFieldDefs -> ILTypeDef

/// Make a type definition for a value type used to point to raw data.
/// These are useful when generating array initialization code 
/// according to the 
///   ldtoken    field valuetype '<PrivateImplementationDetails>'/'$$struct0x6000127-1' '<PrivateImplementationDetails>'::'$$method0x6000127-1'
///   call       void System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class System.Array,valuetype System.RuntimeFieldHandle)
/// idiom.
1783
val mkRawDataValueTypeDef:  ILType -> string * size:int32 * pack:uint16 -> ILTypeDef
L
latkin 已提交
1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799

/// Injecting code into existing code blocks.  A branch will
/// be added from the given instructions to the (unique) entry of
/// the code, and the first instruction will be the new entry
/// of the method.  The instructions should be non-branching.

val prependInstrsToCode: ILInstr list -> ILCode -> ILCode
val prependInstrsToMethod: ILInstr list -> ILMethodDef -> ILMethodDef

/// Injecting initialization code into a class.
/// Add some code to the end of the .cctor for a type.  Create a .cctor
/// if one doesn't exist already.
val prependInstrsToClassCtor: ILInstr list -> ILSourceMarker option -> ILTypeDef -> ILTypeDef

/// Derived functions for making some simple constructors
val mkILStorageCtor: ILSourceMarker option * ILInstr list * ILType * (string * ILType) list * ILMemberAccess -> ILMethodDef
D
Don Syme 已提交
1800 1801
val mkILSimpleStorageCtor: ILSourceMarker option * ILTypeSpec option * ILType * ILParameter list * (string * ILType) list * ILMemberAccess -> ILMethodDef
val mkILSimpleStorageCtorWithParamNames: ILSourceMarker option * ILTypeSpec option * ILType * ILParameter list * (string * string * ILType) list * ILMemberAccess -> ILMethodDef
L
latkin 已提交
1802

A
Avi Avni 已提交
1803
val mkILDelegateMethods: ILMemberAccess -> ILGlobals -> ILType * ILType -> ILParameter list * ILReturn -> ILMethodDef list
L
latkin 已提交
1804 1805

/// Given a delegate type definition which lies in a particular scope, 
W
WilliamBerryiii 已提交
1806
/// make a reference to its constructor.
L
latkin 已提交
1807 1808 1809 1810 1811 1812 1813
val mkCtorMethSpecForDelegate: ILGlobals -> ILType * bool -> ILMethodSpec 

/// The toplevel "class" for a module or assembly.
val mkILTypeForGlobalFunctions: ILScopeRef -> ILType

/// Making tables of custom attributes, etc.
val mkILCustomAttrs: ILAttribute list -> ILAttributes
1814
val mkILCustomAttrsFromArray: ILAttribute[] -> ILAttributes
1815 1816
val storeILCustomAttrs: ILAttributes -> ILAttributesStored
val mkILCustomAttrsReader: (int32 -> ILAttribute[]) -> ILAttributesStored
L
latkin 已提交
1817 1818
val emptyILCustomAttrs: ILAttributes

D
Don Syme 已提交
1819 1820
val mkILSecurityDecls: ILSecurityDecl list -> ILSecurityDecls
val emptyILSecurityDecls: ILSecurityDecls
1821 1822
val storeILSecurityDecls: ILSecurityDecls -> ILSecurityDeclsStored
val mkILSecurityDeclsReader: (int32 -> ILSecurityDecl[]) -> ILSecurityDeclsStored
L
latkin 已提交
1823

D
Don Syme 已提交
1824 1825
val mkMethBodyAux: MethodBody -> ILLazyMethodBody
val mkMethBodyLazyAux: Lazy<MethodBody> -> ILLazyMethodBody
L
latkin 已提交
1826 1827 1828 1829 1830 1831 1832 1833 1834 1835

val mkILEvents: ILEventDef list -> ILEventDefs
val mkILEventsLazy: Lazy<ILEventDef list> -> ILEventDefs
val emptyILEvents: ILEventDefs

val mkILProperties: ILPropertyDef list -> ILPropertyDefs
val mkILPropertiesLazy: Lazy<ILPropertyDef list> -> ILPropertyDefs
val emptyILProperties: ILPropertyDefs

val mkILMethods: ILMethodDef list -> ILMethodDefs
1836 1837
val mkILMethodsFromArray: ILMethodDef[] -> ILMethodDefs
val mkILMethodsComputed: (unit -> ILMethodDef[]) -> ILMethodDefs
L
latkin 已提交
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847
val emptyILMethods: ILMethodDefs

val mkILFields: ILFieldDef list -> ILFieldDefs
val mkILFieldsLazy: Lazy<ILFieldDef list> -> ILFieldDefs
val emptyILFields: ILFieldDefs

val mkILMethodImpls: ILMethodImplDef list -> ILMethodImplDefs
val mkILMethodImplsLazy: Lazy<ILMethodImplDef list> -> ILMethodImplDefs
val emptyILMethodImpls: ILMethodImplDefs

1848 1849
val mkILTypeDefs: ILTypeDef list -> ILTypeDefs
val mkILTypeDefsFromArray: ILTypeDef[] -> ILTypeDefs
L
latkin 已提交
1850 1851 1852 1853 1854 1855 1856 1857 1858 1859
val emptyILTypeDefs: ILTypeDefs

/// Create table of types which is loaded/computed on-demand, and whose individual 
/// elements are also loaded/computed on-demand. Any call to tdefs.AsList will 
/// result in the laziness being forced.  Operations can examine the
/// custom attributes and name of each type in order to decide whether
/// to proceed with examining the other details of the type.
/// 
/// Note that individual type definitions may contain further delays 
/// in their method, field and other tables. 
1860
val mkILTypeDefsComputed: (unit -> ILPreTypeDef[]) -> ILTypeDefs
L
latkin 已提交
1861 1862
val addILTypeDef: ILTypeDef -> ILTypeDefs -> ILTypeDefs

A
Avi Avni 已提交
1863
val mkTypeForwarder: ILScopeRef -> string -> ILNestedExportedTypes -> ILAttributes -> ILTypeDefAccess -> ILExportedTypeOrForwarder
L
latkin 已提交
1864 1865 1866 1867 1868 1869 1870 1871
val mkILNestedExportedTypes: ILNestedExportedType list -> ILNestedExportedTypes
val mkILNestedExportedTypesLazy: Lazy<ILNestedExportedType list> -> ILNestedExportedTypes

val mkILExportedTypes: ILExportedTypeOrForwarder list -> ILExportedTypesAndForwarders
val mkILExportedTypesLazy: Lazy<ILExportedTypeOrForwarder list> ->   ILExportedTypesAndForwarders

val mkILResources: ILResource list -> ILResources

W
WilliamBerryiii 已提交
1872
/// Making modules.
D
Don Syme 已提交
1873
val mkILSimpleModule: assemblyName:string -> moduleName:string -> dll:bool -> subsystemVersion: (int * int) -> useHighEntropyVA: bool -> ILTypeDefs -> int32 option -> string option -> int -> ILExportedTypesAndForwarders -> string -> ILModuleDef
L
latkin 已提交
1874 1875 1876 1877 1878 1879 1880 1881

/// Generate references to existing type definitions, method definitions
/// etc.  Useful for generating references, e.g. to a  class we're processing
/// Also used to reference type definitions that we've generated.  [ILScopeRef] 
/// is normally ILScopeRef.Local, unless we've generated the ILTypeDef in
/// an auxiliary module or are generating multiple assemblies at 
/// once.

D
Don Syme 已提交
1882 1883 1884
val mkRefForNestedILTypeDef: ILScopeRef -> ILTypeDef list * ILTypeDef -> ILTypeRef
val mkRefForILMethod       : ILScopeRef -> ILTypeDef list * ILTypeDef -> ILMethodDef -> ILMethodRef
val mkRefForILField       : ILScopeRef -> ILTypeDef list * ILTypeDef -> ILFieldDef  -> ILFieldRef
L
latkin 已提交
1885 1886 1887 1888 1889 1890 1891

val mkRefToILMethod: ILTypeRef * ILMethodDef -> ILMethodRef
val mkRefToILField: ILTypeRef * ILFieldDef -> ILFieldRef

val mkRefToILAssembly: ILAssemblyManifest -> ILAssemblyRef
val mkRefToILModule: ILModuleDef -> ILModuleRef

1892
val NoMetadataIdx: int32
L
latkin 已提交
1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914

// -------------------------------------------------------------------- 
// Rescoping.
//
// Given an object O1 referenced from where1 (e.g. O1 binds to some  
// result R when referenced from where1), and given that SR2 resolves to where1 from where2, 
// produce a new O2 for use from where2 (e.g. O2 binds to R from where2)
//
// So, ILScopeRef tells you how to reference the original scope from 
// the new scope. e.g. if ILScopeRef is:
//    [ILScopeRef.Local] then the object is returned unchanged
//    [ILScopeRef.Module m] then an object is returned 
//                        where all ILScopeRef.Local references 
//                        become ILScopeRef.Module m
//    [ILScopeRef.Assembly m] then an object is returned 
//                         where all ILScopeRef.Local and ILScopeRef.Module references 
//                        become ILScopeRef.Assembly m
// -------------------------------------------------------------------- 

/// Rescoping. The first argument tells the function how to reference the original scope from 
/// the new scope. 
val rescopeILScopeRef: ILScopeRef -> ILScopeRef -> ILScopeRef
1915

L
latkin 已提交
1916 1917 1918
/// Rescoping. The first argument tells the function how to reference the original scope from 
/// the new scope. 
val rescopeILTypeSpec: ILScopeRef -> ILTypeSpec -> ILTypeSpec
1919

L
latkin 已提交
1920 1921 1922
/// Rescoping. The first argument tells the function how to reference the original scope from 
/// the new scope. 
val rescopeILType: ILScopeRef -> ILType -> ILType
1923

L
latkin 已提交
1924 1925 1926
/// Rescoping. The first argument tells the function how to reference the original scope from 
/// the new scope. 
val rescopeILMethodRef: ILScopeRef -> ILMethodRef -> ILMethodRef 
1927

L
latkin 已提交
1928 1929 1930 1931
/// Rescoping. The first argument tells the function how to reference the original scope from 
/// the new scope. 
val rescopeILFieldRef: ILScopeRef -> ILFieldRef -> ILFieldRef

D
Don Syme 已提交
1932 1933 1934
/// Unscoping. Clears every scope information, use for looking up IL method references only.
val unscopeILType: ILType -> ILType

D
Don Syme 已提交
1935
val buildILCode: string -> lab2pc: Dictionary<ILCodeLabel,int> -> instrs:ILInstr[] -> ILExceptionSpec list -> ILLocalDebugInfo list -> ILCode
L
latkin 已提交
1936 1937 1938 1939 1940 1941 1942 1943 1944 1945

/// Instantiate type variables that occur within types and other items. 
val instILTypeAux: int -> ILGenericArgs -> ILType -> ILType

/// Instantiate type variables that occur within types and other items. 
val instILType: ILGenericArgs -> ILType -> ILType

/// This is a 'vendor neutral' way of referencing mscorlib. 
val ecmaPublicKey: PublicKey

W
WilliamBerryiii 已提交
1946
/// Discriminating different important built-in types.
D
desco 已提交
1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963
val isILObjectTy: ILType -> bool
val isILStringTy: ILType -> bool
val isILSByteTy: ILType -> bool
val isILByteTy: ILType -> bool
val isILInt16Ty: ILType -> bool
val isILUInt16Ty: ILType -> bool
val isILInt32Ty: ILType -> bool
val isILUInt32Ty: ILType -> bool
val isILInt64Ty: ILType -> bool
val isILUInt64Ty: ILType -> bool
val isILIntPtrTy: ILType -> bool
val isILUIntPtrTy: ILType -> bool
val isILBoolTy: ILType -> bool
val isILCharTy: ILType -> bool
val isILTypedReferenceTy: ILType -> bool
val isILDoubleTy: ILType -> bool
val isILSingleTy: ILType -> bool
L
latkin 已提交
1964

D
Don Syme 已提交
1965
val sha1HashInt64 : byte[] -> int64
L
latkin 已提交
1966
/// Get a public key token from a public key.
D
Don Syme 已提交
1967
val sha1HashBytes: byte[] -> byte[] (* SHA1 hash *)
L
latkin 已提交
1968 1969 1970 1971 1972 1973 1974 1975

/// Get a version number from a CLR version string, e.g. 1.0.3705.0
val parseILVersion: string -> ILVersionInfo
val formatILVersion: ILVersionInfo -> string
val compareILVersions: ILVersionInfo -> ILVersionInfo -> int

/// Decompose a type definition according to its kind.
type ILEnumInfo =
D
Don Syme 已提交
1976
    { enumValues: (string * ILFieldInit) list  
L
latkin 已提交
1977 1978 1979 1980 1981 1982
      enumType: ILType }

val getTyOfILEnumInfo: ILEnumInfo -> ILType

val computeILEnumInfo: string * ILFieldDefs -> ILEnumInfo

1983
/// A utility type provided for completeness
L
latkin 已提交
1984 1985
[<Sealed>]
type ILEventRef =
D
Don Syme 已提交
1986
    static member Create: ILTypeRef * string -> ILEventRef
1987
    member DeclaringTypeRef: ILTypeRef
L
latkin 已提交
1988 1989
    member Name: string

1990
/// A utility type provided for completeness
L
latkin 已提交
1991 1992
[<Sealed>]
type ILPropertyRef =
D
Don Syme 已提交
1993
     static member Create: ILTypeRef * string -> ILPropertyRef
1994
     member DeclaringTypeRef: ILTypeRef
L
latkin 已提交
1995 1996 1997 1998 1999 2000
     member Name: string
     interface System.IComparable

val runningOnMono: bool

type ILReferences = 
D
Don Syme 已提交
2001 2002
    { AssemblyReferences: ILAssemblyRef list 
      ModuleReferences: ILModuleRef list }
L
latkin 已提交
2003

W
WilliamBerryiii 已提交
2004
/// Find the full set of assemblies referenced by a module.
L
latkin 已提交
2005 2006 2007
val computeILRefs: ILModuleDef -> ILReferences
val emptyILRefs: ILReferences