Skip to content

Commit 7526d75

Browse files
committed
fantomasd
1 parent 8ed5f2b commit 7526d75

File tree

5 files changed

+56
-27
lines changed

5 files changed

+56
-27
lines changed

src/Compiler/AbstractIL/il.fsi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,12 @@ val internal prependInstrsToClassCtor:
22172217

22182218
/// Derived functions for making some simple constructors
22192219
val internal mkILStorageCtor:
2220-
ILInstr list * ILType * (string * ILType * ILAttribute list) list * ILMemberAccess * ILDebugPoint option * ILDebugImports option ->
2220+
ILInstr list *
2221+
ILType *
2222+
(string * ILType * ILAttribute list) list *
2223+
ILMemberAccess *
2224+
ILDebugPoint option *
2225+
ILDebugImports option ->
22212226
ILMethodDef
22222227

22232228
val internal mkILSimpleStorageCtor:

src/Compiler/CodeGen/EraseClosures.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
560560
mkILStorageCtor (
561561
[ mkLdarg0; mkNormalCall (mkILCtorMethSpecForTy (cenv.mkILTyFuncTy, [])) ],
562562
nowTy,
563-
mkILCloFldSpecs cenv nowFields |> List.map (fun (name,t) -> (name,t,[])),
563+
mkILCloFldSpecs cenv nowFields |> List.map (fun (name, t) -> (name, t, [])),
564564
ILMemberAccess.Assembly,
565565
None,
566566
None
@@ -695,7 +695,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
695695
mkILStorageCtor (
696696
[ mkLdarg0; mkNormalCall (mkILCtorMethSpecForTy (nowEnvParentClass, [])) ],
697697
nowTy,
698-
mkILCloFldSpecs cenv nowFields |> List.map (fun (name,t) -> (name,t,[])),
698+
mkILCloFldSpecs cenv nowFields |> List.map (fun (name, t) -> (name, t, [])),
699699
ILMemberAccess.Assembly,
700700
None,
701701
cloImports

src/Compiler/CodeGen/EraseUnions.fs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,17 @@ let mkUnionCaseFieldId (fdef: IlxUnionCaseField) =
214214
// Use the lower case name of a field or constructor as the field/parameter name if it differs from the uppercase name
215215
fdef.LowerName, fdef.Type
216216

217-
let inline getFieldsNullability (g:TcGlobals) (ilf:ILFieldDef) =
217+
let inline getFieldsNullability (g: TcGlobals) (ilf: ILFieldDef) =
218218
if g.checkNullness then
219219
ilf.CustomAttrs.AsArray()
220220
|> Array.tryFind (IsILAttrib g.attrib_NullableAttribute)
221-
else None
221+
else
222+
None
222223

223224
let mkUnionCaseFieldIdAndAttrs g fdef =
224-
let nm,t = mkUnionCaseFieldId fdef
225+
let nm, t = mkUnionCaseFieldId fdef
225226
let attrs = getFieldsNullability g fdef.ILField
226-
nm,t,attrs |> Option.toList
227+
nm, t, attrs |> Option.toList
227228

228229
let refToFieldInTy ty (nm, fldTy) = mkILFieldSpecInTy (ty, nm, fldTy)
229230

@@ -724,7 +725,7 @@ let mkMethodsAndPropertiesForFields
724725
let ilReturn =
725726
match getFieldsNullability g field.ILField with
726727
| None -> ilReturn
727-
| Some a -> ilReturn.WithCustomAttrs(mkILCustomAttrsFromArray [|a|])
728+
| Some a -> ilReturn.WithCustomAttrs(mkILCustomAttrsFromArray [| a |])
728729

729730
yield
730731
mkILNonGenericInstanceMethod (
@@ -816,15 +817,17 @@ let convAlternativeDef
816817

817818
match getFieldsNullability g fd.ILField with
818819
| None -> plainParam
819-
| Some a -> { plainParam with CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrsFromArray [|a|]) } )
820+
| Some a ->
821+
{ plainParam with
822+
CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrsFromArray [| a |])
823+
})
820824

821825
|> Array.toList,
822826
mkILReturn baseTy,
823827
mkMethodBody (true, locals, fields.Length + locals.Length, nonBranchingInstrsToCode ilInstrs, attr, imports)
824828
)
825829
|> addAltAttribs
826830
|> addMethodGeneratedAttrs
827-
828831

829832
mdef
830833

