Skip to content

Commit

Permalink
code cleanup and file rename
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyme committed Nov 29, 2014
1 parent 2e1f4db commit 79b8293
Show file tree
Hide file tree
Showing 76 changed files with 1,883 additions and 2,015 deletions.
23 changes: 23 additions & 0 deletions src/absil/illib.fs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ module Dictionary =

// FUTURE CLEANUP: remove this adhoc collection
type Hashset<'T> = Dictionary<'T,int>

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module Hashset =
let create (n:int) = new Hashset<'T>(n, HashIdentity.Structural)
Expand Down Expand Up @@ -498,6 +499,28 @@ type ResultOrException<'TResult> =
| Result of 'TResult
| Exception of System.Exception

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module ResultOrException =

let success a = Result a
let raze (b:exn) = Exception b

// map
let (|?>) res f =
match res with
| Result x -> Result(f x )
| Exception err -> Exception err

let ForceRaise res =
match res with
| Result x -> x
| Exception err -> raise err

let otherwise f x =
match x with
| Result x -> success x
| Exception _err -> f()


//-------------------------------------------------------------------------
// Library: extensions to flat list (immutable arrays)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// 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.

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

open Internal.Utilities
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.AbstractIL
Expand All @@ -14,7 +15,7 @@ open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.ErrorLogger
open Microsoft.FSharp.Compiler.PrettyNaming
open Microsoft.FSharp.Compiler.Lib
open Microsoft.FSharp.Compiler.Env
open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.Infos

let mkIComparableCompareToSlotSig g =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// 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.

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

open Internal.Utilities
open Microsoft.FSharp.Compiler.AbstractIL
open Microsoft.FSharp.Compiler.AbstractIL.Internal
open Microsoft.FSharp.Compiler

open Microsoft.FSharp.Compiler.Tast
open Microsoft.FSharp.Compiler.Env
open Microsoft.FSharp.Compiler.TcGlobals

val CheckAugmentationAttribs : bool -> TcGlobals -> Import.ImportMap -> Tycon -> unit
val TyconIsCandidateForAugmentationWithCompare : TcGlobals -> Tycon -> bool
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/formats.fs → src/fsharp/CheckFormatStrings.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 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.

module internal Microsoft.FSharp.Compiler.Formats
module internal Microsoft.FSharp.Compiler.CheckFormatStrings

open Internal.Utilities
open Microsoft.FSharp.Compiler
Expand All @@ -11,7 +11,7 @@ open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.ErrorLogger
open Microsoft.FSharp.Compiler.Tast
open Microsoft.FSharp.Compiler.Tastops
open Microsoft.FSharp.Compiler.Env
open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.ConstraintSolver

type FormatItem = Simple of TType | FuncAndVal
Expand Down
5 changes: 3 additions & 2 deletions src/fsharp/formats.fsi → src/fsharp/CheckFormatStrings.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
///
/// Must be updated if the Printf runtime component is updated.
module internal Microsoft.FSharp.Compiler.Formats
module internal Microsoft.FSharp.Compiler.CheckFormatStrings

open Internal.Utilities
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.Tast
open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.AbstractIL.Internal

val ParseFormatString : Range.range -> Env.TcGlobals -> string -> TType -> TType -> TType -> TType * TType
val ParseFormatString : Range.range -> TcGlobals -> string -> TType -> TType -> TType -> TType * TType
18 changes: 9 additions & 9 deletions src/fsharp/csolve.fs → src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ open Microsoft.FSharp.Compiler.ErrorLogger
open Microsoft.FSharp.Compiler.Tast
open Microsoft.FSharp.Compiler.Tastops
open Microsoft.FSharp.Compiler.Tastops.DebugPrint
open Microsoft.FSharp.Compiler.Env
open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.Lib
open Microsoft.FSharp.Compiler.Infos
open Microsoft.FSharp.Compiler.Infos.AccessibilityLogic
open Microsoft.FSharp.Compiler.Infos.AttributeChecking
open Microsoft.FSharp.Compiler.Typrelns
open Microsoft.FSharp.Compiler.TypeRelations
open Microsoft.FSharp.Compiler.PrettyNaming

