Skip to content

Commit 79b8293

Browse files
committed
code cleanup and file rename
1 parent 2e1f4db commit 79b8293

76 files changed

Lines changed: 1883 additions & 2015 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/absil/illib.fs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ module Dictionary =
465465

466466
// FUTURE CLEANUP: remove this adhoc collection
467467
type Hashset<'T> = Dictionary<'T,int>
468+
468469
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
469470
module Hashset =
470471
let create (n:int) = new Hashset<'T>(n, HashIdentity.Structural)
@@ -498,6 +499,28 @@ type ResultOrException<'TResult> =
498499
| Result of 'TResult
499500
| Exception of System.Exception
500501

502+
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
503+
module ResultOrException =
504+
505+
let success a = Result a
506+
let raze (b:exn) = Exception b
507+
508+
// map
509+
let (|?>) res f =
510+
match res with
511+
| Result x -> Result(f x )
512+
| Exception err -> Exception err
513+
514+
let ForceRaise res =
515+
match res with
516+
| Result x -> x
517+
| Exception err -> raise err
518+
519+
let otherwise f x =
520+
match x with
521+
| Result x -> success x
522+
| Exception _err -> f()
523+
501524

502525
//-------------------------------------------------------------------------
503526
// Library: extensions to flat list (immutable arrays)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

33
/// Generate the hash/compare functions we add to user-defined types by default.
4-
module internal Microsoft.FSharp.Compiler.Augment
4+
module internal Microsoft.FSharp.Compiler.AugmentWithHashCompare
5+
56
open Internal.Utilities
67
open Microsoft.FSharp.Compiler
78
open Microsoft.FSharp.Compiler.AbstractIL
@@ -14,7 +15,7 @@ open Microsoft.FSharp.Compiler.Ast
1415
open Microsoft.FSharp.Compiler.ErrorLogger
1516
open Microsoft.FSharp.Compiler.PrettyNaming
1617
open Microsoft.FSharp.Compiler.Lib
17-
open Microsoft.FSharp.Compiler.Env
18+
open Microsoft.FSharp.Compiler.TcGlobals
1819
open Microsoft.FSharp.Compiler.Infos
1920

2021
let mkIComparableCompareToSlotSig g =
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

33
/// Generate the hash/compare functions we add to user-defined types by default.
4-
module internal Microsoft.FSharp.Compiler.Augment
4+
module internal Microsoft.FSharp.Compiler.AugmentWithHashCompare
55

66
open Internal.Utilities
77
open Microsoft.FSharp.Compiler.AbstractIL
88
open Microsoft.FSharp.Compiler.AbstractIL.Internal
99
open Microsoft.FSharp.Compiler
1010

1111
open Microsoft.FSharp.Compiler.Tast
12-
open Microsoft.FSharp.Compiler.Env
12+
open Microsoft.FSharp.Compiler.TcGlobals
1313

1414
val CheckAugmentationAttribs : bool -> TcGlobals -> Import.ImportMap -> Tycon -> unit
1515
val TyconIsCandidateForAugmentationWithCompare : TcGlobals -> Tycon -> bool
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

3-
module internal Microsoft.FSharp.Compiler.Formats
3+
module internal Microsoft.FSharp.Compiler.CheckFormatStrings
44

55
open Internal.Utilities
66
open Microsoft.FSharp.Compiler
@@ -11,7 +11,7 @@ open Microsoft.FSharp.Compiler.Ast
1111
open Microsoft.FSharp.Compiler.ErrorLogger
1212
open Microsoft.FSharp.Compiler.Tast
1313
open Microsoft.FSharp.Compiler.Tastops
14-
open Microsoft.FSharp.Compiler.Env
14+
open Microsoft.FSharp.Compiler.TcGlobals
1515
open Microsoft.FSharp.Compiler.ConstraintSolver
1616

1717
type FormatItem = Simple of TType | FuncAndVal
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
///
66
/// Must be updated if the Printf runtime component is updated.
77
8-
module internal Microsoft.FSharp.Compiler.Formats
8+
module internal Microsoft.FSharp.Compiler.CheckFormatStrings
99

