Skip to content

Commit 662d87c

Browse files
committed
additional cleanup and comments in tast.fs
1 parent a27f527 commit 662d87c

12 files changed

Lines changed: 399 additions & 157 deletions

src/fsharp/AugmentWithHashCompare.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ let TyconIsCandidateForAugmentationWithHash g tycon = TyconIsCandidateForAugment
818818
// IComparable semantics associated with F# types.
819819
//-------------------------------------------------------------------------
820820

821-
let slotImplMethod (final,c,slotsig) =
821+
let slotImplMethod (final,c,slotsig) : ValMemberInfo =
822822
{ ImplementedSlotSigs=[slotsig];
823823
MemberFlags=
824824
{ IsInstance=true;
@@ -829,7 +829,7 @@ let slotImplMethod (final,c,slotsig) =
829829
IsImplemented=false;
830830
ApparentParent=c}
831831

832-
let nonVirtualMethod c =
832+
let nonVirtualMethod c : ValMemberInfo =
833833
{ ImplementedSlotSigs=[];
834834
MemberFlags={ IsInstance=true;
835835
IsDispatchSlot=false;

src/fsharp/IlxGen.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ let StorageForValRef m (v: ValRef) eenv = StorageForVal m v.Deref eenv
776776
let IsValRefIsDllImport g (vref:ValRef) =
777777
vref.Attribs |> HasFSharpAttributeOpt g g.attrib_DllImportAttribute
778778

779-
let GetMethodSpecForMemberVal amap g memberInfo (vref:ValRef) =
779+
let GetMethodSpecForMemberVal amap g (memberInfo:ValMemberInfo) (vref:ValRef) =
780780
let m = vref.Range
781781
let tps,curriedArgInfos,returnTy,retInfo =
782782
assert(vref.ValReprInfo.IsSome);

src/fsharp/NicePrint.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ module private TastDefinitionPrinting =
13001300
let isGenerated = if isUnionCase then isGeneratedUnionCaseField else isGeneratedExceptionField
13011301
sepListL (wordL "*") (List.mapi (layoutUnionOrExceptionField denv isGenerated) fields)
13021302

1303-
let layoutUnionCase denv prefixL ucase =
1303+
let layoutUnionCase denv prefixL (ucase:UnionCase) =
13041304
let nmL = wordL (DemangleOperatorName ucase.Id.idText)
13051305
//let nmL = layoutAccessibility denv ucase.Accessibility nmL
13061306
match ucase.RecdFields with

src/fsharp/PostInferenceChecks.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ open Microsoft.FSharp.Compiler.PrettyNaming
3333
//--------------------------------------------------------------------------
3434

3535
let testFlagMemberBody = ref false
36-
let testHookMemberBody membInfo (expr:Expr) =
36+
let testHookMemberBody (membInfo: ValMemberInfo) (expr:Expr) =
3737
if !testFlagMemberBody then
3838
let m = expr.Range
3939
printf "TestMemberBody,%A,%s,%d,%d,%d,%d\n"
40-
(membInfo.MemberFlags.MemberKind)
40+
membInfo.MemberFlags.MemberKind
4141
m.FileName
4242
m.StartLine
4343
m.StartColumn
@@ -739,7 +739,7 @@ and CheckExprOp cenv env (op,tyargs,args,m) context =
739739
CheckTypeInstNoByrefs cenv m tyargs;
740740
CheckExprs cenv env args
741741

742-
and CheckLambdas memInfo cenv env inlined topValInfo alwaysCheckNoReraise e m ety =
742+
and CheckLambdas (memInfo: ValMemberInfo option) cenv env inlined topValInfo alwaysCheckNoReraise e m ety =
743743
// The topValInfo here says we are _guaranteeing_ to compile a function value
744744
// as a .NET method with precisely the corresponding argument counts.
745745
match e with

src/fsharp/TastOps.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,7 +3051,7 @@ module DebugPrint = begin
30513051

30523052
let layoutUnionCaseArgTypes argtys = sepListL (wordL "*") (List.map typeL argtys)
30533053

3054-
let ucaseL prefixL ucase =
3054+
let ucaseL prefixL (ucase: UnionCase) =
30553055
let nmL = wordL (DemangleOperatorName ucase.Id.idText)
30563056
match ucase.RecdFields |> List.map (fun rfld -> rfld.FormalType) with
30573057
| [] -> (prefixL ^^ nmL)
@@ -4620,7 +4620,7 @@ and remapRecdField g tmenv x =
46204620
rfield_fattribs = x.rfield_fattribs |> remapAttribs g tmenv; }
46214621
and remapRecdFields g tmenv (x:TyconRecdFields) = x.AllFieldsAsList |> List.map (remapRecdField g tmenv) |> MakeRecdFieldsTable
46224622

4623-
and remapUnionCase g tmenv x =
4623+
and remapUnionCase g tmenv (x:UnionCase) =
46244624
{ x with
46254625
FieldTable = x.FieldTable |> remapRecdFields g tmenv;
46264626
ReturnType = x.ReturnType |> remapType tmenv;
@@ -4942,7 +4942,7 @@ and remarkBind m (TBind(v,repr,_)) =
49424942
//--------------------------------------------------------------------------
49434943

49444944
let isRecdOrStructFieldAllocObservable (f:RecdField) = not f.IsStatic && f.IsMutable
4945-
let ucaseAllocObservable uc = uc.FieldTable.FieldsByIndex |> Array.exists isRecdOrStructFieldAllocObservable
4945+
let ucaseAllocObservable (uc:UnionCase) = uc.FieldTable.FieldsByIndex |> Array.exists isRecdOrStructFieldAllocObservable
49464946
let isUnionCaseAllocObservable (uc:UnionCaseRef) = uc.UnionCase |> ucaseAllocObservable
49474947

49484948
let isRecdOrUnionOrStructTyconAllocObservable (_g:TcGlobals) (tycon:Tycon) =
@@ -6960,7 +6960,7 @@ let ModuleNameIsMangled g attrs =
69606960
let CompileAsEvent g attrs = HasFSharpAttribute g g.attrib_CLIEventAttribute attrs
69616961

69626962

6963-
let MemberIsCompiledAsInstance g parent isExtensionMember membInfo attrs =
6963+
let MemberIsCompiledAsInstance g parent isExtensionMember (membInfo:ValMemberInfo) attrs =
69646964
// All extension members are compiled as static members
69656965
if isExtensionMember then false
69666966
// Anything implementing a dispatch slot is compiled as an instance member

src/fsharp/TastPickle.fs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,10 +1259,12 @@ let p_typs = (p_list p_typ)
12591259

12601260
let fill_p_attribs,p_attribs = p_hole()
12611261

1262-
let p_nonlocal_val_ref {EnclosingEntity=a;ItemKey= key } st =
1262+
let p_nonlocal_val_ref (nlv:NonLocalValOrMemberRef) st =
1263+
let a = nlv.EnclosingEntity
1264+
let key = nlv.ItemKey
12631265
let pkey = key.PartialKey
1264-
p_tcref "nlvref" a st;
1265-
p_option p_string pkey.MemberParentMangledName st;
1266+
p_tcref "nlvref" a st
1267+
p_option p_string pkey.MemberParentMangledName st
12661268
p_bool pkey.MemberIsOverride st;
12671269
p_string pkey.LogicalName st;
12681270
p_int pkey.TotalArgCount st;
@@ -1280,14 +1282,15 @@ let fill_u_typ,u_typ = u_hole()
12801282
let u_typs = (u_list u_typ)
12811283
let fill_u_attribs,u_attribs = u_hole()
12821284

1283-
let u_nonlocal_val_ref st =
1285+
let u_nonlocal_val_ref st : NonLocalValOrMemberRef =
12841286
let a = u_tcref st
12851287
let b1 = u_option u_string st
12861288
let b2 = u_bool st
12871289
let b3 = u_string st
12881290
let c = u_int st
12891291
let d = u_option u_typ st
1290-
{EnclosingEntity = a; ItemKey=ValLinkageFullKey({ MemberParentMangledName=b1; MemberIsOverride=b2;LogicalName=b3; TotalArgCount=c }, d) }
1292+
{ EnclosingEntity = a
1293+
ItemKey=ValLinkageFullKey({ MemberParentMangledName=b1; MemberIsOverride=b2;LogicalName=b3; TotalArgCount=c }, d) }
12911294

12921295
let u_vref st =
12931296
let tag = u_byte st
@@ -1722,7 +1725,7 @@ and p_attrib_expr (AttribExpr(e1,e2)) st =
17221725
and p_attrib_arg (AttribNamedArg(a,b,c,d)) st =
17231726
p_tup4 p_string p_typ p_bool p_attrib_expr (a,b,c,d) st
17241727

1725-
and p_member_info x st =
1728+
and p_member_info (x:ValMemberInfo) st =
17261729
p_tup4 (p_tcref "member_info") p_MemberFlags (p_list p_slotsig) p_bool
17271730
(x.ApparentParent,x.MemberFlags,x.ImplementedSlotSigs,x.IsImplemented) st
17281731

@@ -2003,7 +2006,7 @@ and u_attrib_arg st =
20032006
let a,b,c,d = u_tup4 u_string u_typ u_bool u_attrib_expr st
20042007
AttribNamedArg(a,b,c,d)
20052008

2006-
and u_member_info st =
2009+
and u_member_info st : ValMemberInfo =
20072010
let x2,x3,x4,x5 = u_tup4 u_tcref u_MemberFlags (u_list u_slotsig) u_bool st
20082011
{ ApparentParent=x2;
20092012
MemberFlags=x3;

src/fsharp/TypeChecker.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ type ValMemberInfoTransient = ValMemberInfoTransient of ValMemberInfo * string *
916916
let MakeMemberDataAndMangledNameForMemberVal(g,tcref,isExtrinsic,attrs,optImplSlotTys,memberFlags,valSynData,id,isCompGen) =
917917
let logicalName = ComputeLogicalName id memberFlags
918918
let optIntfSlotTys = if optImplSlotTys |> List.forall (isInterfaceTy g) then optImplSlotTys else []
919-
let memberInfo =
919+
let memberInfo : ValMemberInfo =
920920
{ ApparentParent=tcref
921921
MemberFlags=memberFlags
922922
IsImplemented=false

src/fsharp/TypeRelations.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ module SignatureConformance = begin
715715
let ucases1 = r1.UnionCasesAsList
716716
let ucases2 = r2.UnionCasesAsList
717717
if ucases1.Length <> ucases2.Length then
718-
let names l = List.map (fun c -> c.Id.idText) l
718+
let names (l: UnionCase list) = l |> List.map (fun c -> c.Id.idText)
719719
reportNiceError "union case" (names ucases1) (names ucases2)
720720
else List.forall2 (checkUnionCase aenv) ucases1 ucases2
721721
| (TRecdRepr implFields), (TRecdRepr sigFields) ->

src/fsharp/build.fs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,31 +3612,31 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
36123612
ILScopeRef = ilScopeRef;
36133613
ILAssemblyRefs = ilAssemblyRefs }
36143614
tcImports.RegisterDll(dllinfo);
3615-
let ccuData =
3616-
{ IsFSharp=false;
3617-
UsesQuotations=false;
3618-
InvalidateEvent=(new Event<_>()).Publish;
3615+
let ccuData : CcuData =
3616+
{ IsFSharp=false
3617+
UsesQuotations=false
3618+
InvalidateEvent=(new Event<_>()).Publish
36193619
IsProviderGenerated = true
3620-
QualifiedName= Some (assembly.PUntaint((fun a -> a.FullName), m));
3621-
Contents = NewCcuContents ilScopeRef m ilShortAssemName (NewEmptyModuleOrNamespaceType Namespace) ;
3622-
ILScopeRef = ilScopeRef;
3623-
Stamp = newStamp();
3624-
SourceCodeDirectory = "";
3620+
QualifiedName= Some (assembly.PUntaint((fun a -> a.FullName), m))
3621+
Contents = NewCcuContents ilScopeRef m ilShortAssemName (NewEmptyModuleOrNamespaceType Namespace)
3622+
ILScopeRef = ilScopeRef
3623+
Stamp = newStamp()
3624+
SourceCodeDirectory = ""
36253625
FileName = Some fileName
36263626
MemberSignatureEquality = (fun ty1 ty2 -> Tastops.typeEquivAux EraseAll g ty1 ty2)
36273627
ImportProvidedType = (fun ty -> Import.ImportProvidedType (tcImports.GetImportMap()) m ty)
36283628
TypeForwarders = Map.empty }
36293629

36303630
let ccu = CcuThunk.Create(ilShortAssemName,ccuData)
36313631
let ccuinfo =
3632-
{ FSharpViewOfMetadata=ccu;
3633-
ILScopeRef = ilScopeRef;
3634-
AssemblyAutoOpenAttributes = [];
3635-
AssemblyInternalsVisibleToAttributes = [];
3636-
IsProviderGenerated = true;
3637-
TypeProviders=[];
3632+
{ FSharpViewOfMetadata=ccu
3633+
ILScopeRef = ilScopeRef
3634+
AssemblyAutoOpenAttributes = []
3635+
AssemblyInternalsVisibleToAttributes = []
3636+
IsProviderGenerated = true
3637+
TypeProviders=[]
36383638
FSharpOptimizationData = notlazy None }
3639-
tcImports.RegisterCcu(ccuinfo);
3639+
tcImports.RegisterCcu(ccuinfo)
36403640
// Yes, it is generative
36413641
true, dllinfo.ProviderGeneratedStaticLinkMap
36423642

@@ -3682,7 +3682,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
36823682
let pdbDir = (try Filename.directoryName filename with _ -> ".")
36833683
let pdbFile = (try Filename.chopExtension filename with _ -> filename)+".pdb"
36843684
if FileSystem.SafeExists pdbFile then
3685-
if verbose then dprintf "reading PDB file %s from directory %s\n" pdbFile pdbDir;
3685+
if verbose then dprintf "reading PDB file %s from directory %s\n" pdbFile pdbDir
36863686
Some pdbDir
36873687
else
36883688
None
@@ -3691,7 +3691,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
36913691

36923692
let ilILBinaryReader = OpenILBinary(filename,tcConfig.optimizeForMemory,tcConfig.openBinariesInMemory,ilGlobalsOpt,pdbPathOption, tcConfig.primaryAssembly.Name, tcConfig.noDebugData, tcConfig.shadowCopyReferences)
36933693

3694-
tcImports.AttachDisposeAction(fun _ -> ILBinaryReader.CloseILModuleReader ilILBinaryReader);
3694+
tcImports.AttachDisposeAction(fun _ -> ILBinaryReader.CloseILModuleReader ilILBinaryReader)
36953695
ilILBinaryReader.ILModuleDef, ilILBinaryReader.ILAssemblyRefs
36963696
with e ->
36973697
error(Error(FSComp.SR.buildErrorOpeningBinaryFile(filename, e.Message),m))
@@ -3871,7 +3871,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
38713871
match providers with
38723872
| [] ->
38733873
if wasApproved then
3874-
warning(Error(FSComp.SR.etHostingAssemblyFoundWithoutHosts(fileNameOfRuntimeAssembly,typeof<Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute>.FullName),m));
3874+
warning(Error(FSComp.SR.etHostingAssemblyFoundWithoutHosts(fileNameOfRuntimeAssembly,typeof<Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute>.FullName),m))
38753875
| _ ->
38763876

38773877
if typeProviderEnvironment.showResolutionMessages then
@@ -3937,24 +3937,24 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
39373937
| _ -> error(InternalError("PrepareToImportReferencedIlDll: cannot reference .NET netmodules directly, reference the containing assembly instead",m))
39383938

39393939
let nm = aref.Name
3940-
if verbose then dprintn ("Converting IL assembly to F# data structures "+nm);
3940+
if verbose then dprintn ("Converting IL assembly to F# data structures "+nm)
39413941
let auxModuleLoader = tcImports.MkLoaderForMultiModuleIlAssemblies m
39423942
let invalidateCcu = new Event<_>()
39433943
let ccu = Import.ImportILAssembly(tcImports.GetImportMap,m,auxModuleLoader,ilScopeRef,tcConfig.implicitIncludeDir, Some filename,ilModule,invalidateCcu.Publish)
39443944

39453945
let ilg = defaultArg ilGlobalsOpt EcmaILGlobals
39463946

39473947
let ccuinfo =
3948-
{ FSharpViewOfMetadata=ccu;
3949-
ILScopeRef = ilScopeRef;
3950-
AssemblyAutoOpenAttributes = GetAutoOpenAttributes ilg ilModule;
3951-
AssemblyInternalsVisibleToAttributes = GetInternalsVisibleToAttributes ilg ilModule;
3948+
{ FSharpViewOfMetadata=ccu
3949+
ILScopeRef = ilScopeRef
3950+
AssemblyAutoOpenAttributes = GetAutoOpenAttributes ilg ilModule
3951+
AssemblyInternalsVisibleToAttributes = GetInternalsVisibleToAttributes ilg ilModule
39523952
#if EXTENSIONTYPING
3953-
IsProviderGenerated = false;
3954-
TypeProviders = [];
3953+
IsProviderGenerated = false
3954+
TypeProviders = []
39553955
#endif
39563956
FSharpOptimizationData = notlazy None }
3957-
tcImports.RegisterCcu(ccuinfo);
3957+
tcImports.RegisterCcu(ccuinfo)
39583958
let phase2 () =
39593959
#if EXTENSIONTYPING
39603960
ccuinfo.TypeProviders <- tcImports.ImportTypeProviderExtensions (tpApprovals, displayPSTypeProviderSecurityDialogBlockingUI, tcConfig, filename, ilScopeRef, ilModule.ManifestOfAssembly.CustomAttrs.AsList, ccu.Contents, invalidateCcu, m)
@@ -3970,14 +3970,14 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
39703970
let ilModule = dllinfo.RawMetadata
39713971
let ilScopeRef = dllinfo.ILScopeRef
39723972
let ilShortAssemName = getNameOfScopeRef ilScopeRef
3973-
if verbose then dprintn ("Converting F# assembly to F# data structures "+(getNameOfScopeRef ilScopeRef));
3973+
if verbose then dprintn ("Converting F# assembly to F# data structures "+(getNameOfScopeRef ilScopeRef))
39743974
let attrs = GetCustomAttributesOfIlModule ilModule
3975-
assert (List.exists IsSignatureDataVersionAttr attrs);
3976-
if verbose then dprintn ("Relinking interface info from F# assembly "+ilShortAssemName);
3975+
assert (List.exists IsSignatureDataVersionAttr attrs)
3976+
if verbose then dprintn ("Relinking interface info from F# assembly "+ilShortAssemName)
39773977
let resources = ilModule.Resources.AsList
39783978
let externalSigAndOptData = ["FSharp.Core";"FSharp.LanguageService.Compiler"]
39793979
if not(List.contains ilShortAssemName externalSigAndOptData) then
3980-
assert (List.exists IsSignatureDataResource resources);
3980+
assert (List.exists IsSignatureDataResource resources)
39813981
let optDataReaders =
39823982
resources
39833983
|> List.choose (fun r -> if IsOptimizationDataResource r then Some(GetOptimizationDataResourceName r,r.GetByteReader(m)) else None)
@@ -3994,9 +3994,9 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
39943994
if List.contains ilShortAssemName externalSigAndOptData then
39953995
let sigFileName = Path.ChangeExtension(filename, "sigdata")
39963996
if not sigDataReaders.IsEmpty then
3997-
error(Error(FSComp.SR.buildDidNotExpectSigdataResource(),m));
3997+
error(Error(FSComp.SR.buildDidNotExpectSigdataResource(),m))
39983998
if not (FileSystem.SafeExists sigFileName) then
3999-
error(Error(FSComp.SR.buildExpectedSigdataFile(), m));
3999+
error(Error(FSComp.SR.buildExpectedSigdataFile(), m))
40004000
[ (ilShortAssemName, (fun () -> FileSystem.ReadAllBytesShim sigFileName))]
40014001
else
40024002
sigDataReaders
@@ -4009,9 +4009,9 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
40094009
if List.contains ilShortAssemName externalSigAndOptData then
40104010
let optDataFile = Path.ChangeExtension(filename, "optdata")
40114011
if not optDataReaders.IsEmpty then
4012-
error(Error(FSComp.SR.buildDidNotExpectOptDataResource(),m));
4012+
error(Error(FSComp.SR.buildDidNotExpectOptDataResource(),m))
40134013
if not (FileSystem.SafeExists optDataFile) then
4014-
error(Error(FSComp.SR.buildExpectedFileAlongSideFSharpCore(optDataFile),m));
4014+
error(Error(FSComp.SR.buildExpectedFileAlongSideFSharpCore(optDataFile),m))
40154015
[ (ilShortAssemName, (fun () -> FileSystem.ReadAllBytesShim optDataFile))]
40164016
else
40174017
optDataReaders
@@ -4093,7 +4093,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
40934093
let phase2 () =
40944094
(* Relink *)
40954095
(* dprintf "Phase2: %s\n" filename; REMOVE DIAGNOSTICS *)
4096-
ccuRawDataAndInfos |> List.iter (fun (data,_,_) -> data.OptionalFixup(fun nm -> availableToOptionalCcu(tcImports.FindCcu(m,nm,lookupOnly=false))) |> ignore);
4096+
ccuRawDataAndInfos |> List.iter (fun (data,_,_) -> data.OptionalFixup(fun nm -> availableToOptionalCcu(tcImports.FindCcu(m,nm,lookupOnly=false))) |> ignore)
40974097
#if EXTENSIONTYPING
40984098
ccuRawDataAndInfos |> List.iter (fun (_,_,phase2) -> phase2())
40994099
#endif
@@ -4325,7 +4325,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
43254325
sysCcu.FSharpViewOfMetadata
43264326
else
43274327
let search =
4328-
seq { yield sysCcu.FSharpViewOfMetadata;
4328+
seq { yield sysCcu.FSharpViewOfMetadata
43294329
yield! frameworkTcImports.GetCcusInDeclOrder()
43304330
for dllName in SystemAssemblies tcConfig.primaryAssembly.Name do
43314331
match frameworkTcImports.CcuTable.TryFind dllName with

0 commit comments

Comments
 (0)