提交 4b9f397e 编写于 作者: D Don Syme

cleaup whitespace and types

上级 98eec39f
...@@ -3263,8 +3263,8 @@ let cdef_cctorCode2CodeOrCreate tag f cd = ...@@ -3263,8 +3263,8 @@ let cdef_cctorCode2CodeOrCreate tag f cd =
let mdefs = cd.Methods let mdefs = cd.Methods
let cctor = let cctor =
match mdefs.FindByName ".cctor" with match mdefs.FindByName ".cctor" with
| [ mdef ] -> mdef | [mdef] -> mdef
| [ ] -> mkILClassCtor (mkMethodBody (false,emptyILLocals,1,nonBranchingInstrsToCode [ ],tag)) | [] -> mkILClassCtor (mkMethodBody (false,emptyILLocals,1,nonBranchingInstrsToCode [ ],tag))
| _ -> failwith "bad method table: more than one .cctor found" | _ -> failwith "bad method table: more than one .cctor found"
let methods = ILMethodDefs (fun () -> [| yield f cctor; for md in mdefs do if md.Name <> ".cctor" then yield md |]) let methods = ILMethodDefs (fun () -> [| yield f cctor; for md in mdefs do if md.Name <> ".cctor" then yield md |])
...@@ -3458,10 +3458,10 @@ let mkILSimpleClass ilg (nm, access, methods, fields, nestedTypes, props, events ...@@ -3458,10 +3458,10 @@ let mkILSimpleClass ilg (nm, access, methods, fields, nestedTypes, props, events
let mkILTypeDefForGlobalFunctions ilg (methods,fields) = mkILSimpleClass ilg (typeNameForGlobalFunctions, ILTypeDefAccess.Public, methods, fields, emptyILTypeDefs, emptyILProperties, emptyILEvents, emptyILCustomAttrs,ILTypeInit.BeforeField) let mkILTypeDefForGlobalFunctions ilg (methods,fields) = mkILSimpleClass ilg (typeNameForGlobalFunctions, ILTypeDefAccess.Public, methods, fields, emptyILTypeDefs, emptyILProperties, emptyILEvents, emptyILCustomAttrs,ILTypeInit.BeforeField)
let destTypeDefsWithGlobalFunctionsFirst ilg (tdefs: ILTypeDefs) = let destTypeDefsWithGlobalFunctionsFirst ilg (tdefs: ILTypeDefs) =
let l = tdefs.AsArray let l = tdefs.AsList
let top,nontop = l |> Array.partition (fun td -> td.Name = typeNameForGlobalFunctions) let top,nontop = l |> List.partition (fun td -> td.Name = typeNameForGlobalFunctions)
let top2 = if top.Length = 0 then [| mkILTypeDefForGlobalFunctions ilg (emptyILMethods, emptyILFields) |] else top let top2 = if top.Length = 0 then [ mkILTypeDefForGlobalFunctions ilg (emptyILMethods, emptyILFields) ] else top
Array.append top2 nontop top2@nontop
let mkILSimpleModule assname modname dll subsystemVersion useHighEntropyVA tdefs hashalg locale flags exportedTypes metadataVersion = let mkILSimpleModule assname modname dll subsystemVersion useHighEntropyVA tdefs hashalg locale flags exportedTypes metadataVersion =
{ Manifest= { Manifest=
...@@ -5101,8 +5101,8 @@ let resolveILMethodRef td (mref:ILMethodRef) = ...@@ -5101,8 +5101,8 @@ let resolveILMethodRef td (mref:ILMethodRef) =
(md.Parameters,mref.ArgTypes) ||> ILList.lengthsEqAndForall2 (fun p1 p2 -> p1.Type = p2) && (md.Parameters,mref.ArgTypes) ||> ILList.lengthsEqAndForall2 (fun p1 p2 -> p1.Type = p2) &&
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct // REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
md.Return.Type = mref.ReturnType) with md.Return.Type = mref.ReturnType) with
| [ ] -> failwith ("no method named "+nm+" with appropriate argument types found in type "+td.Name); | [] -> failwith ("no method named "+nm+" with appropriate argument types found in type "+td.Name);
| [ mdef ] -> mdef | [mdef] -> mdef
| _ -> failwith ("multiple methods named "+nm+" appear with identical argument types in type "+td.Name) | _ -> failwith ("multiple methods named "+nm+" appear with identical argument types in type "+td.Name)
let mkRefToILModule m = let mkRefToILModule m =
...@@ -5135,4 +5135,4 @@ type ILPropertyRef = ...@@ -5135,4 +5135,4 @@ type ILPropertyRef =
{ prA: ILTypeRef; prB: string } { prA: ILTypeRef; prB: string }
static member Create (a,b) = {prA=a;prB=b} static member Create (a,b) = {prA=a;prB=b}
member x.EnclosingTypeRef = x.prA member x.EnclosingTypeRef = x.prA
member x.Name = x.prB member x.Name = x.prB
\ No newline at end of file
...@@ -1421,7 +1421,7 @@ type ILTypeDefs = ...@@ -1421,7 +1421,7 @@ type ILTypeDefs =
member AsList : ILTypeDef list member AsList : ILTypeDef list
/// Get some information about the type defs, but do not force the read of the type defs themselves /// Get some information about the type defs, but do not force the read of the type defs themselves
member AsArrayOfLazyTypeDefs : (string list * string * ILAttributes * Lazy<ILTypeDef>)[] member AsArrayOfLazyTypeDefs : (string list * string * ILAttributes * Lazy<ILTypeDef>) array
/// Calls to [FindByName] will result in any laziness in the overall /// Calls to [FindByName] will result in any laziness in the overall
/// set of ILTypeDefs being read in in addition /// set of ILTypeDefs being read in in addition
...@@ -1794,7 +1794,7 @@ val EcmaILGlobals : ILGlobals ...@@ -1794,7 +1794,7 @@ val EcmaILGlobals : ILGlobals
/// When writing a binary the fake "toplevel" type definition (called <Module>) /// When writing a binary the fake "toplevel" type definition (called <Module>)
/// must come first. This function puts it first, and creates it in the returned list as an empty typedef if it /// 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. /// doesn't already exist.
val destTypeDefsWithGlobalFunctionsFirst: ILGlobals -> ILTypeDefs -> ILTypeDef[] val destTypeDefsWithGlobalFunctionsFirst: ILGlobals -> ILTypeDefs -> ILTypeDef list
/// Note: not all custom attribute data can be decoded without binding types. In particular /// Note: not all custom attribute data can be decoded without binding types. In particular
/// enums must be bound in order to discover the size of the underlying integer. /// enums must be bound in order to discover the size of the underlying integer.
...@@ -2069,7 +2069,7 @@ val emptyILTypeDefs: ILTypeDefs ...@@ -2069,7 +2069,7 @@ val emptyILTypeDefs: ILTypeDefs
/// ///
/// Note that individual type definitions may contain further delays /// Note that individual type definitions may contain further delays
/// in their method, field and other tables. /// in their method, field and other tables.
val mkILTypeDefsComputed: (unit -> (string list * string * ILAttributes * Lazy<ILTypeDef>)[]) -> ILTypeDefs val mkILTypeDefsComputed: (unit -> (string list * string * ILAttributes * Lazy<ILTypeDef>) array) -> ILTypeDefs
val addILTypeDef: ILTypeDef -> ILTypeDefs -> ILTypeDefs val addILTypeDef: ILTypeDef -> ILTypeDefs -> ILTypeDefs
val mkILNestedExportedTypes: ILNestedExportedType list -> ILNestedExportedTypes val mkILNestedExportedTypes: ILNestedExportedType list -> ILNestedExportedTypes
...@@ -2255,22 +2255,6 @@ val getTyOfILEnumInfo: ILEnumInfo -> ILType ...@@ -2255,22 +2255,6 @@ val getTyOfILEnumInfo: ILEnumInfo -> ILType
val computeILEnumInfo: string * ILFieldDefs -> ILEnumInfo val computeILEnumInfo: string * ILFieldDefs -> ILEnumInfo
val runningOnMono: bool
type ILReferences =
{ AssemblyReferences: ILAssemblyRef list;
ModuleReferences: ILModuleRef list; }
/// Find the full set of assemblies referenced by a module
val computeILRefs: ILModuleDef -> ILReferences
val emptyILRefs: ILReferences
// --------------------------------------------------------------------
// The following functions are used to define an extension to the In reality the only extension is ILX
type ILTypeDefKindExtension<'Extension> = TypeDefKindExtension
val RegisterTypeDefKindExtension: ILTypeDefKindExtension<'Extension> -> ('Extension -> IlxExtensionTypeKind) * (IlxExtensionTypeKind -> bool) * (IlxExtensionTypeKind -> 'Extension)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// For completeness. These do not occur in metadata but tools that // For completeness. These do not occur in metadata but tools that
...@@ -2289,4 +2273,21 @@ type ILPropertyRef = ...@@ -2289,4 +2273,21 @@ type ILPropertyRef =
static member Create : ILTypeRef * string -> ILPropertyRef static member Create : ILTypeRef * string -> ILPropertyRef
member EnclosingTypeRef: ILTypeRef member EnclosingTypeRef: ILTypeRef
member Name: string member Name: string
interface System.IComparable interface System.IComparable
\ No newline at end of file
val runningOnMono: bool
type ILReferences =
{ AssemblyReferences: ILAssemblyRef list;
ModuleReferences: ILModuleRef list; }
/// Find the full set of assemblies referenced by a module
val computeILRefs: ILModuleDef -> ILReferences
val emptyILRefs: ILReferences
// --------------------------------------------------------------------
// The following functions are used to define an extension to the In reality the only extension is ILX
type ILTypeDefKindExtension<'Extension> = TypeDefKindExtension
val RegisterTypeDefKindExtension: ILTypeDefKindExtension<'Extension> -> ('Extension -> IlxExtensionTypeKind) * (IlxExtensionTypeKind -> bool) * (IlxExtensionTypeKind -> 'Extension)
...@@ -1008,9 +1008,9 @@ let GetTypeNameAsElemPair cenv n = ...@@ -1008,9 +1008,9 @@ let GetTypeNameAsElemPair cenv n =
let rec GenTypeDefPass1 enc cenv (td:ILTypeDef) = let rec GenTypeDefPass1 enc cenv (td:ILTypeDef) =
ignore (cenv.typeDefs.AddUniqueEntry "type index" (fun (TdKey (_,n)) -> n) (TdKey (enc,td.Name))) ignore (cenv.typeDefs.AddUniqueEntry "type index" (fun (TdKey (_,n)) -> n) (TdKey (enc,td.Name)))
GenTypeDefsPass1 (enc@[td.Name]) cenv td.NestedTypes.AsArray GenTypeDefsPass1 (enc@[td.Name]) cenv td.NestedTypes.AsList
and GenTypeDefsPass1 enc cenv tds = Array.iter (GenTypeDefPass1 enc cenv) tds and GenTypeDefsPass1 enc cenv tds = List.iter (GenTypeDefPass1 enc cenv) tds
//===================================================================== //=====================================================================
// Pass 2 - allocate indexes for methods and fields and write rows for types // Pass 2 - allocate indexes for methods and fields and write rows for types
...@@ -1545,12 +1545,12 @@ and GenTypeDefPass2 pidx enc cenv (td:ILTypeDef) = ...@@ -1545,12 +1545,12 @@ and GenTypeDefPass2 pidx enc cenv (td:ILTypeDef) =
events |> List.iter (GenEventDefPass2 cenv tidx) events |> List.iter (GenEventDefPass2 cenv tidx)
td.Fields.AsList |> List.iter (GenFieldDefPass2 cenv tidx) td.Fields.AsList |> List.iter (GenFieldDefPass2 cenv tidx)
td.Methods |> Seq.iter (GenMethodDefPass2 cenv tidx) td.Methods |> Seq.iter (GenMethodDefPass2 cenv tidx)
td.NestedTypes.AsArray |> GenTypeDefsPass2 tidx (enc@[td.Name]) cenv td.NestedTypes.AsList |> GenTypeDefsPass2 tidx (enc@[td.Name]) cenv
with e -> with e ->
failwith ("Error in pass2 for type "+td.Name+", error: "+e.Message) failwith ("Error in pass2 for type "+td.Name+", error: "+e.Message)
and GenTypeDefsPass2 pidx enc cenv tds = and GenTypeDefsPass2 pidx enc cenv tds =
Array.iter (GenTypeDefPass2 pidx enc cenv) tds List.iter (GenTypeDefPass2 pidx enc cenv) tds
//===================================================================== //=====================================================================
// Pass 3 - write details of methods, fields, IL code, custom attrs etc. // Pass 3 - write details of methods, fields, IL code, custom attrs etc.
...@@ -3141,14 +3141,14 @@ let rec GenTypeDefPass3 enc cenv (td:ILTypeDef) = ...@@ -3141,14 +3141,14 @@ let rec GenTypeDefPass3 enc cenv (td:ILTypeDef) =
td.SecurityDecls.AsList |> GenSecurityDeclsPass3 cenv (hds_TypeDef,tidx) td.SecurityDecls.AsList |> GenSecurityDeclsPass3 cenv (hds_TypeDef,tidx)
td.CustomAttrs |> GenCustomAttrsPass3Or4 cenv (hca_TypeDef,tidx) td.CustomAttrs |> GenCustomAttrsPass3Or4 cenv (hca_TypeDef,tidx)
td.GenericParams |> List.iteri (fun n gp -> GenGenericParamPass3 cenv env n (tomd_TypeDef,tidx) gp) td.GenericParams |> List.iteri (fun n gp -> GenGenericParamPass3 cenv env n (tomd_TypeDef,tidx) gp)
td.NestedTypes.AsArray |> GenTypeDefsPass3 (enc@[td.Name]) cenv td.NestedTypes.AsList |> GenTypeDefsPass3 (enc@[td.Name]) cenv
with e -> with e ->
failwith ("Error in pass3 for type "+td.Name+", error: "+e.Message) failwith ("Error in pass3 for type "+td.Name+", error: "+e.Message)
reraise() reraise()
raise e raise e
and GenTypeDefsPass3 enc cenv tds = and GenTypeDefsPass3 enc cenv tds =
Array.iter (GenTypeDefPass3 enc cenv) tds List.iter (GenTypeDefPass3 enc cenv) tds
/// ILTypeDef --> generate generic params on ILMethodDef: ensures /// ILTypeDef --> generate generic params on ILMethodDef: ensures
/// GenericParam table is built sorted by owner. /// GenericParam table is built sorted by owner.
...@@ -3159,14 +3159,14 @@ let rec GenTypeDefPass4 enc cenv (td:ILTypeDef) = ...@@ -3159,14 +3159,14 @@ let rec GenTypeDefPass4 enc cenv (td:ILTypeDef) =
let tidx = GetIdxForTypeDef cenv (TdKey(enc,td.Name)) let tidx = GetIdxForTypeDef cenv (TdKey(enc,td.Name))
td.Methods |> Seq.iter (GenMethodDefPass4 cenv env) td.Methods |> Seq.iter (GenMethodDefPass4 cenv env)
List.iteri (fun n gp -> GenGenericParamPass4 cenv env n (tomd_TypeDef,tidx) gp) td.GenericParams List.iteri (fun n gp -> GenGenericParamPass4 cenv env n (tomd_TypeDef,tidx) gp) td.GenericParams
GenTypeDefsPass4 (enc@[td.Name]) cenv td.NestedTypes.AsArray GenTypeDefsPass4 (enc@[td.Name]) cenv td.NestedTypes.AsList
with e -> with e ->
failwith ("Error in pass4 for type "+td.Name+", error: "+e.Message) failwith ("Error in pass4 for type "+td.Name+", error: "+e.Message)
reraise() reraise()
raise e raise e
and GenTypeDefsPass4 enc cenv tds = and GenTypeDefsPass4 enc cenv tds =
Array.iter (GenTypeDefPass4 enc cenv) tds List.iter (GenTypeDefPass4 enc cenv) tds
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// ILExportedTypesAndForwarders --> ILExportedTypeOrForwarder table // ILExportedTypesAndForwarders --> ILExportedTypeOrForwarder table
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册