1010
open Internal.Utilities
1111
open Microsoft.FSharp.Compiler
1212
open Microsoft.FSharp.Compiler.Tast
13+
open Microsoft.FSharp.Compiler.TcGlobals
1314
open Microsoft.FSharp.Compiler.AbstractIL.Internal
1415

15-
val ParseFormatString : Range.range -> Env.TcGlobals -> string -> TType -> TType -> TType -> TType * TType
16+
val ParseFormatString : Range.range -> TcGlobals -> string -> TType -> TType -> TType -> TType * TType
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ open Microsoft.FSharp.Compiler.ErrorLogger
4444
open Microsoft.FSharp.Compiler.Tast
4545
open Microsoft.FSharp.Compiler.Tastops
4646
open Microsoft.FSharp.Compiler.Tastops.DebugPrint
47-
open Microsoft.FSharp.Compiler.Env
47+
open Microsoft.FSharp.Compiler.TcGlobals
4848
open Microsoft.FSharp.Compiler.Lib
4949
open Microsoft.FSharp.Compiler.Infos
5050
open Microsoft.FSharp.Compiler.Infos.AccessibilityLogic
5151
open Microsoft.FSharp.Compiler.Infos.AttributeChecking
52-
open Microsoft.FSharp.Compiler.Typrelns
52+
open Microsoft.FSharp.Compiler.TypeRelations
5353
open Microsoft.FSharp.Compiler.PrettyNaming
5454

5555
//-------------------------------------------------------------------------
@@ -120,9 +120,9 @@ exception ConstraintSolverMissingConstraint of DisplayEnv * Tast.Typar * Tast.Ty
120120
exception ConstraintSolverError of string * range * range
121121
exception ConstraintSolverRelatedInformation of string option * range * exn
122122

123-
exception ErrorFromApplyingDefault of Env.TcGlobals * DisplayEnv * Tast.Typar * TType * exn * range
124-
exception ErrorFromAddingTypeEquation of Env.TcGlobals * DisplayEnv * TType * TType * exn * range
125-
exception ErrorsFromAddingSubsumptionConstraint of Env.TcGlobals * DisplayEnv * TType * TType * exn * range
123+
exception ErrorFromApplyingDefault of TcGlobals * DisplayEnv * Tast.Typar * TType * exn * range
124+
exception ErrorFromAddingTypeEquation of TcGlobals * DisplayEnv * TType * TType * exn * range
125+
exception ErrorsFromAddingSubsumptionConstraint of TcGlobals * DisplayEnv * TType * TType * exn * range
126126
exception ErrorFromAddingConstraint of DisplayEnv * exn * range
127127
exception PossibleOverload of DisplayEnv * string * exn * range
128128
exception UnresolvedOverloading of DisplayEnv * exn list * string * range
@@ -135,7 +135,7 @@ type TcValF = (ValRef -> ValUseFlag -> TType list -> range -> Expr * TType)
135135

