diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 9bd796db14..d027afabeb 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -764,7 +764,7 @@ let StorageForVal m v eenv = try eenv.valsInScope.[v] with :? KeyNotFoundException -> assert false - errorR(Error(FSComp.SR.ilUndefinedValue(showL(vspecAtBindL v)),m)) + errorR(Error(FSComp.SR.ilUndefinedValue(showL(valAtBindL v)),m)) notlazy (Arg 668(* random value for post-hoc diagnostic analysis on generated tree *) ) v.Force() diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index b97e6b7da7..5e34582267 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -976,11 +976,11 @@ let AbstractLazyModulInfoByHiding isAssemblyBoundary mhi = // Under those checks, the further hidden* checks may be subsumed (meaning, not required anymore). let hiddenTycon, hiddenTyconRepr, hiddenVal, hiddenRecdField, hiddenUnionCase = - Zset.memberOf mhi.mhiTycons, - Zset.memberOf mhi.mhiTyconReprs, - Zset.memberOf mhi.mhiVals, - Zset.memberOf mhi.mhiRecdFields, - Zset.memberOf mhi.mhiUnionCases + Zset.memberOf mhi.HiddenTycons, + Zset.memberOf mhi.HiddenTyconReprs, + Zset.memberOf mhi.HiddenVals, + Zset.memberOf mhi.HiddenRecdFields, + Zset.memberOf mhi.HiddenUnionCases let rec abstractExprInfo ivalue = match ivalue with @@ -3229,7 +3229,7 @@ and OptimizeModuleExpr cenv env x = not (ValueIsUsedOrHasEffect cenv (fun () -> fvs.FreeLocals) (bind, binfo)) && // Check the thing is hidden by the signature (if any) - hidden.mhiVals.Contains bind.Var && + hidden.HiddenVals.Contains bind.Var && // Check the thing is not compiled as a static field or property, since reflected definitions and other reflective stuff might need it not (IsCompiledAsStaticProperty cenv.g bind.Var)) diff --git a/src/fsharp/SignatureConformance.fs b/src/fsharp/SignatureConformance.fs index ed5c04da71..ac0c23e970 100644 --- a/src/fsharp/SignatureConformance.fs +++ b/src/fsharp/SignatureConformance.fs @@ -37,8 +37,8 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = // Used when checking attributes. let sigToImplRemap = let remap = Remap.Empty - let remap = (remapInfo.mrpiEntities,remap) ||> List.foldBack (fun (implTcref ,signTcref) acc -> addTyconRefRemap signTcref implTcref acc) - let remap = (remapInfo.mrpiVals ,remap) ||> List.foldBack (fun (implValRef,signValRef) acc -> addValRemap signValRef.Deref implValRef.Deref acc) + let remap = (remapInfo.RepackagedEntities,remap) ||> List.foldBack (fun (implTcref ,signTcref) acc -> addTyconRefRemap signTcref implTcref acc) + let remap = (remapInfo.RepackagedVals ,remap) ||> List.foldBack (fun (implValRef,signValRef) acc -> addValRemap signValRef.Deref implValRef.Deref acc) remap // For all attributable elements (types, modules, exceptions, record fields, unions, parameters, generic type parameters) diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 19414aa5f5..23242b1aff 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -3442,7 +3442,7 @@ module DebugPrint = begin let rec MemberL (v:Val) (membInfo:ValMemberInfo) = (aboveListL [ wordL(tagText "compiled_name! = ") ^^ wordL (tagText v.CompiledName) ; wordL(tagText "membInfo-slotsig! = ") ^^ listL slotSigL membInfo.ImplementedSlotSigs ]) - and vspecAtBindL v = + and valAtBindL v = let vL = valL v in let mutL = (if v.IsMutable then wordL(tagText "mutable") ++ vL else vL) mutL --- (aboveListL (List.concat [[wordL(tagText ":") ^^ typeL v.Type]; @@ -3512,7 +3512,7 @@ module DebugPrint = begin then emptyL else let iimplsLs = iimpls |> List.map (fun (ty, _, _) -> wordL(tagText "interface") --- typeL ty) - let adhocLs = adhoc |> List.map (fun vref -> vspecAtBindL vref.Deref) + let adhocLs = adhoc |> List.map (fun vref -> valAtBindL vref.Deref) (wordL(tagText "with") @@-- aboveListL (iimplsLs @ adhocLs)) @@ wordL(tagText "end") let layoutUnionCaseArgTypes argtys = sepListL (wordL(tagText "*")) (List.map typeL argtys) @@ -3559,7 +3559,7 @@ module DebugPrint = begin let vsprs = tycon.MembersOfFSharpTyconSorted |> List.filter (fun v -> v.IsDispatchSlot) - |> List.map (fun vref -> vspecAtBindL vref.Deref) + |> List.map (fun vref -> valAtBindL vref.Deref) let vals = tycon.TrueFieldsAsList |> List.map (fun f -> (if f.IsStatic then wordL(tagText "static") else emptyL) ^^ wordL(tagText "val") ^^ layoutRecdField f) let alldecls = inherits @ vsprs @ vals let emptyMeasure = match tycon.TypeOrMeasureKind with TyparKind.Measure -> isNil alldecls | _ -> false @@ -3590,7 +3590,7 @@ module DebugPrint = begin //-------------------------------------------------------------------------- and bindingL (TBind(v, repr, _)) = - vspecAtBindL v --- (wordL(tagText "=") ^^ exprL repr) + valAtBindL v --- (wordL(tagText "=") ^^ exprL repr) and exprL expr = exprWrapL false expr and atomL expr = exprWrapL true expr // true means bracket if needed to be atomic expr @@ -3628,11 +3628,11 @@ module DebugPrint = begin | ThenDoSeq -> "; (*ThenDo*)" ((exprL x0 ^^ rightL (tagText flag)) @@ exprL x1) |> wrap | Expr.Lambda(_, _, baseValOpt, argvs, body, _, _) -> - let formalsL = spaceListL (List.map vspecAtBindL argvs) in + let formalsL = spaceListL (List.map valAtBindL argvs) in let bindingL = match baseValOpt with | None -> wordL(tagText "lam") ^^ formalsL ^^ rightL(tagText ".") - | Some basev -> wordL(tagText "lam") ^^ (leftL(tagText "base=") ^^ vspecAtBindL basev) --- formalsL ^^ rightL(tagText ".") in + | Some basev -> wordL(tagText "lam") ^^ (leftL(tagText "base=") ^^ valAtBindL basev) --- formalsL ^^ rightL(tagText ".") in (bindingL ++ exprL body) |> wrap | Expr.TyLambda(_, argtyvs, body, _, _) -> ((wordL(tagText "LAM") ^^ spaceListL (List.map typarL argtyvs) ^^ rightL(tagText ".")) ++ exprL body) |> wrap @@ -3727,7 +3727,7 @@ module DebugPrint = begin | Expr.Obj (_lambdaId, ty, basev, ccall, overrides, iimpls, _) -> wordL(tagText "OBJ:") ^^ aboveListL [typeL ty; exprL ccall; - optionL vspecAtBindL basev; + optionL valAtBindL basev; aboveListL (List.map overrideL overrides); aboveListL (List.map iimplL iimpls)] @@ -3812,7 +3812,7 @@ module DebugPrint = begin and tmethodL (TObjExprMethod(TSlotSig(nm, _, _, _, _, _), _, tps, vs, e, _)) = (wordL(tagText "TObjExprMethod") --- (wordL (tagText nm)) ^^ wordL(tagText "=")) -- (wordL(tagText "METH-LAM") --- angleBracketListL (List.map typarL tps) ^^ rightL(tagText ".")) --- - (wordL(tagText "meth-lam") --- tupleL (List.map (List.map vspecAtBindL >> tupleL) vs) ^^ rightL(tagText ".")) --- + (wordL(tagText "meth-lam") --- tupleL (List.map (List.map valAtBindL >> tupleL) vs) ^^ rightL(tagText ".")) --- (atomL e) and overrideL tmeth = wordL(tagText "with") ^^ tmethodL tmeth and iimplL (ty, tmeths) = wordL(tagText "impl") ^^ aboveListL (typeL ty :: List.map tmethodL tmeths) @@ -3850,33 +3850,33 @@ let SigTypeOfImplFile (TImplFile(_, _, mexpr, _, _, _)) = mexpr.Type //-------------------------------------------------------------------------- type SignatureRepackageInfo = - { mrpiVals : (ValRef * ValRef) list; - mrpiEntities: (TyconRef * TyconRef) list } + { RepackagedVals : (ValRef * ValRef) list; + RepackagedEntities: (TyconRef * TyconRef) list } - member remapInfo.ImplToSigMapping = { TypeEquivEnv.Empty with EquivTycons = TyconRefMap.OfList remapInfo.mrpiEntities } - static member Empty = { mrpiVals = []; mrpiEntities= [] } + member remapInfo.ImplToSigMapping = { TypeEquivEnv.Empty with EquivTycons = TyconRefMap.OfList remapInfo.RepackagedEntities } + static member Empty = { RepackagedVals = []; RepackagedEntities= [] } type SignatureHidingInfo = - { mhiTycons : Zset; - mhiTyconReprs : Zset; - mhiVals : Zset; - mhiRecdFields : Zset; - mhiUnionCases : Zset } + { HiddenTycons : Zset; + HiddenTyconReprs : Zset; + HiddenVals : Zset; + HiddenRecdFields : Zset; + HiddenUnionCases : Zset } static member Empty = - { mhiTycons = Zset.empty tyconOrder; - mhiTyconReprs = Zset.empty tyconOrder; - mhiVals = Zset.empty valOrder; - mhiRecdFields = Zset.empty recdFieldRefOrder; - mhiUnionCases = Zset.empty unionCaseRefOrder } + { HiddenTycons = Zset.empty tyconOrder; + HiddenTyconReprs = Zset.empty tyconOrder; + HiddenVals = Zset.empty valOrder; + HiddenRecdFields = Zset.empty recdFieldRefOrder; + HiddenUnionCases = Zset.empty unionCaseRefOrder } let addValRemap v v' tmenv = { tmenv with valRemap= tmenv.valRemap.Add v (mkLocalValRef v') } let mkRepackageRemapping mrpi = - { valRemap = ValMap.OfList (mrpi.mrpiVals |> List.map (fun (vref, x) -> vref.Deref, x)); + { valRemap = ValMap.OfList (mrpi.RepackagedVals |> List.map (fun (vref, x) -> vref.Deref, x)); tpinst = emptyTyparInst; - tyconRefRemap = TyconRefMap.OfList mrpi.mrpiEntities + tyconRefRemap = TyconRefMap.OfList mrpi.RepackagedEntities removeTraitSolutions = false } //-------------------------------------------------------------------------- @@ -3888,18 +3888,18 @@ let accEntityRemap (msigty:ModuleOrNamespaceType) (entity:Entity) (mrpi, mhi) = match sigtyconOpt with | None -> // The type constructor is not present in the signature. Hence it is hidden. - let mhi = { mhi with mhiTycons = Zset.add entity mhi.mhiTycons } + let mhi = { mhi with HiddenTycons = Zset.add entity mhi.HiddenTycons } (mrpi, mhi) | Some sigtycon -> // The type constructor is in the signature. Hence record the repackage entry let sigtcref = mkLocalTyconRef sigtycon let tcref = mkLocalTyconRef entity - let mrpi = { mrpi with mrpiEntities = ((tcref, sigtcref) :: mrpi.mrpiEntities) } + let mrpi = { mrpi with RepackagedEntities = ((tcref, sigtcref) :: mrpi.RepackagedEntities) } // OK, now look for hidden things let mhi = if (match entity.TypeReprInfo with TNoRepr -> false | _ -> true) && (match sigtycon.TypeReprInfo with TNoRepr -> true | _ -> false) then // The type representation is absent in the signature, hence it is hidden - { mhi with mhiTyconReprs = Zset.add entity mhi.mhiTyconReprs } + { mhi with HiddenTyconReprs = Zset.add entity mhi.HiddenTyconReprs } else // The type representation is present in the signature. // Find the fields that have been hidden or which were non-public anyway. @@ -3912,7 +3912,7 @@ let accEntityRemap (msigty:ModuleOrNamespaceType) (entity:Entity) (mrpi, mhi) = | _ -> // The field is not in the signature. Hence it is regarded as hidden. let rfref = tcref.MakeNestedRecdFieldRef rfield - { mhi with mhiRecdFields = Zset.add rfref mhi.mhiRecdFields }) + { mhi with HiddenRecdFields = Zset.add rfref mhi.HiddenRecdFields }) entity.AllFieldsArray |> List.foldBack (fun (ucase:UnionCase) mhi -> match sigtycon.GetUnionCaseByName ucase.DisplayName with @@ -3922,7 +3922,7 @@ let accEntityRemap (msigty:ModuleOrNamespaceType) (entity:Entity) (mrpi, mhi) = | _ -> // The constructor is not in the signature. Hence it is regarded as hidden. let ucref = tcref.MakeNestedUnionCaseRef ucase - { mhi with mhiUnionCases = Zset.add ucref mhi.mhiUnionCases }) + { mhi with HiddenUnionCases = Zset.add ucref mhi.HiddenUnionCases }) (entity.UnionCasesAsList) (mrpi, mhi) @@ -3931,13 +3931,13 @@ let accSubEntityRemap (msigty:ModuleOrNamespaceType) (entity:Entity) (mrpi, mhi) match sigtyconOpt with | None -> // The type constructor is not present in the signature. Hence it is hidden. - let mhi = { mhi with mhiTycons = Zset.add entity mhi.mhiTycons } + let mhi = { mhi with HiddenTycons = Zset.add entity mhi.HiddenTycons } (mrpi, mhi) | Some sigtycon -> // The type constructor is in the signature. Hence record the repackage entry let sigtcref = mkLocalTyconRef sigtycon let tcref = mkLocalTyconRef entity - let mrpi = { mrpi with mrpiEntities = ((tcref, sigtcref) :: mrpi.mrpiEntities) } + let mrpi = { mrpi with RepackagedEntities = ((tcref, sigtcref) :: mrpi.RepackagedEntities) } (mrpi, mhi) let valLinkageAEquiv g aenv (v1:Val) (v2:Val) = @@ -3955,11 +3955,11 @@ let accValRemap g aenv (msigty:ModuleOrNamespaceType) (implVal:Val) (mrpi, mhi) match sigValOpt with | None -> if verbose then dprintf "accValRemap, hide = %s#%d\n" implVal.LogicalName implVal.Stamp - let mhi = { mhi with mhiVals = Zset.add implVal mhi.mhiVals } + let mhi = { mhi with HiddenVals = Zset.add implVal mhi.HiddenVals } (mrpi, mhi) | Some (sigVal:Val) -> // The value is in the signature. Add the repackage entry. - let mrpi = { mrpi with mrpiVals = (vref, mkLocalValRef sigVal) :: mrpi.mrpiVals } + let mrpi = { mrpi with RepackagedVals = (vref, mkLocalValRef sigVal) :: mrpi.RepackagedVals } (mrpi, mhi) let getCorrespondingSigTy nm (msigty:ModuleOrNamespaceType) = @@ -4053,9 +4053,9 @@ let ComputeRemappingFromImplementationToSignature g mdef msigty = let accTyconHidingInfoAtAssemblyBoundary (tycon:Tycon) mhi = if not (canAccessFromEverywhere tycon.Accessibility) then // The type constructor is not public, hence hidden at the assembly boundary. - { mhi with mhiTycons = Zset.add tycon mhi.mhiTycons } + { mhi with HiddenTycons = Zset.add tycon mhi.HiddenTycons } elif not (canAccessFromEverywhere tycon.TypeReprAccessibility) then - { mhi with mhiTyconReprs = Zset.add tycon mhi.mhiTyconReprs } + { mhi with HiddenTyconReprs = Zset.add tycon mhi.HiddenTyconReprs } else mhi |> Array.foldBack @@ -4063,7 +4063,7 @@ let accTyconHidingInfoAtAssemblyBoundary (tycon:Tycon) mhi = if not (canAccessFromEverywhere rfield.Accessibility) then let tcref = mkLocalTyconRef tycon let rfref = tcref.MakeNestedRecdFieldRef rfield - { mhi with mhiRecdFields = Zset.add rfref mhi.mhiRecdFields } + { mhi with HiddenRecdFields = Zset.add rfref mhi.HiddenRecdFields } else mhi) tycon.AllFieldsArray |> List.foldBack @@ -4071,7 +4071,7 @@ let accTyconHidingInfoAtAssemblyBoundary (tycon:Tycon) mhi = if not (canAccessFromEverywhere ucase.Accessibility) then let tcref = mkLocalTyconRef tycon let ucref = tcref.MakeNestedUnionCaseRef ucase - { mhi with mhiUnionCases = Zset.add ucref mhi.mhiUnionCases } + { mhi with HiddenUnionCases = Zset.add ucref mhi.HiddenUnionCases } else mhi) (tycon.UnionCasesAsList) @@ -4086,7 +4086,7 @@ let accValHidingInfoAtAssemblyBoundary (vspec:Val) mhi = // anything that's not a module or member binding gets assembly visibility not vspec.IsMemberOrModuleBinding then // The value is not public, hence hidden at the assembly boundary. - { mhi with mhiVals = Zset.add vspec mhi.mhiVals } + { mhi with HiddenVals = Zset.add vspec mhi.HiddenVals } else mhi @@ -4121,10 +4121,10 @@ let IsHidden setF accessF remapF debugF = if verbose then dprintf "IsHidden, #mrmi = %d, %s = %b\n" mrmi.Length (showL (debugF x)) res; res -let IsHiddenTycon mrmi x = IsHidden (fun mhi -> mhi.mhiTycons) (fun tc -> tc.Accessibility) (fun rpi x -> (remapTyconRef rpi.tyconRefRemap (mkLocalTyconRef x)).Deref) DebugPrint.tyconL mrmi x -let IsHiddenTyconRepr mrmi x = IsHidden (fun mhi -> mhi.mhiTyconReprs) (fun v -> v.TypeReprAccessibility) (fun rpi x -> (remapTyconRef rpi.tyconRefRemap (mkLocalTyconRef x)).Deref) DebugPrint.tyconL mrmi x -let IsHiddenVal mrmi x = IsHidden (fun mhi -> mhi.mhiVals) (fun v -> v.Accessibility) (fun rpi x -> (remapValRef rpi (mkLocalValRef x)).Deref) DebugPrint.valL mrmi x -let IsHiddenRecdField mrmi x = IsHidden (fun mhi -> mhi.mhiRecdFields) (fun rfref -> rfref.RecdField.Accessibility) (fun rpi x -> remapRecdFieldRef rpi.tyconRefRemap x) DebugPrint.recdFieldRefL mrmi x +let IsHiddenTycon mrmi x = IsHidden (fun mhi -> mhi.HiddenTycons) (fun tc -> tc.Accessibility) (fun rpi x -> (remapTyconRef rpi.tyconRefRemap (mkLocalTyconRef x)).Deref) DebugPrint.tyconL mrmi x +let IsHiddenTyconRepr mrmi x = IsHidden (fun mhi -> mhi.HiddenTyconReprs) (fun v -> v.TypeReprAccessibility) (fun rpi x -> (remapTyconRef rpi.tyconRefRemap (mkLocalTyconRef x)).Deref) DebugPrint.tyconL mrmi x +let IsHiddenVal mrmi x = IsHidden (fun mhi -> mhi.HiddenVals) (fun v -> v.Accessibility) (fun rpi x -> (remapValRef rpi (mkLocalValRef x)).Deref) DebugPrint.valL mrmi x +let IsHiddenRecdField mrmi x = IsHidden (fun mhi -> mhi.HiddenRecdFields) (fun rfref -> rfref.RecdField.Accessibility) (fun rpi x -> remapRecdFieldRef rpi.tyconRefRemap x) DebugPrint.recdFieldRefL mrmi x //-------------------------------------------------------------------------- diff --git a/src/fsharp/TastOps.fsi b/src/fsharp/TastOps.fsi index 0731970c19..badacfda0e 100755 --- a/src/fsharp/TastOps.fsi +++ b/src/fsharp/TastOps.fsi @@ -3,26 +3,18 @@ /// Defines derived expression manipulation and construction functions. module internal Microsoft.FSharp.Compiler.Tastops -open System.Text open System.Collections.Generic open Internal.Utilities open Microsoft.FSharp.Compiler.AbstractIL open Microsoft.FSharp.Compiler.AbstractIL.IL open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.Range open Microsoft.FSharp.Compiler.Rational open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger open Microsoft.FSharp.Compiler.Tast open Microsoft.FSharp.Compiler.TcGlobals open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Lib - -#if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping -#endif //------------------------------------------------------------------------- // Type equivalence @@ -42,10 +34,6 @@ val measureEquiv : TcGlobals -> Measure -> Measure -> bool /// Reduce a type to its more anonical form subject to an erasure flag, inference equations and abbreviations val stripTyEqnsWrtErasure: Erasure -> TcGlobals -> TType -> TType -//------------------------------------------------------------------------- -// Build common types -//------------------------------------------------------------------------- - /// Build a function type val mkFunTy : TType -> TType -> TType @@ -77,139 +65,232 @@ val stripExpr : Expr -> Expr /// Get the values for a set of bindings val valsOfBinds : Bindings -> Vals -val (|ExprValWithPossibleTypeInst|_|) : Expr -> (ValRef * ValUseFlag * TType list * range) option -//------------------------------------------------------------------------- -// Build decision trees imperatively -//------------------------------------------------------------------------- +/// Look for a use of an F# value, possibly including application of a generic thing to a set of type arguments +val (|ExprValWithPossibleTypeInst|_|) : Expr -> (ValRef * ValUseFlag * TType list * range) option +/// Build decision trees imperatively type MatchBuilder = + + /// Create a new builder new : SequencePointInfoForBinding * range -> MatchBuilder + + /// Add a new destination target member AddTarget : DecisionTreeTarget -> int + + /// Add a new destination target that is an expression result member AddResultTarget : Expr * SequencePointInfoForTarget -> DecisionTree + + /// Finish the targets member CloseTargets : unit -> DecisionTreeTarget list - member Close : DecisionTree * range * TType -> Expr -//------------------------------------------------------------------------- -// Make some special decision graphs -//------------------------------------------------------------------------- + /// Build the overall expression + member Close : DecisionTree * range * TType -> Expr +/// Add an if-then-else boolean conditional node into a decision tree val mkBoolSwitch : range -> Expr -> DecisionTree -> DecisionTree -> DecisionTree + +/// Build a conditional expression val primMkCond : SequencePointInfoForBinding -> SequencePointInfoForTarget -> SequencePointInfoForTarget -> range -> TType -> Expr -> Expr -> Expr -> Expr + +/// Build a conditional expression val mkCond : SequencePointInfoForBinding -> SequencePointInfoForTarget -> range -> TType -> Expr -> Expr -> Expr -> Expr + +/// Build a conditional expression that checks for non-nullness val mkNonNullCond : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -val mkIfThen : TcGlobals -> range -> Expr -> Expr -> Expr -//------------------------------------------------------------------------- -// Generate new locals -//------------------------------------------------------------------------- +/// Build an if-then statement +val mkIfThen : TcGlobals -> range -> Expr -> Expr -> Expr +/// Build an expression corresponding to the use of a value /// Note: try to use exprForValRef or the expression returned from mkLocal instead of this. val exprForVal : range -> Val -> Expr + +/// Build an expression corresponding to the use of a reference to a value val exprForValRef : range -> ValRef -> Expr -/// Return the local and an expression to reference it +/// Make a new local value and build an expression to reference it val mkLocal : range -> string -> TType -> Val * Expr + +/// Make a new compiler-generated local value and build an expression to reference it val mkCompGenLocal : range -> string -> TType -> Val * Expr + +/// Make a new mutable compiler-generated local value and build an expression to reference it val mkMutableCompGenLocal : range -> string -> TType -> Val * Expr -val mkCompGenLocalAndInvisbleBind : TcGlobals -> string -> range -> Expr -> Val * Expr * Binding -//------------------------------------------------------------------------- -// Make lambdas -//------------------------------------------------------------------------- +/// Make a new mutable compiler-generated local value, 'let' bind it to an expression +/// 'invisibly' (no sequence point etc.), and build an expression to reference it +val mkCompGenLocalAndInvisbleBind : TcGlobals -> string -> range -> Expr -> Val * Expr * Binding +/// Build a lambda expression taking multiple values val mkMultiLambda : range -> Val list -> Expr * TType -> Expr + +/// Rebuild a lambda during an expression tree traversal val rebuildLambda : range -> Val option -> Val option -> Val list -> Expr * TType -> Expr + +/// Build a lambda expression taking a single value val mkLambda : range -> Val -> Expr * TType -> Expr + +/// Build a generic lambda expression (type abstraction) val mkTypeLambda : range -> Typars -> Expr * TType -> Expr + +/// Build an object expression val mkObjExpr : TType * Val option * Expr * ObjExprMethod list * (TType * ObjExprMethod list) list * Range.range -> Expr + +/// Build an type-chose expression, indicating that a local free choice of a type variable val mkTypeChoose : range -> Typars -> Expr -> Expr + +/// Build an iterated (curried) lambda expression val mkLambdas : range -> Typars -> Val list -> Expr * TType -> Expr + +/// Build an iterated (tupled+curried) lambda expression val mkMultiLambdasCore : range -> Val list list -> Expr * TType -> Expr * TType + +/// Build an iterated generic (type abstraction + tupled+curried) lambda expression val mkMultiLambdas : range -> Typars -> Val list list -> Expr * TType -> Expr + +/// Build a lambda expression that corresponds to the implementation of a member val mkMemberLambdas : range -> Typars -> Val option -> Val option -> Val list list -> Expr * TType -> Expr +/// Build a 'while' loop expression val mkWhile : TcGlobals -> SequencePointInfoForWhileLoop * SpecialWhileLoopMarker * Expr * Expr * range -> Expr + +/// Build a 'for' loop expression val mkFor : TcGlobals -> SequencePointInfoForForLoop * Val * Expr * ForLoopStyle * Expr * Expr * range -> Expr + +/// Build a 'try/with' expression val mkTryWith : TcGlobals -> Expr * (* filter val *) Val * (* filter expr *) Expr * (* handler val *) Val * (* handler expr *) Expr * range * TType * SequencePointInfoForTry * SequencePointInfoForWith -> Expr -val mkTryFinally: TcGlobals -> Expr * Expr * range * TType * SequencePointInfoForTry * SequencePointInfoForFinally -> Expr -//------------------------------------------------------------------------- -// Make let/letrec -//------------------------------------------------------------------------- - +/// Build a 'try/finally' expression +val mkTryFinally: TcGlobals -> Expr * Expr * range * TType * SequencePointInfoForTry * SequencePointInfoForFinally -> Expr -// Generate a user-level let-bindings +/// Build a user-level value binding val mkBind : SequencePointInfoForBinding -> Val -> Expr -> Binding + +/// Build a user-level let-binding val mkLetBind : range -> Binding -> Expr -> Expr + +/// Build a user-level value sequence of let bindings val mkLetsBind : range -> Binding list -> Expr -> Expr + +/// Build a user-level value sequence of let bindings val mkLetsFromBindings : range -> Bindings -> Expr -> Expr + +/// Build a user-level let expression val mkLet : SequencePointInfoForBinding -> range -> Val -> Expr -> Expr -> Expr + +/// Make a binding that binds a function value to a lambda taking multiple arguments val mkMultiLambdaBind : Val -> SequencePointInfoForBinding -> range -> Typars -> Val list list -> Expr * TType -> Binding // Compiler generated bindings may involve a user variable. // Compiler generated bindings may give rise to a sequence point if they are part of // an SPAlways expression. Compiler generated bindings can arise from for example, inlining. val mkCompGenBind : Val -> Expr -> Binding + +/// Make a set of bindings that bind compiler generated values to corresponding expressions. +/// Compiler-generated bindings do not give rise to a sequence point in debugging. val mkCompGenBinds : Val list -> Exprs -> Bindings + +/// Make a let-expression that locally binds a compiler-generated value to an expression. +/// Compiler-generated bindings do not give rise to a sequence point in debugging. val mkCompGenLet : range -> Val -> Expr -> Expr -> Expr + +/// Make a let-expression that locally binds a compiler-generated value to an expression, where the expression +/// is returned by the given continuation. Compiler-generated bindings do not give rise to a sequence point in debugging. val mkCompGenLetIn: range -> string -> TType -> Expr -> (Val * Expr -> Expr) -> Expr -// Invisible bindings are never given a sequence point and should never have side effects +/// Make a let-expression that locally binds a value to an expression in an "invisible" way. +/// Invisible bindings are not given a sequence point and should not have side effects. val mkInvisibleLet : range -> Val -> Expr -> Expr -> Expr + +/// Make a binding that binds a value to an expression in an "invisible" way. +/// Invisible bindings are not given a sequence point and should not have side effects. val mkInvisibleBind : Val -> Expr -> Binding + +/// Make a set of bindings that bind values to expressions in an "invisible" way. +/// Invisible bindings are not given a sequence point and should not have side effects. val mkInvisibleBinds : Vals -> Exprs -> Bindings + +/// Make a let-rec expression that locally binds values to expressions where self-reference back to the values is possible. val mkLetRecBinds : range -> Bindings -> Expr -> Expr -//------------------------------------------------------------------------- -// Generalization/inference helpers -//------------------------------------------------------------------------- - /// TypeScheme (generalizedTypars, tauTy) /// /// generalizedTypars -- the truly generalized type parameters /// tauTy -- the body of the generalized type. A 'tau' type is one with its type parameters stripped off. type TypeScheme = TypeScheme of Typars * TType +/// Make the right-hand side of a generalized binding, incorporating the generalized generic parameters from the type +/// scheme into the right-hand side as type generalizations. val mkGenericBindRhs : TcGlobals -> range -> Typars -> TypeScheme -> Expr -> Expr -val isBeingGeneralized : Typar -> TypeScheme -> bool -//------------------------------------------------------------------------- -// Make lazy and/or -//------------------------------------------------------------------------- +/// Test if the type parameter is one of those being generalized by a type scheme. +val isBeingGeneralized : Typar -> TypeScheme -> bool +/// Make the expression corresponding to 'expr1 && expr2' val mkLazyAnd : TcGlobals -> range -> Expr -> Expr -> Expr + +/// Make the expression corresponding to 'expr1 || expr2' val mkLazyOr : TcGlobals -> range -> Expr -> Expr -> Expr + +/// Make a byref type val mkByrefTy : TcGlobals -> TType -> TType + +/// Make a byref type with a in/out kind inference parameter val mkByrefTyWithInference : TcGlobals -> TType -> TType -> TType + +/// Make a in-byref type with a in kind parameter val mkInByrefTy : TcGlobals -> TType -> TType -val mkOutByrefTy : TcGlobals -> TType -> TType -//------------------------------------------------------------------------- -// Make construction operations -//------------------------------------------------------------------------- +/// Make an out-byref type with an out kind parameter +val mkOutByrefTy : TcGlobals -> TType -> TType +/// Make an expression that constructs a union case, e.g. 'Some(expr)' val mkUnionCaseExpr : UnionCaseRef * TypeInst * Exprs * range -> Expr + +/// Make an expression that constructs an exception value val mkExnExpr : TyconRef * Exprs * range -> Expr + +/// Make an expression that is IL assembly code val mkAsmExpr : ILInstr list * TypeInst * Exprs * TTypes * range -> Expr + +/// Make an expression that coerces one expression to another type val mkCoerceExpr : Expr * TType * range * TType -> Expr -val mkReraise : range -> TType -> Expr -val mkReraiseLibCall : TcGlobals -> TType -> range -> Expr +/// Make an expression that re-raises an exception +val mkReraise : range -> TType -> Expr -//------------------------------------------------------------------------- -// Make projection operations -//------------------------------------------------------------------------- +/// Make an expression that re-raises an exception via a library call +val mkReraiseLibCall : TcGlobals -> TType -> range -> Expr +/// Make an expression that gets an item from a tuple val mkTupleFieldGet : TcGlobals -> TupInfo * Expr * TypeInst * int * range -> Expr + +/// Make an expression that gets an item from an anonymous record val mkAnonRecdFieldGet : TcGlobals -> AnonRecdTypeInfo * Expr * TypeInst * int * range -> Expr + +/// Make an expression that gets an item from an anonymous record (via the address of the value if it is a struct) val mkAnonRecdFieldGetViaExprAddr : AnonRecdTypeInfo * Expr * TypeInst * int * range -> Expr + +/// Make an expression that gets an instance field from a record or class (via the address of the value if it is a struct) val mkRecdFieldGetViaExprAddr : Expr * RecdFieldRef * TypeInst * range -> Expr + +/// Make an expression that gets the address of an instance field from a record or class (via the address of the value if it is a struct) val mkRecdFieldGetAddrViaExprAddr : readonly: bool * Expr * RecdFieldRef * TypeInst * range -> Expr + +/// Make an expression that gets a static field from a record or class val mkStaticRecdFieldGet : RecdFieldRef * TypeInst * range -> Expr + +/// Make an expression that sets a static field in a record or class val mkStaticRecdFieldSet : RecdFieldRef * TypeInst * Expr * range -> Expr + +/// Make an expression that gets the address of a static field in a record or class val mkStaticRecdFieldGetAddr : readonly: bool * RecdFieldRef * TypeInst * range -> Expr + +/// Make an expression that sets an instance the field of a record or class (via the address of the value if it is a struct) val mkRecdFieldSetViaExprAddr : Expr * RecdFieldRef * TypeInst * Expr * range -> Expr + +/// Make an expression that gets the tag of a union value (via the address of the value if it is a struct) val mkUnionCaseTagGetViaExprAddr : Expr * TyconRef * TypeInst * range -> Expr /// Make a 'TOp.UnionCaseProof' expression, which proves a union value is over a particular case (used only for ref-unions, not struct-unions) @@ -238,9 +319,13 @@ val mkUnionCaseFieldSet : Expr * UnionCaseRef * TypeInst * int * E /// Like mkUnionCaseFieldGetUnprovenViaExprAddr, but for struct-unions, the input should be a copy of the expression. val mkUnionCaseFieldGetUnproven : TcGlobals -> Expr * UnionCaseRef * TypeInst * int * range -> Expr +/// Make an expression that gets an instance field from an F# exception value val mkExnCaseFieldGet : Expr * TyconRef * int * range -> Expr + +/// Make an expression that sets an instance field in an F# exception value val mkExnCaseFieldSet : Expr * TyconRef * int * Expr * range -> Expr +/// Make an expression that gets the address of an element in an array val mkArrayElemAddress : TcGlobals -> readonly: bool * ILReadonly * bool * ILArrayShape * TType * Expr list * range -> Expr //------------------------------------------------------------------------- @@ -272,49 +357,60 @@ val mkGetTupleItemN : TcGlobals -> range -> int -> ILType -> bool -> Expr -> TTy /// Evaluate the TupInfo to work out if it is a struct or a ref. Currently this is very simple /// but TupInfo may later be used carry variables that infer structness. val evalTupInfoIsStruct : TupInfo -> bool + +/// Evaluate the AnonRecdTypeInfo to work out if it is a struct or a ref. val evalAnonInfoIsStruct : AnonRecdTypeInfo -> bool /// If it is a tuple type, ensure it's outermost type is a .NET tuple type, otherwise leave unchanged val convertToTypeWithMetadataIfPossible : TcGlobals -> TType -> TType - -//------------------------------------------------------------------------- -// Take the address of an expression, or force it into a mutable local. Any allocated -// mutable local may need to be kept alive over a larger expression, hence we return -// a wrapping function that wraps "let mutable loc = Expr in ..." around a larger -// expression. -//------------------------------------------------------------------------- - +/// An exception representing a warning for a defensive copy of an immutable struct exception DefensiveCopyWarning of string * range + type Mutates = AddressOfOp | DefinitelyMutates | PossiblyMutates | NeverMutates + +/// Helper to take the address of an expression val mkExprAddrOfExprAux : TcGlobals -> bool -> bool -> Mutates -> Expr -> ValRef option -> range -> (Val * Expr) option * Expr * bool * bool -val mkExprAddrOfExpr : TcGlobals -> bool -> bool -> Mutates -> Expr -> ValRef option -> range -> (Expr -> Expr) * Expr * bool * bool -//------------------------------------------------------------------------- -// Tables keyed on values and/or type parameters -//------------------------------------------------------------------------- +/// Take the address of an expression, or force it into a mutable local. Any allocated +/// mutable local may need to be kept alive over a larger expression, hence we return +/// a wrapping function that wraps "let mutable loc = Expr in ..." around a larger +/// expression. +val mkExprAddrOfExpr : TcGlobals -> bool -> bool -> Mutates -> Expr -> ValRef option -> range -> (Expr -> Expr) * Expr * bool * bool /// Maps Val to T, based on stamps [] type ValMap<'T> = + member Contents : StampMap<'T> + member Item : Val -> 'T with get + member TryFind : Val -> 'T option + member ContainsVal : Val -> bool + member Add : Val -> 'T -> ValMap<'T> + member Remove : Val -> ValMap<'T> + member IsEmpty : bool + static member Empty : ValMap<'T> + static member OfList : (Val * 'T) list -> ValMap<'T> /// Mutable data structure mapping Val's to T based on stamp keys [] type ValHash<'T> = + member Values : seq<'T> + member TryFind : Val -> 'T option + member Add : Val * 'T -> unit - static member Create : unit -> ValHash<'T> + static member Create : unit -> ValHash<'T> /// Maps Val's to list of T based on stamp keys [] @@ -332,97 +428,126 @@ type ValMultiMap<'T> = static member Empty : ValMultiMap<'T> +/// Maps type parameters to entries based on stamp keys [] -/// Maps Typar to T based on stamp keys type TyparMap<'T> = + /// Get the entry for the given type parameter member Item : Typar -> 'T with get + /// Determine is the map contains an entry for the given type parameter member ContainsKey : Typar -> bool + /// Try to find the entry for the given type parameter member TryFind : Typar -> 'T option + /// Make a new map, containing a new entry for the given type parameter member Add : Typar * 'T -> TyparMap<'T> + /// The empty map static member Empty : TyparMap<'T> -[] /// Maps TyconRef to T based on stamp keys +[] type TyconRefMap<'T> = + /// Get the entry for the given type definition member Item : TyconRef -> 'T with get + /// Try to find the entry for the given type definition member TryFind : TyconRef -> 'T option + /// Determine is the map contains an entry for the given type definition member ContainsKey : TyconRef -> bool + /// Make a new map, containing a new entry for the given type definition member Add : TyconRef -> 'T -> TyconRefMap<'T> + /// Remove the entry for the given type definition, if any member Remove : TyconRef -> TyconRefMap<'T> + /// Determine if the map is empty member IsEmpty : bool + /// The empty map static member Empty : TyconRefMap<'T> + /// Make a new map, containing entries for the given type definitions static member OfList : (TyconRef * 'T) list -> TyconRefMap<'T> /// Maps TyconRef to list of T based on stamp keys [] type TyconRefMultiMap<'T> = + /// Fetch the entries for the given type definition member Find : TyconRef -> 'T list + /// Make a new map, containing a new entry for the given type definition member Add : TyconRef * 'T -> TyconRefMultiMap<'T> + /// The empty map static member Empty : TyconRefMultiMap<'T> + /// Make a new map, containing a entries for the given type definitions static member OfList : (TyconRef * 'T) list -> TyconRefMultiMap<'T> -//------------------------------------------------------------------------- -// Orderings on Tycon, Val, RecdFieldRef, Typar -//------------------------------------------------------------------------- +/// An ordering for value definitions, based on stamp +val valOrder: IComparer -val valOrder : IComparer -val tyconOrder : IComparer -val recdFieldRefOrder : IComparer -val typarOrder : IComparer +/// An ordering for type definitions, based on stamp +val tyconOrder: IComparer -//------------------------------------------------------------------------- -// Equality on Tycon and Val -//------------------------------------------------------------------------- +/// An ordering for record fields, based on stamp +val recdFieldRefOrder: IComparer +/// An ordering for type parameters, based on stamp +val typarOrder: IComparer + +/// Equality for type definition references val tyconRefEq : TcGlobals -> TyconRef -> TyconRef -> bool + +/// Equality for value references val valRefEq : TcGlobals -> ValRef -> ValRef -> bool //------------------------------------------------------------------------- // Operations on types: substitution //------------------------------------------------------------------------- +/// Represents an instantiation where types replace type parameters type TyparInst = (Typar * TType) list +/// Represents an instantiation where type definition references replace other type definition references type TyconRefRemap = TyconRefMap + +/// Represents an instantiation where value references replace other value references type ValRemap = ValMap +/// Represents a combination of substitutions/instantiations where things replace other things during remapping [] type Remap = - { tpinst : TyparInst; - valRemap: ValRemap; - tyconRefRemap : TyconRefRemap; + { tpinst : TyparInst + valRemap: ValRemap + tyconRefRemap : TyconRefRemap removeTraitSolutions: bool } static member Empty : Remap val addTyconRefRemap : TyconRef -> TyconRef -> Remap -> Remap -val addValRemap : Val -> Val -> Remap -> Remap +val addValRemap : Val -> Val -> Remap -> Remap val mkTyparInst : Typars -> TTypes -> TyparInst + val mkTyconRefInst : TyconRef -> TypeInst -> TyparInst + val emptyTyparInst : TyparInst val instType : TyparInst -> TType -> TType + val instTypes : TyparInst -> TypeInst -> TypeInst + val instTyparConstraints : TyparInst -> TyparConstraint list -> TyparConstraint list + val instTrait : TyparInst -> TraitConstraintInfo -> TraitConstraintInfo //------------------------------------------------------------------------- @@ -430,8 +555,11 @@ val instTrait : TyparInst -> TraitConstraintInfo -> TraitConstraint //------------------------------------------------------------------------- val generalizeTypars : Typars -> TypeInst + val generalizeTyconRef : TyconRef -> TTypes * TType + val generalizedTyconRef : TyconRef -> TType + val mkTyparToTyparRenaming : Typars -> Typars -> TyparInst * TTypes //------------------------------------------------------------------------- @@ -439,12 +567,16 @@ val mkTyparToTyparRenaming : Typars -> Typars -> TyparInst * TTypes //------------------------------------------------------------------------- val reduceTyconRefAbbrev : TyconRef -> TypeInst -> TType + val reduceTyconRefMeasureableOrProvided : TcGlobals -> TyconRef -> TypeInst -> TType + val reduceTyconRefAbbrevMeasureable : TyconRef -> Measure /// set bool to 'true' to allow shortcutting of type parameter equation chains during stripping val stripTyEqnsA : TcGlobals -> bool -> TType -> TType + val stripTyEqns : TcGlobals -> TType -> TType + val stripTyEqnsAndMeasureEqns : TcGlobals -> TType -> TType val tryNormalizeMeasureInType : TcGlobals -> TType -> TType @@ -455,7 +587,9 @@ val tryNormalizeMeasureInType : TcGlobals -> TType -> TType /// See through F# exception abbreviations val stripExnEqns : TyconRef -> Tycon + val recdFieldsOfExnDefRef : TyconRef -> RecdField list + val recdFieldTysOfExnDefRef : TyconRef -> TType list //------------------------------------------------------------------------- @@ -464,63 +598,102 @@ val recdFieldTysOfExnDefRef : TyconRef -> TType list //------------------------------------------------------------------------- val destForallTy : TcGlobals -> TType -> Typars * TType + val destFunTy : TcGlobals -> TType -> TType * TType + val destAnyTupleTy : TcGlobals -> TType -> TupInfo * TTypes + val destRefTupleTy : TcGlobals -> TType -> TTypes + val destStructTupleTy : TcGlobals -> TType -> TTypes + val destTyparTy : TcGlobals -> TType -> Typar + val destAnyParTy : TcGlobals -> TType -> Typar + val destMeasureTy : TcGlobals -> TType -> Measure + val tryDestForallTy : TcGlobals -> TType -> Typars * TType val isFunTy : TcGlobals -> TType -> bool + val isForallTy : TcGlobals -> TType -> bool + val isAnyTupleTy : TcGlobals -> TType -> bool + val isRefTupleTy : TcGlobals -> TType -> bool + val isStructTupleTy : TcGlobals -> TType -> bool + val isStructAnonRecdTy : TcGlobals -> TType -> bool + val isAnonRecdTy : TcGlobals -> TType -> bool + val isUnionTy : TcGlobals -> TType -> bool + val isReprHiddenTy : TcGlobals -> TType -> bool + val isFSharpObjModelTy : TcGlobals -> TType -> bool + val isRecdTy : TcGlobals -> TType -> bool + val isFSharpStructOrEnumTy : TcGlobals -> TType -> bool + val isFSharpEnumTy : TcGlobals -> TType -> bool + val isTyparTy : TcGlobals -> TType -> bool + val isAnyParTy : TcGlobals -> TType -> bool + val tryAnyParTy : TcGlobals -> TType -> ValueOption + val tryAnyParTyOption : TcGlobals -> TType -> Typar option + val isMeasureTy : TcGlobals -> TType -> bool val mkAppTy : TyconRef -> TypeInst -> TType val mkProvenUnionCaseTy : UnionCaseRef -> TypeInst -> TType + val isProvenUnionCaseTy : TType -> bool val isAppTy : TcGlobals -> TType -> bool + val tryAppTy : TcGlobals -> TType -> ValueOption + val destAppTy : TcGlobals -> TType -> TyconRef * TypeInst + val tcrefOfAppTy : TcGlobals -> TType -> TyconRef + val tryDestAppTy : TcGlobals -> TType -> ValueOption + val tryDestTyparTy : TcGlobals -> TType -> ValueOption + val tryDestFunTy : TcGlobals -> TType -> ValueOption<(TType * TType)> + val tryDestAnonRecdTy : TcGlobals -> TType -> ValueOption + val argsOfAppTy : TcGlobals -> TType -> TypeInst + val mkInstForAppTy : TcGlobals -> TType -> TyparInst /// Try to get a TyconRef for a type without erasing type abbreviations val tryNiceEntityRefOfTy : TType -> ValueOption -val tryNiceEntityRefOfTyOption : TType -> TyconRef option +val tryNiceEntityRefOfTyOption : TType -> TyconRef option val domainOfFunTy : TcGlobals -> TType -> TType + val rangeOfFunTy : TcGlobals -> TType -> TType + val stripFunTy : TcGlobals -> TType -> TType list * TType + val stripFunTyN : TcGlobals -> int -> TType -> TType list * TType val applyForallTy : TcGlobals -> TType -> TypeInst -> TType val tryDestAnyTupleTy : TcGlobals -> TType -> TupInfo * TType list + val tryDestRefTupleTy : TcGlobals -> TType -> TType list //------------------------------------------------------------------------- @@ -535,7 +708,9 @@ val actualTysOfUnionCaseFields : TyparInst -> UnionCaseRef -> TType list val actualTysOfInstanceRecdFields : TyparInst -> TyconRef -> TType list val actualTyOfRecdField : TyparInst -> RecdField -> TType + val actualTyOfRecdFieldRef : RecdFieldRef -> TypeInst -> TType + val actualTyOfRecdFieldForTycon : Tycon -> TypeInst -> RecdField -> TType //------------------------------------------------------------------------- @@ -545,14 +720,21 @@ val actualTyOfRecdFieldForTycon : Tycon -> TypeInst -> RecdField -> TType //------------------------------------------------------------------------- type UncurriedArgInfos = (TType * ArgReprInfo) list + type CurriedArgInfos = UncurriedArgInfos list val destTopForallTy : TcGlobals -> ValReprInfo -> TType -> Typars * TType + val GetTopTauTypeInFSharpForm : TcGlobals -> ArgReprInfo list list -> TType -> range -> CurriedArgInfos * TType + val GetTopValTypeInFSharpForm : TcGlobals -> ValReprInfo -> TType -> range -> Typars * CurriedArgInfos * TType * ArgReprInfo + val IsCompiledAsStaticProperty : TcGlobals -> Val -> bool + val IsCompiledAsStaticPropertyWithField : TcGlobals -> Val -> bool + val GetTopValTypeInCompiledForm : TcGlobals -> ValReprInfo -> TType -> range -> Typars * CurriedArgInfos * TType option * ArgReprInfo + val GetFSharpViewOfReturnType : TcGlobals -> TType option -> TType val NormalizeDeclaredTyparsForEquiRecursiveInference : TcGlobals -> Typars -> Typars @@ -568,40 +750,58 @@ val applyTys : TcGlobals -> TType -> TType list * 'T list -> TType //------------------------------------------------------------------------- val emptyFreeTypars : FreeTypars + val unionFreeTypars : FreeTypars -> FreeTypars -> FreeTypars val emptyFreeTycons : FreeTycons + val unionFreeTycons : FreeTycons -> FreeTycons -> FreeTycons val emptyFreeTyvars : FreeTyvars + val isEmptyFreeTyvars : FreeTyvars -> bool + val unionFreeTyvars : FreeTyvars -> FreeTyvars -> FreeTyvars val emptyFreeLocals : FreeLocals + val unionFreeLocals : FreeLocals -> FreeLocals -> FreeLocals type FreeVarOptions val CollectLocalsNoCaching : FreeVarOptions + val CollectTyparsNoCaching : FreeVarOptions + val CollectTyparsAndLocalsNoCaching : FreeVarOptions + val CollectTyparsAndLocals : FreeVarOptions + val CollectLocals : FreeVarOptions + val CollectTypars : FreeVarOptions + val CollectAllNoCaching : FreeVarOptions + val CollectAll : FreeVarOptions val accFreeInTypes : FreeVarOptions -> TType list -> FreeTyvars -> FreeTyvars + val accFreeInType : FreeVarOptions -> TType -> FreeTyvars -> FreeTyvars + val accFreeInTypars : FreeVarOptions -> Typars -> FreeTyvars -> FreeTyvars val freeInType : FreeVarOptions -> TType -> FreeTyvars + val freeInTypes : FreeVarOptions -> TType list -> FreeTyvars + val freeInVal : FreeVarOptions -> Val -> FreeTyvars // This one puts free variables in canonical left-to-right order. val freeInTypeLeftToRight : TcGlobals -> bool -> TType -> Typars + val freeInTypesLeftToRight : TcGlobals -> bool -> TType list -> Typars + val freeInTypesLeftToRightSkippingConstraints : TcGlobals -> TType list -> Typars val freeInModuleTy: ModuleOrNamespaceType -> FreeTyvars @@ -614,25 +814,39 @@ val isDimensionless : TcGlobals -> TType -> bool [] type TypeEquivEnv = - { EquivTypars: TyparMap; + { EquivTypars: TyparMap EquivTycons: TyconRefRemap } static member Empty : TypeEquivEnv + member BindEquivTypars : Typars -> Typars -> TypeEquivEnv + static member FromTyparInst : TyparInst -> TypeEquivEnv + static member FromEquivTypars : Typars -> Typars -> TypeEquivEnv val traitsAEquivAux : Erasure -> TcGlobals -> TypeEquivEnv -> TraitConstraintInfo -> TraitConstraintInfo -> bool + val traitsAEquiv : TcGlobals -> TypeEquivEnv -> TraitConstraintInfo -> TraitConstraintInfo -> bool + val typarConstraintsAEquivAux : Erasure -> TcGlobals -> TypeEquivEnv -> TyparConstraint -> TyparConstraint -> bool + val typarConstraintsAEquiv : TcGlobals -> TypeEquivEnv -> TyparConstraint -> TyparConstraint -> bool + val typarsAEquiv : TcGlobals -> TypeEquivEnv -> Typars -> Typars -> bool + val typeAEquivAux : Erasure -> TcGlobals -> TypeEquivEnv -> TType -> TType -> bool + val typeAEquiv : TcGlobals -> TypeEquivEnv -> TType -> TType -> bool + val returnTypesAEquivAux : Erasure -> TcGlobals -> TypeEquivEnv -> TType option -> TType option -> bool + val returnTypesAEquiv : TcGlobals -> TypeEquivEnv -> TType option -> TType option -> bool + val tcrefAEquiv : TcGlobals -> TypeEquivEnv -> TyconRef -> TyconRef -> bool + val valLinkageAEquiv : TcGlobals -> TypeEquivEnv -> Val -> Val -> bool + val anonInfoEquiv : AnonRecdTypeInfo -> AnonRecdTypeInfo -> bool //------------------------------------------------------------------------- @@ -650,11 +864,17 @@ val getErasedTypes : TcGlobals -> TType -> TType list //------------------------------------------------------------------------- val MeasurePower : Measure -> int -> Measure + val ListMeasureVarOccsWithNonZeroExponents : Measure -> (Typar * Rational) list + val ListMeasureConOccsWithNonZeroExponents : TcGlobals -> bool -> Measure -> (TyconRef * Rational) list + val ProdMeasures : Measure list -> Measure + val MeasureVarExponent : Typar -> Measure -> Rational + val MeasureExprConExponent : TcGlobals -> bool -> TyconRef -> Measure -> Rational + val normalizeMeasure : TcGlobals -> Measure -> Measure @@ -663,19 +883,26 @@ val normalizeMeasure : TcGlobals -> Measure -> Measure //------------------------------------------------------------------------- val GetTypeOfMemberInFSharpForm : TcGlobals -> ValRef -> Typars * CurriedArgInfos * TType * ArgReprInfo + val GetTypeOfMemberInMemberForm : TcGlobals -> ValRef -> Typars * CurriedArgInfos * TType option * ArgReprInfo + val GetTypeOfIntrinsicMemberInCompiledForm : TcGlobals -> ValRef -> Typars * CurriedArgInfos * TType option * ArgReprInfo + val GetMemberTypeInMemberForm : TcGlobals -> MemberFlags -> ValReprInfo -> TType -> range -> Typars * CurriedArgInfos * TType option * ArgReprInfo /// Returns (parentTypars,memberParentTypars,memberMethodTypars,memberToParentInst,tinst) val PartitionValTyparsForApparentEnclosingType : TcGlobals -> Val -> (Typars * Typars * Typars * TyparInst * TType list) option + /// Returns (parentTypars,memberParentTypars,memberMethodTypars,memberToParentInst,tinst) val PartitionValTypars : TcGlobals -> Val -> (Typars * Typars * Typars * TyparInst * TType list) option + /// Returns (parentTypars,memberParentTypars,memberMethodTypars,memberToParentInst,tinst) val PartitionValRefTypars : TcGlobals -> ValRef -> (Typars * Typars * Typars * TyparInst * TType list) option val ReturnTypeOfPropertyVal : TcGlobals -> Val -> TType + val ArgInfosOfPropertyVal : TcGlobals -> Val -> UncurriedArgInfos + val ArgInfosOfMember: TcGlobals -> ValRef -> CurriedArgInfos val GetMemberCallInfo : TcGlobals -> ValRef * ValUseFlag -> int * bool * bool * bool * bool * bool * bool * bool @@ -686,68 +913,95 @@ val GetMemberCallInfo : TcGlobals -> ValRef * ValUseFlag -> int * bool * bool * type TyparConstraintsWithTypars = (Typar * TyparConstraint) list - module PrettyTypes = + val NeedsPrettyTyparName : Typar -> bool + val NewPrettyTypars : TyparInst -> Typars -> string list -> Typars * TyparInst + val PrettyTyparNames : (Typar -> bool) -> string list -> Typars -> string list + val PrettifyType : TcGlobals -> TType -> TType * TyparConstraintsWithTypars + val PrettifyInstAndTyparsAndType : TcGlobals -> TyparInst * Typars * TType -> (TyparInst * Typars * TType) * TyparConstraintsWithTypars + val PrettifyTypePair : TcGlobals -> TType * TType -> (TType * TType) * TyparConstraintsWithTypars + val PrettifyTypes : TcGlobals -> TTypes -> TTypes * TyparConstraintsWithTypars + val PrettifyInst : TcGlobals -> TyparInst -> TyparInst * TyparConstraintsWithTypars + val PrettifyInstAndType : TcGlobals -> TyparInst * TType -> (TyparInst * TType) * TyparConstraintsWithTypars + val PrettifyInstAndTypes : TcGlobals -> TyparInst * TTypes -> (TyparInst * TTypes) * TyparConstraintsWithTypars + val PrettifyInstAndSig : TcGlobals -> TyparInst * TTypes * TType -> (TyparInst * TTypes * TType) * TyparConstraintsWithTypars + val PrettifyCurriedTypes : TcGlobals -> TType list list -> TType list list * TyparConstraintsWithTypars + val PrettifyCurriedSigTypes : TcGlobals -> TType list list * TType -> (TType list list * TType) * TyparConstraintsWithTypars + val PrettifyInstAndUncurriedSig : TcGlobals -> TyparInst * UncurriedArgInfos * TType -> (TyparInst * UncurriedArgInfos * TType) * TyparConstraintsWithTypars + val PrettifyInstAndCurriedSig : TcGlobals -> TyparInst * TTypes * CurriedArgInfos * TType -> (TyparInst * TTypes * CurriedArgInfos * TType) * TyparConstraintsWithTypars [] type DisplayEnv = - { includeStaticParametersInTypeNames : bool; - openTopPathsSorted: Lazy; - openTopPathsRaw: string list list; - shortTypeNames: bool; - suppressNestedTypes: bool; - maxMembers : int option; - showObsoleteMembers: bool; - showHiddenMembers: bool; - showTyparBinding: bool; - showImperativeTyparAnnotations: bool; - suppressInlineKeyword:bool; - suppressMutableKeyword:bool; - showMemberContainers: bool; - shortConstraints:bool; - useColonForReturnType:bool; - showAttributes: bool; - showOverrides:bool; - showConstraintTyparAnnotations:bool; - abbreviateAdditionalConstraints: bool; + { includeStaticParametersInTypeNames : bool + openTopPathsSorted: Lazy + openTopPathsRaw: string list list + shortTypeNames: bool + suppressNestedTypes: bool + maxMembers : int option + showObsoleteMembers: bool + showHiddenMembers: bool + showTyparBinding: bool + showImperativeTyparAnnotations: bool + suppressInlineKeyword:bool + suppressMutableKeyword:bool + showMemberContainers: bool + shortConstraints:bool + useColonForReturnType:bool + showAttributes: bool + showOverrides:bool + showConstraintTyparAnnotations:bool + abbreviateAdditionalConstraints: bool showTyparDefaultConstraints: bool g: TcGlobals contextAccessibility: Accessibility generatedValueLayout:(Val -> layout option) } + member SetOpenPaths: string list list -> DisplayEnv + static member Empty: TcGlobals -> DisplayEnv member AddAccessibility : Accessibility -> DisplayEnv + member AddOpenPath : string list -> DisplayEnv + member AddOpenModuleOrNamespace : ModuleOrNamespaceRef -> DisplayEnv val tagEntityRefName: xref: EntityRef -> name: string -> StructuredFormat.TaggedText /// Return the full text for an item as we want it displayed to the user as a fully qualified entity val fullDisplayTextOfModRef : ModuleOrNamespaceRef -> string + val fullDisplayTextOfParentOfModRef : ModuleOrNamespaceRef -> ValueOption + val fullDisplayTextOfValRef : ValRef -> string + val fullDisplayTextOfValRefAsLayout : ValRef -> StructuredFormat.Layout + val fullDisplayTextOfTyconRef : TyconRef -> string + val fullDisplayTextOfTyconRefAsLayout : TyconRef -> StructuredFormat.Layout + val fullDisplayTextOfExnRef : TyconRef -> string + val fullDisplayTextOfExnRefAsLayout : TyconRef -> StructuredFormat.Layout + val fullDisplayTextOfUnionCaseRef : UnionCaseRef -> string + val fullDisplayTextOfRecdFieldRef : RecdFieldRef -> string val ticksAndArgCountTextOfTyconRef : TyconRef -> string @@ -758,22 +1012,23 @@ val qualifiedMangledNameOfTyconRef : TyconRef -> string -> string val trimPathByDisplayEnv : DisplayEnv -> string list -> string val prefixOfStaticReq : TyparStaticReq -> string + val prefixOfRigidTypar : Typar -> string /// Utilities used in simplifying types for visual presentation module SimplifyTypes = + type TypeSimplificationInfo = - { singletons : Typar Zset; - inplaceConstraints : Zmap; - postfixConstraints : TyparConstraintsWithTypars; } + { singletons : Typar Zset + inplaceConstraints : Zmap + postfixConstraints : TyparConstraintsWithTypars } + val typeSimplificationInfo0 : TypeSimplificationInfo - val CollectInfo : bool -> TType list -> TyparConstraintsWithTypars -> TypeSimplificationInfo -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- + val CollectInfo : bool -> TType list -> TyparConstraintsWithTypars -> TypeSimplificationInfo val superOfTycon : TcGlobals -> Tycon -> TType + val abstractSlotValsOfTycons : Tycon list -> Val list //------------------------------------------------------------------------- @@ -781,11 +1036,15 @@ val abstractSlotValsOfTycons : Tycon list -> Val list //------------------------------------------------------------------------- val emptyFreeVars : FreeVars + val unionFreeVars : FreeVars -> FreeVars -> FreeVars val accFreeInTargets : FreeVarOptions -> DecisionTreeTarget array -> FreeVars -> FreeVars + val accFreeInExprs : FreeVarOptions -> Exprs -> FreeVars -> FreeVars + val accFreeInSwitchCases : FreeVarOptions -> DecisionTreeCase list -> DecisionTree option -> FreeVars -> FreeVars + val accFreeInDecisionTree : FreeVarOptions -> DecisionTree -> FreeVars -> FreeVars /// Get the free variables in a module definition. @@ -797,277 +1056,382 @@ val freeInExpr : FreeVarOptions -> Expr -> FreeVars /// Get the free variables in the right hand side of a binding. val freeInBindingRhs : FreeVarOptions -> Binding -> FreeVars +/// Check if a set of free type variables are all public val freeTyvarsAllPublic : FreeTyvars -> bool -val freeVarsAllPublic : FreeVars -> bool -//------------------------------------------------------------------------- -// Mark/range/position information from expressions -//------------------------------------------------------------------------- +/// Check if a set of free variables are all public +val freeVarsAllPublic : FreeVars -> bool +/// Get the mark/range/position information from an expression type Expr with member Range : range -//------------------------------------------------------------------------- -// type-of operations on the expression tree -//------------------------------------------------------------------------- - +/// Compute the type of an expression from the expression itself val tyOfExpr : TcGlobals -> Expr -> TType -//------------------------------------------------------------------------- -// Top expressions to implement top types -//------------------------------------------------------------------------- - +/// A flag to govern whether arity inference should be type-directed or syntax-directed when +/// inferring an arity from a lambda expression. [] -type AllowTypeDirectedDetupling = Yes | No +type AllowTypeDirectedDetupling = + | Yes + | No +/// Given a (curried) lambda expression, pull off its arguments val stripTopLambda : Expr * TType -> Typars * Val list list * Expr * TType + +/// Given a lambda expression, extract the ValReprInfo for its arguments and other details val InferArityOfExpr : TcGlobals -> AllowTypeDirectedDetupling -> TType -> Attribs list list -> Attribs -> Expr -> ValReprInfo + +/// Given a lambda binding, extract the ValReprInfo for its arguments and other details val InferArityOfExprBinding : TcGlobals -> AllowTypeDirectedDetupling -> Val -> Expr -> ValReprInfo -//------------------------------------------------------------------------- -// Copy expressions and types -//------------------------------------------------------------------------- - +/// Mutate a value to indicate it should be considered a local rather than a module-bound definition // REVIEW: this mutation should not be needed val setValHasNoArity : Val -> Val +/// Indicate what should happen to value definitions when copying expressions type ValCopyFlag = | CloneAll | CloneAllAndMarkExprValsAsCompilerGenerated - // OnlyCloneExprVals is a nasty setting to reuse the cloning logic in a mode where all - // Tycon and "module/member" Val objects keep their identity, but the Val objects for all Expr bindings - // are cloned. This is used to 'fixup' the TAST created by tlr.fs - // - // This is a fragile mode of use. It's not really clear why TLR needs to create a "bad" expression tree that - // reuses Val objects as multiple value bindings, and its been the cause of several subtle bugs. + + /// OnlyCloneExprVals is a nasty setting to reuse the cloning logic in a mode where all + /// Tycon and "module/member" Val objects keep their identity, but the Val objects for all Expr bindings + /// are cloned. This is used to 'fixup' the TAST created by tlr.fs + /// + /// This is a fragile mode of use. It's not really clear why TLR needs to create a "bad" expression tree that + /// reuses Val objects as multiple value bindings, and its been the cause of several subtle bugs. | OnlyCloneExprVals +/// Remap a reference to a type definition using the given remapping substitution val remapTyconRef : TyconRefRemap -> TyconRef -> TyconRef + +/// Remap a reference to a union case using the given remapping substitution val remapUnionCaseRef : TyconRefRemap -> UnionCaseRef -> UnionCaseRef + +/// Remap a reference to a record field using the given remapping substitution val remapRecdFieldRef : TyconRefRemap -> RecdFieldRef -> RecdFieldRef + +/// Remap a reference to a value using the given remapping substitution val remapValRef : Remap -> ValRef -> ValRef + +/// Remap an expression using the given remapping substitution val remapExpr : TcGlobals -> ValCopyFlag -> Remap -> Expr -> Expr + +/// Remap an attribute using the given remapping substitution val remapAttrib : TcGlobals -> Remap -> Attrib -> Attrib + +/// Remap a (possible generic) type using the given remapping substitution val remapPossibleForallTy : TcGlobals -> Remap -> TType -> TType + +/// Copy an entire module or namespace type using the given copying flags val copyModuleOrNamespaceType : TcGlobals -> ValCopyFlag -> ModuleOrNamespaceType -> ModuleOrNamespaceType + +/// Copy an entire expression using the given copying flags val copyExpr : TcGlobals -> ValCopyFlag -> Expr -> Expr + +/// Copy an entire implementation file using the given copying flags val copyImplFile : TcGlobals -> ValCopyFlag -> TypedImplFile -> TypedImplFile + +/// Copy a method slot signature, including new generic type parameters if the slot signature represents a generic method val copySlotSig : SlotSig -> SlotSig + +/// Instantiate the generic type parameters in a method slot signature, building a new one val instSlotSig : TyparInst -> SlotSig -> SlotSig -val instExpr : TcGlobals -> TyparInst -> Expr -> Expr -//------------------------------------------------------------------------- -// Build the remapping that corresponds to a module meeting its signature -// and also report the set of tycons, tycon representations and values hidden in the process. -//------------------------------------------------------------------------- +/// Instantiate the generic type parameters in an expression, building a new one +val instExpr : TcGlobals -> TyparInst -> Expr -> Expr +/// The remapping that corresponds to a module meeting its signature +/// and also report the set of tycons, tycon representations and values hidden in the process. type SignatureRepackageInfo = - { mrpiVals: (ValRef * ValRef) list; - mrpiEntities: (TyconRef * TyconRef) list } + { /// The list of corresponding values + RepackagedVals: (ValRef * ValRef) list + + /// The list of corresponding modules, namespacea and type definitions + RepackagedEntities: (TyconRef * TyconRef) list } + /// The empty table static member Empty : SignatureRepackageInfo +/// A set of tables summarizing the items hidden by a signature type SignatureHidingInfo = - { mhiTycons : Zset; - mhiTyconReprs : Zset; - mhiVals : Zset; - mhiRecdFields : Zset; - mhiUnionCases : Zset } + { HiddenTycons: Zset + HiddenTyconReprs: Zset + HiddenVals: Zset + HiddenRecdFields: Zset + HiddenUnionCases: Zset } + + /// The empty table representing no hiding static member Empty : SignatureHidingInfo -val ComputeRemappingFromInferredSignatureToExplicitSignature : TcGlobals -> ModuleOrNamespaceType -> ModuleOrNamespaceType -> SignatureRepackageInfo * SignatureHidingInfo +/// Compute the remapping information implied by a signature being inferred for a particular implementation val ComputeRemappingFromImplementationToSignature : TcGlobals -> ModuleOrNamespaceExpr -> ModuleOrNamespaceType -> SignatureRepackageInfo * SignatureHidingInfo + +/// Compute the remapping information implied by an explicit signature being given for an inferred signature +val ComputeRemappingFromInferredSignatureToExplicitSignature : TcGlobals -> ModuleOrNamespaceType -> ModuleOrNamespaceType -> SignatureRepackageInfo * SignatureHidingInfo + +/// Compute the hiding information that corresponds to the hiding applied at an assembly boundary val ComputeHidingInfoAtAssemblyBoundary : ModuleOrNamespaceType -> SignatureHidingInfo -> SignatureHidingInfo + val mkRepackageRemapping : SignatureRepackageInfo -> Remap +/// Wrap one module or namespace implementation in a 'namespace N' outer wrapper val wrapModuleOrNamespaceExprInNamespace : Ident -> CompilationPath -> ModuleOrNamespaceExpr -> ModuleOrNamespaceExpr + +/// Wrap one module or namespace definition in a 'namespace N' outer wrapper val wrapModuleOrNamespaceTypeInNamespace : Ident -> CompilationPath -> ModuleOrNamespaceType -> ModuleOrNamespaceType * ModuleOrNamespace + +/// Wrap one module or namespace definition in a 'module M = ..' outer wrapper val wrapModuleOrNamespaceType : Ident -> CompilationPath -> ModuleOrNamespaceType -> ModuleOrNamespace +/// Given an implementation, fetch its recorded signature val SigTypeOfImplFile : TypedImplFile -> ModuleOrNamespaceType -//------------------------------------------------------------------------- -// Given a list of top-most signatures that together constrain the public compilation units -// of an assembly, compute a remapping that converts local references to non-local references. -// This remapping must be applied to all pickled expressions and types -// exported from the assembly. -//------------------------------------------------------------------------- - - +/// Given a namespace, module or type definition, try to produce a reference to that entity. val tryRescopeEntity : CcuThunk -> Entity -> ValueOption + +/// Given a value definition, try to produce a reference to that value. Fails for local values. val tryRescopeVal : CcuThunk -> Remap -> Val -> ValueOption +/// Make the substitution (remapping) table for viewing a module or namespace 'from the outside' +/// +/// Given the top-most signatures constrains the public compilation units +/// of an assembly, compute a remapping that converts local references to non-local references. +/// This remapping must be applied to all pickled expressions and types +/// exported from the assembly. val MakeExportRemapping : CcuThunk -> ModuleOrNamespace -> Remap + +/// Make a remapping table for viewing a module or namespace 'from the outside' val ApplyExportRemappingToEntity : TcGlobals -> Remap -> ModuleOrNamespace -> ModuleOrNamespace -/// Query SignatureRepackageInfo +/// Determine if a type definition is hidden by a signature val IsHiddenTycon : (Remap * SignatureHidingInfo) list -> Tycon -> bool + +/// Determine if the representation of a type definition is hidden by a signature val IsHiddenTyconRepr : (Remap * SignatureHidingInfo) list -> Tycon -> bool + +/// Determine if a member, function or value is hidden by a signature val IsHiddenVal : (Remap * SignatureHidingInfo) list -> Val -> bool -val IsHiddenRecdField : (Remap * SignatureHidingInfo) list -> RecdFieldRef -> bool -//------------------------------------------------------------------------- -// Adjust marks in expressions -//------------------------------------------------------------------------- +/// Determine if a record field is hidden by a signature +val IsHiddenRecdField : (Remap * SignatureHidingInfo) list -> RecdFieldRef -> bool +/// Adjust marks in expressions, replacing all marks by thegiven mark. +/// Used when inlining. val remarkExpr : range -> Expr -> Expr - -//------------------------------------------------------------------------- -// Make applications -//------------------------------------------------------------------------- +/// Build the application of a (possibly generic, possibly curried) function value to a set of type and expression arguments val primMkApp : (Expr * TType) -> TypeInst -> Exprs -> range -> Expr + +/// Build the application of a (possibly generic, possibly curried) function value to a set of type and expression arguments. +/// Reduce the application via let-bindings if the function value is a lambda expression. val mkApps : TcGlobals -> (Expr * TType) * TType list list * Exprs * range -> Expr + +/// Build the application of a generic construct to a set of type arguments. +/// Reduce the application via substitution if the function value is a typed lambda expression. val mkTyAppExpr : range -> Expr * TType -> TType list -> Expr +/// Build an expression to mutate a local /// localv <- e val mkValSet : range -> ValRef -> Expr -> Expr + +/// Build an expression to mutate the contents of a local pointer /// *localv_ptr = e val mkAddrSet : range -> ValRef -> Expr -> Expr + +/// Build an expression to dereference a local pointer /// *localv_ptr val mkAddrGet : range -> ValRef -> Expr + +/// Build an expression to take the address of a local /// &localv val mkValAddr : range -> readonly: bool -> ValRef -> Expr -//------------------------------------------------------------------------- -// Note these take the address of the record expression if it is a struct, and -// apply a type instantiation if it is a first-class polymorphic record field. -//------------------------------------------------------------------------- - +/// Build an exression representing the read of an instance class or record field. +/// First take the address of the record expression if it is a struct. val mkRecdFieldGet : TcGlobals -> Expr * RecdFieldRef * TypeInst * range -> Expr -//------------------------------------------------------------------------- -// Get the targets used in a decision graph (for reporting warnings) -//------------------------------------------------------------------------- - +/// Accumulate the targets actually used in a decision graph (for reporting warnings) val accTargetsOfDecisionTree : DecisionTree -> int list -> int list -//------------------------------------------------------------------------- -// Optimizations on decision graphs -//------------------------------------------------------------------------- - +/// Make a 'match' expression applying some peep-hole optimizations along the way, e.g to +/// pre-decide the branch taken at compile-time. val mkAndSimplifyMatch : SequencePointInfoForBinding -> range -> range -> TType -> DecisionTree -> DecisionTreeTarget list -> Expr +/// Make a 'match' expression without applying any peep-hole optimizations. val primMkMatch : SequencePointInfoForBinding * range * DecisionTree * DecisionTreeTarget array * range * TType -> Expr -//------------------------------------------------------------------------- -// Work out what things on the r.h.s. of a let rec need to be fixed up -//------------------------------------------------------------------------- - +/// Work out what things on the right-han-side of a 'let rec' recursive binding need to be fixed up val IterateRecursiveFixups : TcGlobals -> Val option -> (Val option -> Expr -> (Expr -> Expr) -> Expr -> unit) -> Expr * (Expr -> Expr) -> Expr -> unit -//------------------------------------------------------------------------- -// From lambdas taking multiple variables to lambdas taking a single variable -// of tuple type. -//------------------------------------------------------------------------- - +/// Given a lambda expression taking multiple variables, build a corresponding lambda taking a tuple val MultiLambdaToTupledLambda : TcGlobals -> Val list -> Expr -> Val * Expr -val AdjustArityOfLambdaBody : TcGlobals -> int -> Val list -> Expr -> Val list * Expr -//------------------------------------------------------------------------- -// Make applications, doing beta reduction by introducing let-bindings -//------------------------------------------------------------------------- +/// Given a lambda expression, adjust it to have be one or two lambda expressions (fun a -> (fun b -> ...)) +/// where the first has the given arity. +val AdjustArityOfLambdaBody : TcGlobals -> int -> Val list -> Expr -> Val list * Expr +/// Make an application expression, doing beta reduction by introducing let-bindings val MakeApplicationAndBetaReduce : TcGlobals -> Expr * TType * TypeInst list * Exprs * range -> Expr +/// COmbine two static-resolution requirements on a type parameter val JoinTyparStaticReq : TyparStaticReq -> TyparStaticReq -> TyparStaticReq -//------------------------------------------------------------------------- -// More layout - this is for debugging -//------------------------------------------------------------------------- +/// Layout for internal compiler debugging purposes module DebugPrint = + /// A global flag indicating whether debug output should include ranges val layoutRanges : bool ref + + /// Convert a type to a string for debugging purposes val showType : TType -> string + + /// Convert an expression to a string for debugging purposes val showExpr : Expr -> string + /// Debug layout for a reference to a value val valRefL : ValRef -> layout + + /// Debug layout for a reference to a union case val unionCaseRefL : UnionCaseRef -> layout - val vspecAtBindL : Val -> layout + + /// Debug layout for an value definition at its binding site + val valAtBindL : Val -> layout + + /// Debug layout for an integer val intL : int -> layout + + /// Debug layout for a value definition val valL : Val -> layout + + /// Debug layout for a type parameter definition val typarDeclL : Typar -> layout + + /// Debug layout for a trait constraint val traitL : TraitConstraintInfo -> layout + + /// Debug layout for a type parameter val typarL : Typar -> layout + + /// Debug layout for a set of type parameters val typarsL : Typars -> layout + + /// Debug layout for a type val typeL : TType -> layout + + /// Debug layout for a method slot signature val slotSigL : SlotSig -> layout + + /// Debug layout for the type signature of a module or namespace definition val entityTypeL : ModuleOrNamespaceType -> layout + + /// Debug layout for a module or namespace definition val entityL : ModuleOrNamespace -> layout + + /// Debug layout for the type of a value val typeOfValL : Val -> layout + + /// Debug layout for a binding of an expression to a value val bindingL : Binding -> layout + + /// Debug layout for an expression val exprL : Expr -> layout + + /// Debug layout for a type definition val tyconL : Tycon -> layout + + /// Debug layout for a decision tree val decisionTreeL : DecisionTree -> layout + + /// Debug layout for an implementation file val implFileL : TypedImplFile -> layout + + /// Debug layout for a list of implementation files val implFilesL : TypedImplFile list -> layout - val recdFieldRefL : RecdFieldRef -> layout -//------------------------------------------------------------------------- -// Fold on expressions -//------------------------------------------------------------------------- + /// Debug layout for class and record fields + val recdFieldRefL : RecdFieldRef -> layout +/// A set of function parameters (visitor) for folding over expressions type ExprFolder<'State> = - { exprIntercept : ('State -> Expr -> 'State) -> 'State -> Expr -> 'State option; - valBindingSiteIntercept : 'State -> bool * Val -> 'State; - nonRecBindingsIntercept : 'State -> Binding -> 'State; - recBindingsIntercept : 'State -> Bindings -> 'State; - dtreeIntercept : 'State -> DecisionTree -> 'State; - targetIntercept : ('State -> Expr -> 'State) -> 'State -> DecisionTreeTarget -> 'State option; - tmethodIntercept : ('State -> Expr -> 'State) -> 'State -> ObjExprMethod -> 'State option;} + { exprIntercept : ('State -> Expr -> 'State) -> 'State -> Expr -> 'State option + valBindingSiteIntercept : 'State -> bool * Val -> 'State + nonRecBindingsIntercept : 'State -> Binding -> 'State + recBindingsIntercept : 'State -> Bindings -> 'State + dtreeIntercept : 'State -> DecisionTree -> 'State + targetIntercept : ('State -> Expr -> 'State) -> 'State -> DecisionTreeTarget -> 'State option + tmethodIntercept : ('State -> Expr -> 'State) -> 'State -> ObjExprMethod -> 'State option} + +/// The empty set of actions for folding over expressions val ExprFolder0 : ExprFolder<'State> + +/// Fold over all the expressions in an implementation file val FoldImplFile: ExprFolder<'State> -> ('State -> TypedImplFile -> 'State) + +/// Fold over all the expressions in an expression val FoldExpr : ExprFolder<'State> -> ('State -> Expr -> 'State) #if DEBUG +/// Extract some statistics from an expression val ExprStats : Expr -> string #endif -//------------------------------------------------------------------------- -// Make some common types -//------------------------------------------------------------------------- - +/// Build a nativeptr type val mkNativePtrTy : TcGlobals -> TType -> TType + +/// Build a 'voidptr' type val mkVoidPtrTy : TcGlobals -> TType + +/// Build a single-dimensional array type val mkArrayType : TcGlobals -> TType -> TType + +/// Determine is a type is an option type val isOptionTy : TcGlobals -> TType -> bool + +/// Take apart an option type val destOptionTy : TcGlobals -> TType -> TType + +/// Try to take apart an option type val tryDestOptionTy : TcGlobals -> TType -> ValueOption +/// Determine if a type is a System.Linq.Expression type val isLinqExpressionTy : TcGlobals -> TType -> bool -val destLinqExpressionTy : TcGlobals -> TType -> TType -val tryDestLinqExpressionTy : TcGlobals -> TType -> TType option -(* -val isQuoteExprTy : TcGlobals -> TType -> bool -val destQuoteExprTy : TcGlobals -> TType -> TType -val tryDestQuoteExprTy : TcGlobals -> TType -> TType option -*) +/// Take apart a System.Linq.Expression type +val destLinqExpressionTy : TcGlobals -> TType -> TType -//------------------------------------------------------------------------- -// Primitives associated with compiling the IEvent idiom to .NET events -//------------------------------------------------------------------------- +/// Try to take apart a System.Linq.Expression type +val tryDestLinqExpressionTy : TcGlobals -> TType -> TType option +/// Determine if a type is an IDelegateEvent type val isIDelegateEventType : TcGlobals -> TType -> bool + +/// Take apart an IDelegateEvent type val destIDelegateEventType : TcGlobals -> TType -> TType + +/// Build an IEvent type val mkIEventType : TcGlobals -> TType -> TType -> TType + +/// Build an IObservable type val mkIObservableType : TcGlobals -> TType -> TType -val mkIObserverType : TcGlobals -> TType -> TType -//------------------------------------------------------------------------- -// Primitives associated with printf format string parsing -//------------------------------------------------------------------------- +/// Build an IObserver type +val mkIObserverType : TcGlobals -> TType -> TType +/// Build an Lazy type val mkLazyTy : TcGlobals -> TType -> TType + +/// Build an PrintFormat type val mkPrintfFormatTy : TcGlobals -> TType -> TType -> TType -> TType -> TType -> TType //------------------------------------------------------------------------- // Classify types //------------------------------------------------------------------------- +/// Represents metadata extracted from a nominal type type TypeDefMetadata = | ILTypeMetadata of TILObjectReprData | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata @@ -1075,43 +1439,94 @@ type TypeDefMetadata = | ProvidedTypeMetadata of TProvidedTypeInfo #endif +/// Extract metadata from a type definition val metadataOfTycon : Tycon -> TypeDefMetadata + +/// Extract metadata from a type val metadataOfTy : TcGlobals -> TType -> TypeDefMetadata -val isStringTy : TcGlobals -> TType -> bool -val isListTy : TcGlobals -> TType -> bool -val isILAppTy : TcGlobals -> TType -> bool -val isArrayTy : TcGlobals -> TType -> bool -val isArray1DTy : TcGlobals -> TType -> bool -val destArrayTy : TcGlobals -> TType -> TType -val destListTy : TcGlobals -> TType -> TType +/// Determine if a type is the System.String type +val isStringTy : TcGlobals -> TType -> bool + +/// Determine if a type is an F# list type +val isListTy : TcGlobals -> TType -> bool + +/// Determine if a type is a nominal .NET type +val isILAppTy : TcGlobals -> TType -> bool + +/// Determine if a type is any kind of array type +val isArrayTy : TcGlobals -> TType -> bool + +/// Determine if a type is a single-dimensional array type +val isArray1DTy : TcGlobals -> TType -> bool + +/// Get the element type of an array type +val destArrayTy : TcGlobals -> TType -> TType + +/// Get the element type of an F# list type +val destListTy : TcGlobals -> TType -> TType -val mkArrayTy : TcGlobals -> int -> TType -> range -> TType -val isArrayTyconRef : TcGlobals -> TyconRef -> bool +/// Build an array type of the given rank +val mkArrayTy : TcGlobals -> int -> TType -> range -> TType + +/// Check if a type definition is one of the artifical type definitions used for array types of different ranks +val isArrayTyconRef : TcGlobals -> TyconRef -> bool + +/// Determine the rank of one of the artifical type definitions used for array types val rankOfArrayTyconRef : TcGlobals -> TyconRef -> int -val isUnitTy : TcGlobals -> TType -> bool -val isObjTy : TcGlobals -> TType -> bool -val isVoidTy : TcGlobals -> TType -> bool +/// Determine if a type is the F# unit type +val isUnitTy : TcGlobals -> TType -> bool + +/// Determine if a type is the System.Object type +val isObjTy : TcGlobals -> TType -> bool + +/// Determine if a type is the System.Void type +val isVoidTy : TcGlobals -> TType -> bool /// Get the element type of an array type -val destArrayTy : TcGlobals -> TType -> TType +val destArrayTy : TcGlobals -> TType -> TType + /// Get the rank of an array type val rankOfArrayTy : TcGlobals -> TType -> int -val isInterfaceTyconRef : TyconRef -> bool +/// Determine if a reference to a type definition is an interface type +val isInterfaceTyconRef : TyconRef -> bool + +/// Determine if a type is a delegate type +val isDelegateTy : TcGlobals -> TType -> bool + +/// Determine if a type is an interface type +val isInterfaceTy : TcGlobals -> TType -> bool -val isDelegateTy : TcGlobals -> TType -> bool -val isInterfaceTy : TcGlobals -> TType -> bool -val isRefTy : TcGlobals -> TType -> bool -val isSealedTy : TcGlobals -> TType -> bool -val isComInteropTy : TcGlobals -> TType -> bool -val underlyingTypeOfEnumTy : TcGlobals -> TType -> TType -val normalizeEnumTy : TcGlobals -> TType -> TType +/// Determine if a type is a FSharpRef type +val isRefTy : TcGlobals -> TType -> bool + +/// Determine if a type is a sealed type +val isSealedTy : TcGlobals -> TType -> bool + +/// Determine if a type is a ComInterop type +val isComInteropTy : TcGlobals -> TType -> bool + +/// Determine the underlying type of an enum type (normally int32) +val underlyingTypeOfEnumTy : TcGlobals -> TType -> TType + +/// If the input type is an enum type, then convert to its underlying type, otherwise return the input type +val normalizeEnumTy : TcGlobals -> TType -> TType + +/// Determine if a type is a struct type val isStructTy : TcGlobals -> TType -> bool + +/// Determine if a type is an unmanaged type val isUnmanagedTy : TcGlobals -> TType -> bool + +/// Determine if a type is a class type val isClassTy : TcGlobals -> TType -> bool + +/// Determine if a type is an enum type val isEnumTy : TcGlobals -> TType -> bool + +/// Determine if a type is a struct, record or union type val isStructRecordOrUnionTyconTy : TcGlobals -> TType -> bool /// For "type Class as self", 'self' is fixed up after initialization. To support this, @@ -1119,9 +1534,16 @@ val isStructRecordOrUnionTyconTy : TcGlobals -> TType -> bool /// returns the underlying type. val StripSelfRefCell : TcGlobals * ValBaseOrThisInfo * TType -> TType +/// An active pattern to determine if a type is a nominal type, possibly instantiated val (|AppTy|_|) : TcGlobals -> TType -> (TyconRef * TType list) option + +/// An active pattern to match System.Nullable types val (|NullableTy|_|) : TcGlobals -> TType -> TType option + +/// An active pattern to transform System.Nullable types to their input, otherwise leave the input unchanged val (|StripNullableTy|) : TcGlobals -> TType -> TType + +/// Matches any byref type, yielding the target type val (|ByrefTy|_|) : TcGlobals -> TType -> TType option //------------------------------------------------------------------------- @@ -1129,35 +1551,53 @@ val (|ByrefTy|_|) : TcGlobals -> TType -> TType option //------------------------------------------------------------------------- val IsUnionTypeWithNullAsTrueValue: TcGlobals -> Tycon -> bool + val TyconHasUseNullAsTrueValueAttribute : TcGlobals -> Tycon -> bool + val CanHaveUseNullAsTrueValueAttribute : TcGlobals -> Tycon -> bool + val MemberIsCompiledAsInstance : TcGlobals -> TyconRef -> bool -> ValMemberInfo -> Attribs -> bool + val ValSpecIsCompiledAsInstance : TcGlobals -> Val -> bool + val ValRefIsCompiledAsInstanceMember : TcGlobals -> ValRef -> bool + val ModuleNameIsMangled : TcGlobals -> Attribs -> bool val CompileAsEvent : TcGlobals -> Attribs -> bool val TypeNullIsExtraValue : TcGlobals -> range -> TType -> bool + val TypeNullIsTrueValue : TcGlobals -> TType -> bool + val TypeNullNotLiked : TcGlobals -> range -> TType -> bool + val TypeNullNever : TcGlobals -> TType -> bool val TypeSatisfiesNullConstraint : TcGlobals -> range -> TType -> bool + val TypeHasDefaultValue : TcGlobals -> range -> TType -> bool val isAbstractTycon : Tycon -> bool val isUnionCaseRefDefinitelyMutable : UnionCaseRef -> bool + val isRecdOrUnionOrStructTyconRefDefinitelyMutable : TyconRef -> bool + val isExnDefinitelyMutable : TyconRef -> bool + val isUnionCaseFieldMutable : TcGlobals -> UnionCaseRef -> int -> bool + val isExnFieldMutable : TyconRef -> int -> bool + val isRecdOrStructTyconRefReadOnly: TcGlobals -> range -> TyconRef -> bool + val isRecdOrStructTyconRefAssumedImmutable: TcGlobals -> TyconRef -> bool + val isRecdOrStructTyReadOnly: TcGlobals -> range -> TType -> bool val useGenuineField : Tycon -> RecdField -> bool + val ComputeFieldName : Tycon -> RecdField -> string //------------------------------------------------------------------------- @@ -1165,6 +1605,7 @@ val ComputeFieldName : Tycon -> RecdField -> string //------------------------------------------------------------------------- val slotSigHasVoidReturnTy : SlotSig -> bool + val actualReturnTyOfSlotSig : TypeInst -> TypeInst -> SlotSig -> TType option val returnTyOfMethod : TcGlobals -> ObjExprMethod -> TType option @@ -1174,25 +1615,37 @@ val returnTyOfMethod : TcGlobals -> ObjExprMethod -> TType option //------------------------------------------------------------------------- val mkRefCell : TcGlobals -> range -> TType -> Expr -> Expr + val mkRefCellGet : TcGlobals -> range -> TType -> Expr -> Expr + val mkRefCellSet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkLazyDelayed : TcGlobals -> range -> TType -> Expr -> Expr -val mkLazyForce : TcGlobals -> range -> TType -> Expr -> Expr +val mkLazyForce : TcGlobals -> range -> TType -> Expr -> Expr val mkRefCellContentsRef : TcGlobals -> RecdFieldRef + val isRefCellTy : TcGlobals -> TType -> bool + val destRefCellTy : TcGlobals -> TType -> TType + val mkRefCellTy : TcGlobals -> TType -> TType val mkSeqTy : TcGlobals -> TType -> TType + val mkIEnumeratorTy : TcGlobals -> TType -> TType + val mkListTy : TcGlobals -> TType -> TType + val mkOptionTy : TcGlobals -> TType -> TType + val mkNoneCase : TcGlobals -> UnionCaseRef + val mkSomeCase : TcGlobals -> UnionCaseRef val mkNil : TcGlobals -> range -> TType -> Expr + val mkCons : TcGlobals -> TType -> Expr -> Expr -> Expr //------------------------------------------------------------------------- @@ -1200,17 +1653,29 @@ val mkCons : TcGlobals -> TType -> Expr -> Expr -> Expr //------------------------------------------------------------------------- val mkSequential : SequencePointInfoForSeq -> range -> Expr -> Expr -> Expr + val mkCompGenSequential : range -> Expr -> Expr -> Expr + val mkSequentials : SequencePointInfoForSeq -> TcGlobals -> range -> Exprs -> Expr + val mkRecordExpr : TcGlobals -> RecordConstructionInfo * TyconRef * TypeInst * RecdFieldRef list * Exprs * range -> Expr + val mkUnbox : TType -> Expr -> range -> Expr + val mkBox : TType -> Expr -> range -> Expr + val mkIsInst : TType -> Expr -> range -> Expr + val mkNull : range -> TType -> Expr + val mkNullTest : TcGlobals -> range -> Expr -> Expr -> Expr -> Expr + val mkNonNullTest : TcGlobals -> range -> Expr -> Expr + val mkIsInstConditional : TcGlobals -> range -> TType -> Expr -> Val -> Expr -> Expr -> Expr + val mkThrow : range -> TType -> Expr -> Expr + val mkGetArg0 : range -> TType -> Expr val mkDefault : range * TType -> Expr @@ -1218,18 +1683,31 @@ val mkDefault : range * TType -> Expr val isThrow : Expr -> bool val mkString : TcGlobals -> range -> string -> Expr + val mkBool : TcGlobals -> range -> bool -> Expr + val mkByte : TcGlobals -> range -> byte -> Expr + val mkUInt16 : TcGlobals -> range -> uint16 -> Expr + val mkTrue : TcGlobals -> range -> Expr + val mkFalse : TcGlobals -> range -> Expr + val mkUnit : TcGlobals -> range -> Expr + val mkInt32 : TcGlobals -> range -> int32 -> Expr + val mkInt : TcGlobals -> range -> int -> Expr + val mkZero : TcGlobals -> range -> Expr + val mkOne : TcGlobals -> range -> Expr + val mkTwo : TcGlobals -> range -> Expr + val mkMinusOne : TcGlobals -> range -> Expr + val destInt32 : Expr -> int32 option //------------------------------------------------------------------------- @@ -1237,8 +1715,11 @@ val destInt32 : Expr -> int32 option //------------------------------------------------------------------------- val isQuotedExprTy : TcGlobals -> TType -> bool + val destQuotedExprTy : TcGlobals -> TType -> TType + val mkQuotedExprTy : TcGlobals -> TType -> TType + val mkRawQuotedExprTy : TcGlobals -> TType //------------------------------------------------------------------------- @@ -1246,9 +1727,13 @@ val mkRawQuotedExprTy : TcGlobals -> TType //------------------------------------------------------------------------- val mspec_Type_GetTypeFromHandle : TcGlobals -> ILMethodSpec + val fspec_Missing_Value : TcGlobals -> ILFieldSpec + val mkInitializeArrayMethSpec: TcGlobals -> ILMethodSpec + val mkByteArrayTy : TcGlobals -> TType + val mkInvalidCastExnNewobj: TcGlobals -> ILInstr @@ -1259,122 +1744,207 @@ val mkInvalidCastExnNewobj: TcGlobals -> ILInstr val mkCallNewFormat : TcGlobals -> range -> TType -> TType -> TType -> TType -> TType -> Expr -> Expr val mkCallUnbox : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallGetGenericComparer : TcGlobals -> range -> Expr + val mkCallGetGenericEREqualityComparer : TcGlobals -> range -> Expr + val mkCallGetGenericPEREqualityComparer : TcGlobals -> range -> Expr val mkCallUnboxFast : TcGlobals -> range -> TType -> Expr -> Expr + val canUseUnboxFast : TcGlobals -> range -> TType -> bool val mkCallDispose : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallSeq : TcGlobals -> range -> TType -> Expr -> Expr val mkCallTypeTest : TcGlobals -> range -> TType -> Expr -> Expr + val canUseTypeTestFast : TcGlobals -> TType -> bool val mkCallTypeOf : TcGlobals -> range -> TType -> Expr + val mkCallTypeDefOf : TcGlobals -> range -> TType -> Expr val mkCallCreateInstance : TcGlobals -> range -> TType -> Expr + val mkCallCreateEvent : TcGlobals -> range -> TType -> TType -> Expr -> Expr -> Expr -> Expr + val mkCallArrayLength : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallArrayGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallArray2DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr + val mkCallArray3DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr + val mkCallArray4DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr + val mkCallArraySet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr + val mkCallArray2DSet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr + val mkCallArray3DSet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr + val mkCallArray4DSet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr val mkCallHash : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallBox : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallIsNull : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallIsNotNull : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallRaise : TcGlobals -> range -> TType -> Expr -> Expr val mkCallGenericComparisonWithComparerOuter : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr + val mkCallGenericEqualityEROuter : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallGenericEqualityWithComparerOuter : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr + val mkCallGenericHashWithComparerOuter : TcGlobals -> range -> TType -> Expr -> Expr -> Expr val mkCallEqualsOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallNotEqualsOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallLessThanOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallLessThanOrEqualsOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallGreaterThanOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallGreaterThanOrEqualsOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr val mkCallAdditionOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallSubtractionOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallMultiplyOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallDivisionOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallModulusOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallBitwiseAndOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallBitwiseOrOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallBitwiseXorOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallShiftLeftOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallShiftRightOperator : TcGlobals -> range -> TType -> Expr -> Expr -> Expr val mkCallUnaryNegOperator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallUnaryNotOperator : TcGlobals -> range -> TType -> Expr -> Expr val mkCallAdditionChecked : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallSubtractionChecked : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallMultiplyChecked : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallUnaryNegChecked : TcGlobals -> range -> TType -> Expr -> Expr val mkCallToByteChecked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToSByteChecked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToInt16Checked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToUInt16Checked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToIntChecked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToInt32Checked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToUInt32Checked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToInt64Checked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToUInt64Checked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToIntPtrChecked : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToUIntPtrChecked : TcGlobals -> range -> TType -> Expr -> Expr val mkCallToByteOperator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToSByteOperator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToInt16Operator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToUInt16Operator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToIntOperator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToInt32Operator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToUInt32Operator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToInt64Operator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToUInt64Operator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToSingleOperator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToDoubleOperator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToIntPtrOperator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToUIntPtrOperator : TcGlobals -> range -> TType -> Expr -> Expr val mkCallToCharOperator : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallToEnumOperator : TcGlobals -> range -> TType -> Expr -> Expr val mkCallDeserializeQuotationFSharp20Plus : TcGlobals -> range -> Expr -> Expr -> Expr -> Expr -> Expr + val mkCallDeserializeQuotationFSharp40Plus : TcGlobals -> range -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr + val mkCallCastQuotation : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallLiftValueWithName : TcGlobals -> range -> TType -> string -> Expr -> Expr + val mkCallLiftValueWithDefn : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallSeqCollect : TcGlobals -> range -> TType -> TType -> Expr -> Expr -> Expr + val mkCallSeqUsing : TcGlobals -> range -> TType -> TType -> Expr -> Expr -> Expr + val mkCallSeqDelay : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallSeqAppend : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallSeqFinally : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallSeqGenerated : TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallSeqOfFunctions : TcGlobals -> range -> TType -> TType -> Expr -> Expr -> Expr -> Expr + val mkCallSeqToArray : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallSeqToList : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallSeqMap : TcGlobals -> range -> TType -> TType -> Expr -> Expr -> Expr + val mkCallSeqSingleton : TcGlobals -> range -> TType -> Expr -> Expr + val mkCallSeqEmpty : TcGlobals -> range -> TType -> Expr + val mkILAsmCeq : TcGlobals -> range -> Expr -> Expr -> Expr + val mkILAsmClt : TcGlobals -> range -> Expr -> Expr -> Expr val mkCallFailInit : TcGlobals -> range -> Expr + val mkCallFailStaticInit : TcGlobals -> range -> Expr + val mkCallCheckThis : TcGlobals -> range -> TType -> Expr -> Expr val mkCase : DecisionTreeTest * DecisionTree -> DecisionTreeCase @@ -1382,13 +1952,17 @@ val mkCase : DecisionTreeTest * DecisionTree -> DecisionTreeCase val mkCallQuoteToLinqLambdaExpression : TcGlobals -> range -> TType -> Expr -> Expr val mkCallGetQuerySourceAsEnumerable : TcGlobals -> range -> TType -> TType -> Expr -> Expr + val mkCallNewQuerySource : TcGlobals -> range -> TType -> TType -> Expr -> Expr val mkArray : TType * Exprs * range -> Expr val mkStaticCall_String_Concat2 : TcGlobals -> range -> Expr -> Expr -> Expr + val mkStaticCall_String_Concat3 : TcGlobals -> range -> Expr -> Expr -> Expr -> Expr + val mkStaticCall_String_Concat4 : TcGlobals -> range -> Expr -> Expr -> Expr -> Expr -> Expr + val mkStaticCall_String_Concat_Array : TcGlobals -> range -> Expr -> Expr //------------------------------------------------------------------------- @@ -1397,8 +1971,11 @@ val mkStaticCall_String_Concat_Array : TcGlobals -> range -> Expr -> Expr //------------------------------------------------------------------------- val mkDecr : TcGlobals -> range -> Expr -> Expr + val mkIncr : TcGlobals -> range -> Expr -> Expr + val mkLdlen : TcGlobals -> range -> Expr -> Expr + val mkLdelem : TcGlobals -> range -> TType -> Expr -> Expr -> Expr //------------------------------------------------------------------------- @@ -1406,18 +1983,29 @@ val mkLdelem : TcGlobals -> range -> TType -> Expr -> Expr -> Expr //------------------------------------------------------------------------- val TryDecodeILAttribute : TcGlobals -> ILTypeRef -> ILAttributes -> (ILAttribElem list * ILAttributeNamedArg list) option + val TryFindILAttribute : BuiltinAttribInfo -> ILAttributes -> bool + val TryFindILAttributeOpt : BuiltinAttribInfo option -> ILAttributes -> bool val IsMatchingFSharpAttribute : TcGlobals -> BuiltinAttribInfo -> Attrib -> bool + val IsMatchingFSharpAttributeOpt : TcGlobals -> BuiltinAttribInfo option -> Attrib -> bool + val HasFSharpAttribute : TcGlobals -> BuiltinAttribInfo -> Attribs -> bool + val HasFSharpAttributeOpt : TcGlobals -> BuiltinAttribInfo option -> Attribs -> bool + val TryFindFSharpAttribute : TcGlobals -> BuiltinAttribInfo -> Attribs -> Attrib option + val TryFindFSharpAttributeOpt : TcGlobals -> BuiltinAttribInfo option -> Attribs -> Attrib option + val TryFindFSharpBoolAttribute : TcGlobals -> BuiltinAttribInfo -> Attribs -> bool option + val TryFindFSharpBoolAttributeAssumeFalse : TcGlobals -> BuiltinAttribInfo -> Attribs -> bool option + val TryFindFSharpStringAttribute : TcGlobals -> BuiltinAttribInfo -> Attribs -> string option + val TryFindFSharpInt32Attribute : TcGlobals -> BuiltinAttribInfo -> Attribs -> int32 option /// Try to find a specific attribute on a type definition, where the attribute accepts a string argument. @@ -1438,19 +2026,29 @@ val TryFindAttributeUsageAttribute : TcGlobals -> range -> TyconRef -> bool opti /// returns Some(assemblyName) for success val TryDecodeTypeProviderAssemblyAttr : ILGlobals -> ILAttribute -> string option #endif + val IsSignatureDataVersionAttr : ILAttribute -> bool + val TryFindAutoOpenAttr : IL.ILGlobals -> ILAttribute -> string option + val TryFindInternalsVisibleToAttr : IL.ILGlobals -> ILAttribute -> string option -val IsMatchingSignatureDataVersionAttr : IL.ILGlobals -> ILVersionInfo -> ILAttribute -> bool +val IsMatchingSignatureDataVersionAttr : IL.ILGlobals -> ILVersionInfo -> ILAttribute -> bool val mkCompilationMappingAttr : TcGlobals -> int -> ILAttribute val mkCompilationMappingAttrWithSeqNum : TcGlobals -> int -> int -> ILAttribute + + val mkCompilationMappingAttrWithVariantNumAndSeqNum : TcGlobals -> int -> int -> int -> ILAttribute + val mkCompilationMappingAttrForQuotationResource : TcGlobals -> string * ILTypeRef list -> ILAttribute + val mkCompilationArgumentCountsAttr : TcGlobals -> int list -> ILAttribute + val mkCompilationSourceNameAttr : TcGlobals -> string -> ILAttribute + val mkSignatureDataVersionAttr : TcGlobals -> ILVersionInfo -> ILAttribute + val mkCompilerGeneratedAttr : TcGlobals -> int -> ILAttribute //------------------------------------------------------------------------- @@ -1458,16 +2056,23 @@ val mkCompilerGeneratedAttr : TcGlobals -> int -> ILAtt //------------------------------------------------------------------------- val isInByrefTy : TcGlobals -> TType -> bool + val isOutByrefTy : TcGlobals -> TType -> bool + val isByrefTy : TcGlobals -> TType -> bool val isNativePtrTy : TcGlobals -> TType -> bool + val destByrefTy : TcGlobals -> TType -> TType + val destNativePtrTy : TcGlobals -> TType -> TType val isByrefTyconRef : TcGlobals -> TyconRef -> bool + val isByrefLikeTyconRef : TcGlobals -> range -> TyconRef -> bool + val isSpanLikeTyconRef : TcGlobals -> range -> TyconRef -> bool + val isByrefLikeTy : TcGlobals -> range -> TType -> bool /// Check if the type is a byref-like but not a byref. @@ -1478,33 +2083,37 @@ val isSpanLikeTy : TcGlobals -> range -> TType -> bool //------------------------------------------------------------------------- val isRefTupleExpr : Expr -> bool + val tryDestRefTupleExpr : Expr -> Exprs val mkAnyTupledTy : TcGlobals -> TupInfo -> TType list -> TType + val mkAnyTupled : TcGlobals -> range -> TupInfo -> Exprs -> TType list -> Expr + val mkRefTupled : TcGlobals -> range -> Exprs -> TType list -> Expr + val mkRefTupledNoTypes : TcGlobals -> range -> Exprs -> Expr + val mkRefTupledTy : TcGlobals -> TType list -> TType + val mkRefTupledVarsTy : TcGlobals -> Val list -> TType -val mkRefTupledVars : TcGlobals -> range -> Val list -> Expr -val mkMethodTy : TcGlobals -> TType list list -> TType -> TType +val mkRefTupledVars : TcGlobals -> range -> Val list -> Expr -//------------------------------------------------------------------------- -// Anonymous records -//------------------------------------------------------------------------- +val mkMethodTy : TcGlobals -> TType list list -> TType -> TType val mkAnyAnonRecdTy : TcGlobals -> AnonRecdTypeInfo -> TType list -> TType -val mkAnonRecd : TcGlobals -> range -> AnonRecdTypeInfo -> Exprs -> TType list -> Expr -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- +val mkAnonRecd : TcGlobals -> range -> AnonRecdTypeInfo -> Exprs -> TType list -> Expr val AdjustValForExpectedArity : TcGlobals -> range -> ValRef -> ValUseFlag -> ValReprInfo -> Expr * TType + val AdjustValToTopVal : Val -> ParentRef -> ValReprInfo -> unit + val LinearizeTopMatch : TcGlobals -> ParentRef -> Expr -> Expr + val AdjustPossibleSubsumptionExpr : TcGlobals -> Expr -> Exprs -> (Expr * Exprs) option + val NormalizeAndAdjustPossibleSubsumptionExprs : TcGlobals -> Expr -> Expr //------------------------------------------------------------------------- @@ -1514,28 +2123,35 @@ val NormalizeAndAdjustPossibleSubsumptionExprs : TcGlobals -> Expr -> Expr val buildAccessPath : CompilationPath option -> string val XmlDocArgsEnc : TcGlobals -> Typars * Typars -> TType list -> string + val XmlDocSigOfVal : TcGlobals -> string -> Val -> string + val XmlDocSigOfUnionCase : (string list -> string) + val XmlDocSigOfField : (string list -> string) + val XmlDocSigOfProperty : (string list -> string) + val XmlDocSigOfTycon : (string list -> string) + val XmlDocSigOfSubModul : (string list -> string) + val XmlDocSigOfEntity : EntityRef -> string //--------------------------------------------------------------------------- // Resolve static optimizations //------------------------------------------------------------------------- + type StaticOptimizationAnswer = | Yes = 1y | No = -1y | Unknown = 0y + val DecideStaticOptimizations : TcGlobals -> StaticOptimization list -> StaticOptimizationAnswer -val mkStaticOptimizationExpr : TcGlobals -> StaticOptimization list * Expr * Expr * range -> Expr -//--------------------------------------------------------------------------- -// Build for loops -//------------------------------------------------------------------------- +val mkStaticOptimizationExpr : TcGlobals -> StaticOptimization list * Expr * Expr * range -> Expr +/// Build for loops val mkFastForLoop : TcGlobals -> SequencePointInfoForForLoop * range * Val * Expr * bool * Expr * Expr -> Expr //--------------------------------------------------------------------------- @@ -1546,12 +2162,15 @@ type ActivePatternElemRef with member Name : string val TryGetActivePatternInfo : ValRef -> PrettyNaming.ActivePatternInfo option + val mkChoiceCaseRef : TcGlobals -> range -> int -> int -> UnionCaseRef type PrettyNaming.ActivePatternInfo with + member Names : string list member ResultType : TcGlobals -> range -> TType list -> TType + member OverallType : TcGlobals -> range -> TType -> TType list -> TType val doesActivePatternHaveFreeTypars : TcGlobals -> ValRef -> bool @@ -1562,61 +2181,84 @@ val doesActivePatternHaveFreeTypars : TcGlobals -> ValRef -> bool [] type ExprRewritingEnv = - {PreIntercept: ((Expr -> Expr) -> Expr -> Expr option) option; - PostTransform: Expr -> Expr option; - PreInterceptBinding: ((Expr -> Expr) -> Binding -> Binding option) option; - IsUnderQuotations: bool } + { PreIntercept: ((Expr -> Expr) -> Expr -> Expr option) option + PostTransform: Expr -> Expr option + PreInterceptBinding: ((Expr -> Expr) -> Binding -> Binding option) option + IsUnderQuotations: bool } val RewriteExpr : ExprRewritingEnv -> Expr -> Expr + val RewriteImplFile : ExprRewritingEnv -> TypedImplFile -> TypedImplFile val IsGenericValWithGenericContraints: TcGlobals -> Val -> bool type Entity with + member HasInterface : TcGlobals -> TType -> bool + member HasOverride : TcGlobals -> string -> TType list -> bool + member HasMember : TcGlobals -> string -> TType list -> bool type EntityRef with + member HasInterface : TcGlobals -> TType -> bool + member HasOverride : TcGlobals -> string -> TType list -> bool + member HasMember : TcGlobals -> string -> TType list -> bool val (|AttribBitwiseOrExpr|_|) : TcGlobals -> Expr -> (Expr * Expr) option + val (|EnumExpr|_|) : TcGlobals -> Expr -> Expr option + val (|TypeOfExpr|_|) : TcGlobals -> Expr -> TType option + val (|TypeDefOfExpr|_|) : TcGlobals -> Expr -> TType option val EvalLiteralExprOrAttribArg: TcGlobals -> Expr -> Expr + val EvaledAttribExprEquality : TcGlobals -> Expr -> Expr -> bool + val IsSimpleSyntacticConstantExpr: TcGlobals -> Expr -> bool val (|ConstToILFieldInit|_|): Const -> ILFieldInit option val (|ExtractAttribNamedArg|_|) : string -> AttribNamedArg list -> AttribExpr option + val (|AttribInt32Arg|_|) : AttribExpr -> int32 option + val (|AttribInt16Arg|_|) : AttribExpr -> int16 option + val (|AttribBoolArg|_|) : AttribExpr -> bool option + val (|AttribStringArg|_|) : AttribExpr -> string option + val (|Int32Expr|_|) : Expr -> int32 option /// Determines types that are potentially known to satisfy the 'comparable' constraint and returns /// a set of residual types that must also satisfy the constraint val (|SpecialComparableHeadType|_|) : TcGlobals -> TType -> TType list option + val (|SpecialEquatableHeadType|_|) : TcGlobals -> TType -> TType list option + val (|SpecialNotEquatableHeadType|_|) : TcGlobals -> TType -> unit option type OptimizeForExpressionOptions = OptimizeIntRangesOnly | OptimizeAllForExpressions + val DetectAndOptimizeForExpression : TcGlobals -> OptimizeForExpressionOptions -> Expr -> Expr val TryEliminateDesugaredConstants : TcGlobals -> range -> Const -> Expr option val MemberIsExplicitImpl : TcGlobals -> ValMemberInfo -> bool + val ValIsExplicitImpl : TcGlobals -> Val -> bool + val ValRefIsExplicitImpl : TcGlobals -> ValRef -> bool val (|LinearMatchExpr|_|) : Expr -> (SequencePointInfoForBinding * range * DecisionTree * DecisionTreeTarget * Expr * SequencePointInfoForTarget * range * TType) option + val rebuildLinearMatchExpr : (SequencePointInfoForBinding * range * DecisionTree * DecisionTreeTarget * Expr * SequencePointInfoForTarget * range * TType) -> Expr val mkCoerceIfNeeded : TcGlobals -> tgtTy: TType -> srcTy: TType -> Expr -> Expr diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index d9bdb7e52e..a20b3743ca 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -17387,7 +17387,7 @@ let CheckModuleSignature g cenv m denvAtEnd rootSigOpt implFileTypePriorToSig im // Compute the remapping from implementation to signature let remapInfo , _ = ComputeRemappingFromInferredSignatureToExplicitSignature cenv.g implFileTypePriorToSig sigFileType - let aenv = { TypeEquivEnv.Empty with EquivTycons = TyconRefMap.OfList remapInfo.mrpiEntities } + let aenv = { TypeEquivEnv.Empty with EquivTycons = TyconRefMap.OfList remapInfo.RepackagedEntities } if not (SignatureConformance.Checker(cenv.g, cenv.amap, denv, remapInfo, true).CheckSignature aenv (mkLocalModRef implFileSpecPriorToSig) sigFileType) then ( // We can just raise 'ReportedError' since CheckModuleOrNamespace raises its own error