@@ -987,7 +990,6 @@ let convAlternativeDef
987990
)
988991
|> addAltAttribs
989992
|> addMethodGeneratedAttrs
990-
991993

992994
let nullaryProp =
993995

@@ -1162,6 +1164,7 @@ let convAlternativeDef
11621164
|> Array.map (fun field ->
11631165
let fldName, fldTy, attrs = mkUnionCaseFieldIdAndAttrs g field
11641166
let fdef = mkILInstanceField (fldName, fldTy, None, ILMemberAccess.Assembly)
1167+
11651168
let fdef =
11661169
match attrs with
11671170
| [] -> fdef
@@ -1204,9 +1207,10 @@ let convAlternativeDef
12041207
cud.UnionCasesAccessibility)
12051208

12061209
let basicCtorFields =
1207-
basicFields |> List.map (fun fdef ->
1210+
basicFields
1211+
|> List.map (fun fdef ->
12081212
let existingAttrs = fdef.CustomAttrs.AsArray()
1209-
let nullableAttr = getFieldsNullability g fdef |> Option.toList
1213+
let nullableAttr = getFieldsNullability g fdef |> Option.toList
12101214
fdef.Name, fdef.FieldType, nullableAttr)
12111215

12121216
let basicCtorMeth =
@@ -1304,7 +1308,7 @@ let mkClassUnionDef
13041308
| SingleCase
13051309
| RuntimeTypes
13061310
| TailOrNull -> []
1307-
| IntegerTag -> [ let n,t = mkTagFieldId g.ilg cuspec in n,t,[] ]
1311+
| IntegerTag -> [ let n, t = mkTagFieldId g.ilg cuspec in n, t, [] ]
13081312

13091313
let isStruct = td.IsStruct
13101314

@@ -1344,7 +1348,9 @@ let mkClassUnionDef
13441348
if isStruct && not (cidx = minNullaryIdx) then
13451349
[]
13461350
else
1347-
let fields = alt.FieldDefs |> Array.map (mkUnionCaseFieldIdAndAttrs g) |> Array.toList
1351+
let fields =
1352+
alt.FieldDefs |> Array.map (mkUnionCaseFieldIdAndAttrs g) |> Array.toList
1353+
13481354
[
13491355
(mkILSimpleStorageCtor (
13501356
baseInit,
@@ -1414,7 +1420,10 @@ let mkClassUnionDef
14141420
fieldDefs
14151421
|> Array.filter (fun f -> fieldsEmitted.Add(struct (f.LowerName, f.Type)))
14161422

1417-
let fields = fieldsToBeAddedIntoType |> Array.map (mkUnionCaseFieldIdAndAttrs g) |> Array.toList
1423+
let fields =
1424+
fieldsToBeAddedIntoType
1425+
|> Array.map (mkUnionCaseFieldIdAndAttrs g)
1426+
|> Array.toList
14181427

14191428
let props, meths =
14201429
mkMethodsAndPropertiesForFields
@@ -1437,6 +1446,7 @@ let mkClassUnionDef
14371446
for fldName, fldTy, attrs in (selfFields @ tagFieldsInObject) do
14381447
let fdef =
14391448
let fdef = mkILInstanceField (fldName, fldTy, None, ILMemberAccess.Assembly)
1449+
14401450
match attrs with
14411451
| [] -> fdef
14421452
| attrs -> fdef.With(customAttrs = mkILCustomAttrs attrs)

src/Compiler/CodeGen/IlxGen.fs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,9 @@ type AnonTypeGenerationTable() =
20572057
if ilTypeRef.Scope.IsLocalRef then
20582058

20592059
let flds =
2060-
[ for i, nm in Array.indexed nms -> (nm, nm + "@", ILType.TypeVar(uint16 i), []) ]
2060+
[
2061+
for i, nm in Array.indexed nms -> (nm, nm + "@", ILType.TypeVar(uint16 i), [])
2062+
]
20612063

20622064
let ilGenericParams =
20632065
[
@@ -2082,7 +2084,7 @@ type AnonTypeGenerationTable() =
20822084
let ilFieldDefs =
20832085
mkILFields
20842086
[
2085-
for _, fldName, fldTy,_attrs in flds ->
2087+
for _, fldName, fldTy, _attrs in flds ->
20862088
let fdef = mkILInstanceField (fldName, fldTy, None, ILMemberAccess.Private)
20872089
let attrs = [ g.CompilerGeneratedAttribute; g.DebuggerBrowsableNeverAttribute ]
20882090
fdef.With(customAttrs = mkILCustomAttrs attrs)
@@ -2092,7 +2094,7 @@ type AnonTypeGenerationTable() =
20922094
let ilProperties =
20932095
mkILProperties
20942096
[
2095-
for i, (propName, _fldName, fldTy,_attrs) in List.indexed flds ->
2097+
for i, (propName, _fldName, fldTy, _attrs) in List.indexed flds ->
20962098
ILPropertyDef(
20972099
name = propName,
20982100
attributes = PropertyAttributes.None,
@@ -2108,7 +2110,7 @@ type AnonTypeGenerationTable() =
21082110

21092111
let ilMethods =
21102112
[
2111-
for propName, fldName, fldTy,_attrs in flds ->
2113+
for propName, fldName, fldTy, _attrs in flds ->
21122114
let attrs = if isStruct then [ GetReadOnlyAttribute g ] else []
21132115

21142116
mkLdfldMethodDef ("get_" + propName, ILMemberAccess.Public, false, ilTy, fldName, fldTy, ILAttributes.Empty, attrs)
@@ -2158,7 +2160,7 @@ type AnonTypeGenerationTable() =
21582160

21592161
let rfields =
21602162
(tps, flds)
2161-
||> List.map2 (fun tp (propName, _fldName, _fldTy,_attrs) ->
2163+
||> List.map2 (fun tp (propName, _fldName, _fldTy, _attrs) ->
21622164
Construct.NewRecdField
21632165
false
21642166
None
@@ -5843,7 +5845,8 @@ and GenActualSlotsig
58435845
GenReturnType cenv m eenv.tyenv (Option.map (instType instForSlotSig) ilSlotRetTy)
58445846

58455847
let iLRet = mkILReturn ilRetTy
5846-
let ilRetWithAttrs =
5848+
5849+
let ilRetWithAttrs =
58475850
match ilSlotRetTy with
58485851
| None -> iLRet
58495852
| Some t ->
@@ -11220,9 +11223,10 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
1122011223
let isStruct = isStructTyconRef tcref
1122111224

1122211225
let retTyAttrs = GenAdditionalAttributesForTy g fspec.FormalType |> mkILCustomAttrs
11223-
let attrs =
11226+
11227+
let attrs =
1122411228
if isStruct && not isStatic then
11225-
[ GetReadOnlyAttribute g]
11229+
[ GetReadOnlyAttribute g ]
1122611230
else
1122711231
[]
1122811232

@@ -11241,9 +11245,15 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
1124111245

1124211246
let ilParams =
1124311247
let param = mkILParamNamed ("value", ilPropType)
11248+
1124411249
match GenAdditionalAttributesForTy g fspec.FormalType with
1124511250
| [] -> [ param ]
11246-
| attrs -> [ {param with CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs ) }]
11251+
| attrs ->
11252+
[
11253+
{ param with
11254+
CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs)
11255+
}
11256+
]
1124711257

1124811258
let ilReturn = mkILReturn ILType.Void
1124911259

@@ -11812,7 +11822,7 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) : ILTypeRef option =
1181211822
let ilPropType = GenType cenv m eenv.tyenv fld.FormalType
1181311823
let ilMethName = "get_" + fld.LogicalName
1181411824
let ilFieldName = ComputeFieldName exnc fld
11815-
let typeDerivedAttributes = GenAdditionalAttributesForTy g fld.FormalType
11825+
let typeDerivedAttributes = GenAdditionalAttributesForTy g fld.FormalType
1181611826

1181711827
let ilMethodDef =
1181811828
let def =

src/Compiler/CodeGen/IlxGenSupport.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ open FSharp.Compiler.TypedTree
1313
/// Make a method that simply loads a field
1414
let mkLdfldMethodDef (ilMethName, iLAccess, isStatic, ilTy, ilFieldName, ilPropType, retTyAttrs, customAttrs) =
1515
let ilFieldSpec = mkILFieldSpecInTy (ilTy, ilFieldName, ilPropType)
16-
let ilReturn = { mkILReturn ilPropType with CustomAttrsStored = storeILCustomAttrs retTyAttrs}
16+
17+
let ilReturn =
18+
{ mkILReturn ilPropType with
19+
CustomAttrsStored = storeILCustomAttrs retTyAttrs
20+
}
1721

1822
let ilMethodDef =
1923
if isStatic then

0 commit comments

Comments
 (0)