Skip to content

Commit

Permalink
fantomas
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom committed Aug 31, 2023
1 parent dd48e63 commit f9076e2
Showing 3 changed files with 34 additions and 13 deletions.
40 changes: 29 additions & 11 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
@@ -498,8 +498,7 @@ let ComputeMemberAccessCore hidden (accessibility: Accessibility option) enclosi
| _ -> ILMemberAccess.Assembly
else
match accessibility with
| Some access when realInternalSignature ->
access.AsILMemberAccess(enclosingEntityCompilationPath)
| Some access when realInternalSignature -> access.AsILMemberAccess(enclosingEntityCompilationPath)
| _ -> ILMemberAccess.Public

let ComputeMemberAccess hidden (accessibility: Accessibility option) realInternalSignature =
@@ -2338,8 +2337,7 @@ and AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbuf
.FindNestedTypeDefsBuilder(tref.Enclosing)
.AddTypeDef(tdef, eliminateIfEmpty, addAtEnd, tdefDiscards)

member _.FindNestedTypeDefBuilder(tref: ILTypeRef) =
gtdefs.FindNestedTypeDefBuilder(tref)
member _.FindNestedTypeDefBuilder(tref: ILTypeRef) = gtdefs.FindNestedTypeDefBuilder(tref)

member _.GetCurrentFields(tref: ILTypeRef) =
gtdefs.FindNestedTypeDefBuilder(tref).GetCurrentFields()
@@ -8417,7 +8415,12 @@ and GenBindingAfterDebugPoint cenv cgbuf eenv bind isStateVar startMarkOpt =
/// Generate a static field definition...
let ilFieldDefs =
let access =
ComputeMemberAccessCore (not hasLiteralAttr || IsHiddenVal eenv.realInternalSignature eenv.sigToImplRemapInfo vspec) (Some vspec.Accessibility) (getApparentEnclosingEntityAccess vspec) cenv.g.realInternalSignature
ComputeMemberAccessCore
(not hasLiteralAttr
|| IsHiddenVal eenv.realInternalSignature eenv.sigToImplRemapInfo vspec)
(Some vspec.Accessibility)
(getApparentEnclosingEntityAccess vspec)
cenv.g.realInternalSignature

let ilFieldDef = mkILStaticField (fspec.Name, fty, None, None, access)

@@ -10084,21 +10087,25 @@ and GenModuleOrNamespaceContents cenv (cgbuf: CodeGenBuffer) qname lazyInitInfo
match bind with
| ModuleOrNamespaceBinding.Binding b -> Some b
| _ -> None

let filterTref bind =
match bind with
| ModuleOrNamespaceBinding.Binding b ->
let (TBind (vspec, _, _)) = b

match vspec.TryDeclaringEntity with
| Parent tcref ->
tref = tcref.CompiledRepresentationForNamedType
| Parent tcref -> tref = tcref.CompiledRepresentationForNamedType
| _ -> false
| _ -> false

let typBinds, remainder = bindsRemaining |> List.partition filterTref

let binds =
typBinds
|> List.map filterBinding
|> List.filter Option.isSome
|> List.map Option.get

CodeGenInitMethod
cenv
cgbuf
@@ -10110,6 +10117,7 @@ and GenModuleOrNamespaceContents cenv (cgbuf: CodeGenBuffer) qname lazyInitInfo
CG.EmitInstr cgbuf (pop 0) Push0 I_ret //)
)
m

bindsRemaining <- remainder

while not bindsRemaining.IsEmpty do
@@ -10124,11 +10132,13 @@ and GenModuleOrNamespaceContents cenv (cgbuf: CodeGenBuffer) qname lazyInitInfo
|> List.map (function
| ModuleOrNamespaceBinding.Binding recBind -> recBind
| _ -> failwith "GenModuleOrNamespaceContents - unexpected")

let otherBinds =
bindsRemaining
|> List.skipWhile (function
| ModuleOrNamespaceBinding.Binding _ -> true
| _ -> false)

GenLetRecBindings cenv cgbuf eenv (recBinds, m)
bindsRemaining <- otherBinds

@@ -10697,8 +10707,13 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
let ilTypeName = tref.Name

let hidden = IsHiddenTycon eenv.realInternalSignature eenv.sigToImplRemapInfo tycon
let hiddenRepr = hidden || IsHiddenTyconRepr eenv.realInternalSignature eenv.sigToImplRemapInfo tycon
let tyconAccess = ComputeTypeAccess tref hidden tycon.Accessibility cenv.g.realInternalSignature

let hiddenRepr =
hidden
|| IsHiddenTyconRepr eenv.realInternalSignature eenv.sigToImplRemapInfo tycon

let tyconAccess =
ComputeTypeAccess tref hidden tycon.Accessibility cenv.g.realInternalSignature

// The implicit augmentation doesn't actually create CompareTo(object) or Object.Equals
// So we do it here.
@@ -10800,7 +10815,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option

let tyconRepr = tycon.TypeReprInfo

let reprAccess = ComputeMemberAccess hiddenRepr None cenv.g.realInternalSignature
let reprAccess = ComputeMemberAccess hiddenRepr None cenv.g.realInternalSignature

// DebugDisplayAttribute gets copied to the subtypes generated as part of DU compilation
let debugDisplayAttrs, normalAttrs =
@@ -10899,7 +10914,10 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
else
(fspec.IsCompilerGenerated
|| hiddenRepr
|| IsHiddenRecdField eenv.realInternalSignature eenv.sigToImplRemapInfo (tcref.MakeNestedRecdFieldRef fspec))
|| IsHiddenRecdField
eenv.realInternalSignature
eenv.sigToImplRemapInfo
(tcref.MakeNestedRecdFieldRef fspec))

let ilType = GenType cenv m eenvinner.tyenv fspec.FormalType
let ilFieldName = ComputeFieldName tycon fspec
5 changes: 4 additions & 1 deletion src/Compiler/Interactive/fsi.fs
Original file line number Diff line number Diff line change
@@ -1618,7 +1618,10 @@ let rec ConvReflectionTypeToILType (reflectionTy: Type) =

let internal mkBoundValueTypedImpl tcGlobals m moduleName name ty =
let vis = Accessibility.TAccess([])
let compPath = (CompilationPath.CompPath(ILScopeRef.Local, SyntaxAccess.Unknown, []))

let compPath =
(CompilationPath.CompPath(ILScopeRef.Local, SyntaxAccess.Unknown, []))

let mutable mty = Unchecked.defaultof<_>

let entity =
2 changes: 1 addition & 1 deletion src/Compiler/TypedTree/TypedTree.fsi
Original file line number Diff line number Diff line change
@@ -1447,7 +1447,7 @@ type Accessibility =

member CompilationPaths: CompilationPath list

/// Readable rendering of Accessibility
/// Readable rendering of Accessibility
override ToString: unit -> string

[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]

0 comments on commit f9076e2

Please sign in to comment.