Skip to content

Commit

Permalink
additional cleanup and comments in tast.fs
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyme committed Nov 29, 2014
1 parent a27f527 commit 662d87c
Show file tree
Hide file tree
Showing 12 changed files with 399 additions and 157 deletions.
4 changes: 2 additions & 2 deletions src/fsharp/AugmentWithHashCompare.fs
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ let TyconIsCandidateForAugmentationWithHash g tycon = TyconIsCandidateForAugment
// IComparable semantics associated with F# types.
//-------------------------------------------------------------------------

let slotImplMethod (final,c,slotsig) =
let slotImplMethod (final,c,slotsig) : ValMemberInfo =
{ ImplementedSlotSigs=[slotsig];
MemberFlags=
{ IsInstance=true;
Expand All @@ -829,7 +829,7 @@ let slotImplMethod (final,c,slotsig) =
IsImplemented=false;
ApparentParent=c}

let nonVirtualMethod c =
let nonVirtualMethod c : ValMemberInfo =
{ ImplementedSlotSigs=[];
MemberFlags={ IsInstance=true;
IsDispatchSlot=false;
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ let StorageForValRef m (v: ValRef) eenv = StorageForVal m v.Deref eenv
let IsValRefIsDllImport g (vref:ValRef) =
vref.Attribs |> HasFSharpAttributeOpt g g.attrib_DllImportAttribute

let GetMethodSpecForMemberVal amap g memberInfo (vref:ValRef) =
let GetMethodSpecForMemberVal amap g (memberInfo:ValMemberInfo) (vref:ValRef) =
let m = vref.Range
let tps,curriedArgInfos,returnTy,retInfo =
assert(vref.ValReprInfo.IsSome);
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ module private TastDefinitionPrinting =
let isGenerated = if isUnionCase then isGeneratedUnionCaseField else isGeneratedExceptionField
sepListL (wordL "*") (List.mapi (layoutUnionOrExceptionField denv isGenerated) fields)

let layoutUnionCase denv prefixL ucase =
let layoutUnionCase denv prefixL (ucase:UnionCase) =
let nmL = wordL (DemangleOperatorName ucase.Id.idText)
//let nmL = layoutAccessibility denv ucase.Accessibility nmL
match ucase.RecdFields with
Expand Down
6 changes: 3 additions & 3 deletions src/fsharp/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ open Microsoft.FSharp.Compiler.PrettyNaming
//--------------------------------------------------------------------------

let testFlagMemberBody = ref false
let testHookMemberBody membInfo (expr:Expr) =
let testHookMemberBody (membInfo: ValMemberInfo) (expr:Expr) =
if !testFlagMemberBody then
let m = expr.Range
printf "TestMemberBody,%A,%s,%d,%d,%d,%d\n"
(membInfo.MemberFlags.MemberKind)
membInfo.MemberFlags.MemberKind
m.FileName
m.StartLine
m.StartColumn
Expand Down Expand Up @@ -739,7 +739,7 @@ and CheckExprOp cenv env (op,tyargs,args,m) context =
CheckTypeInstNoByrefs cenv m tyargs;
CheckExprs cenv env args

and CheckLambdas memInfo cenv env inlined topValInfo alwaysCheckNoReraise e m ety =
and CheckLambdas (memInfo: ValMemberInfo option) cenv env inlined topValInfo alwaysCheckNoReraise e m ety =
// The topValInfo here says we are _guaranteeing_ to compile a function value
// as a .NET method with precisely the corresponding argument counts.
match e with
Expand Down
8 changes: 4 additions & 4 deletions src/fsharp/TastOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3051,7 +3051,7 @@ module DebugPrint = begin

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

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

and remapUnionCase g tmenv x =
and remapUnionCase g tmenv (x:UnionCase) =
{ x with
FieldTable = x.FieldTable |> remapRecdFields g tmenv;
ReturnType = x.ReturnType |> remapType tmenv;
Expand Down Expand Up @@ -4942,7 +4942,7 @@ and remarkBind m (TBind(v,repr,_)) =
//--------------------------------------------------------------------------

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

let isRecdOrUnionOrStructTyconAllocObservable (_g:TcGlobals) (tycon:Tycon) =
Expand Down Expand Up @@ -6960,7 +6960,7 @@ let ModuleNameIsMangled g attrs =
let CompileAsEvent g attrs = HasFSharpAttribute g g.attrib_CLIEventAttribute attrs


let MemberIsCompiledAsInstance g parent isExtensionMember membInfo attrs =
let MemberIsCompiledAsInstance g parent isExtensionMember (membInfo:ValMemberInfo) attrs =
// All extension members are compiled as static members
if isExtensionMember then false
// Anything implementing a dispatch slot is compiled as an instance member
Expand Down
17 changes: 10 additions & 7 deletions src/fsharp/TastPickle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,10 +1259,12 @@ let p_typs = (p_list p_typ)

let fill_p_attribs,p_attribs = p_hole()

let p_nonlocal_val_ref {EnclosingEntity=a;ItemKey= key } st =
let p_nonlocal_val_ref (nlv:NonLocalValOrMemberRef) st =
let a = nlv.EnclosingEntity
let key = nlv.ItemKey
let pkey = key.PartialKey
p_tcref "nlvref" a st;
p_option p_string pkey.MemberParentMangledName st;
p_tcref "nlvref" a st
p_option p_string pkey.MemberParentMangledName st
p_bool pkey.MemberIsOverride st;
p_string pkey.LogicalName st;
p_int pkey.TotalArgCount st;
Expand All @@ -1280,14 +1282,15 @@ let fill_u_typ,u_typ = u_hole()
let u_typs = (u_list u_typ)
let fill_u_attribs,u_attribs = u_hole()

let u_nonlocal_val_ref st =
let u_nonlocal_val_ref st : NonLocalValOrMemberRef =
let a = u_tcref st
let b1 = u_option u_string st
let b2 = u_bool st
let b3 = u_string st
let c = u_int st
let d = u_option u_typ st
{EnclosingEntity = a; ItemKey=ValLinkageFullKey({ MemberParentMangledName=b1; MemberIsOverride=b2;LogicalName=b3; TotalArgCount=c }, d) }
{ EnclosingEntity = a
ItemKey=ValLinkageFullKey({ MemberParentMangledName=b1; MemberIsOverride=b2;LogicalName=b3; TotalArgCount=c }, d) }

let u_vref st =
let tag = u_byte st
Expand Down Expand Up @@ -1722,7 +1725,7 @@ and p_attrib_expr (AttribExpr(e1,e2)) st =
and p_attrib_arg (AttribNamedArg(a,b,c,d)) st =
p_tup4 p_string p_typ p_bool p_attrib_expr (a,b,c,d) st

and p_member_info x st =
and p_member_info (x:ValMemberInfo) st =
p_tup4 (p_tcref "member_info") p_MemberFlags (p_list p_slotsig) p_bool
(x.ApparentParent,x.MemberFlags,x.ImplementedSlotSigs,x.IsImplemented) st

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

and u_member_info st =
and u_member_info st : ValMemberInfo =
let x2,x3,x4,x5 = u_tup4 u_tcref u_MemberFlags (u_list u_slotsig) u_bool st
{ ApparentParent=x2;
MemberFlags=x3;
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ type ValMemberInfoTransient = ValMemberInfoTransient of ValMemberInfo * string *
let MakeMemberDataAndMangledNameForMemberVal(g,tcref,isExtrinsic,attrs,optImplSlotTys,memberFlags,valSynData,id,isCompGen) =
let logicalName = ComputeLogicalName id memberFlags
let optIntfSlotTys = if optImplSlotTys |> List.forall (isInterfaceTy g) then optImplSlotTys else []
let memberInfo =
let memberInfo : ValMemberInfo =
{ ApparentParent=tcref
MemberFlags=memberFlags
IsImplemented=false
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/TypeRelations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ module SignatureConformance = begin
let ucases1 = r1.UnionCasesAsList
let ucases2 = r2.UnionCasesAsList
if ucases1.Length <> ucases2.Length then
let names l = List.map (fun c -> c.Id.idText) l
let names (l: UnionCase list) = l |> List.map (fun c -> c.Id.idText)
reportNiceError "union case" (names ucases1) (names ucases2)
else List.forall2 (checkUnionCase aenv) ucases1 ucases2
| (TRecdRepr implFields), (TRecdRepr sigFields) ->
Expand Down
74 changes: 37 additions & 37 deletions src/fsharp/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3612,31 +3612,31 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
ILScopeRef = ilScopeRef;
ILAssemblyRefs = ilAssemblyRefs }
tcImports.RegisterDll(dllinfo);
let ccuData =
{ IsFSharp=false;
UsesQuotations=false;
InvalidateEvent=(new Event<_>()).Publish;
let ccuData : CcuData =
{ IsFSharp=false
UsesQuotations=false
InvalidateEvent=(new Event<_>()).Publish
IsProviderGenerated = true
QualifiedName= Some (assembly.PUntaint((fun a -> a.FullName), m));
Contents = NewCcuContents ilScopeRef m ilShortAssemName (NewEmptyModuleOrNamespaceType Namespace) ;
ILScopeRef = ilScopeRef;
Stamp = newStamp();
SourceCodeDirectory = "";
QualifiedName= Some (assembly.PUntaint((fun a -> a.FullName), m))
Contents = NewCcuContents ilScopeRef m ilShortAssemName (NewEmptyModuleOrNamespaceType Namespace)
ILScopeRef = ilScopeRef
Stamp = newStamp()
SourceCodeDirectory = ""
FileName = Some fileName
MemberSignatureEquality = (fun ty1 ty2 -> Tastops.typeEquivAux EraseAll g ty1 ty2)
ImportProvidedType = (fun ty -> Import.ImportProvidedType (tcImports.GetImportMap()) m ty)
TypeForwarders = Map.empty }

let ccu = CcuThunk.Create(ilShortAssemName,ccuData)
let ccuinfo =
{ FSharpViewOfMetadata=ccu;
ILScopeRef = ilScopeRef;
AssemblyAutoOpenAttributes = [];
AssemblyInternalsVisibleToAttributes = [];
IsProviderGenerated = true;
TypeProviders=[];
{ FSharpViewOfMetadata=ccu
ILScopeRef = ilScopeRef
AssemblyAutoOpenAttributes = []
AssemblyInternalsVisibleToAttributes = []
IsProviderGenerated = true
TypeProviders=[]
FSharpOptimizationData = notlazy None }
tcImports.RegisterCcu(ccuinfo);
tcImports.RegisterCcu(ccuinfo)
// Yes, it is generative
true, dllinfo.ProviderGeneratedStaticLinkMap

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

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

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

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

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

let ilg = defaultArg ilGlobalsOpt EcmaILGlobals

let ccuinfo =
{ FSharpViewOfMetadata=ccu;
ILScopeRef = ilScopeRef;
AssemblyAutoOpenAttributes = GetAutoOpenAttributes ilg ilModule;
AssemblyInternalsVisibleToAttributes = GetInternalsVisibleToAttributes ilg ilModule;
{ FSharpViewOfMetadata=ccu
ILScopeRef = ilScopeRef
AssemblyAutoOpenAttributes = GetAutoOpenAttributes ilg ilModule
AssemblyInternalsVisibleToAttributes = GetInternalsVisibleToAttributes ilg ilModule
#if EXTENSIONTYPING
IsProviderGenerated = false;
TypeProviders = [];
IsProviderGenerated = false
TypeProviders = []
#endif
FSharpOptimizationData = notlazy None }
tcImports.RegisterCcu(ccuinfo);
tcImports.RegisterCcu(ccuinfo)
let phase2 () =
#if EXTENSIONTYPING
ccuinfo.TypeProviders <- tcImports.ImportTypeProviderExtensions (tpApprovals, displayPSTypeProviderSecurityDialogBlockingUI, tcConfig, filename, ilScopeRef, ilModule.ManifestOfAssembly.CustomAttrs.AsList, ccu.Contents, invalidateCcu, m)
Expand All @@ -3970,14 +3970,14 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
let ilModule = dllinfo.RawMetadata
let ilScopeRef = dllinfo.ILScopeRef
let ilShortAssemName = getNameOfScopeRef ilScopeRef
if verbose then dprintn ("Converting F# assembly to F# data structures "+(getNameOfScopeRef ilScopeRef));
if verbose then dprintn ("Converting F# assembly to F# data structures "+(getNameOfScopeRef ilScopeRef))
let attrs = GetCustomAttributesOfIlModule ilModule
assert (List.exists IsSignatureDataVersionAttr attrs);
if verbose then dprintn ("Relinking interface info from F# assembly "+ilShortAssemName);
assert (List.exists IsSignatureDataVersionAttr attrs)
if verbose then dprintn ("Relinking interface info from F# assembly "+ilShortAssemName)
let resources = ilModule.Resources.AsList
let externalSigAndOptData = ["FSharp.Core";"FSharp.LanguageService.Compiler"]
if not(List.contains ilShortAssemName externalSigAndOptData) then
assert (List.exists IsSignatureDataResource resources);
assert (List.exists IsSignatureDataResource resources)
let optDataReaders =
resources
|> List.choose (fun r -> if IsOptimizationDataResource r then Some(GetOptimizationDataResourceName r,r.GetByteReader(m)) else None)
Expand All @@ -3994,9 +3994,9 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
if List.contains ilShortAssemName externalSigAndOptData then
let sigFileName = Path.ChangeExtension(filename, "sigdata")
if not sigDataReaders.IsEmpty then
error(Error(FSComp.SR.buildDidNotExpectSigdataResource(),m));
error(Error(FSComp.SR.buildDidNotExpectSigdataResource(),m))
if not (FileSystem.SafeExists sigFileName) then
error(Error(FSComp.SR.buildExpectedSigdataFile(), m));
error(Error(FSComp.SR.buildExpectedSigdataFile(), m))
[ (ilShortAssemName, (fun () -> FileSystem.ReadAllBytesShim sigFileName))]
else
sigDataReaders
Expand All @@ -4009,9 +4009,9 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
if List.contains ilShortAssemName externalSigAndOptData then
let optDataFile = Path.ChangeExtension(filename, "optdata")
if not optDataReaders.IsEmpty then
error(Error(FSComp.SR.buildDidNotExpectOptDataResource(),m));
error(Error(FSComp.SR.buildDidNotExpectOptDataResource(),m))
if not (FileSystem.SafeExists optDataFile) then
error(Error(FSComp.SR.buildExpectedFileAlongSideFSharpCore(optDataFile),m));
error(Error(FSComp.SR.buildExpectedFileAlongSideFSharpCore(optDataFile),m))
[ (ilShortAssemName, (fun () -> FileSystem.ReadAllBytesShim optDataFile))]
else
optDataReaders
Expand Down Expand Up @@ -4093,7 +4093,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
let phase2 () =
(* Relink *)
(* dprintf "Phase2: %s\n" filename; REMOVE DIAGNOSTICS *)
ccuRawDataAndInfos |> List.iter (fun (data,_,_) -> data.OptionalFixup(fun nm -> availableToOptionalCcu(tcImports.FindCcu(m,nm,lookupOnly=false))) |> ignore);
ccuRawDataAndInfos |> List.iter (fun (data,_,_) -> data.OptionalFixup(fun nm -> availableToOptionalCcu(tcImports.FindCcu(m,nm,lookupOnly=false))) |> ignore)
#if EXTENSIONTYPING
ccuRawDataAndInfos |> List.iter (fun (_,_,phase2) -> phase2())
#endif
Expand Down Expand Up @@ -4325,7 +4325,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
sysCcu.FSharpViewOfMetadata
else
let search =
seq { yield sysCcu.FSharpViewOfMetadata;
seq { yield sysCcu.FSharpViewOfMetadata
yield! frameworkTcImports.GetCcusInDeclOrder()
for dllName in SystemAssemblies tcConfig.primaryAssembly.Name do
match frameworkTcImports.CcuTable.TryFind dllName with
Expand Down
Loading

0 comments on commit 662d87c

Please sign in to comment.