136136
type ConstraintSolverState =
137137
{
138-
g: Env.TcGlobals;
138+
g: TcGlobals;
139139
amap: Import.ImportMap;
140140
InfoReader : InfoReader;
141141
TcVal : TcValF
@@ -1273,7 +1273,7 @@ and MemberConstraintSolutionOfMethInfo css m minfo minst =
12731273
let minst = [] // GENERIC TYPE PROVIDERS: for generics, we would have an minst here
12741274
let allArgVars, allArgs = minfo.GetParamTypes(amap, m, minst) |> List.concat |> List.mapi (fun i ty -> mkLocal m ("arg"+string i) ty) |> List.unzip
12751275
let objArgVars, objArgs = (if minfo.IsInstance then [mkLocal m "this" minfo.EnclosingType] else []) |> List.unzip
1276-
let callMethInfoOpt, callExpr,callExprTy = Typrelns.ProvidedMethodCalls.BuildInvokerExpressionForProvidedMethodCall css.TcVal (g, amap, mi, objArgs, NeverMutates, false, ValUseFlag.NormalValUse, allArgs, m)
1276+
let callMethInfoOpt, callExpr,callExprTy = TypeRelations.ProvidedMethodCalls.BuildInvokerExpressionForProvidedMethodCall css.TcVal (g, amap, mi, objArgs, NeverMutates, false, ValUseFlag.NormalValUse, allArgs, m)
12771277
let closedExprSln = ClosedExprSln (mkLambdas m [] (objArgVars@allArgVars) (callExpr, callExprTy) )
12781278
// If the call is a simple call to an IL method with all the arguments in the natural order, then revert to use ILMethSln.
12791279
// This is important for calls to operators on generated provided types. There is an (unchecked) condition
@@ -1627,7 +1627,7 @@ and SolveTypeSupportsComparison (csenv:ConstraintSolverEnv) ndeep m2 trace ty =
16271627
// Give a good error for structural types excluded from the comparison relation because of their fields
16281628
elif (isAppTy g ty &&
16291629
let tcref = tcrefOfAppTy g ty
1630-
Augment.TyconIsCandidateForAugmentationWithCompare g tcref.Deref &&
1630+
AugmentWithHashCompare.TyconIsCandidateForAugmentationWithCompare g tcref.Deref &&
16311631
isNone tcref.GeneratedCompareToWithComparerValues) then
16321632

16331633
ErrorD (ConstraintSolverError(FSComp.SR.csTypeDoesNotSupportComparison3(NicePrint.minimalStringOfType denv ty),m,m2))
@@ -1655,7 +1655,7 @@ and SolveTypSupportsEquality (csenv:ConstraintSolverEnv) ndeep m2 trace ty =
16551655
let tcref,tinst = destAppTy g ty
16561656

16571657
// Give a good error for structural types excluded from the equality relation because of their fields
1658-
if (Augment.TyconIsCandidateForAugmentationWithEquals g tcref.Deref &&
1658+
if (AugmentWithHashCompare.TyconIsCandidateForAugmentationWithEquals g tcref.Deref &&
16591659
isNone tcref.GeneratedHashAndEqualsWithComparerValues) then
16601660

16611661
ErrorD (ConstraintSolverError(FSComp.SR.csTypeDoesNotSupportEquality3(NicePrint.minimalStringOfType denv ty),m,m2))
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

3+
/// Solves constraints using a mutable constraint-solver state
34
module internal Microsoft.FSharp.Compiler.ConstraintSolver
45

56
open Internal.Utilities
@@ -15,18 +16,32 @@ open Microsoft.FSharp.Compiler.Range
1516
open Microsoft.FSharp.Compiler.Import
1617
open Microsoft.FSharp.Compiler.Tastops
1718
open Microsoft.FSharp.Compiler.Tast
18-
open Microsoft.FSharp.Compiler.Env
19+
open Microsoft.FSharp.Compiler.TcGlobals
1920
open Microsoft.FSharp.Compiler.Infos
2021

22+
/// Create a type variable representing the use of a "_" in F# code
2123
val NewAnonTypar : TyparKind * range * TyparRigidity * TyparStaticReq * TyparDynamicReq -> Typar
24+
25+
/// Create an inference type variable
2226
val NewInferenceType : unit -> TType
27+
28+
/// Create an inference type variable representing an error condition when checking an expression
2329
val NewErrorType : unit -> TType
30+
31+
/// Create an inference type variable representing an error condition when checking a measure
2432
val NewErrorMeasure : unit -> MeasureExpr
33+
34+
/// Create a list of inference type variables, one for each element in the input list
2535
val NewInferenceTypes : 'a list -> TType list
2636

37+
/// Given a set of formal type parameters and their constraints, make new inference type variables for
38+
/// each and ensure that the constraints on the new type variables are adjusted to refer to these.
2739
val FreshenAndFixupTypars : range -> TyparRigidity -> Typars -> TType list -> Typars -> Typars * TyparInst * TType list
40+
2841
val FreshenTypeInst : range -> Typars -> Typars * TyparInst * TType list
42+
2943
val FreshenTypars : range -> Typars -> TType list
44+
3045
val FreshenMethInfo : range -> MethInfo -> TType list
3146

3247
exception ConstraintSolverTupleDiffLengths of DisplayEnv * TType list * TType list * range * range
@@ -42,16 +57,15 @@ exception ErrorsFromAddingSubsumptionConstraint of TcGlobals * DisplayEn
4257
exception ErrorFromAddingConstraint of DisplayEnv * exn * range
4358
exception UnresolvedConversionOperator of DisplayEnv * TType * TType * range
4459
exception PossibleOverload of DisplayEnv * string * exn * range
45-
exception UnresolvedOverloading of DisplayEnv * exn list (* PossibleOverload list *) * string * range
46-
//exception PossibleBestOverload of DisplayEnv * string * range
60+
exception UnresolvedOverloading of DisplayEnv * exn list * string * range
4761
exception NonRigidTypar of DisplayEnv * string option * range * TType * TType * range
4862

49-
/// function type that denotes captured tcVal used in constraint solver
63+
/// A function that denotes captured tcVal, Used in constraint solver and elsewhere to get appropriate expressions for a ValRef.
5064
type TcValF = (ValRef -> ValUseFlag -> TType list -> range -> Expr * TType)
5165

5266
[<Sealed>]
5367
type ConstraintSolverState =
54-
static member New: TcGlobals * Import.ImportMap * InfoReader * TcValF-> ConstraintSolverState
68+
static member New: TcGlobals * Import.ImportMap * InfoReader * TcValF -> ConstraintSolverState
5569

5670
type ConstraintSolverEnv
5771

@@ -69,10 +83,9 @@ val SimplifyMeasuresInTypeScheme : TcGlobals -> bool -> Typars -> TT
6983
val SolveTyparEqualsTyp : ConstraintSolverEnv -> int -> range -> OptionalTrace -> TType -> TType -> OperationResult<unit>
7084
val SolveTypEqualsTypKeepAbbrevs : ConstraintSolverEnv -> int -> range -> OptionalTrace -> TType -> TType -> OperationResult<unit>
7185
val CanonicalizeRelevantMemberConstraints : ConstraintSolverEnv -> int -> OptionalTrace -> Typars -> OperationResult<unit>
72-
val ResolveOverloading : ConstraintSolverEnv -> OptionalTrace -> string -> ndeep: int -> bool -> int * int -> AccessorDomain -> Typrelns.CalledMeth<Expr> list -> bool -> TType option -> Typrelns.CalledMeth<Expr> option * OperationResult<unit>
73-
val UnifyUniqueOverloading : ConstraintSolverEnv -> int * int -> string -> AccessorDomain -> Typrelns.CalledMeth<SynExpr> list -> TType -> OperationResult<bool>
86+
val ResolveOverloading : ConstraintSolverEnv -> OptionalTrace -> string -> ndeep: int -> bool -> int * int -> AccessorDomain -> TypeRelations.CalledMeth<Expr> list -> bool -> TType option -> TypeRelations.CalledMeth<Expr> option * OperationResult<unit>
87+
val UnifyUniqueOverloading : ConstraintSolverEnv -> int * int -> string -> AccessorDomain -> TypeRelations.CalledMeth<SynExpr> list -> TType -> OperationResult<bool>
7488
val EliminateConstraintsForGeneralizedTypars : ConstraintSolverEnv -> OptionalTrace -> Typars -> unit
75-
//val AdjustCalledArgType : TcGlobals -> InfoReader -> bool -> Typrelns.CalledArg -> Typrelns.CallerArg<'T> -> TType
7689

7790
val CheckDeclaredTypars : DisplayEnv -> ConstraintSolverState -> range -> Typars -> Typars -> unit
7891

0 commit comments

Comments
 (0)