//-------------------------------------------------------------------------
Expand Down Expand Up @@ -120,9 +120,9 @@ exception ConstraintSolverMissingConstraint of DisplayEnv * Tast.Typar * Tast.Ty
exception ConstraintSolverError of string * range * range
exception ConstraintSolverRelatedInformation of string option * range * exn

exception ErrorFromApplyingDefault of Env.TcGlobals * DisplayEnv * Tast.Typar * TType * exn * range
exception ErrorFromAddingTypeEquation of Env.TcGlobals * DisplayEnv * TType * TType * exn * range
exception ErrorsFromAddingSubsumptionConstraint of Env.TcGlobals * DisplayEnv * TType * TType * exn * range
exception ErrorFromApplyingDefault of TcGlobals * DisplayEnv * Tast.Typar * TType * exn * range
exception ErrorFromAddingTypeEquation of TcGlobals * DisplayEnv * TType * TType * exn * range
exception ErrorsFromAddingSubsumptionConstraint of TcGlobals * DisplayEnv * TType * TType * exn * range
exception ErrorFromAddingConstraint of DisplayEnv * exn * range
exception PossibleOverload of DisplayEnv * string * exn * range
exception UnresolvedOverloading of DisplayEnv * exn list * string * range
Expand All @@ -135,7 +135,7 @@ type TcValF = (ValRef -> ValUseFlag -> TType list -> range -> Expr * TType)

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

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

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

ErrorD (ConstraintSolverError(FSComp.SR.csTypeDoesNotSupportEquality3(NicePrint.minimalStringOfType denv ty),m,m2))
Expand Down
29 changes: 21 additions & 8 deletions src/fsharp/csolve.fsi → src/fsharp/ConstraintSolver.fsi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 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.

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

open Internal.Utilities
Expand All @@ -15,18 +16,32 @@ open Microsoft.FSharp.Compiler.Range
open Microsoft.FSharp.Compiler.Import
open Microsoft.FSharp.Compiler.Tastops
open Microsoft.FSharp.Compiler.Tast
open Microsoft.FSharp.Compiler.Env
open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.Infos

/// Create a type variable representing the use of a "_" in F# code
val NewAnonTypar : TyparKind * range * TyparRigidity * TyparStaticReq * TyparDynamicReq -> Typar

/// Create an inference type variable
val NewInferenceType : unit -> TType

/// Create an inference type variable representing an error condition when checking an expression
val NewErrorType : unit -> TType

/// Create an inference type variable representing an error condition when checking a measure
val NewErrorMeasure : unit -> MeasureExpr

/// Create a list of inference type variables, one for each element in the input list
val NewInferenceTypes : 'a list -> TType list

/// Given a set of formal type parameters and their constraints, make new inference type variables for
/// each and ensure that the constraints on the new type variables are adjusted to refer to these.
val FreshenAndFixupTypars : range -> TyparRigidity -> Typars -> TType list -> Typars -> Typars * TyparInst * TType list

val FreshenTypeInst : range -> Typars -> Typars * TyparInst * TType list

val FreshenTypars : range -> Typars -> TType list

val FreshenMethInfo : range -> MethInfo -> TType list

exception ConstraintSolverTupleDiffLengths of DisplayEnv * TType list * TType list * range * range
Expand All @@ -42,16 +57,15 @@ exception ErrorsFromAddingSubsumptionConstraint of TcGlobals * DisplayEn
exception ErrorFromAddingConstraint of DisplayEnv * exn * range
exception UnresolvedConversionOperator of DisplayEnv * TType * TType * range
exception PossibleOverload of DisplayEnv * string * exn * range
exception UnresolvedOverloading of DisplayEnv * exn list (* PossibleOverload list *) * string * range
//exception PossibleBestOverload of DisplayEnv * string * range
exception UnresolvedOverloading of DisplayEnv * exn list * string * range
exception NonRigidTypar of DisplayEnv * string option * range * TType * TType * range

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

[<Sealed>]
type ConstraintSolverState =
static member New: TcGlobals * Import.ImportMap * InfoReader * TcValF-> ConstraintSolverState
static member New: TcGlobals * Import.ImportMap * InfoReader * TcValF -> ConstraintSolverState

type ConstraintSolverEnv

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

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

Expand Down
Loading

0 comments on commit 79b8293

Please sign in to comment.