From 33313b98d6c674a09b49a86c47b48ad4983dfb87 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 6 Mar 2024 15:18:34 +0100 Subject: [PATCH] More ValueOption in compiler: part 3 (and the last) --- .../.FSharp.Compiler.Service/8.0.300.md | 2 +- src/Compiler/Driver/CompilerDiagnostics.fs | 5 +- src/Compiler/Driver/CreateILModule.fs | 5 +- .../GraphChecking/FileContentMapping.fs | 26 +- src/Compiler/Facilities/AsyncMemoize.fs | 5 +- src/Compiler/Facilities/AsyncMemoize.fsi | 3 +- src/Compiler/Facilities/DiagnosticsLogger.fs | 5 +- src/Compiler/Facilities/DiagnosticsLogger.fsi | 3 +- src/Compiler/Symbols/Exprs.fs | 288 ++++++++----- src/Compiler/Symbols/Exprs.fsi | 144 ++++--- src/Compiler/Symbols/SymbolHelpers.fs | 41 +- src/Compiler/Symbols/SymbolHelpers.fsi | 9 +- src/Compiler/Symbols/SymbolPatterns.fs | 150 ++++--- src/Compiler/Symbols/SymbolPatterns.fsi | 105 +++-- src/Compiler/TypedTree/TypeProviders.fs | 9 +- src/Compiler/TypedTree/TypedTreeBasics.fs | 5 +- src/Compiler/TypedTree/TypedTreeBasics.fsi | 3 +- src/Compiler/TypedTree/TypedTreeOps.fs | 404 +++++++++++------- src/Compiler/TypedTree/TypedTreeOps.fsi | 152 ++++--- 19 files changed, 845 insertions(+), 519 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 148f3734185..01dad9dd324 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -32,7 +32,7 @@ * Autogenerated .Is* members for unions skipped for single-case unions. ([PR 16571](https://github.com/dotnet/fsharp/pull/16571)) * `implicitCtorSynPats` in `SynTypeDefnSimpleRepr.General` is now `SynPat option` instead of `SynSimplePats option`. ([PR #16425](https://github.com/dotnet/fsharp/pull/16425)) * `SyntaxVisitorBase<'T>.VisitSimplePats` now takes `SynPat` instead of `SynSimplePat list`. ([PR #16425](https://github.com/dotnet/fsharp/pull/16425)) -* Reduce allocations in compiler checking via `ValueOption` usage ([PR #16323](https://github.com/dotnet/fsharp/pull/16323), [PR #16567](https://github.com/dotnet/fsharp/pull/16567)) +* Reduce allocations in compiler checking via `ValueOption` usage ([PR #16323](https://github.com/dotnet/fsharp/pull/16323), [PR #16567](https://github.com/dotnet/fsharp/pull/16567), [PR #16822](https://github.com/dotnet/fsharp/pull/16822)) * Reverted [#16348](https://github.com/dotnet/fsharp/pull/16348) `ThreadStatic` `CancellationToken` changes to improve test stability and prevent potential unwanted cancellations. ([PR #16536](https://github.com/dotnet/fsharp/pull/16536)) * Refactored parenthesization API. ([PR #16461])(https://github.com/dotnet/fsharp/pull/16461)) * Optimize some interpolated strings by lowering to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556)) diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 3327aa0a635..2705b8138a8 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -610,10 +610,11 @@ module OldStyleMessages = let mutable showParserStackOnParseError = false #endif +[] let (|InvalidArgument|_|) (exn: exn) = match exn with - | :? ArgumentException as e -> Some e.Message - | _ -> None + | :? ArgumentException as e -> ValueSome e.Message + | _ -> ValueNone let OutputNameSuggestions (os: StringBuilder) suggestNames suggestionsF idText = if suggestNames then diff --git a/src/Compiler/Driver/CreateILModule.fs b/src/Compiler/Driver/CreateILModule.fs index 04cda7f6c3f..506171ed0ef 100644 --- a/src/Compiler/Driver/CreateILModule.fs +++ b/src/Compiler/Driver/CreateILModule.fs @@ -54,11 +54,12 @@ module AttributeHelpers = | Some(Attrib(_, _, [ AttribBoolArg p ], _, _, _, _)) -> Some p | _ -> None + [] let (|ILVersion|_|) (versionString: string) = try - Some(parseILVersion versionString) + ValueSome(parseILVersion versionString) with e -> - None + ValueNone //---------------------------------------------------------------------------- // ValidateKeySigningAttributes, GetStrongNameSigner diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index c19edc6ac57..e64a64e2ace 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -330,7 +330,8 @@ let visitNameofResult (nameofResult: NameofResult) : FileContentEntry = FileContentEntry.PrefixedIdentifier(longIdentToPath false longIdent) /// Special case of `nameof Module` type of expression -let (|NameofExpr|_|) (e: SynExpr) : NameofResult option = +[] +let (|NameofExpr|_|) (e: SynExpr) : NameofResult voption = let rec stripParen (e: SynExpr) = match e with | SynExpr.Paren(expr = expr) -> stripParen expr @@ -339,15 +340,15 @@ let (|NameofExpr|_|) (e: SynExpr) : NameofResult option = match e with | SynExpr.App(flag = ExprAtomicFlag.NonAtomic; isInfix = false; funcExpr = SynExpr.Ident NameofIdent; argExpr = moduleNameExpr) -> match stripParen moduleNameExpr with - | SynExpr.Ident moduleNameIdent -> Some(NameofResult.SingleIdent moduleNameIdent) + | SynExpr.Ident moduleNameIdent -> ValueSome(NameofResult.SingleIdent moduleNameIdent) | SynExpr.LongIdent(longDotId = longIdent) -> match longIdent.LongIdent with - | [] -> None + | [] -> ValueNone // This is highly unlikely to be produced by the parser - | [ moduleNameIdent ] -> Some(NameofResult.SingleIdent moduleNameIdent) - | lid -> Some(NameofResult.LongIdent(lid)) - | _ -> None - | _ -> None + | [ moduleNameIdent ] -> ValueSome(NameofResult.SingleIdent moduleNameIdent) + | lid -> ValueSome(NameofResult.LongIdent(lid)) + | _ -> ValueNone + | _ -> ValueNone let visitSynExpr (e: SynExpr) : FileContentEntry list = let rec visit (e: SynExpr) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = @@ -566,6 +567,7 @@ let visitSynExpr (e: SynExpr) : FileContentEntry list = visit e id /// Special case of `| nameof Module ->` type of pattern +[] let (|NameofPat|_|) (pat: SynPat) = let rec stripPats p = match p with @@ -582,11 +584,11 @@ let (|NameofPat|_|) (pat: SynPat) = argPats = SynArgPats.Pats [] accessibility = None) -> match longIdent with - | [] -> None - | [ moduleNameIdent ] -> Some(NameofResult.SingleIdent moduleNameIdent) - | lid -> Some(NameofResult.LongIdent lid) - | _ -> None - | _ -> None + | [] -> ValueNone + | [ moduleNameIdent ] -> ValueSome(NameofResult.SingleIdent moduleNameIdent) + | lid -> ValueSome(NameofResult.LongIdent lid) + | _ -> ValueNone + | _ -> ValueNone let visitPat (p: SynPat) : FileContentEntry list = let rec visit (p: SynPat) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = diff --git a/src/Compiler/Facilities/AsyncMemoize.fs b/src/Compiler/Facilities/AsyncMemoize.fs index d6ae83ada6e..1749994f5ae 100644 --- a/src/Compiler/Facilities/AsyncMemoize.fs +++ b/src/Compiler/Facilities/AsyncMemoize.fs @@ -30,15 +30,16 @@ module internal Utils = let replayDiagnostics (logger: DiagnosticsLogger) = Seq.iter ((<|) logger.DiagnosticSink) + [] let (|TaskCancelled|_|) (ex: exn) = match ex with - | :? System.Threading.Tasks.TaskCanceledException as tce -> Some tce + | :? System.Threading.Tasks.TaskCanceledException as tce -> ValueSome tce //| :? System.AggregateException as ae -> // if ae.InnerExceptions |> Seq.forall (fun e -> e :? System.Threading.Tasks.TaskCanceledException) then // ae.InnerExceptions |> Seq.tryHead |> Option.map (fun e -> e :?> System.Threading.Tasks.TaskCanceledException) // else // None - | _ -> None + | _ -> ValueNone type internal StateUpdate<'TValue> = | CancelRequest diff --git a/src/Compiler/Facilities/AsyncMemoize.fsi b/src/Compiler/Facilities/AsyncMemoize.fsi index 1cce68cf999..5bfc1a10168 100644 --- a/src/Compiler/Facilities/AsyncMemoize.fsi +++ b/src/Compiler/Facilities/AsyncMemoize.fsi @@ -9,7 +9,8 @@ module internal Utils = /// Return file name with one directory above it val shortPath: path: string -> string - val (|TaskCancelled|_|): ex: exn -> TaskCanceledException option + [] + val (|TaskCancelled|_|): ex: exn -> TaskCanceledException voption type internal JobEvent = | Requested diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fs b/src/Compiler/Facilities/DiagnosticsLogger.fs index 75dfaaef39e..d0bcce53048 100644 --- a/src/Compiler/Facilities/DiagnosticsLogger.fs +++ b/src/Compiler/Facilities/DiagnosticsLogger.fs @@ -67,10 +67,11 @@ exception StopProcessingExn of exn option with | StopProcessingExn(Some exn) -> "StopProcessingExn, originally (" + exn.ToString() + ")" | _ -> "StopProcessingExn" +[] let (|StopProcessing|_|) exn = match exn with - | StopProcessingExn _ -> Some() - | _ -> None + | StopProcessingExn _ -> ValueSome() + | _ -> ValueNone let StopProcessing<'T> = StopProcessingExn None diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fsi b/src/Compiler/Facilities/DiagnosticsLogger.fsi index bcbdd197b73..89d64020f25 100644 --- a/src/Compiler/Facilities/DiagnosticsLogger.fsi +++ b/src/Compiler/Facilities/DiagnosticsLogger.fsi @@ -37,7 +37,8 @@ val NoSuggestions: Suggestions /// Thrown when we stop processing the F# Interactive entry or #load. exception StopProcessingExn of exn option -val (|StopProcessing|_|): exn: exn -> unit option +[] +val (|StopProcessing|_|): exn: exn -> unit voption val StopProcessing<'T> : exn diff --git a/src/Compiler/Symbols/Exprs.fs b/src/Compiler/Symbols/Exprs.fs index 4d0b994f35b..a2f58ba9ee6 100644 --- a/src/Compiler/Symbols/Exprs.fs +++ b/src/Compiler/Symbols/Exprs.fs @@ -218,108 +218,115 @@ module FSharpExprConvert = rfref.RecdField.LogicalName.StartsWithOrdinal("init") // Match "if [AI_clt](init@41, 6) then IntrinsicFunctions.FailStaticInit () else ()" + [] let (|StaticInitializationCheck|_|) e = match e with - | Expr.Match (_, _, TDSwitch(Expr.Op (TOp.ILAsm ([ AI_clt ], _), _, [Expr.Op (TOp.ValFieldGet rfref, _, _, _) ;_], _), _, _, _), _, _, _) when IsStaticInitializationField rfref -> Some () - | _ -> None + | Expr.Match (_, _, TDSwitch(Expr.Op (TOp.ILAsm ([ AI_clt ], _), _, [Expr.Op (TOp.ValFieldGet rfref, _, _, _) ;_], _), _, _, _), _, _, _) when IsStaticInitializationField rfref -> ValueSome () + | _ -> ValueNone // Match "init@41 <- 6" + [] let (|StaticInitializationCount|_|) e = match e with - | Expr.Op (TOp.ValFieldSet rfref, _, _, _) when IsStaticInitializationField rfref -> Some () - | _ -> None + | Expr.Op (TOp.ValFieldSet rfref, _, _, _) when IsStaticInitializationField rfref -> ValueSome () + | _ -> ValueNone + [] let (|ILUnaryOp|_|) e = match e with - | AI_neg -> Some mkCallUnaryNegOperator - | AI_not -> Some mkCallUnaryNotOperator - | _ -> None + | AI_neg -> ValueSome mkCallUnaryNegOperator + | AI_not -> ValueSome mkCallUnaryNotOperator + | _ -> ValueNone + [] let (|ILMulDivOp|_|) e = match e with - | AI_mul -> Some (mkCallMultiplyOperator, true) + | AI_mul -> ValueSome (mkCallMultiplyOperator, true) | AI_mul_ovf - | AI_mul_ovf_un -> Some (mkCallMultiplyChecked, true) + | AI_mul_ovf_un -> ValueSome (mkCallMultiplyChecked, true) | AI_div - | AI_div_un -> Some (mkCallDivisionOperator, false) - | _ -> None + | AI_div_un -> ValueSome (mkCallDivisionOperator, false) + | _ -> ValueNone + [] let (|ILBinaryOp|_|) e = match e with - | AI_add -> Some mkCallAdditionOperator + | AI_add -> ValueSome mkCallAdditionOperator | AI_add_ovf - | AI_add_ovf_un -> Some mkCallAdditionChecked - | AI_sub -> Some mkCallSubtractionOperator + | AI_add_ovf_un -> ValueSome mkCallAdditionChecked + | AI_sub -> ValueSome mkCallSubtractionOperator | AI_sub_ovf - | AI_sub_ovf_un -> Some mkCallSubtractionChecked + | AI_sub_ovf_un -> ValueSome mkCallSubtractionChecked | AI_rem - | AI_rem_un -> Some mkCallModulusOperator - | AI_ceq -> Some mkCallEqualsOperator + | AI_rem_un -> ValueSome mkCallModulusOperator + | AI_ceq -> ValueSome mkCallEqualsOperator | AI_clt - | AI_clt_un -> Some mkCallLessThanOperator + | AI_clt_un -> ValueSome mkCallLessThanOperator | AI_cgt - | AI_cgt_un -> Some mkCallGreaterThanOperator - | AI_and -> Some mkCallBitwiseAndOperator - | AI_or -> Some mkCallBitwiseOrOperator - | AI_xor -> Some mkCallBitwiseXorOperator - | AI_shl -> Some mkCallShiftLeftOperator + | AI_cgt_un -> ValueSome mkCallGreaterThanOperator + | AI_and -> ValueSome mkCallBitwiseAndOperator + | AI_or -> ValueSome mkCallBitwiseOrOperator + | AI_xor -> ValueSome mkCallBitwiseXorOperator + | AI_shl -> ValueSome mkCallShiftLeftOperator | AI_shr - | AI_shr_un -> Some mkCallShiftRightOperator - | _ -> None + | AI_shr_un -> ValueSome mkCallShiftRightOperator + | _ -> ValueNone + [] let (|ILConvertOp|_|) e = match e with | AI_conv basicTy -> match basicTy with - | DT_R -> Some mkCallToDoubleOperator - | DT_I1 -> Some mkCallToSByteOperator - | DT_U1 -> Some mkCallToByteOperator - | DT_I2 -> Some mkCallToInt16Operator - | DT_U2 -> Some mkCallToUInt16Operator - | DT_I4 -> Some mkCallToInt32Operator - | DT_U4 -> Some mkCallToUInt32Operator - | DT_I8 -> Some mkCallToInt64Operator - | DT_U8 -> Some mkCallToUInt64Operator - | DT_R4 -> Some mkCallToSingleOperator - | DT_R8 -> Some mkCallToDoubleOperator - | DT_I -> Some mkCallToIntPtrOperator - | DT_U -> Some mkCallToUIntPtrOperator - | DT_REF -> None + | DT_R -> ValueSome mkCallToDoubleOperator + | DT_I1 -> ValueSome mkCallToSByteOperator + | DT_U1 -> ValueSome mkCallToByteOperator + | DT_I2 -> ValueSome mkCallToInt16Operator + | DT_U2 -> ValueSome mkCallToUInt16Operator + | DT_I4 -> ValueSome mkCallToInt32Operator + | DT_U4 -> ValueSome mkCallToUInt32Operator + | DT_I8 -> ValueSome mkCallToInt64Operator + | DT_U8 -> ValueSome mkCallToUInt64Operator + | DT_R4 -> ValueSome mkCallToSingleOperator + | DT_R8 -> ValueSome mkCallToDoubleOperator + | DT_I -> ValueSome mkCallToIntPtrOperator + | DT_U -> ValueSome mkCallToUIntPtrOperator + | DT_REF -> ValueNone | AI_conv_ovf basicTy | AI_conv_ovf_un basicTy -> match basicTy with - | DT_R -> Some mkCallToDoubleOperator - | DT_I1 -> Some mkCallToSByteChecked - | DT_U1 -> Some mkCallToByteChecked - | DT_I2 -> Some mkCallToInt16Checked - | DT_U2 -> Some mkCallToUInt16Checked - | DT_I4 -> Some mkCallToInt32Checked - | DT_U4 -> Some mkCallToUInt32Checked - | DT_I8 -> Some mkCallToInt64Checked - | DT_U8 -> Some mkCallToUInt64Checked - | DT_R4 -> Some mkCallToSingleOperator - | DT_R8 -> Some mkCallToDoubleOperator - | DT_I -> Some mkCallToIntPtrChecked - | DT_U -> Some mkCallToUIntPtrChecked - | DT_REF -> None - | _ -> None - + | DT_R -> ValueSome mkCallToDoubleOperator + | DT_I1 -> ValueSome mkCallToSByteChecked + | DT_U1 -> ValueSome mkCallToByteChecked + | DT_I2 -> ValueSome mkCallToInt16Checked + | DT_U2 -> ValueSome mkCallToUInt16Checked + | DT_I4 -> ValueSome mkCallToInt32Checked + | DT_U4 -> ValueSome mkCallToUInt32Checked + | DT_I8 -> ValueSome mkCallToInt64Checked + | DT_U8 -> ValueSome mkCallToUInt64Checked + | DT_R4 -> ValueSome mkCallToSingleOperator + | DT_R8 -> ValueSome mkCallToDoubleOperator + | DT_I -> ValueSome mkCallToIntPtrChecked + | DT_U -> ValueSome mkCallToUIntPtrChecked + | DT_REF -> ValueNone + | _ -> ValueNone + + [] let (|TTypeConvOp|_|) (cenv: SymbolEnv) ty = let g = cenv.g match ty with - | _ when typeEquiv g ty g.sbyte_ty -> Some mkCallToSByteOperator - | _ when typeEquiv g ty g.byte_ty -> Some mkCallToByteOperator - | _ when typeEquiv g ty g.int16_ty -> Some mkCallToInt16Operator - | _ when typeEquiv g ty g.uint16_ty -> Some mkCallToUInt16Operator - | _ when typeEquiv g ty g.int32_ty -> Some mkCallToInt32Operator - | _ when typeEquiv g ty g.uint32_ty -> Some mkCallToUInt32Operator - | _ when typeEquiv g ty g.int64_ty -> Some mkCallToInt64Operator - | _ when typeEquiv g ty g.uint64_ty -> Some mkCallToUInt64Operator - | _ when typeEquiv g ty g.float32_ty -> Some mkCallToSingleOperator - | _ when typeEquiv g ty g.float_ty -> Some mkCallToDoubleOperator - | _ when typeEquiv g ty g.nativeint_ty -> Some mkCallToIntPtrOperator - | _ when typeEquiv g ty g.unativeint_ty -> Some mkCallToUIntPtrOperator - | _ -> None + | _ when typeEquiv g ty g.sbyte_ty -> ValueSome mkCallToSByteOperator + | _ when typeEquiv g ty g.byte_ty -> ValueSome mkCallToByteOperator + | _ when typeEquiv g ty g.int16_ty -> ValueSome mkCallToInt16Operator + | _ when typeEquiv g ty g.uint16_ty -> ValueSome mkCallToUInt16Operator + | _ when typeEquiv g ty g.int32_ty -> ValueSome mkCallToInt32Operator + | _ when typeEquiv g ty g.uint32_ty -> ValueSome mkCallToUInt32Operator + | _ when typeEquiv g ty g.int64_ty -> ValueSome mkCallToInt64Operator + | _ when typeEquiv g ty g.uint64_ty -> ValueSome mkCallToUInt64Operator + | _ when typeEquiv g ty g.float32_ty -> ValueSome mkCallToSingleOperator + | _ when typeEquiv g ty g.float_ty -> ValueSome mkCallToDoubleOperator + | _ when typeEquiv g ty g.nativeint_ty -> ValueSome mkCallToIntPtrOperator + | _ when typeEquiv g ty g.unativeint_ty -> ValueSome mkCallToUIntPtrOperator + | _ -> ValueNone let ConvType cenv ty = FSharpType(cenv, ty) @@ -1398,99 +1405,146 @@ and FSharpImplementationFileContents(cenv, mimpl) = module FSharpExprPatterns = - let (|Value|_|) (e: FSharpExpr) = match e.E with E.Value v -> Some v | _ -> None - - let (|Const|_|) (e: FSharpExpr) = match e.E with E.Const (v, ty) -> Some (v, ty) | _ -> None + [] + let (|Value|_|) (e: FSharpExpr) = match e.E with E.Value v -> ValueSome v | _ -> ValueNone - let (|TypeLambda|_|) (e: FSharpExpr) = match e.E with E.TypeLambda (v, e) -> Some (v, e) | _ -> None + [] + let (|Const|_|) (e: FSharpExpr) = match e.E with E.Const (v, ty) -> ValueSome (v, ty) | _ -> ValueNone - let (|Lambda|_|) (e: FSharpExpr) = match e.E with E.Lambda (v, e) -> Some (v, e) | _ -> None + [] + let (|TypeLambda|_|) (e: FSharpExpr) = match e.E with E.TypeLambda (v, e) -> ValueSome (v, e) | _ -> ValueNone - let (|Application|_|) (e: FSharpExpr) = match e.E with E.Application (f, tys, e) -> Some (f, tys, e) | _ -> None + [] + let (|Lambda|_|) (e: FSharpExpr) = match e.E with E.Lambda (v, e) -> ValueSome (v, e) | _ -> ValueNone - let (|IfThenElse|_|) (e: FSharpExpr) = match e.E with E.IfThenElse (e1, e2, e3) -> Some (e1, e2, e3) | _ -> None + [] + let (|Application|_|) (e: FSharpExpr) = match e.E with E.Application (f, tys, e) -> ValueSome (f, tys, e) | _ -> ValueNone - let (|Let|_|) (e: FSharpExpr) = match e.E with E.Let ((dp, v, e), b) -> Some ((dp, v, e), b) | _ -> None + [] + let (|IfThenElse|_|) (e: FSharpExpr) = match e.E with E.IfThenElse (e1, e2, e3) -> ValueSome (e1, e2, e3) | _ -> ValueNone - let (|LetRec|_|) (e: FSharpExpr) = match e.E with E.LetRec (ves, b) -> Some (ves, b) | _ -> None + [] + let (|Let|_|) (e: FSharpExpr) = match e.E with E.Let ((dp, v, e), b) -> ValueSome ((dp, v, e), b) | _ -> ValueNone - let (|NewRecord|_|) (e: FSharpExpr) = match e.E with E.NewRecord (ty, es) -> Some (ty, es) | _ -> None + [] + let (|LetRec|_|) (e: FSharpExpr) = match e.E with E.LetRec (ves, b) -> ValueSome (ves, b) | _ -> ValueNone - let (|NewAnonRecord|_|) (e: FSharpExpr) = match e.E with E.NewAnonRecord (ty, es) -> Some (ty, es) | _ -> None + [] + let (|NewRecord|_|) (e: FSharpExpr) = match e.E with E.NewRecord (ty, es) -> ValueSome (ty, es) | _ -> ValueNone - let (|NewUnionCase|_|) (e: FSharpExpr) = match e.E with E.NewUnionCase (e, tys, es) -> Some (e, tys, es) | _ -> None + [] + let (|NewAnonRecord|_|) (e: FSharpExpr) = match e.E with E.NewAnonRecord (ty, es) -> ValueSome (ty, es) | _ -> ValueNone - let (|NewTuple|_|) (e: FSharpExpr) = match e.E with E.NewTuple (ty, es) -> Some (ty, es) | _ -> None + [] + let (|NewUnionCase|_|) (e: FSharpExpr) = match e.E with E.NewUnionCase (e, tys, es) -> ValueSome (e, tys, es) | _ -> ValueNone - let (|TupleGet|_|) (e: FSharpExpr) = match e.E with E.TupleGet (ty, n, es) -> Some (ty, n, es) | _ -> None + [] + let (|NewTuple|_|) (e: FSharpExpr) = match e.E with E.NewTuple (ty, es) -> ValueSome (ty, es) | _ -> ValueNone - let (|Call|_|) (e: FSharpExpr) = match e.E with E.Call (a, b, c, d, _e, f) -> Some (a, b, c, d, f) | _ -> None + [] + let (|TupleGet|_|) (e: FSharpExpr) = match e.E with E.TupleGet (ty, n, es) -> ValueSome (ty, n, es) | _ -> ValueNone - let (|CallWithWitnesses|_|) (e: FSharpExpr) = match e.E with E.Call (a, b, c, d, e, f) -> Some (a, b, c, d, e, f) | _ -> None + [] + let (|Call|_|) (e: FSharpExpr) = match e.E with E.Call (a, b, c, d, _e, f) -> ValueSome (a, b, c, d, f) | _ -> ValueNone - let (|NewObject|_|) (e: FSharpExpr) = match e.E with E.NewObject (a, b, c) -> Some (a, b, c) | _ -> None + [] + let (|CallWithWitnesses|_|) (e: FSharpExpr) = match e.E with E.Call (a, b, c, d, e, f) -> ValueSome (a, b, c, d, e, f) | _ -> ValueNone - let (|FSharpFieldGet|_|) (e: FSharpExpr) = match e.E with E.FSharpFieldGet (a, b, c) -> Some (a, b, c) | _ -> None + [] + let (|NewObject|_|) (e: FSharpExpr) = match e.E with E.NewObject (a, b, c) -> ValueSome (a, b, c) | _ -> ValueNone - let (|AnonRecordGet|_|) (e: FSharpExpr) = match e.E with E.AnonRecordGet (a, b, c) -> Some (a, b, c) | _ -> None + [] + let (|FSharpFieldGet|_|) (e: FSharpExpr) = match e.E with E.FSharpFieldGet (a, b, c) -> ValueSome (a, b, c) | _ -> ValueNone - let (|FSharpFieldSet|_|) (e: FSharpExpr) = match e.E with E.FSharpFieldSet (a, b, c, d) -> Some (a, b, c, d) | _ -> None + [] + let (|AnonRecordGet|_|) (e: FSharpExpr) = match e.E with E.AnonRecordGet (a, b, c) -> ValueSome (a, b, c) | _ -> ValueNone - let (|UnionCaseGet|_|) (e: FSharpExpr) = match e.E with E.UnionCaseGet (a, b, c, d) -> Some (a, b, c, d) | _ -> None + [] + let (|FSharpFieldSet|_|) (e: FSharpExpr) = match e.E with E.FSharpFieldSet (a, b, c, d) -> ValueSome (a, b, c, d) | _ -> ValueNone - let (|UnionCaseTag|_|) (e: FSharpExpr) = match e.E with E.UnionCaseTag (a, b) -> Some (a, b) | _ -> None + [] + let (|UnionCaseGet|_|) (e: FSharpExpr) = match e.E with E.UnionCaseGet (a, b, c, d) -> ValueSome (a, b, c, d) | _ -> ValueNone - let (|UnionCaseTest|_|) (e: FSharpExpr) = match e.E with E.UnionCaseTest (a, b, c) -> Some (a, b, c) | _ -> None + [] + let (|UnionCaseTag|_|) (e: FSharpExpr) = match e.E with E.UnionCaseTag (a, b) -> ValueSome (a, b) | _ -> ValueNone - let (|NewArray|_|) (e: FSharpExpr) = match e.E with E.NewArray (a, b) -> Some (a, b) | _ -> None + [] + let (|UnionCaseTest|_|) (e: FSharpExpr) = match e.E with E.UnionCaseTest (a, b, c) -> ValueSome (a, b, c) | _ -> ValueNone - let (|Coerce|_|) (e: FSharpExpr) = match e.E with E.Coerce (a, b) -> Some (a, b) | _ -> None + [] + let (|NewArray|_|) (e: FSharpExpr) = match e.E with E.NewArray (a, b) -> ValueSome (a, b) | _ -> ValueNone - let (|Quote|_|) (e: FSharpExpr) = match e.E with E.Quote a -> Some a | _ -> None + [] + let (|Coerce|_|) (e: FSharpExpr) = match e.E with E.Coerce (a, b) -> ValueSome (a, b) | _ -> ValueNone - let (|TypeTest|_|) (e: FSharpExpr) = match e.E with E.TypeTest (a, b) -> Some (a, b) | _ -> None + [] + let (|Quote|_|) (e: FSharpExpr) = match e.E with E.Quote a -> ValueSome a | _ -> ValueNone - let (|Sequential|_|) (e: FSharpExpr) = match e.E with E.Sequential (dp, a) -> Some (dp, a) | _ -> None + [] + let (|TypeTest|_|) (e: FSharpExpr) = match e.E with E.TypeTest (a, b) -> ValueSome (a, b) | _ -> ValueNone - let (|DebugPoint|_|) (e: FSharpExpr) = match e.E with E.DebugPoint (dp, a) -> Some (dp, a) | _ -> None + [] + let (|Sequential|_|) (e: FSharpExpr) = match e.E with E.Sequential (dp, a) -> ValueSome (dp, a) | _ -> ValueNone - let (|FastIntegerForLoop|_|) (e: FSharpExpr) = match e.E with E.IntegerForLoop (dpFor, dpEquals, a, b, c, d) -> Some (dpFor, dpEquals, a, b, c, d) | _ -> None + [] + let (|DebugPoint|_|) (e: FSharpExpr) = match e.E with E.DebugPoint (dp, a) -> ValueSome (dp, a) | _ -> ValueNone - let (|WhileLoop|_|) (e: FSharpExpr) = match e.E with E.WhileLoop (dpWhile, a, b) -> Some (dpWhile, a, b) | _ -> None + [] + let (|FastIntegerForLoop|_|) (e: FSharpExpr) = match e.E with E.IntegerForLoop (dpFor, dpEquals, a, b, c, d) -> ValueSome (dpFor, dpEquals, a, b, c, d) | _ -> ValueNone - let (|TryFinally|_|) (e: FSharpExpr) = match e.E with E.TryFinally (dpTry, dpFinally, a, b) -> Some (dpTry, dpFinally, a, b) | _ -> None + [] + let (|WhileLoop|_|) (e: FSharpExpr) = match e.E with E.WhileLoop (dpWhile, a, b) -> ValueSome (dpWhile, a, b) | _ -> ValueNone - let (|TryWith|_|) (e: FSharpExpr) = match e.E with E.TryWith (dpTry, dpWith, a, b, c, d, e) -> Some (dpTry, dpWith, a, b, c, d, e) | _ -> None + [] + let (|TryFinally|_|) (e: FSharpExpr) = match e.E with E.TryFinally (dpTry, dpFinally, a, b) -> ValueSome (dpTry, dpFinally, a, b) | _ -> ValueNone - let (|NewDelegate|_|) (e: FSharpExpr) = match e.E with E.NewDelegate (ty, e) -> Some (ty, e) | _ -> None + [] + let (|TryWith|_|) (e: FSharpExpr) = match e.E with E.TryWith (dpTry, dpWith, a, b, c, d, e) -> ValueSome (dpTry, dpWith, a, b, c, d, e) | _ -> ValueNone - let (|DefaultValue|_|) (e: FSharpExpr) = match e.E with E.DefaultValue ty -> Some ty | _ -> None + [] + let (|NewDelegate|_|) (e: FSharpExpr) = match e.E with E.NewDelegate (ty, e) -> ValueSome (ty, e) | _ -> ValueNone - let (|AddressSet|_|) (e: FSharpExpr) = match e.E with E.AddressSet (a, b) -> Some (a, b) | _ -> None + [] + let (|DefaultValue|_|) (e: FSharpExpr) = match e.E with E.DefaultValue ty -> ValueSome ty | _ -> ValueNone - let (|ValueSet|_|) (e: FSharpExpr) = match e.E with E.ValueSet (a, b) -> Some (a, b) | _ -> None + [] + let (|AddressSet|_|) (e: FSharpExpr) = match e.E with E.AddressSet (a, b) -> ValueSome (a, b) | _ -> ValueNone - let (|AddressOf|_|) (e: FSharpExpr) = match e.E with E.AddressOf a -> Some a | _ -> None + [] + let (|ValueSet|_|) (e: FSharpExpr) = match e.E with E.ValueSet (a, b) -> ValueSome (a, b) | _ -> ValueNone - let (|ThisValue|_|) (e: FSharpExpr) = match e.E with E.ThisValue a -> Some a | _ -> None + [] + let (|AddressOf|_|) (e: FSharpExpr) = match e.E with E.AddressOf a -> ValueSome a | _ -> ValueNone - let (|BaseValue|_|) (e: FSharpExpr) = match e.E with E.BaseValue a -> Some a | _ -> None + [] + let (|ThisValue|_|) (e: FSharpExpr) = match e.E with E.ThisValue a -> ValueSome a | _ -> ValueNone - let (|ILAsm|_|) (e: FSharpExpr) = match e.E with E.ILAsm (a, b, c) -> Some (a, b, c) | _ -> None + [] + let (|BaseValue|_|) (e: FSharpExpr) = match e.E with E.BaseValue a -> ValueSome a | _ -> ValueNone - let (|ILFieldGet|_|) (e: FSharpExpr) = match e.E with E.ILFieldGet (a, b, c) -> Some (a, b, c) | _ -> None + [] + let (|ILAsm|_|) (e: FSharpExpr) = match e.E with E.ILAsm (a, b, c) -> ValueSome (a, b, c) | _ -> ValueNone - let (|ILFieldSet|_|) (e: FSharpExpr) = match e.E with E.ILFieldSet (a, b, c, d) -> Some (a, b, c, d) | _ -> None + [] + let (|ILFieldGet|_|) (e: FSharpExpr) = match e.E with E.ILFieldGet (a, b, c) -> ValueSome (a, b, c) | _ -> ValueNone - let (|ObjectExpr|_|) (e: FSharpExpr) = match e.E with E.ObjectExpr (a, b, c, d) -> Some (a, b, c, d) | _ -> None + [] + let (|ILFieldSet|_|) (e: FSharpExpr) = match e.E with E.ILFieldSet (a, b, c, d) -> ValueSome (a, b, c, d) | _ -> ValueNone - let (|DecisionTree|_|) (e: FSharpExpr) = match e.E with E.DecisionTree (a, b) -> Some (a, b) | _ -> None + [] + let (|ObjectExpr|_|) (e: FSharpExpr) = match e.E with E.ObjectExpr (a, b, c, d) -> ValueSome (a, b, c, d) | _ -> ValueNone - let (|DecisionTreeSuccess|_|) (e: FSharpExpr) = match e.E with E.DecisionTreeSuccess (a, b) -> Some (a, b) | _ -> None + [] + let (|DecisionTree|_|) (e: FSharpExpr) = match e.E with E.DecisionTree (a, b) -> ValueSome (a, b) | _ -> ValueNone - let (|UnionCaseSet|_|) (e: FSharpExpr) = match e.E with E.UnionCaseSet (a, b, c, d, e) -> Some (a, b, c, d, e) | _ -> None + [] + let (|DecisionTreeSuccess|_|) (e: FSharpExpr) = match e.E with E.DecisionTreeSuccess (a, b) -> ValueSome (a, b) | _ -> ValueNone - let (|TraitCall|_|) (e: FSharpExpr) = match e.E with E.TraitCall (a, b, c, d, e, f) -> Some (a, b, c, d, e, f) | _ -> None + [] + let (|UnionCaseSet|_|) (e: FSharpExpr) = match e.E with E.UnionCaseSet (a, b, c, d, e) -> ValueSome (a, b, c, d, e) | _ -> ValueNone - let (|WitnessArg|_|) (e: FSharpExpr) = match e.E with E.WitnessArg n -> Some n | _ -> None + [] + let (|TraitCall|_|) (e: FSharpExpr) = match e.E with E.TraitCall (a, b, c, d, e, f) -> ValueSome (a, b, c, d, e, f) | _ -> ValueNone + [] + let (|WitnessArg|_|) (e: FSharpExpr) = match e.E with E.WitnessArg n -> ValueSome n | _ -> ValueNone diff --git a/src/Compiler/Symbols/Exprs.fsi b/src/Compiler/Symbols/Exprs.fsi index fddc3d0ea4e..9e715ea5366 100644 --- a/src/Compiler/Symbols/Exprs.fsi +++ b/src/Compiler/Symbols/Exprs.fsi @@ -92,38 +92,48 @@ type public FSharpObjectExprOverride = module public FSharpExprPatterns = /// Matches expressions which are uses of values - val (|Value|_|): FSharpExpr -> FSharpMemberOrFunctionOrValue option + [] + val (|Value|_|): FSharpExpr -> FSharpMemberOrFunctionOrValue voption /// Matches expressions which are the application of function values - val (|Application|_|): FSharpExpr -> (FSharpExpr * FSharpType list * FSharpExpr list) option + [] + val (|Application|_|): FSharpExpr -> (FSharpExpr * FSharpType list * FSharpExpr list) voption /// Matches expressions which are type abstractions - val (|TypeLambda|_|): FSharpExpr -> (FSharpGenericParameter list * FSharpExpr) option + [] + val (|TypeLambda|_|): FSharpExpr -> (FSharpGenericParameter list * FSharpExpr) voption /// Matches expressions with a decision expression, each branch of which ends in DecisionTreeSuccess passing control and values to one of the targets. - val (|DecisionTree|_|): FSharpExpr -> (FSharpExpr * (FSharpMemberOrFunctionOrValue list * FSharpExpr) list) option + [] + val (|DecisionTree|_|): FSharpExpr -> (FSharpExpr * (FSharpMemberOrFunctionOrValue list * FSharpExpr) list) voption /// Special expressions at the end of a conditional decision structure in the decision expression node of a DecisionTree . /// The given expressions are passed as values to the decision tree target. - val (|DecisionTreeSuccess|_|): FSharpExpr -> (int * FSharpExpr list) option + [] + val (|DecisionTreeSuccess|_|): FSharpExpr -> (int * FSharpExpr list) voption /// Matches expressions which are lambda abstractions - val (|Lambda|_|): FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpExpr) option + [] + val (|Lambda|_|): FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpExpr) voption /// Matches expressions which are conditionals - val (|IfThenElse|_|): FSharpExpr -> (FSharpExpr * FSharpExpr * FSharpExpr) option + [] + val (|IfThenElse|_|): FSharpExpr -> (FSharpExpr * FSharpExpr * FSharpExpr) voption /// Matches expressions which are let definitions + [] val (|Let|_|): - FSharpExpr -> ((FSharpMemberOrFunctionOrValue * FSharpExpr * DebugPointAtBinding) * FSharpExpr) option + FSharpExpr -> ((FSharpMemberOrFunctionOrValue * FSharpExpr * DebugPointAtBinding) * FSharpExpr) voption /// Matches expressions which are calls to members or module-defined functions. When calling curried functions and members the /// arguments are collapsed to a single collection of arguments, as done in the compiled version of these. + [] val (|Call|_|): FSharpExpr -> - (FSharpExpr option * FSharpMemberOrFunctionOrValue * FSharpType list * FSharpType list * FSharpExpr list) option + (FSharpExpr option * FSharpMemberOrFunctionOrValue * FSharpType list * FSharpType list * FSharpExpr list) voption /// Like Call but also indicates witness arguments + [] val (|CallWithWitnesses|_|): FSharpExpr -> (FSharpExpr option * @@ -131,103 +141,134 @@ module public FSharpExprPatterns = FSharpType list * FSharpType list * FSharpExpr list * - FSharpExpr list) option + FSharpExpr list) voption /// Matches expressions which are calls to object constructors - val (|NewObject|_|): FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpType list * FSharpExpr list) option + [] + val (|NewObject|_|): FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpType list * FSharpExpr list) voption /// Matches expressions which are uses of the 'this' value - val (|ThisValue|_|): FSharpExpr -> FSharpType option + [] + val (|ThisValue|_|): FSharpExpr -> FSharpType voption /// Matches expressions which are uses of the 'base' value - val (|BaseValue|_|): FSharpExpr -> FSharpType option + [] + val (|BaseValue|_|): FSharpExpr -> FSharpType voption /// Matches expressions which are quotation literals - val (|Quote|_|): FSharpExpr -> FSharpExpr option + [] + val (|Quote|_|): FSharpExpr -> FSharpExpr voption /// Matches expressions which are let-rec definitions + [] val (|LetRec|_|): - FSharpExpr -> ((FSharpMemberOrFunctionOrValue * FSharpExpr * DebugPointAtBinding) list * FSharpExpr) option + FSharpExpr -> ((FSharpMemberOrFunctionOrValue * FSharpExpr * DebugPointAtBinding) list * FSharpExpr) voption /// Matches record expressions - val (|NewRecord|_|): FSharpExpr -> (FSharpType * FSharpExpr list) option + [] + val (|NewRecord|_|): FSharpExpr -> (FSharpType * FSharpExpr list) voption /// Matches anonymous record expressions - val (|NewAnonRecord|_|): FSharpExpr -> (FSharpType * FSharpExpr list) option + [] + val (|NewAnonRecord|_|): FSharpExpr -> (FSharpType * FSharpExpr list) voption /// Matches expressions getting a field from an anonymous record. The integer represents the /// index into the sorted fields of the anonymous record. - val (|AnonRecordGet|_|): FSharpExpr -> (FSharpExpr * FSharpType * int) option + [] + val (|AnonRecordGet|_|): FSharpExpr -> (FSharpExpr * FSharpType * int) voption /// Matches expressions which get a field from a record or class - val (|FSharpFieldGet|_|): FSharpExpr -> (FSharpExpr option * FSharpType * FSharpField) option + [] + val (|FSharpFieldGet|_|): FSharpExpr -> (FSharpExpr option * FSharpType * FSharpField) voption /// Matches expressions which set a field in a record or class - val (|FSharpFieldSet|_|): FSharpExpr -> (FSharpExpr option * FSharpType * FSharpField * FSharpExpr) option + [] + val (|FSharpFieldSet|_|): FSharpExpr -> (FSharpExpr option * FSharpType * FSharpField * FSharpExpr) voption /// Matches expressions which create an object corresponding to a union case - val (|NewUnionCase|_|): FSharpExpr -> (FSharpType * FSharpUnionCase * FSharpExpr list) option + [] + val (|NewUnionCase|_|): FSharpExpr -> (FSharpType * FSharpUnionCase * FSharpExpr list) voption /// Matches expressions which get a field from a union case - val (|UnionCaseGet|_|): FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase * FSharpField) option + [] + val (|UnionCaseGet|_|): FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase * FSharpField) voption /// Matches expressions which set a field from a union case (only used in FSharp.Core itself) - val (|UnionCaseSet|_|): FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase * FSharpField * FSharpExpr) option + [] + val (|UnionCaseSet|_|): FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase * FSharpField * FSharpExpr) voption /// Matches expressions which gets the tag for a union case - val (|UnionCaseTag|_|): FSharpExpr -> (FSharpExpr * FSharpType) option + [] + val (|UnionCaseTag|_|): FSharpExpr -> (FSharpExpr * FSharpType) voption /// Matches expressions which test if an expression corresponds to a particular union case - val (|UnionCaseTest|_|): FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase) option + [] + val (|UnionCaseTest|_|): FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase) voption /// Matches tuple expressions - val (|NewTuple|_|): FSharpExpr -> (FSharpType * FSharpExpr list) option + [] + val (|NewTuple|_|): FSharpExpr -> (FSharpType * FSharpExpr list) voption /// Matches expressions which get a value from a tuple - val (|TupleGet|_|): FSharpExpr -> (FSharpType * int * FSharpExpr) option + [] + val (|TupleGet|_|): FSharpExpr -> (FSharpType * int * FSharpExpr) voption /// Matches expressions which coerce the type of a value - val (|Coerce|_|): FSharpExpr -> (FSharpType * FSharpExpr) option + [] + val (|Coerce|_|): FSharpExpr -> (FSharpType * FSharpExpr) voption /// Matches array expressions - val (|NewArray|_|): FSharpExpr -> (FSharpType * FSharpExpr list) option + [] + val (|NewArray|_|): FSharpExpr -> (FSharpType * FSharpExpr list) voption /// Matches expressions which test the runtime type of a value - val (|TypeTest|_|): FSharpExpr -> (FSharpType * FSharpExpr) option + [] + val (|TypeTest|_|): FSharpExpr -> (FSharpType * FSharpExpr) voption /// Matches expressions which set the contents of an address - val (|AddressSet|_|): FSharpExpr -> (FSharpExpr * FSharpExpr) option + [] + val (|AddressSet|_|): FSharpExpr -> (FSharpExpr * FSharpExpr) voption /// Matches expressions which set the contents of a mutable variable - val (|ValueSet|_|): FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpExpr) option + [] + val (|ValueSet|_|): FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpExpr) voption /// Matches default-value expressions, including null expressions - val (|DefaultValue|_|): FSharpExpr -> FSharpType option + [] + val (|DefaultValue|_|): FSharpExpr -> FSharpType voption /// Matches constant expressions, including signed and unsigned integers, strings, characters, booleans, arrays /// of bytes and arrays of unit16. - val (|Const|_|): FSharpExpr -> (obj * FSharpType) option + [] + val (|Const|_|): FSharpExpr -> (obj * FSharpType) voption /// Matches expressions which take the address of a location - val (|AddressOf|_|): FSharpExpr -> FSharpExpr option + [] + val (|AddressOf|_|): FSharpExpr -> FSharpExpr voption /// Matches sequential expressions - val (|Sequential|_|): FSharpExpr -> (FSharpExpr * FSharpExpr) option + [] + val (|Sequential|_|): FSharpExpr -> (FSharpExpr * FSharpExpr) voption /// Matches debug points at leaf expressions in control flow - val (|DebugPoint|_|): FSharpExpr -> (DebugPointAtLeafExpr * FSharpExpr) option + [] + val (|DebugPoint|_|): FSharpExpr -> (DebugPointAtLeafExpr * FSharpExpr) voption /// Matches fast-integer loops (up or down) + [] val (|FastIntegerForLoop|_|): - FSharpExpr -> (FSharpExpr * FSharpExpr * FSharpExpr * bool * DebugPointAtFor * DebugPointAtInOrTo) option + FSharpExpr -> (FSharpExpr * FSharpExpr * FSharpExpr * bool * DebugPointAtFor * DebugPointAtInOrTo) voption /// Matches while loops - val (|WhileLoop|_|): FSharpExpr -> (FSharpExpr * FSharpExpr * DebugPointAtWhile) option + [] + val (|WhileLoop|_|): FSharpExpr -> (FSharpExpr * FSharpExpr * DebugPointAtWhile) voption /// Matches try/finally expressions - val (|TryFinally|_|): FSharpExpr -> (FSharpExpr * FSharpExpr * DebugPointAtTry * DebugPointAtFinally) option + [] + val (|TryFinally|_|): FSharpExpr -> (FSharpExpr * FSharpExpr * DebugPointAtTry * DebugPointAtFinally) voption /// Matches try/with expressions + [] val (|TryWith|_|): FSharpExpr -> (FSharpExpr * @@ -236,29 +277,36 @@ module public FSharpExprPatterns = FSharpMemberOrFunctionOrValue * FSharpExpr * DebugPointAtTry * - DebugPointAtWith) option + DebugPointAtWith) voption /// Matches expressions which create an instance of a delegate type - val (|NewDelegate|_|): FSharpExpr -> (FSharpType * FSharpExpr) option + [] + val (|NewDelegate|_|): FSharpExpr -> (FSharpType * FSharpExpr) voption /// Matches expressions which are IL assembly code - val (|ILAsm|_|): FSharpExpr -> (string * FSharpType list * FSharpExpr list) option + [] + val (|ILAsm|_|): FSharpExpr -> (string * FSharpType list * FSharpExpr list) voption /// Matches expressions which fetch a field from a .NET type - val (|ILFieldGet|_|): FSharpExpr -> (FSharpExpr option * FSharpType * string) option + [] + val (|ILFieldGet|_|): FSharpExpr -> (FSharpExpr option * FSharpType * string) voption /// Matches expressions which set a field in a .NET type - val (|ILFieldSet|_|): FSharpExpr -> (FSharpExpr option * FSharpType * string * FSharpExpr) option + [] + val (|ILFieldSet|_|): FSharpExpr -> (FSharpExpr option * FSharpType * string * FSharpExpr) voption /// Matches object expressions, returning the base type, the base call, the overrides and the interface implementations + [] val (|ObjectExpr|_|): FSharpExpr -> - (FSharpType * FSharpExpr * FSharpObjectExprOverride list * (FSharpType * FSharpObjectExprOverride list) list) option + (FSharpType * FSharpExpr * FSharpObjectExprOverride list * (FSharpType * FSharpObjectExprOverride list) list) voption /// Matches expressions for an unresolved call to a trait + [] val (|TraitCall|_|): FSharpExpr -> - (FSharpType list * string * SynMemberFlags * FSharpType list * FSharpType list * FSharpExpr list) option + (FSharpType list * string * SynMemberFlags * FSharpType list * FSharpType list * FSharpExpr list) voption /// Indicates a witness argument index from the witness arguments supplied to the enclosing method - val (|WitnessArg|_|): FSharpExpr -> int option + [] + val (|WitnessArg|_|): FSharpExpr -> int voption diff --git a/src/Compiler/Symbols/SymbolHelpers.fs b/src/Compiler/Symbols/SymbolHelpers.fs index af89176ff6e..1584e096edd 100644 --- a/src/Compiler/Symbols/SymbolHelpers.fs +++ b/src/Compiler/Symbols/SymbolHelpers.fs @@ -356,12 +356,13 @@ module internal SymbolHelpers = [ for tp, ty in prettyTyparInst -> wordL (tagTypeParameter ("'" + tp.DisplayName)) ^^ wordL (tagText (FSComp.SR.descriptionWordIs())) ^^ NicePrint.layoutType denv ty ] + [] let (|ItemWhereTypIsPreferred|_|) item = match item with | Item.DelegateCtor ty | Item.CtorGroup(_, [DefaultStructCtor(_, ty)]) - | Item.Types(_, [ty]) -> Some ty - | _ -> None + | Item.Types(_, [ty]) -> ValueSome ty + | _ -> ValueNone /// Specifies functions for comparing 'Item' objects with respect to the user /// (this means that some values that are not technically equal are treated as equal @@ -730,19 +731,21 @@ module internal SymbolHelpers = #if !NO_TYPEPROVIDERS /// Determine if an item is a provided type + [] let (|ItemIsProvidedType|_|) g item = match item with | Item.Types(_name, tys) -> match tys with | [AppTy g (tcref, _typeInst)] -> if tcref.IsProvidedErasedTycon || tcref.IsProvidedGeneratedTycon then - Some tcref + ValueSome tcref else - None - | _ -> None - | _ -> None + ValueNone + | _ -> ValueNone + | _ -> ValueNone /// Determine if an item is a provided type that has static parameters + [] let (|ItemIsProvidedTypeWithStaticArguments|_|) m g item = match item with | Item.Types(_name, tys) -> @@ -755,31 +758,33 @@ module internal SymbolHelpers = | _ -> failwith "unreachable" let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m) let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters", m) - Some staticParameters + ValueSome staticParameters else - None - | _ -> None - | _ -> None + ValueNone + | _ -> ValueNone + | _ -> ValueNone + [] let (|ItemIsProvidedMethodWithStaticArguments|_|) item = match item with // Prefer the static parameters from the uninstantiated method info | Item.MethodGroup(_, _, Some minfo) -> match minfo.ProvidedStaticParameterInfo with - | Some (_, staticParameters) -> Some staticParameters - | _ -> None + | Some (_, staticParameters) -> ValueSome staticParameters + | _ -> ValueNone | Item.MethodGroup(_, [minfo], _) -> match minfo.ProvidedStaticParameterInfo with - | Some (_, staticParameters) -> Some staticParameters - | _ -> None - | _ -> None + | Some (_, staticParameters) -> ValueSome staticParameters + | _ -> ValueNone + | _ -> ValueNone /// Determine if an item has static arguments + [] let (|ItemIsWithStaticArguments|_|) m g item = match item with - | ItemIsProvidedTypeWithStaticArguments m g staticParameters -> Some staticParameters - | ItemIsProvidedMethodWithStaticArguments staticParameters -> Some staticParameters - | _ -> None + | ItemIsProvidedTypeWithStaticArguments m g staticParameters -> ValueSome staticParameters + | ItemIsProvidedMethodWithStaticArguments staticParameters -> ValueSome staticParameters + | _ -> ValueNone #endif diff --git a/src/Compiler/Symbols/SymbolHelpers.fsi b/src/Compiler/Symbols/SymbolHelpers.fsi index b25bf18d60f..e2eef38bbb6 100755 --- a/src/Compiler/Symbols/SymbolHelpers.fsi +++ b/src/Compiler/Symbols/SymbolHelpers.fsi @@ -59,13 +59,16 @@ module internal SymbolHelpers = val SelectMethodGroupItems2: TcGlobals -> range -> ItemWithInst -> ItemWithInst list #if !NO_TYPEPROVIDERS - val (|ItemIsProvidedType|_|): TcGlobals -> Item -> TyconRef option + [] + val (|ItemIsProvidedType|_|): TcGlobals -> Item -> TyconRef voption + [] val (|ItemIsWithStaticArguments|_|): - range -> TcGlobals -> Item -> Tainted[] option + range -> TcGlobals -> Item -> Tainted[] voption + [] val (|ItemIsProvidedTypeWithStaticArguments|_|): - range -> TcGlobals -> Item -> Tainted[] option + range -> TcGlobals -> Item -> Tainted[] voption #endif val SimplerDisplayEnv: DisplayEnv -> DisplayEnv diff --git a/src/Compiler/Symbols/SymbolPatterns.fs b/src/Compiler/Symbols/SymbolPatterns.fs index 44b77965a28..ef46a13bfcf 100644 --- a/src/Compiler/Symbols/SymbolPatterns.fs +++ b/src/Compiler/Symbols/SymbolPatterns.fs @@ -29,13 +29,15 @@ module FSharpSymbolPatterns = res))) |> Option.isSome + [] let (|AbbreviatedType|_|) (entity: FSharpEntity) = - if entity.IsFSharpAbbreviation then Some entity.AbbreviatedType - else None + if entity.IsFSharpAbbreviation then ValueSome entity.AbbreviatedType + else ValueNone + [] let (|TypeWithDefinition|_|) (ty: FSharpType) = - if ty.HasTypeDefinition then Some ty.TypeDefinition - else None + if ty.HasTypeDefinition then ValueSome ty.TypeDefinition + else ValueNone let rec getEntityAbbreviatedType (entity: FSharpEntity) = if entity.IsFSharpAbbreviation then @@ -44,6 +46,7 @@ module FSharpSymbolPatterns = | abbreviatedTy -> entity, Some abbreviatedTy else entity, None + [] let (|Attribute|_|) (entity: FSharpEntity) = let isAttribute (entity: FSharpEntity) = let getBaseType (entity: FSharpEntity) = @@ -60,150 +63,183 @@ module FSharpSymbolPatterns = try ty.FullName = "System.Attribute" || isAttributeType (getBaseType ty) with _ -> false isAttributeType (Some entity) - if isAttribute entity then Some() else None + if isAttribute entity then ValueSome() else ValueNone + [] let (|ValueType|_|) (e: FSharpEntity) = - if e.IsEnum || e.IsValueType || e.HasAttribute() then Some() - else None + if e.IsEnum || e.IsValueType || e.HasAttribute() then ValueSome() + else ValueNone #if !NO_TYPEPROVIDERS + [] let (|Class|_|) (original: FSharpEntity, abbreviated: FSharpEntity, _) = if abbreviated.IsClass - && (not abbreviated.IsStaticInstantiation || original.IsFSharpAbbreviation) then Some() - else None + && (not abbreviated.IsStaticInstantiation || original.IsFSharpAbbreviation) then ValueSome() + else ValueNone #else + [] let (|Class|_|) (original: FSharpEntity, abbreviated: FSharpEntity, _) = - if abbreviated.IsClass && original.IsFSharpAbbreviation then Some() - else None + if abbreviated.IsClass && original.IsFSharpAbbreviation then ValueSome() + else ValueNone #endif - let (|Record|_|) (e: FSharpEntity) = if e.IsFSharpRecord then Some() else None + [] + let (|Record|_|) (e: FSharpEntity) = if e.IsFSharpRecord then ValueSome() else ValueNone - let (|UnionType|_|) (e: FSharpEntity) = if e.IsFSharpUnion then Some() else None + [] + let (|UnionType|_|) (e: FSharpEntity) = if e.IsFSharpUnion then ValueSome() else ValueNone - let (|Delegate|_|) (e: FSharpEntity) = if e.IsDelegate then Some() else None + [] + let (|Delegate|_|) (e: FSharpEntity) = if e.IsDelegate then ValueSome() else ValueNone - let (|FSharpException|_|) (e: FSharpEntity) = if e.IsFSharpExceptionDeclaration then Some() else None + [] + let (|FSharpException|_|) (e: FSharpEntity) = if e.IsFSharpExceptionDeclaration then ValueSome() else ValueNone - let (|Interface|_|) (e: FSharpEntity) = if e.IsInterface then Some() else None + [] + let (|Interface|_|) (e: FSharpEntity) = if e.IsInterface then ValueSome() else ValueNone + [] let (|AbstractClass|_|) (e: FSharpEntity) = - if e.HasAttribute() then Some() else None + if e.HasAttribute() then ValueSome() else ValueNone + [] let (|FSharpType|_|) (e: FSharpEntity) = if e.IsDelegate || e.IsFSharpExceptionDeclaration || e.IsFSharpRecord || e.IsFSharpUnion || e.IsInterface || e.IsMeasure - || (e.IsFSharp && e.IsOpaque && not e.IsFSharpModule && not e.IsNamespace) then Some() - else None + || (e.IsFSharp && e.IsOpaque && not e.IsFSharpModule && not e.IsNamespace) then ValueSome() + else ValueNone #if !NO_TYPEPROVIDERS + [] let (|ProvidedType|_|) (e: FSharpEntity) = if (e.IsProvided || e.IsProvidedAndErased || e.IsProvidedAndGenerated) && e.CompiledName = e.DisplayName then - Some() - else None + ValueSome() + else ValueNone #endif - let (|ByRef|_|) (e: FSharpEntity) = if e.IsByRef then Some() else None + [] + let (|ByRef|_|) (e: FSharpEntity) = if e.IsByRef then ValueSome() else ValueNone - let (|Array|_|) (e: FSharpEntity) = if e.IsArrayType then Some() else None + [] + let (|Array|_|) (e: FSharpEntity) = if e.IsArrayType then ValueSome() else ValueNone - let (|FSharpModule|_|) (entity: FSharpEntity) = if entity.IsFSharpModule then Some() else None + [] + let (|FSharpModule|_|) (entity: FSharpEntity) = if entity.IsFSharpModule then ValueSome() else ValueNone - let (|Namespace|_|) (entity: FSharpEntity) = if entity.IsNamespace then Some() else None + [] + let (|Namespace|_|) (entity: FSharpEntity) = if entity.IsNamespace then ValueSome() else ValueNone #if !NO_TYPEPROVIDERS - let (|ProvidedAndErasedType|_|) (entity: FSharpEntity) = if entity.IsProvidedAndErased then Some() else None + [] + let (|ProvidedAndErasedType|_|) (entity: FSharpEntity) = if entity.IsProvidedAndErased then ValueSome() else ValueNone #endif - let (|Enum|_|) (entity: FSharpEntity) = if entity.IsEnum then Some() else None + [] + let (|Enum|_|) (entity: FSharpEntity) = if entity.IsEnum then ValueSome() else ValueNone + [] let (|Tuple|_|) (ty: FSharpType) = - if ty.IsTupleType then Some() else None + if ty.IsTupleType then ValueSome() else ValueNone + [] let (|RefCell|_|) (ty: FSharpType) = match ty.StripAbbreviations() with | TypeWithDefinition def when - def.IsFSharpRecord && def.FullName = "Microsoft.FSharp.Core.FSharpRef`1" -> Some() - | _ -> None + def.IsFSharpRecord && def.FullName = "Microsoft.FSharp.Core.FSharpRef`1" -> ValueSome() + | _ -> ValueNone + [] let (|FunctionType|_|) (ty: FSharpType) = - if ty.IsFunctionType then Some() - else None + if ty.IsFunctionType then ValueSome() + else ValueNone + [] let (|Pattern|_|) (symbol: FSharpSymbol) = match symbol with | :? FSharpUnionCase - | :? FSharpActivePatternCase -> Some() - | _ -> None + | :? FSharpActivePatternCase -> ValueSome() + | _ -> ValueNone + [] let (|Field|_|) (symbol: FSharpSymbol) = match symbol with - | :? FSharpField as field -> Some (field, field.FieldType.StripAbbreviations()) - | _ -> None + | :? FSharpField as field -> ValueSome (field, field.FieldType.StripAbbreviations()) + | _ -> ValueNone + [] let (|MutableVar|_|) (symbol: FSharpSymbol) = let isMutable = match symbol with | :? FSharpField as field -> field.IsMutable && not field.IsLiteral | :? FSharpMemberOrFunctionOrValue as func -> func.IsMutable | _ -> false - if isMutable then Some() else None + if isMutable then ValueSome() else ValueNone /// Entity (originalEntity, abbreviatedEntity, abbreviatedTy) + [] let (|FSharpEntity|_|) (symbol: FSharpSymbol) = match symbol with | :? FSharpEntity as entity -> let abbreviatedEntity, abbreviatedTy = getEntityAbbreviatedType entity - Some (entity, abbreviatedEntity, abbreviatedTy) - | _ -> None + ValueSome (entity, abbreviatedEntity, abbreviatedTy) + | _ -> ValueNone + [] let (|Parameter|_|) (symbol: FSharpSymbol) = match symbol with - | :? FSharpParameter -> Some() - | _ -> None + | :? FSharpParameter -> ValueSome() + | _ -> ValueNone + [] let (|UnionCase|_|) (e: FSharpSymbol) = match e with - | :? FSharpUnionCase as uc -> Some uc - | _ -> None + | :? FSharpUnionCase as uc -> ValueSome uc + | _ -> ValueNone + [] let (|RecordField|_|) (e: FSharpSymbol) = match e with | :? FSharpField as field -> match field.DeclaringEntity with - | None -> None - | Some e -> if e.IsFSharpRecord then Some field else None - | _ -> None + | None -> ValueNone + | Some e -> if e.IsFSharpRecord then ValueSome field else ValueNone + | _ -> ValueNone + [] let (|ActivePatternCase|_|) (symbol: FSharpSymbol) = match symbol with - | :? FSharpActivePatternCase as case -> Some case - | _ -> None + | :? FSharpActivePatternCase as case -> ValueSome case + | _ -> ValueNone /// Func (memberFunctionOrValue, fullType) + [] let (|MemberFunctionOrValue|_|) (symbol: FSharpSymbol) = match symbol with - | :? FSharpMemberOrFunctionOrValue as func -> Some func - | _ -> None + | :? FSharpMemberOrFunctionOrValue as func -> ValueSome func + | _ -> ValueNone /// Constructor (enclosingEntity) + [] let (|Constructor|_|) (func: FSharpMemberOrFunctionOrValue) = match func.CompiledName with - | ".ctor" | ".cctor" -> func.DeclaringEntity - | _ -> None + | ".ctor" | ".cctor" -> func.DeclaringEntity |> ValueOptionInternal.ofOption + | _ -> ValueNone + [] let (|Function|_|) excluded (func: FSharpMemberOrFunctionOrValue) = try let ty = func.FullType.StripAbbreviations() if ty.IsFunctionType && not func.IsPropertyGetterMethod && not func.IsPropertySetterMethod && not excluded - && not (PrettyNaming.IsOperatorDisplayName func.DisplayName) then Some() - else None - with _ -> None + && not (PrettyNaming.IsOperatorDisplayName func.DisplayName) then ValueSome() + else ValueNone + with _ -> ValueNone + [] let (|ExtensionMember|_|) (func: FSharpMemberOrFunctionOrValue) = - if func.IsExtensionMember then Some() else None + if func.IsExtensionMember then ValueSome() else ValueNone + [] let (|Event|_|) (func: FSharpMemberOrFunctionOrValue) = - if func.IsEvent then Some () else None \ No newline at end of file + if func.IsEvent then ValueSome () else ValueNone \ No newline at end of file diff --git a/src/Compiler/Symbols/SymbolPatterns.fsi b/src/Compiler/Symbols/SymbolPatterns.fsi index b2635c57d4b..3fd090a818c 100644 --- a/src/Compiler/Symbols/SymbolPatterns.fsi +++ b/src/Compiler/Symbols/SymbolPatterns.fsi @@ -6,79 +6,114 @@ namespace FSharp.Compiler.Symbols [] module public FSharpSymbolPatterns = - val (|AbbreviatedType|_|): FSharpEntity -> FSharpType option + [] + val (|AbbreviatedType|_|): FSharpEntity -> FSharpType voption - val (|TypeWithDefinition|_|): FSharpType -> FSharpEntity option + [] + val (|TypeWithDefinition|_|): FSharpType -> FSharpEntity voption - val (|Attribute|_|): FSharpEntity -> unit option + [] + val (|Attribute|_|): FSharpEntity -> unit voption - val (|ValueType|_|): FSharpEntity -> unit option + [] + val (|ValueType|_|): FSharpEntity -> unit voption - val (|Class|_|): original: FSharpEntity * abbreviated: FSharpEntity * 'a -> unit option + [] + val (|Class|_|): original: FSharpEntity * abbreviated: FSharpEntity * 'a -> unit voption - val (|Record|_|): FSharpEntity -> unit option + [] + val (|Record|_|): FSharpEntity -> unit voption - val (|UnionType|_|): FSharpEntity -> unit option + [] + val (|UnionType|_|): FSharpEntity -> unit voption - val (|Delegate|_|): FSharpEntity -> unit option + [] + val (|Delegate|_|): FSharpEntity -> unit voption - val (|FSharpException|_|): FSharpEntity -> unit option + [] + val (|FSharpException|_|): FSharpEntity -> unit voption - val (|Interface|_|): FSharpEntity -> unit option + [] + val (|Interface|_|): FSharpEntity -> unit voption - val (|AbstractClass|_|): FSharpEntity -> unit option + [] + val (|AbstractClass|_|): FSharpEntity -> unit voption - val (|FSharpType|_|): FSharpEntity -> unit option + [] + val (|FSharpType|_|): FSharpEntity -> unit voption #if !NO_TYPEPROVIDERS - val (|ProvidedType|_|): FSharpEntity -> unit option + [] + val (|ProvidedType|_|): FSharpEntity -> unit voption #endif - val (|ByRef|_|): FSharpEntity -> unit option + [] + val (|ByRef|_|): FSharpEntity -> unit voption - val (|Array|_|): FSharpEntity -> unit option + [] + val (|Array|_|): FSharpEntity -> unit voption - val (|FSharpModule|_|): FSharpEntity -> unit option + [] + val (|FSharpModule|_|): FSharpEntity -> unit voption - val (|Namespace|_|): FSharpEntity -> unit option + [] + val (|Namespace|_|): FSharpEntity -> unit voption #if !NO_TYPEPROVIDERS - val (|ProvidedAndErasedType|_|): FSharpEntity -> unit option + [] + val (|ProvidedAndErasedType|_|): FSharpEntity -> unit voption #endif - val (|Enum|_|): FSharpEntity -> unit option + [] + val (|Enum|_|): FSharpEntity -> unit voption - val (|Tuple|_|): FSharpType -> unit option + [] + val (|Tuple|_|): FSharpType -> unit voption - val (|RefCell|_|): FSharpType -> unit option + [] + val (|RefCell|_|): FSharpType -> unit voption - val (|FunctionType|_|): FSharpType -> unit option + [] + val (|FunctionType|_|): FSharpType -> unit voption - val (|Pattern|_|): FSharpSymbol -> unit option + [] + val (|Pattern|_|): FSharpSymbol -> unit voption - val (|Field|_|): FSharpSymbol -> (FSharpField * FSharpType) option + [] + val (|Field|_|): FSharpSymbol -> (FSharpField * FSharpType) voption - val (|MutableVar|_|): FSharpSymbol -> unit option + [] + val (|MutableVar|_|): FSharpSymbol -> unit voption /// Returns (originalEntity, abbreviatedEntity, abbreviatedType) - val (|FSharpEntity|_|): FSharpSymbol -> (FSharpEntity * FSharpEntity * FSharpType option) option + [] + val (|FSharpEntity|_|): FSharpSymbol -> (FSharpEntity * FSharpEntity * FSharpType option) voption - val (|Parameter|_|): FSharpSymbol -> unit option + [] + val (|Parameter|_|): FSharpSymbol -> unit voption - val (|UnionCase|_|): FSharpSymbol -> FSharpUnionCase option + [] + val (|UnionCase|_|): FSharpSymbol -> FSharpUnionCase voption - val (|RecordField|_|): FSharpSymbol -> FSharpField option + [] + val (|RecordField|_|): FSharpSymbol -> FSharpField voption - val (|ActivePatternCase|_|): FSharpSymbol -> FSharpActivePatternCase option + [] + val (|ActivePatternCase|_|): FSharpSymbol -> FSharpActivePatternCase voption - val (|MemberFunctionOrValue|_|): FSharpSymbol -> FSharpMemberOrFunctionOrValue option + [] + val (|MemberFunctionOrValue|_|): FSharpSymbol -> FSharpMemberOrFunctionOrValue voption - val (|Constructor|_|): FSharpMemberOrFunctionOrValue -> FSharpEntity option + [] + val (|Constructor|_|): FSharpMemberOrFunctionOrValue -> FSharpEntity voption - val (|Function|_|): excluded: bool -> FSharpMemberOrFunctionOrValue -> unit option + [] + val (|Function|_|): excluded: bool -> FSharpMemberOrFunctionOrValue -> unit voption - val (|ExtensionMember|_|): FSharpMemberOrFunctionOrValue -> unit option + [] + val (|ExtensionMember|_|): FSharpMemberOrFunctionOrValue -> unit voption - val (|Event|_|): FSharpMemberOrFunctionOrValue -> unit option + [] + val (|Event|_|): FSharpMemberOrFunctionOrValue -> unit voption val internal hasModuleSuffixAttribute: FSharpEntity -> bool diff --git a/src/Compiler/TypedTree/TypeProviders.fs b/src/Compiler/TypedTree/TypeProviders.fs index 9eb76091897..5897655c778 100644 --- a/src/Compiler/TypedTree/TypeProviders.fs +++ b/src/Compiler/TypedTree/TypeProviders.fs @@ -504,8 +504,13 @@ type IProvidedCustomAttributeProvider = abstract GetAttributeConstructorArgs: provider: ITypeProvider * attribName: string -> (obj option list * (string * obj option) list) option type ProvidedCustomAttributeProvider (attributes :ITypeProvider -> seq) = - let (|Member|_|) (s: string) (x: CustomAttributeNamedArgument) = if x.MemberName = s then Some x.TypedValue else None - let (|Arg|_|) (x: CustomAttributeTypedArgument) = match x.Value with null -> None | v -> Some v + + [] + let (|Member|_|) (s: string) (x: CustomAttributeNamedArgument) = if x.MemberName = s then ValueSome x.TypedValue else ValueNone + + [] + let (|Arg|_|) (x: CustomAttributeTypedArgument) = match x.Value with null -> ValueNone | v -> ValueSome v + let findAttribByName tyFullName (a: CustomAttributeData) = (a.Constructor.DeclaringType.FullName = tyFullName) let findAttrib (ty: Type) a = findAttribByName ty.FullName a interface IProvidedCustomAttributeProvider with diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fs b/src/Compiler/TypedTree/TypedTreeBasics.fs index 1fca2981579..ca2674f873f 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fs +++ b/src/Compiler/TypedTree/TypedTreeBasics.fs @@ -256,10 +256,11 @@ let stripTyparEqns ty = stripTyparEqnsAux false ty let stripUnitEqns unt = stripUnitEqnsAux false unt /// Detect a use of a nominal type, including type abbreviations. +[] let (|AbbrevOrAppTy|_|) (ty: TType) = match stripTyparEqns ty with - | TType_app (tcref, tinst, _) -> Some(tcref, tinst) - | _ -> None + | TType_app (tcref, tinst, _) -> ValueSome(tcref, tinst) + | _ -> ValueNone //--------------------------------------------------------------------------- // These make local/non-local references to values according to whether diff --git a/src/Compiler/TypedTree/TypedTreeBasics.fsi b/src/Compiler/TypedTree/TypedTreeBasics.fsi index c3edc900871..001e4129d06 100644 --- a/src/Compiler/TypedTree/TypedTreeBasics.fsi +++ b/src/Compiler/TypedTree/TypedTreeBasics.fsi @@ -133,7 +133,8 @@ val stripTyparEqns: ty: TType -> TType val stripUnitEqns: unt: Measure -> Measure /// Detect a use of a nominal type, including type abbreviations. -val (|AbbrevOrAppTy|_|): ty: TType -> (TyconRef * TypeInst) option +[] +val (|AbbrevOrAppTy|_|): ty: TType -> (TyconRef * TypeInst) voption val mkLocalValRef: v: Val -> ValRef diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index 8001c049ece..2d9dfe1e68c 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -881,11 +881,14 @@ let tryAnyParTy g ty = ty |> stripTyEqns g |> (function TType_var (v, _) -> Valu let tryAnyParTyOption g ty = ty |> stripTyEqns g |> (function TType_var (v, _) -> Some v | TType_measure unt when isUnitParMeasure g unt -> Some(destUnitParMeasure g unt) | _ -> None) -let (|AppTy|_|) g ty = ty |> stripTyEqns g |> (function TType_app(tcref, tinst, _) -> Some (tcref, tinst) | _ -> None) +[] +let (|AppTy|_|) g ty = ty |> stripTyEqns g |> (function TType_app(tcref, tinst, _) -> ValueSome (tcref, tinst) | _ -> ValueNone) -let (|RefTupleTy|_|) g ty = ty |> stripTyEqns g |> (function TType_tuple(tupInfo, tys) when not (evalTupInfoIsStruct tupInfo) -> Some tys | _ -> None) +[] +let (|RefTupleTy|_|) g ty = ty |> stripTyEqns g |> (function TType_tuple(tupInfo, tys) when not (evalTupInfoIsStruct tupInfo) -> ValueSome tys | _ -> ValueNone) -let (|FunTy|_|) g ty = ty |> stripTyEqns g |> (function TType_fun(domainTy, rangeTy, _) -> Some (domainTy, rangeTy) | _ -> None) +[] +let (|FunTy|_|) g ty = ty |> stripTyEqns g |> (function TType_fun(domainTy, rangeTy, _) -> ValueSome (domainTy, rangeTy) | _ -> ValueNone) let tryNiceEntityRefOfTy ty = let ty = stripTyparEqnsAux false ty @@ -3426,14 +3429,24 @@ let TryFindFSharpAttributeOpt g tref attrs = match tref with None -> None | Some let HasFSharpAttributeOpt g trefOpt attrs = match trefOpt with Some tref -> List.exists (IsMatchingFSharpAttribute g tref) attrs | _ -> false let IsMatchingFSharpAttributeOpt g attrOpt (Attrib(tcref2, _, _, _, _, _, _)) = match attrOpt with Some (AttribInfo(_, tcref)) -> tyconRefEq g tcref tcref2 | _ -> false +[] let (|ExtractAttribNamedArg|_|) nm args = - args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) + args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) |> ValueOptionInternal.ofOption -let (|StringExpr|_|) = function Expr.Const (Const.String n, _, _) -> Some n | _ -> None -let (|AttribInt32Arg|_|) = function AttribExpr(_, Expr.Const (Const.Int32 n, _, _)) -> Some n | _ -> None -let (|AttribInt16Arg|_|) = function AttribExpr(_, Expr.Const (Const.Int16 n, _, _)) -> Some n | _ -> None -let (|AttribBoolArg|_|) = function AttribExpr(_, Expr.Const (Const.Bool n, _, _)) -> Some n | _ -> None -let (|AttribStringArg|_|) = function AttribExpr(_, Expr.Const (Const.String n, _, _)) -> Some n | _ -> None +[] +let (|StringExpr|_|) = function Expr.Const (Const.String n, _, _) -> ValueSome n | _ -> ValueNone + +[] +let (|AttribInt32Arg|_|) = function AttribExpr(_, Expr.Const (Const.Int32 n, _, _)) -> ValueSome n | _ -> ValueNone + +[] +let (|AttribInt16Arg|_|) = function AttribExpr(_, Expr.Const (Const.Int16 n, _, _)) -> ValueSome n | _ -> ValueNone + +[] +let (|AttribBoolArg|_|) = function AttribExpr(_, Expr.Const (Const.Bool n, _, _)) -> ValueSome n | _ -> ValueNone + +[] +let (|AttribStringArg|_|) = function AttribExpr(_, Expr.Const (Const.String n, _, _)) -> ValueSome n | _ -> ValueNone let TryFindFSharpBoolAttributeWithDefault dflt g nm attrs = match TryFindFSharpAttribute g nm attrs with @@ -3634,9 +3647,10 @@ let destByrefTy g ty = | TType_app(tcref, [x], _) when tyconRefEq g g.byref_tcr tcref -> x // all others | _ -> failwith "destByrefTy: not a byref type" +[] let (|ByrefTy|_|) g ty = // Because of byref = byref2 it is better to write this using is/dest - if isByrefTy g ty then Some (destByrefTy g ty) else None + if isByrefTy g ty then ValueSome (destByrefTy g ty) else ValueNone let destNativePtrTy g ty = match ty |> stripTyEqns g with @@ -3724,10 +3738,11 @@ let destNullableTy g ty = | ValueSome ty -> ty | ValueNone -> failwith "destNullableTy: not a Nullable type" +[] let (|NullableTy|_|) g ty = match tryAppTy g ty with - | ValueSome (tcref, [tyarg]) when tyconRefEq g tcref g.system_Nullable_tcref -> Some tyarg - | _ -> None + | ValueSome (tcref, [tyarg]) when tyconRefEq g tcref g.system_Nullable_tcref -> ValueSome tyarg + | _ -> ValueNone let (|StripNullableTy|) g ty = match tryDestNullableTy g ty with @@ -3767,21 +3782,25 @@ type ValRef with | Some membInfo -> membInfo.MemberFlags.IsDispatchSlot | None -> false +[] let (|UnopExpr|_|) _g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, _, [arg1], _) -> Some (vref, arg1) - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, _, [arg1], _) -> ValueSome (vref, arg1) + | _ -> ValueNone +[] let (|BinopExpr|_|) _g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, _, [arg1;arg2], _) -> Some (vref, arg1, arg2) - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, _, [arg1;arg2], _) -> ValueSome (vref, arg1, arg2) + | _ -> ValueNone +[] let (|SpecificUnopExpr|_|) g vrefReqd expr = match expr with - | UnopExpr g (vref, arg1) when valRefEq g vref vrefReqd -> Some arg1 - | _ -> None + | UnopExpr g (vref, arg1) when valRefEq g vref vrefReqd -> ValueSome arg1 + | _ -> ValueNone +[] let (|SignedConstExpr|_|) expr = match expr with | Expr.Const (Const.Int32 _, _, _) @@ -3789,9 +3808,10 @@ let (|SignedConstExpr|_|) expr = | Expr.Const (Const.Int16 _, _, _) | Expr.Const (Const.Int64 _, _, _) | Expr.Const (Const.Single _, _, _) - | Expr.Const (Const.Double _, _, _) -> Some () - | _ -> None + | Expr.Const (Const.Double _, _, _) -> ValueSome () + | _ -> ValueNone +[] let (|IntegerConstExpr|_|) expr = match expr with | Expr.Const (Const.Int32 _, _, _) @@ -3801,37 +3821,42 @@ let (|IntegerConstExpr|_|) expr = | Expr.Const (Const.Byte _, _, _) | Expr.Const (Const.UInt16 _, _, _) | Expr.Const (Const.UInt32 _, _, _) - | Expr.Const (Const.UInt64 _, _, _) -> Some () - | _ -> None + | Expr.Const (Const.UInt64 _, _, _) -> ValueSome () + | _ -> ValueNone +[] let (|FloatConstExpr|_|) expr = match expr with | Expr.Const (Const.Single _, _, _) - | Expr.Const (Const.Double _, _, _) -> Some () - | _ -> None + | Expr.Const (Const.Double _, _, _) -> ValueSome () + | _ -> ValueNone +[] let (|SpecificBinopExpr|_|) g vrefReqd expr = match expr with - | BinopExpr g (vref, arg1, arg2) when valRefEq g vref vrefReqd -> Some (arg1, arg2) - | _ -> None + | BinopExpr g (vref, arg1, arg2) when valRefEq g vref vrefReqd -> ValueSome (arg1, arg2) + | _ -> ValueNone +[] let (|EnumExpr|_|) g expr = match (|SpecificUnopExpr|_|) g g.enum_vref expr with - | None -> (|SpecificUnopExpr|_|) g g.enumOfValue_vref expr + | ValueNone -> (|SpecificUnopExpr|_|) g g.enumOfValue_vref expr | x -> x +[] let (|BitwiseOrExpr|_|) g expr = (|SpecificBinopExpr|_|) g g.bitwise_or_vref expr +[] let (|AttribBitwiseOrExpr|_|) g expr = match expr with - | BitwiseOrExpr g (arg1, arg2) -> Some(arg1, arg2) + | BitwiseOrExpr g (arg1, arg2) -> ValueSome(arg1, arg2) // Special workaround, only used when compiling FSharp.Core.dll. Uses of 'a ||| b' occur before the '|||' bitwise or operator // is defined. These get through type checking because enums implicitly support the '|||' operator through // the automatic resolution of undefined operators (see tc.fs, Item.ImplicitOp). This then compiles as an // application of a lambda to two arguments. We recognize this pattern here | Expr.App (Expr.Lambda _, _, _, [arg1;arg2], _) when g.compilingFSharpCore -> - Some(arg1, arg2) - | _ -> None + ValueSome(arg1, arg2) + | _ -> ValueNone let isUncheckedDefaultOfValRef g vref = valRefEq g vref g.unchecked_defaultof_vref @@ -3858,35 +3883,41 @@ let isTypeDefOfValRef g vref = // There is an internal version of typedefof defined in prim-types.fs that needs to be detected || (g.compilingFSharpCore && vref.LogicalName = "typedefof") +[] let (|UncheckedDefaultOfExpr|_|) g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isUncheckedDefaultOfValRef g vref -> Some ty - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isUncheckedDefaultOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|TypeOfExpr|_|) g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isTypeOfValRef g vref -> Some ty - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isTypeOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|SizeOfExpr|_|) g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isSizeOfValRef g vref -> Some ty - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isSizeOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|TypeDefOfExpr|_|) g expr = match expr with - | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isTypeDefOfValRef g vref -> Some ty - | _ -> None + | Expr.App (Expr.Val (vref, _, _), _, [ty], [], _) when isTypeDefOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|NameOfExpr|_|) g expr = match expr with - | Expr.App(Expr.Val(vref,_,_),_,[ty],[],_) when isNameOfValRef g vref -> Some ty - | _ -> None + | Expr.App(Expr.Val(vref,_,_),_,[ty],[],_) when isNameOfValRef g vref -> ValueSome ty + | _ -> ValueNone +[] let (|SeqExpr|_|) g expr = match expr with - | Expr.App(Expr.Val(vref,_,_),_,_,_,_) when valRefEq g vref g.seq_vref -> Some() - | _ -> None + | Expr.App(Expr.Val(vref,_,_),_,_,_,_) when valRefEq g vref g.seq_vref -> ValueSome() + | _ -> ValueNone //-------------------------------------------------------------------------- // DEBUG layout @@ -5030,22 +5061,24 @@ let freeTyvarsAllPublic tyvars = /// -- if then else /// -- match e with pat[vs] -> e1[vs] | _ -> e2 +[] let (|LinearMatchExpr|_|) expr = match expr with - | Expr.Match (sp, m, dtree, [|tg1;(TTarget([], e2, _))|], m2, ty) -> Some(sp, m, dtree, tg1, e2, m2, ty) - | _ -> None + | Expr.Match (sp, m, dtree, [|tg1;(TTarget([], e2, _))|], m2, ty) -> ValueSome(sp, m, dtree, tg1, e2, m2, ty) + | _ -> ValueNone let rebuildLinearMatchExpr (sp, m, dtree, tg1, e2, m2, ty) = primMkMatch (sp, m, dtree, [|tg1;(TTarget([], e2, None))|], m2, ty) /// Detect a subset of 'Expr.Op' expressions we process in a linear way (i.e. using tailcalls, rather than /// unbounded stack). Only covers Cons(args,Cons(args,Cons(args,Cons(args,...._)))). +[] let (|LinearOpExpr|_|) expr = match expr with | Expr.Op (TOp.UnionCase _ as op, tinst, args, m) when not args.IsEmpty -> let argsFront, argLast = List.frontAndBack args - Some (op, tinst, argsFront, argLast, m) - | _ -> None + ValueSome (op, tinst, argsFront, argLast, m) + | _ -> ValueNone let rebuildLinearOpExpr (op, tinst, argsFront, argLast, m) = Expr.Op (op, tinst, argsFront@[argLast], m) @@ -8197,10 +8230,11 @@ let MultiLambdaToTupledLambda g vs body = let tupledv, untupler = untupledToRefTupled g vs tupledv, untupler body +[] let (|RefTuple|_|) expr = match expr with - | Expr.Op (TOp.Tuple (TupInfo.Const false), _, args, _) -> Some args - | _ -> None + | Expr.Op (TOp.Tuple (TupInfo.Const false), _, args, _) -> ValueSome args + | _ -> ValueNone let MultiLambdaToTupledLambdaIfNeeded g (vs, arg) body = match vs, arg with @@ -8273,39 +8307,44 @@ let rec MakeApplicationAndBetaReduceAux g (f, fty, tyargsl: TType list list, arg let MakeApplicationAndBetaReduce g (f, fty, tyargsl, argl, m) = MakeApplicationAndBetaReduceAux g (f, fty, tyargsl, argl, m) +[] let (|NewDelegateExpr|_|) g expr = match expr with | Expr.Obj (lambdaId, ty, a, b, [TObjExprMethod(c, d, e, tmvs, body, f)], [], m) when isDelegateTy g ty -> - Some (lambdaId, List.concat tmvs, body, m, (fun bodyR -> Expr.Obj (lambdaId, ty, a, b, [TObjExprMethod(c, d, e, tmvs, bodyR, f)], [], m))) - | _ -> None + ValueSome (lambdaId, List.concat tmvs, body, m, (fun bodyR -> Expr.Obj (lambdaId, ty, a, b, [TObjExprMethod(c, d, e, tmvs, bodyR, f)], [], m))) + | _ -> ValueNone +[] let (|DelegateInvokeExpr|_|) g expr = match expr with | Expr.App ((Expr.Val (invokeRef, _, _)) as delInvokeRef, delInvokeTy, [], [delExpr;delInvokeArg], m) when invokeRef.LogicalName = "Invoke" && isFSharpDelegateTy g (tyOfExpr g delExpr) -> - Some(delInvokeRef, delInvokeTy, delExpr, delInvokeArg, m) - | _ -> None + ValueSome(delInvokeRef, delInvokeTy, delExpr, delInvokeArg, m) + | _ -> ValueNone +[] let (|OpPipeRight|_|) g expr = match expr with | Expr.App (Expr.Val (vref, _, _), _, [_; resType], [xExpr; fExpr], m) when valRefEq g vref g.piperight_vref -> - Some(resType, xExpr, fExpr, m) - | _ -> None + ValueSome(resType, xExpr, fExpr, m) + | _ -> ValueNone +[] let (|OpPipeRight2|_|) g expr = match expr with | Expr.App (Expr.Val (vref, _, _), _, [_; _; resType], [Expr.Op (TOp.Tuple _, _, [arg1; arg2], _); fExpr], m) when valRefEq g vref g.piperight2_vref -> - Some(resType, arg1, arg2, fExpr, m) - | _ -> None + ValueSome(resType, arg1, arg2, fExpr, m) + | _ -> ValueNone +[] let (|OpPipeRight3|_|) g expr = match expr with | Expr.App (Expr.Val (vref, _, _), _, [_; _; _; resType], [Expr.Op (TOp.Tuple _, _, [arg1; arg2; arg3], _); fExpr], m) when valRefEq g vref g.piperight3_vref -> - Some(resType, arg1, arg2, arg3, fExpr, m) - | _ -> None + ValueSome(resType, arg1, arg2, arg3, fExpr, m) + | _ -> ValueNone let rec MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, delExpr, delInvokeTy, delInvokeArg, m) = match delExpr with @@ -8356,14 +8395,15 @@ let stripTupledFunTy g ty = let curriedArgTys = argTys |> List.map (tryDestRefTupleTy g) curriedArgTys, retTy +[] let (|ExprValWithPossibleTypeInst|_|) expr = match expr with | Expr.App (Expr.Val (vref, flags, m), _fty, tyargs, [], _) -> - Some (vref, flags, tyargs, m) + ValueSome (vref, flags, tyargs, m) | Expr.Val (vref, flags, m) -> - Some (vref, flags, [], m) + ValueSome (vref, flags, [], m) | _ -> - None + ValueNone let mkCoerceIfNeeded g tgtTy srcTy expr = if typeEquiv g tgtTy srcTy then @@ -9047,30 +9087,33 @@ let rec TypeHasDefaultValue g m ty = /// Determines types that are potentially known to satisfy the 'comparable' constraint and returns /// a set of residual types that must also satisfy the constraint +[] let (|SpecialComparableHeadType|_|) g ty = if isAnyTupleTy g ty then let _tupInfo, elemTys = destAnyTupleTy g ty - Some elemTys + ValueSome elemTys elif isAnonRecdTy g ty then match tryDestAnonRecdTy g ty with - | ValueNone -> Some [] - | ValueSome (_anonInfo, elemTys) -> Some elemTys + | ValueNone -> ValueSome [] + | ValueSome (_anonInfo, elemTys) -> ValueSome elemTys else match tryAppTy g ty with | ValueSome (tcref, tinst) -> if isArrayTyconRef g tcref || tyconRefEq g tcref g.system_UIntPtr_tcref || tyconRefEq g tcref g.system_IntPtr_tcref then - Some tinst + ValueSome tinst else - None + ValueNone | _ -> - None + ValueNone +[] let (|SpecialEquatableHeadType|_|) g ty = (|SpecialComparableHeadType|_|) g ty +[] let (|SpecialNotEquatableHeadType|_|) g ty = - if isFunTy g ty then Some() else None + if isFunTy g ty then ValueSome() else ValueNone // Can we use the fast helper for the 'LanguagePrimitives.IntrinsicFunctions.TypeTestGeneric'? let canUseTypeTestFast g ty = @@ -9983,23 +10026,24 @@ and EvaledAttribExprEquality g e1 e2 = | TypeDefOfExpr g ty1, TypeDefOfExpr g ty2 -> typeEquiv g ty1 ty2 | _ -> false +[] let (|ConstToILFieldInit|_|) c = match c with - | Const.SByte n -> Some (ILFieldInit.Int8 n) - | Const.Int16 n -> Some (ILFieldInit.Int16 n) - | Const.Int32 n -> Some (ILFieldInit.Int32 n) - | Const.Int64 n -> Some (ILFieldInit.Int64 n) - | Const.Byte n -> Some (ILFieldInit.UInt8 n) - | Const.UInt16 n -> Some (ILFieldInit.UInt16 n) - | Const.UInt32 n -> Some (ILFieldInit.UInt32 n) - | Const.UInt64 n -> Some (ILFieldInit.UInt64 n) - | Const.Bool n -> Some (ILFieldInit.Bool n) - | Const.Char n -> Some (ILFieldInit.Char (uint16 n)) - | Const.Single n -> Some (ILFieldInit.Single n) - | Const.Double n -> Some (ILFieldInit.Double n) - | Const.String s -> Some (ILFieldInit.String s) - | Const.Zero -> Some ILFieldInit.Null - | _ -> None + | Const.SByte n -> ValueSome (ILFieldInit.Int8 n) + | Const.Int16 n -> ValueSome (ILFieldInit.Int16 n) + | Const.Int32 n -> ValueSome (ILFieldInit.Int32 n) + | Const.Int64 n -> ValueSome (ILFieldInit.Int64 n) + | Const.Byte n -> ValueSome (ILFieldInit.UInt8 n) + | Const.UInt16 n -> ValueSome (ILFieldInit.UInt16 n) + | Const.UInt32 n -> ValueSome (ILFieldInit.UInt32 n) + | Const.UInt64 n -> ValueSome (ILFieldInit.UInt64 n) + | Const.Bool n -> ValueSome (ILFieldInit.Bool n) + | Const.Char n -> ValueSome (ILFieldInit.Char (uint16 n)) + | Const.Single n -> ValueSome (ILFieldInit.Single n) + | Const.Double n -> ValueSome (ILFieldInit.Double n) + | Const.String s -> ValueSome (ILFieldInit.String s) + | Const.Zero -> ValueSome ILFieldInit.Null + | _ -> ValueNone let EvalLiteralExprOrAttribArg g x = match x with @@ -10080,49 +10124,56 @@ let mkGetTupleItemN g m n (ty: ILType) isStruct expr retTy = mkAsmExpr ([mkNormalCall(mkILMethodSpecForTupleItem g ty n)], [], [expr], [retTy], m) /// Match an Int32 constant expression +[] let (|Int32Expr|_|) expr = match expr with - | Expr.Const (Const.Int32 n, _, _) -> Some n - | _ -> None + | Expr.Const (Const.Int32 n, _, _) -> ValueSome n + | _ -> ValueNone /// Match a try-finally expression +[] let (|TryFinally|_|) expr = match expr with - | Expr.Op (TOp.TryFinally _, [_resTy], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], _) -> Some(e1, e2) - | _ -> None + | Expr.Op (TOp.TryFinally _, [_resTy], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], _) -> ValueSome(e1, e2) + | _ -> ValueNone // detect ONLY the while loops that result from compiling 'for ... in ... do ...' +[] let (|WhileLoopForCompiledForEachExpr|_|) expr = match expr with | Expr.Op (TOp.While (spInWhile, WhileLoopForCompiledForEachExprMarker), _, [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], m) -> - Some(spInWhile, e1, e2, m) - | _ -> None + ValueSome(spInWhile, e1, e2, m) + | _ -> ValueNone +[] let (|Let|_|) expr = match expr with - | Expr.Let (TBind(v, e1, sp), e2, _, _) -> Some(v, e1, sp, e2) - | _ -> None + | Expr.Let (TBind(v, e1, sp), e2, _, _) -> ValueSome(v, e1, sp, e2) + | _ -> ValueNone +[] let (|RangeInt32Step|_|) g expr = match expr with // detect 'n .. m' | Expr.App (Expr.Val (vf, _, _), _, [tyarg], [startExpr;finishExpr], _) - when valRefEq g vf g.range_op_vref && typeEquiv g tyarg g.int_ty -> Some(startExpr, 1, finishExpr) + when valRefEq g vf g.range_op_vref && typeEquiv g tyarg g.int_ty -> ValueSome(startExpr, 1, finishExpr) // detect (RangeInt32 startExpr N finishExpr), the inlined/compiled form of 'n .. m' and 'n .. N .. m' | Expr.App (Expr.Val (vf, _, _), _, [], [startExpr; Int32Expr n; finishExpr], _) - when valRefEq g vf g.range_int32_op_vref -> Some(startExpr, n, finishExpr) + when valRefEq g vf g.range_int32_op_vref -> ValueSome(startExpr, n, finishExpr) - | _ -> None + | _ -> ValueNone +[] let (|GetEnumeratorCall|_|) expr = match expr with | Expr.Op (TOp.ILCall ( _, _, _, _, _, _, _, ilMethodRef, _, _, _), _, [Expr.Val (vref, _, _) | Expr.Op (_, _, [Expr.Val (vref, ValUseFlag.NormalValUse, _)], _) ], _) -> - if ilMethodRef.Name = "GetEnumerator" then Some vref - else None - | _ -> None + if ilMethodRef.Name = "GetEnumerator" then ValueSome vref + else ValueNone + | _ -> ValueNone // This code matches exactly the output of TcForEachExpr +[] let (|CompiledForEachExpr|_|) g expr = match expr with | Let (enumerableVar, enumerableExpr, spFor, @@ -10146,20 +10197,21 @@ let (|CompiledForEachExpr|_|) g expr = let spInWhile = match spIn with DebugPointAtInOrTo.Yes m -> DebugPointAtWhile.Yes m | DebugPointAtInOrTo.No -> DebugPointAtWhile.No let enumerableTy = tyOfExpr g enumerableExpr - Some (enumerableTy, enumerableExpr, elemVar, bodyExpr, (mBody, spFor, spIn, mFor, mIn, spInWhile, mWholeExpr)) - | _ -> None - + ValueSome (enumerableTy, enumerableExpr, elemVar, bodyExpr, (mBody, spFor, spIn, mFor, mIn, spInWhile, mWholeExpr)) + | _ -> ValueNone +[] let (|CompiledInt32RangeForEachExpr|_|) g expr = match expr with | CompiledForEachExpr g (_, RangeInt32Step g (startExpr, step, finishExpr), elemVar, bodyExpr, ranges) -> - Some (startExpr, step, finishExpr, elemVar, bodyExpr, ranges) - | _ -> None + ValueSome (startExpr, step, finishExpr, elemVar, bodyExpr, ranges) + | _ -> ValueNone +[] let (|ValApp|_|) g vref expr = match expr with - | Expr.App (Expr.Val (vref2, _, _), _f0ty, tyargs, args, m) when valRefEq g vref vref2 -> Some (tyargs, args, m) - | _ -> None + | Expr.App (Expr.Val (vref2, _, _), _f0ty, tyargs, args, m) when valRefEq g vref vref2 -> ValueSome (tyargs, args, m) + | _ -> ValueNone [] module IntegralConst = @@ -10995,24 +11047,27 @@ let mkUnitDelayLambda (g: TcGlobals) m e = let uv, _ = mkCompGenLocal m "unitVar" g.unit_ty mkLambda m uv (e, tyOfExpr g e) +[] let (|UseResumableStateMachinesExpr|_|) g expr = match expr with - | ValApp g g.cgh__useResumableCode_vref (_, _, _m) -> Some () - | _ -> None + | ValApp g g.cgh__useResumableCode_vref (_, _, _m) -> ValueSome () + | _ -> ValueNone /// Match an if...then...else expression or the result of "a && b" or "a || b" +[] let (|IfThenElseExpr|_|) expr = match expr with | Expr.Match (_spBind, _exprm, TDSwitch(cond, [ TCase( DecisionTreeTest.Const (Const.Bool true), TDSuccess ([], 0) )], Some (TDSuccess ([], 1)), _), [| TTarget([], thenExpr, _); TTarget([], elseExpr, _) |], _m, _ty) -> - Some (cond, thenExpr, elseExpr) - | _ -> None + ValueSome (cond, thenExpr, elseExpr) + | _ -> ValueNone /// if __useResumableCode then ... else ... +[] let (|IfUseResumableStateMachinesExpr|_|) g expr = match expr with - | IfThenElseExpr(UseResumableStateMachinesExpr g (), thenExpr, elseExpr) -> Some (thenExpr, elseExpr) - | _ -> None + | IfThenElseExpr(UseResumableStateMachinesExpr g (), thenExpr, elseExpr) -> ValueSome (thenExpr, elseExpr) + | _ -> ValueNone /// Combine a list of ModuleOrNamespaceType's making up the description of a CCU. checking there are now /// duplicate modules etc. @@ -11088,30 +11143,35 @@ let EmptyTraitWitnessInfoHashMap g : TraitWitnessInfoHashMap<'T> = member _.GetHashCode(a) = hash a.MemberName }) +[] let (|WhileExpr|_|) expr = match expr with | Expr.Op (TOp.While (sp1, sp2), _, [Expr.Lambda (_, _, _, [_gv], guardExpr, _, _);Expr.Lambda (_, _, _, [_bv], bodyExpr, _, _)], m) -> - Some (sp1, sp2, guardExpr, bodyExpr, m) - | _ -> None + ValueSome (sp1, sp2, guardExpr, bodyExpr, m) + | _ -> ValueNone +[] let (|TryFinallyExpr|_|) expr = match expr with | Expr.Op (TOp.TryFinally (sp1, sp2), [ty], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], m) -> - Some (sp1, sp2, ty, e1, e2, m) - | _ -> None + ValueSome (sp1, sp2, ty, e1, e2, m) + | _ -> ValueNone +[] let (|IntegerForLoopExpr|_|) expr = match expr with | Expr.Op (TOp.IntegerForLoop (sp1, sp2, style), _, [Expr.Lambda (_, _, _, [_], e1, _, _);Expr.Lambda (_, _, _, [_], e2, _, _);Expr.Lambda (_, _, _, [v], e3, _, _)], m) -> - Some (sp1, sp2, style, e1, e2, v, e3, m) - | _ -> None + ValueSome (sp1, sp2, style, e1, e2, v, e3, m) + | _ -> ValueNone +[] let (|TryWithExpr|_|) expr = match expr with | Expr.Op (TOp.TryWith (spTry, spWith), [resTy], [Expr.Lambda (_, _, _, [_], bodyExpr, _, _); Expr.Lambda (_, _, _, [filterVar], filterExpr, _, _); Expr.Lambda (_, _, _, [handlerVar], handlerExpr, _, _)], m) -> - Some (spTry, spWith, resTy, bodyExpr, filterVar, filterExpr, handlerVar, handlerExpr, m) - | _ -> None + ValueSome (spTry, spWith, resTy, bodyExpr, filterVar, filterExpr, handlerVar, handlerExpr, m) + | _ -> ValueNone +[] let (|MatchTwoCasesExpr|_|) expr = match expr with | Expr.Match (spBind, mExpr, TDSwitch(cond, [ TCase( DecisionTreeTest.UnionCase (ucref, a), TDSuccess ([], tg1) )], Some (TDSuccess ([], tg2)), b), tgs, m, ty) -> @@ -11120,11 +11180,12 @@ let (|MatchTwoCasesExpr|_|) expr = let rebuild (cond, ucref, tg1, tg2, tgs) = Expr.Match (spBind, mExpr, TDSwitch(cond, [ TCase( DecisionTreeTest.UnionCase (ucref, a), TDSuccess ([], tg1) )], Some (TDSuccess ([], tg2)), b), tgs, m, ty) - Some (cond, ucref, tg1, tg2, tgs, rebuild) + ValueSome (cond, ucref, tg1, tg2, tgs, rebuild) - | _ -> None + | _ -> ValueNone /// match e with None -> ... | Some v -> ... or other variations of the same +[] let (|MatchOptionExpr|_|) expr = match expr with | MatchTwoCasesExpr(cond, ucref, tg1, tg2, tgs, rebuildTwoCases) -> @@ -11143,16 +11204,18 @@ let (|MatchOptionExpr|_|) expr = Expr.Let(TBind(someVar, Expr.Op(TOp.UnionCaseFieldGet (a6a, a6b), a7, a8, a9), a10), someBranchExpr, a11, a12), a13, a14), a16) rebuildTwoCases (cond, ucref, tg1, tg2, tgs) - Some (cond, noneBranchExpr, someVar, someBranchExpr, rebuild) - | _ -> None - | _ -> None + ValueSome (cond, noneBranchExpr, someVar, someBranchExpr, rebuild) + | _ -> ValueNone + | _ -> ValueNone +[] let (|ResumableEntryAppExpr|_|) g expr = match expr with - | ValApp g g.cgh__resumableEntry_vref (_, _, _m) -> Some () - | _ -> None + | ValApp g g.cgh__resumableEntry_vref (_, _, _m) -> ValueSome () + | _ -> ValueNone /// Match an (unoptimized) __resumableEntry expression +[] let (|ResumableEntryMatchExpr|_|) g expr = match expr with | Expr.Let(TBind(matchVar, matchExpr, sp1), MatchOptionExpr (Expr.Val(matchVar2, b, c), noneBranchExpr, someVar, someBranchExpr, rebuildMatch), d, e) -> @@ -11164,13 +11227,14 @@ let (|ResumableEntryMatchExpr|_|) g expr = let rebuild (noneBranchExpr, someBranchExpr) = Expr.Let(TBind(matchVar, matchExpr, sp1), rebuildMatch (Expr.Val(matchVar2, b, c), noneBranchExpr, someVar, someBranchExpr), d, e) - Some (noneBranchExpr, someVar, someBranchExpr, rebuild) + ValueSome (noneBranchExpr, someVar, someBranchExpr, rebuild) - else None + else ValueNone - | _ -> None - | _ -> None + | _ -> ValueNone + | _ -> ValueNone +[] let (|StructStateMachineExpr|_|) g expr = match expr with | ValApp g g.cgh__stateMachine_vref ([dataTy; _resultTy], [moveNext; setStateMachine; afterCode], _m) -> @@ -11178,37 +11242,40 @@ let (|StructStateMachineExpr|_|) g expr = | NewDelegateExpr g (_, [moveNextThisVar], moveNextBody, _, _), NewDelegateExpr g (_, [setStateMachineThisVar;setStateMachineStateVar], setStateMachineBody, _, _), NewDelegateExpr g (_, [afterCodeThisVar], afterCodeBody, _, _) -> - Some (dataTy, + ValueSome (dataTy, (moveNextThisVar, moveNextBody), (setStateMachineThisVar, setStateMachineStateVar, setStateMachineBody), (afterCodeThisVar, afterCodeBody)) - | _ -> None - | _ -> None + | _ -> ValueNone + | _ -> ValueNone +[] let (|ResumeAtExpr|_|) g expr = match expr with - | ValApp g g.cgh__resumeAt_vref (_, [pcExpr], _m) -> Some pcExpr - | _ -> None + | ValApp g g.cgh__resumeAt_vref (_, [pcExpr], _m) -> ValueSome pcExpr + | _ -> ValueNone // Detect __debugPoint calls +[] let (|DebugPointExpr|_|) g expr = match expr with - | ValApp g g.cgh__debugPoint_vref (_, [StringExpr debugPointName], _m) -> Some debugPointName - | _ -> None + | ValApp g g.cgh__debugPoint_vref (_, [StringExpr debugPointName], _m) -> ValueSome debugPointName + | _ -> ValueNone // Detect sequencing constructs in state machine code +[] let (|SequentialResumableCode|_|) (g: TcGlobals) expr = match expr with // e1; e2 | Expr.Sequential(e1, e2, NormalSeq, m) -> - Some (e1, e2, m, (fun e1 e2 -> Expr.Sequential(e1, e2, NormalSeq, m))) + ValueSome (e1, e2, m, (fun e1 e2 -> Expr.Sequential(e1, e2, NormalSeq, m))) // let __stack_step = e1 in e2 | Expr.Let(bind, e2, m, _) when bind.Var.CompiledName(g.CompilerGlobalState).StartsWithOrdinal(stackVarPrefix) -> - Some (bind.Expr, e2, m, (fun e1 e2 -> mkLet bind.DebugPoint m bind.Var e1 e2)) + ValueSome (bind.Expr, e2, m, (fun e1 e2 -> mkLet bind.DebugPoint m bind.Var e1 e2)) - | _ -> None + | _ -> ValueNone let mkLabelled m l e = mkCompGenSequential m (Expr.Op (TOp.Label l, [], [], m)) e @@ -11218,13 +11285,14 @@ let rec isReturnsResumableCodeTy g ty = if isFunTy g ty then isReturnsResumableCodeTy g (rangeOfFunTy g ty) else isResumableCodeTy g ty +[] let (|ResumableCodeInvoke|_|) g expr = match expr with // defn.Invoke x --> let arg = x in [defn][arg/x] | Expr.App ((Expr.Val (invokeRef, _, _) as iref), a, b, (f :: args), m) when invokeRef.LogicalName = "Invoke" && isReturnsResumableCodeTy g (tyOfExpr g f) -> - Some (iref, f, args, m, (fun (f2, args2) -> Expr.App ((iref, a, b, (f2 :: args2), m)))) - | _ -> None + ValueSome (iref, f, args, m, (fun (f2, args2) -> Expr.App ((iref, a, b, (f2 :: args2), m)))) + | _ -> ValueNone let ComputeUseMethodImpl g (v: Val) = v.ImplementedSlotSigs |> List.exists (fun slotsig -> @@ -11254,27 +11322,31 @@ let ComputeUseMethodImpl g (v: Val) = not isStructural)) +[] let (|Seq|_|) g expr = match expr with // use 'seq { ... }' as an indicator - | ValApp g g.seq_vref ([elemTy], [e], _m) -> Some (e, elemTy) - | _ -> None + | ValApp g g.seq_vref ([elemTy], [e], _m) -> ValueSome (e, elemTy) + | _ -> ValueNone /// Detect a 'yield x' within a 'seq { ... }' +[] let (|SeqYield|_|) g expr = match expr with - | ValApp g g.seq_singleton_vref (_, [arg], m) -> Some (arg, m) - | _ -> None + | ValApp g g.seq_singleton_vref (_, [arg], m) -> ValueSome (arg, m) + | _ -> ValueNone /// Detect a 'expr; expr' within a 'seq { ... }' +[] let (|SeqAppend|_|) g expr = match expr with - | ValApp g g.seq_append_vref (_, [arg1; arg2], m) -> Some (arg1, arg2, m) - | _ -> None + | ValApp g g.seq_append_vref (_, [arg1; arg2], m) -> ValueSome (arg1, arg2, m) + | _ -> ValueNone let isVarFreeInExpr v e = Zset.contains v (freeInExpr CollectTyparsAndLocals e).FreeLocals /// Detect a 'while gd do expr' within a 'seq { ... }' +[] let (|SeqWhile|_|) g expr = match expr with | ValApp g g.seq_generated_vref (_, [Expr.Lambda (_, _, _, [dummyv], guardExpr, _, _);innerExpr], m) @@ -11283,11 +11355,12 @@ let (|SeqWhile|_|) g expr = // The debug point for 'while' is attached to the innerExpr, see TcSequenceExpression let mWhile = innerExpr.Range let spWhile = match mWhile.NotedSourceConstruct with NotedSourceConstruct.While -> DebugPointAtWhile.Yes mWhile | _ -> DebugPointAtWhile.No - Some (guardExpr, innerExpr, spWhile, m) + ValueSome (guardExpr, innerExpr, spWhile, m) | _ -> - None + ValueNone +[] let (|SeqTryFinally|_|) g expr = match expr with | ValApp g g.seq_finally_vref (_, [arg1;Expr.Lambda (_, _, _, [dummyv], compensation, _, _) as arg2], m) @@ -11300,53 +11373,58 @@ let (|SeqTryFinally|_|) g expr = let spTry = match mTry.NotedSourceConstruct with NotedSourceConstruct.Try -> DebugPointAtTry.Yes mTry | _ -> DebugPointAtTry.No let spFinally = match mFinally.NotedSourceConstruct with NotedSourceConstruct.Finally -> DebugPointAtFinally.Yes mFinally | _ -> DebugPointAtFinally.No - Some (arg1, compensation, spTry, spFinally, m) + ValueSome (arg1, compensation, spTry, spFinally, m) | _ -> - None + ValueNone +[] let (|SeqUsing|_|) g expr = match expr with | ValApp g g.seq_using_vref ([_;_;elemTy], [resource;Expr.Lambda (_, _, _, [v], body, mBind, _)], m) -> // The debug point mFor at the 'use x = ... ' gets attached to the lambda let spBind = match mBind.NotedSourceConstruct with NotedSourceConstruct.Binding -> DebugPointAtBinding.Yes mBind | _ -> DebugPointAtBinding.NoneAtInvisible - Some (resource, v, body, elemTy, spBind, m) + ValueSome (resource, v, body, elemTy, spBind, m) | _ -> - None + ValueNone +[] let (|SeqForEach|_|) g expr = match expr with // Nested for loops are represented by calls to Seq.collect | ValApp g g.seq_collect_vref ([_inpElemTy;_enumty2;genElemTy], [Expr.Lambda (_, _, _, [v], body, mIn, _); inp], mFor) -> // The debug point mIn at the 'in' gets attached to the first argument, see TcSequenceExpression let spIn = match mIn.NotedSourceConstruct with NotedSourceConstruct.InOrTo -> DebugPointAtInOrTo.Yes mIn | _ -> DebugPointAtInOrTo.No - Some (inp, v, body, genElemTy, mFor, mIn, spIn) + ValueSome (inp, v, body, genElemTy, mFor, mIn, spIn) // "for x in e -> e2" is converted to a call to Seq.map by the F# type checker. This could be removed, except it is also visible in F# quotations. | ValApp g g.seq_map_vref ([_inpElemTy;genElemTy], [Expr.Lambda (_, _, _, [v], body, mIn, _); inp], mFor) -> let spIn = match mIn.NotedSourceConstruct with NotedSourceConstruct.InOrTo -> DebugPointAtInOrTo.Yes mIn | _ -> DebugPointAtInOrTo.No // The debug point mFor at the 'for' gets attached to the first argument, see TcSequenceExpression - Some (inp, v, mkCallSeqSingleton g body.Range genElemTy body, genElemTy, mFor, mIn, spIn) + ValueSome (inp, v, mkCallSeqSingleton g body.Range genElemTy body, genElemTy, mFor, mIn, spIn) - | _ -> None + | _ -> ValueNone +[] let (|SeqDelay|_|) g expr = match expr with | ValApp g g.seq_delay_vref ([elemTy], [Expr.Lambda (_, _, _, [v], e, _, _)], _m) when not (isVarFreeInExpr v e) -> - Some (e, elemTy) - | _ -> None + ValueSome (e, elemTy) + | _ -> ValueNone +[] let (|SeqEmpty|_|) g expr = match expr with - | ValApp g g.seq_empty_vref (_, [], m) -> Some m - | _ -> None + | ValApp g g.seq_empty_vref (_, [], m) -> ValueSome m + | _ -> ValueNone let isFSharpExceptionTy g ty = match tryTcrefOfAppTy g ty with | ValueSome tcref -> tcref.IsFSharpException | _ -> false +[] let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceContents) = match moduleOrNamespaceContents with | TMDefs(defs = defs) -> @@ -11375,10 +11453,10 @@ let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceC | _ -> None) if mdDefsLength = emptyModuleOrNamespaces.Length then - Some emptyModuleOrNamespaces + ValueSome emptyModuleOrNamespaces else - None - | _ -> None + ValueNone + | _ -> ValueNone let tryFindExtensionAttribute (g: TcGlobals) (attribs: Attrib list): Attrib option = attribs diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi index 1154b7e8a01..d8da3938882 100755 --- a/src/Compiler/TypedTree/TypedTreeOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.fsi @@ -73,7 +73,8 @@ val (|DebugPoints|): Expr -> Expr * (Expr -> Expr) val valsOfBinds: Bindings -> Vals /// 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 +[] +val (|ExprValWithPossibleTypeInst|_|): Expr -> (ValRef * ValUseFlag * TType list * range) voption /// Build decision trees imperatively type MatchBuilder = @@ -1750,16 +1751,20 @@ val isStructRecordOrUnionTyconTy: TcGlobals -> TType -> bool 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 +[] +val (|AppTy|_|): TcGlobals -> TType -> (TyconRef * TType list) voption /// An active pattern to match System.Nullable types -val (|NullableTy|_|): TcGlobals -> TType -> TType option +[] +val (|NullableTy|_|): TcGlobals -> TType -> TType voption /// 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 +[] +val (|ByrefTy|_|): TcGlobals -> TType -> TType voption //------------------------------------------------------------------------- // Special semantic constraints @@ -2514,19 +2519,25 @@ type EntityRef with member HasMember: TcGlobals -> string -> TType list -> bool -val (|AttribBitwiseOrExpr|_|): TcGlobals -> Expr -> (Expr * Expr) option +[] +val (|AttribBitwiseOrExpr|_|): TcGlobals -> Expr -> (Expr * Expr) voption -val (|EnumExpr|_|): TcGlobals -> Expr -> Expr option +[] +val (|EnumExpr|_|): TcGlobals -> Expr -> Expr voption -val (|TypeOfExpr|_|): TcGlobals -> Expr -> TType option +[] +val (|TypeOfExpr|_|): TcGlobals -> Expr -> TType voption -val (|TypeDefOfExpr|_|): TcGlobals -> Expr -> TType option +[] +val (|TypeDefOfExpr|_|): TcGlobals -> Expr -> TType voption val isNameOfValRef: TcGlobals -> ValRef -> bool -val (|NameOfExpr|_|): TcGlobals -> Expr -> TType option +[] +val (|NameOfExpr|_|): TcGlobals -> Expr -> TType voption -val (|SeqExpr|_|): TcGlobals -> Expr -> unit option +[] +val (|SeqExpr|_|): TcGlobals -> Expr -> unit voption val EvalLiteralExprOrAttribArg: TcGlobals -> Expr -> Expr @@ -2534,27 +2545,37 @@ val EvaledAttribExprEquality: TcGlobals -> Expr -> Expr -> bool val IsSimpleSyntacticConstantExpr: TcGlobals -> Expr -> bool -val (|ConstToILFieldInit|_|): Const -> ILFieldInit option +[] +val (|ConstToILFieldInit|_|): Const -> ILFieldInit voption -val (|ExtractAttribNamedArg|_|): string -> AttribNamedArg list -> AttribExpr option +[] +val (|ExtractAttribNamedArg|_|): string -> AttribNamedArg list -> AttribExpr voption -val (|AttribInt32Arg|_|): AttribExpr -> int32 option +[] +val (|AttribInt32Arg|_|): (AttribExpr -> int32 voption) -val (|AttribInt16Arg|_|): AttribExpr -> int16 option +[] +val (|AttribInt16Arg|_|): (AttribExpr -> int16 voption) -val (|AttribBoolArg|_|): AttribExpr -> bool option +[] +val (|AttribBoolArg|_|): (AttribExpr -> bool voption) -val (|AttribStringArg|_|): AttribExpr -> string option +[] +val (|AttribStringArg|_|): (AttribExpr -> string voption) -val (|Int32Expr|_|): Expr -> int32 option +[] +val (|Int32Expr|_|): Expr -> int32 voption /// 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 (|SpecialComparableHeadType|_|): TcGlobals -> TType -> TType list voption -val (|SpecialEquatableHeadType|_|): TcGlobals -> TType -> TType list option +[] +val (|SpecialEquatableHeadType|_|): TcGlobals -> TType -> TType list voption -val (|SpecialNotEquatableHeadType|_|): TcGlobals -> TType -> unit option +[] +val (|SpecialNotEquatableHeadType|_|): TcGlobals -> TType -> unit voption /// Matches if the given expression is an application /// of the range or range-step operator on an integral type @@ -2614,18 +2635,21 @@ val ValIsExplicitImpl: TcGlobals -> Val -> bool val ValRefIsExplicitImpl: TcGlobals -> ValRef -> bool +[] val (|LinearMatchExpr|_|): - Expr -> (DebugPointAtBinding * range * DecisionTree * DecisionTreeTarget * Expr * range * TType) option + Expr -> (DebugPointAtBinding * range * DecisionTree * DecisionTreeTarget * Expr * range * TType) voption val rebuildLinearMatchExpr: DebugPointAtBinding * range * DecisionTree * DecisionTreeTarget * Expr * range * TType -> Expr -val (|LinearOpExpr|_|): Expr -> (TOp * TypeInst * Expr list * Expr * range) option +[] +val (|LinearOpExpr|_|): Expr -> (TOp * TypeInst * Expr list * Expr * range) voption val rebuildLinearOpExpr: TOp * TypeInst * Expr list * Expr * range -> Expr val mkCoerceIfNeeded: TcGlobals -> tgtTy: TType -> srcTy: TType -> Expr -> Expr +[] val (|InnerExprPat|): Expr -> Expr val allValsOfModDef: ModuleOrNamespaceContents -> seq @@ -2655,48 +2679,61 @@ type TraitWitnessInfoHashMap<'T> = ImmutableDictionary val EmptyTraitWitnessInfoHashMap: TcGlobals -> TraitWitnessInfoHashMap<'T> /// Match expressions that are an application of a particular F# function value -val (|ValApp|_|): TcGlobals -> ValRef -> Expr -> (TypeInst * Exprs * range) option +[] +val (|ValApp|_|): TcGlobals -> ValRef -> Expr -> (TypeInst * Exprs * range) voption /// Match expressions that represent the creation of an instance of an F# delegate value -val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * range * (Expr -> Expr)) option +[] +val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * range * (Expr -> Expr)) voption /// Match a .Invoke on a delegate -val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * Expr * Expr * range) option +[] +val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * Expr * Expr * range) voption /// Match 'if __useResumableCode then ... else ...' expressions -val (|IfUseResumableStateMachinesExpr|_|): TcGlobals -> Expr -> (Expr * Expr) option +[] +val (|IfUseResumableStateMachinesExpr|_|): TcGlobals -> Expr -> (Expr * Expr) voption val CombineCcuContentFragments: ModuleOrNamespaceType list -> ModuleOrNamespaceType /// Recognise a 'match __resumableEntry() with ...' expression -val (|ResumableEntryMatchExpr|_|): g: TcGlobals -> Expr -> (Expr * Val * Expr * (Expr * Expr -> Expr)) option +[] +val (|ResumableEntryMatchExpr|_|): g: TcGlobals -> Expr -> (Expr * Val * Expr * (Expr * Expr -> Expr)) voption /// Recognise a '__stateMachine' expression +[] val (|StructStateMachineExpr|_|): - g: TcGlobals -> expr: Expr -> (TType * (Val * Expr) * (Val * Val * Expr) * (Val * Expr)) option + g: TcGlobals -> expr: Expr -> (TType * (Val * Expr) * (Val * Val * Expr) * (Val * Expr)) voption /// Recognise a sequential or binding construct in a resumable code -val (|SequentialResumableCode|_|): g: TcGlobals -> Expr -> (Expr * Expr * range * (Expr -> Expr -> Expr)) option +[] +val (|SequentialResumableCode|_|): g: TcGlobals -> Expr -> (Expr * Expr * range * (Expr -> Expr -> Expr)) voption /// Recognise a '__debugPoint' expression -val (|DebugPointExpr|_|): g: TcGlobals -> Expr -> string option +[] +val (|DebugPointExpr|_|): g: TcGlobals -> Expr -> string voption /// Recognise a '__resumeAt' expression -val (|ResumeAtExpr|_|): g: TcGlobals -> Expr -> Expr option +[] +val (|ResumeAtExpr|_|): g: TcGlobals -> Expr -> Expr voption /// Recognise a while expression -val (|WhileExpr|_|): Expr -> (DebugPointAtWhile * SpecialWhileLoopMarker * Expr * Expr * range) option +[] +val (|WhileExpr|_|): Expr -> (DebugPointAtWhile * SpecialWhileLoopMarker * Expr * Expr * range) voption /// Recognise an integer for-loop expression +[] val (|IntegerForLoopExpr|_|): - Expr -> (DebugPointAtFor * DebugPointAtInOrTo * ForLoopStyle * Expr * Expr * Val * Expr * range) option + Expr -> (DebugPointAtFor * DebugPointAtInOrTo * ForLoopStyle * Expr * Expr * Val * Expr * range) voption /// Recognise a try-with expression +[] val (|TryWithExpr|_|): - Expr -> (DebugPointAtTry * DebugPointAtWith * TType * Expr * Val * Expr * Val * Expr * range) option + Expr -> (DebugPointAtTry * DebugPointAtWith * TType * Expr * Val * Expr * Val * Expr * range) voption /// Recognise a try-finally expression -val (|TryFinallyExpr|_|): Expr -> (DebugPointAtTry * DebugPointAtFinally * TType * Expr * Expr * range) option +[] +val (|TryFinallyExpr|_|): Expr -> (DebugPointAtTry * DebugPointAtFinally * TType * Expr * Expr * range) voption /// Add a label to use as the target for a goto val mkLabelled: range -> ILCodeLabel -> Expr -> Expr @@ -2720,49 +2757,63 @@ val TryBindTyconRefAttribute: val HasDefaultAugmentationAttribute: g: TcGlobals -> tcref: TyconRef -> bool +[] val (|ResumableCodeInvoke|_|): - g: TcGlobals -> expr: Expr -> (Expr * Expr * Expr list * range * (Expr * Expr list -> Expr)) option + g: TcGlobals -> expr: Expr -> (Expr * Expr * Expr list * range * (Expr * Expr list -> Expr)) voption -val (|OpPipeRight|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * range) option +[] +val (|OpPipeRight|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * range) voption -val (|OpPipeRight2|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * Expr * range) option +[] +val (|OpPipeRight2|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * Expr * range) voption -val (|OpPipeRight3|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * Expr * Expr * range) option +[] +val (|OpPipeRight3|_|): g: TcGlobals -> expr: Expr -> (TType * Expr * Expr * Expr * Expr * range) voption val mkDebugPoint: m: range -> expr: Expr -> Expr /// Match an if...then...else expression or the result of "a && b" or "a || b" -val (|IfThenElseExpr|_|): expr: Expr -> (Expr * Expr * Expr) option +[] +val (|IfThenElseExpr|_|): expr: Expr -> (Expr * Expr * Expr) voption /// Determine if a value is a method implementing an interface dispatch slot using a private method impl val ComputeUseMethodImpl: g: TcGlobals -> v: Val -> bool /// Detect the de-sugared form of a 'yield x' within a 'seq { ... }' -val (|SeqYield|_|): TcGlobals -> Expr -> (Expr * range) option +[] +val (|SeqYield|_|): TcGlobals -> Expr -> (Expr * range) voption /// Detect the de-sugared form of a 'expr; expr' within a 'seq { ... }' -val (|SeqAppend|_|): TcGlobals -> Expr -> (Expr * Expr * range) option +[] +val (|SeqAppend|_|): TcGlobals -> Expr -> (Expr * Expr * range) voption /// Detect the de-sugared form of a 'while gd do expr' within a 'seq { ... }' -val (|SeqWhile|_|): TcGlobals -> Expr -> (Expr * Expr * DebugPointAtWhile * range) option +[] +val (|SeqWhile|_|): TcGlobals -> Expr -> (Expr * Expr * DebugPointAtWhile * range) voption /// Detect the de-sugared form of a 'try .. finally .. ' within a 'seq { ... }' -val (|SeqTryFinally|_|): TcGlobals -> Expr -> (Expr * Expr * DebugPointAtTry * DebugPointAtFinally * range) option +[] +val (|SeqTryFinally|_|): TcGlobals -> Expr -> (Expr * Expr * DebugPointAtTry * DebugPointAtFinally * range) voption /// Detect the de-sugared form of a 'use x = ..' within a 'seq { ... }' -val (|SeqUsing|_|): TcGlobals -> Expr -> (Expr * Val * Expr * TType * DebugPointAtBinding * range) option +[] +val (|SeqUsing|_|): TcGlobals -> Expr -> (Expr * Val * Expr * TType * DebugPointAtBinding * range) voption /// Detect the de-sugared form of a 'for x in collection do ..' within a 'seq { ... }' -val (|SeqForEach|_|): TcGlobals -> Expr -> (Expr * Val * Expr * TType * range * range * DebugPointAtInOrTo) option +[] +val (|SeqForEach|_|): TcGlobals -> Expr -> (Expr * Val * Expr * TType * range * range * DebugPointAtInOrTo) voption /// Detect the outer 'Seq.delay' added for a construct 'seq { ... }' -val (|SeqDelay|_|): TcGlobals -> Expr -> (Expr * TType) option +[] +val (|SeqDelay|_|): TcGlobals -> Expr -> (Expr * TType) voption /// Detect a 'Seq.empty' implicit in the implied 'else' branch of an 'if .. then' in a seq { ... } -val (|SeqEmpty|_|): TcGlobals -> Expr -> range option +[] +val (|SeqEmpty|_|): TcGlobals -> Expr -> range voption /// Detect a 'seq { ... }' expression -val (|Seq|_|): TcGlobals -> Expr -> (Expr * TType) option +[] +val (|Seq|_|): TcGlobals -> Expr -> (Expr * TType) voption /// Indicates if an F# type is the type associated with an F# exception declaration val isFSharpExceptionTy: g: TcGlobals -> ty: TType -> bool @@ -2788,8 +2839,9 @@ type TraitConstraintInfo with /// Matches a ModuleOrNamespaceContents that is empty from a signature printing point of view. /// Signatures printed via the typed tree in NicePrint don't print TMDefOpens or TMDefDo. /// This will match anything that does not have any types or bindings. +[] val (|EmptyModuleOrNamespaces|_|): - moduleOrNamespaceContents: ModuleOrNamespaceContents -> (ModuleOrNamespace list) option + moduleOrNamespaceContents: ModuleOrNamespaceContents -> (ModuleOrNamespace list) voption val tryFindExtensionAttribute: g: TcGlobals -> attribs: Attrib list -> Attrib option