diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs index 9587c3b5e9f..9665bfd2463 100644 --- a/src/Compiler/Checking/CheckPatterns.fs +++ b/src/Compiler/Checking/CheckPatterns.fs @@ -269,7 +269,7 @@ and TcPat warnOnUpper (cenv: cenv) env valReprInfo vFlags (patEnv: TcPatLinearEn | SynPat.As (pat1, pat2, m) -> TcPatUnnamedAs warnOnUpper cenv env vFlags patEnv ty pat1 pat2 m - + | SynPat.Named (SynIdent(id,_), isMemberThis, vis, m) -> TcPatNamed warnOnUpper cenv env vFlags patEnv id ty isMemberThis vis valReprInfo m @@ -522,7 +522,7 @@ and IsNameOf (cenv: cenv) (env: TcEnv) ad m (id: Ident) = /// Check a long identifier in a pattern and TcPatLongIdent warnOnUpper cenv env ad valReprInfo vFlags (patEnv: TcPatLinearEnv) ty (longDotId, tyargs, args, vis, m) = let (SynLongIdent(longId, _, _)) = longDotId - + if tyargs.IsSome then errorR(Error(FSComp.SR.tcInvalidTypeArgumentUsage(), m)) let warnOnUpperForId = @@ -643,7 +643,7 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m // Here we only care about the cases where the user has written the wildcard pattern explicitly // | Case _ -> ... // let myDiscardedArgFunc(Case _) = ...""" - // This needs to be a waring because it was a valid pattern in version 7.0 and earlier and we don't want to break existing code. + // This needs to be a warning because it was a valid pattern in version 7.0 and earlier and we don't want to break existing code. // The rest of the cases will still be reported as FS0725 warning(Error(FSComp.SR.matchNotAllowedForUnionCaseWithNoData(), m)) | _ -> () @@ -725,7 +725,7 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m if numArgTys > 1 then // Expects tuple without enough args let printTy = NicePrint.minimalStringOfType env.DisplayEnv - let missingArgs = + let missingArgs = argNames.[numArgs..numArgTys - 1] |> List.map (fun id -> (if id.rfield_name_generated then "" else id.DisplayName + ": ") + printTy id.FormalType) |> String.concat (Environment.NewLine + "\t") diff --git a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs index fc804ab5e34..10b4a891b32 100644 --- a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs @@ -914,7 +914,7 @@ let inline addVarsToVarSpace (varSpace: LazyWithContext /// Try translate the syntax sugar /// /// Computation expression context (carrying caches, environments, ranges, etc) -/// Flag if it's inital check +/// Flag if it's initial check /// a flag indicating if custom operators are allowed. They are not allowed inside try/with, try/finally, if/then/else etc. /// a lazy data structure indicating the variables bound so far in the overall computation /// the computation expression being analyzed @@ -2793,7 +2793,7 @@ and convertSimpleReturnToExpr (ceenv: ComputationExpressionContext<'a>) comp var | Some(thenExpr, None) -> let elseExprOptOpt = match elseCompOpt with - // When we are missing an 'else' part alltogether in case of 'if cond then return exp', we fallback from BindReturn into regular Bind+Return + // When we are missing an 'else' part altogether in case of 'if cond then return exp', we fallback from BindReturn into regular Bind+Return | None -> None | Some elseComp -> match convertSimpleReturnToExpr ceenv comp varSpace elseComp with diff --git a/src/Compiler/Checking/PatternMatchCompilation.fs b/src/Compiler/Checking/PatternMatchCompilation.fs index 00b25756801..3b42f561c1a 100644 --- a/src/Compiler/Checking/PatternMatchCompilation.fs +++ b/src/Compiler/Checking/PatternMatchCompilation.fs @@ -197,11 +197,11 @@ exception CannotRefute [] [] -type CounterExampleType = +type CounterExampleType = /// Maps to EnumMatchIncomplete exn - | EnumCoversKnown + | EnumCoversKnown /// Maps to MatchIncomplete exn - | WithoutEnum + | WithoutEnum with member x.Combine(other) = match other with EnumCoversKnown -> other | _ -> x let RefuteDiscrimSet g m path discrims : Expr * CounterExampleType = @@ -366,7 +366,7 @@ let ShowCounterExample g denv m refuted = | [] -> raise CannotRefute | (r, eck) :: t -> ((r, eck), t) ||> List.fold (fun (rAcc, eckAcc) (r, eck) -> - CombineRefutations g rAcc r, eckAcc.Combine(eck)) + CombineRefutations g rAcc r, eckAcc.Combine(eck)) let text = LayoutRender.showL (NicePrint.dataExprL denv counterExample) let failingWhenClause = refuted |> List.exists (function RefutedWhenClause -> true | _ -> false) Some(text, failingWhenClause, enumCoversKnown) @@ -400,7 +400,7 @@ let rec isMemOfActives p1 actives = | [] -> false | Active(p2, _, _) :: rest -> pathEq p1 p2 || isMemOfActives p1 rest -// Find the information about the active investigation +// Find the information about the active investigation let rec lookupActive x l = match l with | [] -> raise (KeyNotFoundException()) @@ -423,13 +423,13 @@ type Implication = /// Work out what a successful type test (against tgtTy1) implies about a null test for the same input value. /// /// Example: -/// match x with +/// match x with /// | :? string when false -> ... // note: "when false" used so type test succeeds but proceed to next type test /// | null -> ... /// For any inputs where ':? string' succeeds, 'null' will fail /// /// Example: -/// match x with +/// match x with /// | :? (int option) when false -> ... // note: "when false" used so type test succeeds but proceed to next type test /// | null -> ... /// Nothing can be learned. If ':? (int option)' succeeds, 'null' may still have to be run. @@ -442,7 +442,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutNullTest g tgtTy1 = /// Work out what a failing type test (against tgtTy1) implies about a null test for the same input value. /// /// Example: -/// match x with +/// match x with /// | :? (int option) -> ... /// | null -> ... /// If ':? (int option)' fails then 'null' will fail @@ -455,13 +455,13 @@ let computeWhatFailingTypeTestImpliesAboutNullTest g tgtTy1 = /// Work out what one successful null test implies about a type test (against tgtTy2) for the same input value. /// /// Example: -/// match x with +/// match x with /// | null when false -> ... // note: "when false" used so null test succeeds but proceed to next type test /// | :? string -> ... /// For any inputs where 'null' succeeds, ':? string' will fail /// /// Example: -/// match x with +/// match x with /// | null when false -> ... // note: "when false" used so null test succeeds but proceed to next type test /// | :? (int option) -> ... /// For any inputs where 'null' succeeds, ':? (int option)' will succeed @@ -487,12 +487,12 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = // supertypes (tgtTy2) always succeed. // // Example: - // match x with + // match x with // | :? string when false -> ... // note: "when false" used so type test succeeds but proceed to next type test // | :? IComparable -> ... // // Example: - // match x with + // match x with // | :? string when false -> ... // note: "when false" used so type test succeeds but proceed to next type test // | :? string -> ... // @@ -503,7 +503,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = // type tests of the same object against a unrelated target type (tgtTy2) fails. // // Example: - // match x with + // match x with // | :? int when false -> ... // note: "when false" used so type test succeeds but proceed to next type test // | :? string -> ... // @@ -511,7 +511,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = // // // This only applies if tgtTy2 is not potentially related to the sealed type tgtTy1: - // match x with + // match x with // | :? int when false -> ... // note: "when false" used so type test succeeds but proceed to next type test // | :? IComparable -> ... // @@ -520,7 +520,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = // // // This rule also doesn't apply to unsealed types: - // match x with + // match x with // | :? SomeUnsealedClass when false -> ... // note: "when false" used so type test succeeds but proceed to next type test // | :? SomeInterface -> ... // because the input may be some subtype of SomeUnsealedClass and that type could implement SomeInterface even if @@ -528,7 +528,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = // // // This rule also doesn't apply to types with null as true value: - // match x with + // match x with // | :? (int option) when false -> ... // "when false" means type test succeeds but proceed to next type test // | :? (string option) -> ... // @@ -542,7 +542,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = // a type test of the same input value against an unrelated non-interface type (tgtTy2) always fails // // Example: - // match x with + // match x with // | :? SomeUnsealedClass when false -> ... // "when false" used so type test succeeds but proceed to next type test // | :? SomeUnrelatedClass -> ... // @@ -562,7 +562,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = // always fails. // // Example: - // match x with + // match x with // | :? IComparable when false -> ... // "when false" used so type test succeeds but proceed to next type test // | :? SomeOtherSealedClass -> ... // @@ -586,12 +586,12 @@ let computeWhatFailingTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 = // testing the same input value against an equivalent or subtype type (tgtTy2) always fails. // // Example: - // match x with + // match x with // | :? IComparable -> ... // | :? string -> ... // // Example: - // match x with + // match x with // | :? string -> ... // | :? string -> ... if TypeDefinitelySubsumesTypeNoCoercion 0 g amap m tgtTy1 tgtTy2 then @@ -696,7 +696,7 @@ let discrimWithinSimultaneousClass g amap m discrim prev = | DecisionTreeTest.IsNull, _ -> // Check that each previous test in the set, if successful, gives some information about this test - prev |> List.forall (fun edge -> + prev |> List.forall (fun edge -> match edge with | DecisionTreeTest.IsNull -> true | DecisionTreeTest.IsInst (_, tgtTy1) -> computeWhatSuccessfulTypeTestImpliesAboutNullTest g tgtTy1 <> Implication.Nothing @@ -704,7 +704,7 @@ let discrimWithinSimultaneousClass g amap m discrim prev = | DecisionTreeTest.IsInst (_, tgtTy2), _ -> // Check that each previous test in the set, if successful, gives some information about this test - prev |> List.forall (fun edge -> + prev |> List.forall (fun edge -> match edge with | DecisionTreeTest.IsNull -> true | DecisionTreeTest.IsInst (_, tgtTy1) -> computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 <> Implication.Nothing @@ -885,8 +885,8 @@ let rec investigationPoints inpPat = match inpPat with | TPat_query((_, _, _, _, _, apinfo), subPat, _) -> Array.prepend (not apinfo.IsTotal) (investigationPoints subPat) - | TPat_isinst(_, _tgtTy, subPatOpt, _) -> - match subPatOpt with + | TPat_isinst(_, _tgtTy, subPatOpt, _) -> + match subPatOpt with | None -> singleFalseInvestigationPoint | Some subPat -> Array.prepend false (investigationPoints subPat) | TPat_as(subPat, _, _) -> investigationPoints subPat @@ -904,7 +904,7 @@ let rec investigationPoints inpPat = |> Seq.collect investigationPoints |> Seq.toArray |> Array.prepend false - | TPat_null _ + | TPat_null _ | TPat_const _ -> singleFalseInvestigationPoint | TPat_wild _ | TPat_error _ -> [||] @@ -930,7 +930,7 @@ let rec erasePartialPatterns inpPat = and erasePartials inps = List.map erasePartialPatterns inps - + let ReportUnusedTargets (clauses: MatchClause list) dtree = match dtree, clauses with | TDSuccess _, [ _ ] -> () @@ -948,7 +948,7 @@ let ReportUnusedTargets (clauses: MatchClause list) dtree = | [ head ] -> head.Id.idRange | _ -> c.Pattern.Range | _, Some guard -> guard.Range - + withStartEnd c.Range.Start m.End m |> RuleNeverMatched |> warning) @@ -994,10 +994,10 @@ let CompilePatternBasic let mutable firstIncompleteMatchClauseWithThrowExpr = None let warningsGenerated = new ResizeArray(2) let getIncompleteMatchClause refuted = - // Emit the incomplete match warning. + // Emit the incomplete match warning. if warnOnIncomplete then match actionOnFailure with - | ThrowIncompleteMatchException + | ThrowIncompleteMatchException | IgnoreWithWarning -> let ignoreWithWarning = (actionOnFailure = IgnoreWithWarning) let counterExample = ShowCounterExample g denv mMatch refuted @@ -1070,7 +1070,7 @@ let CompilePatternBasic | ThrowIncompleteMatchException -> mkThrow mMatch resultTy - (mkExnExpr(g.MatchFailureException_tcr, + (mkExnExpr(g.MatchFailureException_tcr, [ mkString g mMatch mMatch.FileName mkInt g mMatch mMatch.StartLine mkInt g mMatch mMatch.StartColumn], mMatch)) @@ -1259,7 +1259,7 @@ let CompilePatternBasic | ActivePatternReturnKind.Boolean -> false let vOpt, addrExp, _readonly, _writeonly = mkExprAddrOfExprAux g mustTakeAddress false NeverMutates appExpr None mMatch match vOpt with - | None -> + | None -> let v, vExpr = mkCompGenLocal m ("activePatternResult" + string (newUnique())) resTy if origInputVal.IsMemberOrModuleBinding then AdjustValToHaveValReprInfo v origInputVal.TryDeclaringEntity ValReprInfo.emptyValData @@ -1316,7 +1316,7 @@ let CompilePatternBasic if not total && aparity > 1 then error(Error(FSComp.SR.patcPartialActivePatternsGenerateOneResult(), m)) - if not total then + if not total then match retKind with | ActivePatternReturnKind.Boolean -> DecisionTreeTest.Const(Const.Bool true) | ActivePatternReturnKind.RefTypeWrapper -> DecisionTreeTest.UnionCase(mkAnySomeCase g false, resTys) @@ -1497,7 +1497,7 @@ let CompilePatternBasic match discrim with | DecisionTreeTest.IsInst (_srcTy, tgtTy2) -> match computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy2 tgtTy1 with - | Implication.Succeeds -> + | Implication.Succeeds -> match pbindOpt with | Some pbind -> let subAccess tpinst exprIn = @@ -1534,7 +1534,7 @@ let CompilePatternBasic match discrim with | DecisionTreeTest.IsNull -> [Frontier (i, newActives, valMap)] - | DecisionTreeTest.IsInst (_, tgtTy) -> + | DecisionTreeTest.IsInst (_, tgtTy) -> match computeWhatSuccessfulTypeTestImpliesAboutNullTest g tgtTy with | Implication.Succeeds -> [Frontier (i, newActives, valMap)] | Implication.Fails -> [] @@ -1637,7 +1637,7 @@ let CompilePatternBasic // - Partial active patterns // - Disjunctive patterns // - Pattern clauses with 'when' -// - isinst patterns +// - isinst patterns // // Partial active patterns that are not the "last" thing in a clause, // combined with subsequent clauses, can cause significant code expansion @@ -1666,13 +1666,13 @@ let CompilePatternBasic // a partial pattern. This can lead to sub-standard code generation // but has long been the technique we use to avoid blow-up of pattern matching. // -// Disjunctive patterns combined with 'when' clauses can also cause signficant code +// Disjunctive patterns combined with 'when' clauses can also cause significant code // expansion. In particular this leads to multiple copies of 'when' expressions (even for one clause) // and each failure path of those 'when' will then continue on the expand any remaining // pattern logic in subsequent clauses. So when generating code we take clauses up // until the first one containing a disjunctive pattern with a 'when' clause. // -// Disjunction will still cause significant expansion, e.g. +// Disjunction will still cause significant expansion, e.g. // (A | B), (C | D) -> // is immediately expanded out to four frontiers each with two investigation points. // A, C -> ... @@ -1682,7 +1682,7 @@ let CompilePatternBasic // // Of course, some decision-logic expansion here is expected. Further, for unions, integers, characters, enums etc. // the column-based matching on A/B and C/D eliminates these relatively efficiently, e.g. to -// one-switch-on-A/B +// one-switch-on-A/B // on each path, one switch on C/D // So disjunction alone isn't considered problematic, but in combination with 'when' patterns @@ -1702,7 +1702,7 @@ let rec CompilePattern g denv amap tcVal infoReader mExpr mMatch warnOnUnused a // First make sure we generate at least some of the obvious incomplete match warnings. let warnOnUnused = false // we can't turn this on since we're pretending all partials fail in order to control the complexity of this. let warnOnIncomplete = true - let clausesPretendAllPartialFail = clausesL |> List.collect (fun (MatchClause(p, whenOpt, tg, m)) -> [MatchClause(erasePartialPatterns p, whenOpt, tg, m)]) + let clausesPretendAllPartialFail = clausesL |> List.collect (fun (MatchClause(p, whenOpt, tg, m)) -> [MatchClause(erasePartialPatterns p, whenOpt, tg, m)]) let _ = CompilePatternBasic g denv amap tcVal infoReader mExpr mMatch warnOnUnused warnOnIncomplete actionOnFailure (origInputVal, origInputValTypars, origInputExprOpt) clausesPretendAllPartialFail inputTy resultTy let warnOnIncomplete = false diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs index 4df0185a2e5..d22f50cdc2f 100644 --- a/src/Compiler/Checking/PostInferenceChecks.fs +++ b/src/Compiler/Checking/PostInferenceChecks.fs @@ -335,9 +335,9 @@ let RecordAnonRecdInfo cenv (anonInfo: AnonRecdTypeInfo) = // approx walk of type //-------------------------------------------------------------------------- -/// Represents the container for nester type instantions, carrying information about the parent (generic type) and data about correspinding generic typar definition. +/// Represents the container for nester type instantions, carrying information about the parent (generic type) and data about corresponding generic typar definition. /// For current use, IlGenericParameterDef was enough. For other future use cases, conversion into F# Typar might be needed. -type TypeInstCtx = +type TypeInstCtx = | NoInfo | IlGenericInst of parent:TyconRef * genericArg:ILGenericParameterDef | TyparInst of parent:TyconRef @@ -649,7 +649,7 @@ let CheckTypeAux permitByRefLike (cenv: cenv) env m ty onInnerByrefError = errorR (Error(FSComp.SR.checkNotSufficientlyGenericBecauseOfScope(tp.DisplayName), m)) let visitTyconRef (ctx:TypeInstCtx) tcref = - let checkInner() = + let checkInner() = match ctx with | TopLevelAllowingByRef -> false | TyparInst(parentTcRef) @@ -694,11 +694,11 @@ let CheckTypeAux permitByRefLike (cenv: cenv) env m ty onInnerByrefError = cenv.potentialUnboundUsesOfVals <- cenv.potentialUnboundUsesOfVals.Add(vref.Stamp, m) | _ -> () - let initialCtx = + let initialCtx = match permitByRefLike with | PermitByRefType.SpanLike | PermitByRefType.NoInnerByRefLike -> TopLevelAllowingByRef - | _ -> NoInfo + | _ -> NoInfo CheckTypeDeep cenv (ignore, Some visitTyconRef, Some visitAppTy, Some visitTraitSolution, Some visitTyar) cenv.g env initialCtx ty @@ -1958,7 +1958,7 @@ and CheckAttribArgExpr cenv env expr = | Const.Single _ | Const.Char _ | Const.Zero - | Const.String _ + | Const.String _ | Const.Decimal _ -> () | _ -> if cenv.reportErrors then @@ -2231,7 +2231,7 @@ let CheckModuleBinding cenv env (TBind(v, e, _) as bind) = // Default augmentation contains the nasty 'Is' etc. let prefix = "Is" if not v.IsImplied && nm.StartsWithOrdinal prefix && hasDefaultAugmentation then - match tcref.GetUnionCaseByName(nm[prefix.Length ..]) with + match tcref.GetUnionCaseByName(nm[prefix.Length ..]) with | Some uc -> error(NameClash(nm, kind, v.DisplayName, v.Range, FSComp.SR.chkUnionCaseDefaultAugmentation(), uc.DisplayName, uc.Range)) | None -> () @@ -2398,10 +2398,10 @@ let CheckEntityDefn cenv env (tycon: Entity) = errorR(Error(FSComp.SR.chkCurriedMethodsCantHaveOutParams(), m)) if numCurriedArgSets = 1 then - let errorIfNotStringTy m ty callerInfo = + let errorIfNotStringTy m ty callerInfo = if not (typeEquiv g g.string_ty ty) then errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, "string", NicePrint.minimalStringOfType cenv.denv ty), m)) - + let errorIfNotStringOptionTy m ty callerInfo = if not ((isOptionTy g ty) && (typeEquiv g g.string_ty (destOptionTy g ty))) then errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, "string", NicePrint.minimalStringOfType cenv.denv (destOptionTy g ty)), m)) @@ -2523,7 +2523,7 @@ let CheckEntityDefn cenv env (tycon: Entity) = if TyconRefHasAttribute g m g.attrib_IsReadOnlyAttribute tcref && not tycon.IsStructOrEnumTycon then errorR(Error(FSComp.SR.tcIsReadOnlyNotStruct(), tycon.Range)) - // Considers TFSharpTyconRepr and TFSharpUnionRepr. + // Considers TFSharpTyconRepr and TFSharpUnionRepr. // [Review] are all cases covered: TILObjectRepr, TAsmRepr. [Yes - these are FSharp.Core.dll only] tycon.AllFieldsArray |> Array.iter (CheckRecdField false cenv env tycon) @@ -2559,10 +2559,10 @@ let CheckEntityDefn cenv env (tycon: Entity) = // We do not have to check access of interface implementations. - if tycon.IsFSharpDelegateTycon then - match tycon.TypeReprInfo with + if tycon.IsFSharpDelegateTycon then + match tycon.TypeReprInfo with | TFSharpTyconRepr r -> - match r.fsobjmodel_kind with + match r.fsobjmodel_kind with | TFSharpDelegate ss -> //ss.ClassTypars //ss.MethodTypars diff --git a/src/Compiler/Facilities/CompilerLocation.fs b/src/Compiler/Facilities/CompilerLocation.fs index 7d902aefc27..abd436647ae 100644 --- a/src/Compiler/Facilities/CompilerLocation.fs +++ b/src/Compiler/Facilities/CompilerLocation.fs @@ -304,7 +304,7 @@ module internal FSharpEnvironment = // How to find dotnet.exe --- woe is me; probing rules make me sad. // Algorithm: // 1. Look for DOTNET_HOST_PATH environment variable - // this is the main user programable override .. provided by user to find a specific dotnet.exe + // this is the main user programmable override .. provided by user to find a specific dotnet.exe // 2. Probe for are we part of an .NetSDK install // In an sdk install we are always installed in: sdk\3.0.100-rc2-014234\FSharp // dotnet or dotnet.exe will be found in the directory that contains the sdk directory diff --git a/src/Compiler/Symbols/SymbolHelpers.fs b/src/Compiler/Symbols/SymbolHelpers.fs index 116e9ba95b7..c516f0c377b 100644 --- a/src/Compiler/Symbols/SymbolHelpers.fs +++ b/src/Compiler/Symbols/SymbolHelpers.fs @@ -5,15 +5,15 @@ namespace FSharp.Compiler.Symbols open System open System.IO -open Internal.Utilities.Library +open Internal.Utilities.Library open Internal.Utilities.Library.Extras open FSharp.Core.Printf -open FSharp.Compiler -open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.InfoReader open FSharp.Compiler.Infos -open FSharp.Compiler.IO +open FSharp.Compiler.IO open FSharp.Compiler.NameResolution open FSharp.Compiler.Syntax.PrettyNaming open FSharp.Compiler.Text @@ -25,7 +25,7 @@ open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypedTreeOps open FSharp.Compiler.TypeHierarchy -open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TcGlobals /// Describe a comment as either a block of text or a file+signature reference into an intellidoc file. [] @@ -38,46 +38,46 @@ module EnvMisc2 = let maxMembers = GetEnvInteger "FCS_MaxMembersInQuickInfo" 10 [] -module internal SymbolHelpers = +module internal SymbolHelpers = let rangeOfValRef preferFlag (vref: ValRef) = - match preferFlag with - | None -> vref.Range - | Some false -> vref.DefinitionRange + match preferFlag with + | None -> vref.Range + | Some false -> vref.DefinitionRange | Some true -> vref.SigRange let rangeOfEntityRef preferFlag (eref: EntityRef) = - match preferFlag with - | None -> eref.Range - | Some false -> eref.DefinitionRange + match preferFlag with + | None -> eref.Range + | Some false -> eref.DefinitionRange | Some true -> eref.SigRange - + let rangeOfPropInfo preferFlag (pinfo: PropInfo) = match pinfo with -#if !NO_TYPEPROVIDERS +#if !NO_TYPEPROVIDERS | ProvidedProp(_, pi, _) -> Construct.ComputeDefinitionLocationOfProvidedItem pi #endif | _ -> pinfo.ArbitraryValRef |> Option.map (rangeOfValRef preferFlag) - let rangeOfMethInfo (g: TcGlobals) preferFlag (minfo: MethInfo) = + let rangeOfMethInfo (g: TcGlobals) preferFlag (minfo: MethInfo) = match minfo with -#if !NO_TYPEPROVIDERS +#if !NO_TYPEPROVIDERS | ProvidedMeth(_, mi, _, _) -> Construct.ComputeDefinitionLocationOfProvidedItem mi #endif | DefaultStructCtor(_, AppTy g (tcref, _)) -> Some(rangeOfEntityRef preferFlag tcref) | _ -> minfo.ArbitraryValRef |> Option.map (rangeOfValRef preferFlag) - let rangeOfEventInfo preferFlag (einfo: EventInfo) = + let rangeOfEventInfo preferFlag (einfo: EventInfo) = match einfo with -#if !NO_TYPEPROVIDERS +#if !NO_TYPEPROVIDERS | ProvidedEvent (_, ei, _) -> Construct.ComputeDefinitionLocationOfProvidedItem ei #endif | _ -> einfo.ArbitraryValRef |> Option.map (rangeOfValRef preferFlag) - - let rangeOfUnionCaseInfo preferFlag (ucinfo: UnionCaseInfo) = - match preferFlag with - | None -> ucinfo.UnionCase.Range - | Some false -> ucinfo.UnionCase.DefinitionRange + + let rangeOfUnionCaseInfo preferFlag (ucinfo: UnionCaseInfo) = + match preferFlag with + | None -> ucinfo.UnionCase.Range + | Some false -> ucinfo.UnionCase.DefinitionRange | Some true -> ucinfo.UnionCase.SigRange let rangeOfRecdField preferFlag (rField: RecdField) = @@ -89,7 +89,7 @@ module internal SymbolHelpers = let rangeOfRecdFieldInfo preferFlag (rfinfo: RecdFieldInfo) = rangeOfRecdField preferFlag rfinfo.RecdField - let rec rangeOfItem (g: TcGlobals) preferFlag d = + let rec rangeOfItem (g: TcGlobals) preferFlag d = match d with | Item.Value vref | Item.CustomBuilder (_, vref) -> Some (rangeOfValRef preferFlag vref) | Item.UnionCase(ucinfo, _) -> Some (rangeOfUnionCaseInfo preferFlag ucinfo) @@ -103,13 +103,13 @@ module internal SymbolHelpers = | Item.Property(info = pinfos; sourceIdentifierRange = mNameOpt) -> match mNameOpt with | Some m -> Some m - | None -> rangeOfPropInfo preferFlag pinfos.Head + | None -> rangeOfPropInfo preferFlag pinfos.Head | Item.Types(_, tys) -> tys |> List.tryPick (tryNiceEntityRefOfTyOption >> Option.map (rangeOfEntityRef preferFlag)) | Item.CustomOperation (_, _, Some minfo) -> rangeOfMethInfo g preferFlag minfo | Item.Trait _ -> None | Item.TypeVar (_, tp) -> Some tp.Range | Item.ModuleOrNamespaces modrefs -> modrefs |> List.tryPick (rangeOfEntityRef preferFlag >> Some) - | Item.MethodGroup(_, minfos, _) + | Item.MethodGroup(_, minfos, _) | Item.CtorGroup(_, minfos) -> minfos |> List.tryPick (rangeOfMethInfo g preferFlag) | Item.ActivePatternResult(APInfo _, _, _, m) -> Some m | Item.SetterArg (_, item) -> rangeOfItem g preferFlag item @@ -122,27 +122,27 @@ module internal SymbolHelpers = | Item.NewDef _ -> None // Provided type definitions do not have a useful F# CCU for the purposes of goto-definition. - let computeCcuOfTyconRef (tcref: TyconRef) = + let computeCcuOfTyconRef (tcref: TyconRef) = #if !NO_TYPEPROVIDERS - if tcref.IsProvided then None else + if tcref.IsProvided then None else #endif ccuOfTyconRef tcref - let ccuOfMethInfo (g: TcGlobals) (minfo: MethInfo) = + let ccuOfMethInfo (g: TcGlobals) (minfo: MethInfo) = match minfo with | DefaultStructCtor(_, AppTy g (tcref, _)) -> computeCcuOfTyconRef tcref - | _ -> - minfo.ArbitraryValRef - |> Option.bind ccuOfValRef + | _ -> + minfo.ArbitraryValRef + |> Option.bind ccuOfValRef |> Option.orElseWith (fun () -> minfo.DeclaringTyconRef |> computeCcuOfTyconRef) - let rec ccuOfItem (g: TcGlobals) d = + let rec ccuOfItem (g: TcGlobals) d = match d with | Item.Value vref | Item.CustomBuilder (_, vref) -> - ccuOfValRef vref + ccuOfValRef vref | Item.UnionCase(ucinfo, _) -> computeCcuOfTyconRef ucinfo.TyconRef @@ -165,9 +165,9 @@ module internal SymbolHelpers = | Item.ILField finfo -> finfo.DeclaringTyconRef |> computeCcuOfTyconRef - | Item.Property(info = pinfos) -> - pinfos |> List.tryPick (fun pinfo -> - pinfo.ArbitraryValRef + | Item.Property(info = pinfos) -> + pinfos |> List.tryPick (fun pinfo -> + pinfo.ArbitraryValRef |> Option.bind ccuOfValRef |> Option.orElseWith (fun () -> pinfo.DeclaringTyconRef |> computeCcuOfTyconRef)) @@ -192,9 +192,9 @@ module internal SymbolHelpers = | Item.DelegateCtor(ty) -> ty |> tryNiceEntityRefOfTyOption |> Option.bind computeCcuOfTyconRef - | Item.ModuleOrNamespaces erefs + | Item.ModuleOrNamespaces erefs | Item.UnqualifiedType erefs -> - erefs |> List.tryPick computeCcuOfTyconRef + erefs |> List.tryPick computeCcuOfTyconRef | Item.SetterArg (_, item) -> ccuOfItem g item @@ -219,22 +219,22 @@ module internal SymbolHelpers = /// Work out the source file for an item and fix it up relative to the CCU if it is relative. let fileNameOfItem (g: TcGlobals) qualProjectDir (m: range) h = - let file = m.FileName + let file = m.FileName if verbose then dprintf "file stored in metadata is '%s'\n" file - if not (FileSystem.IsPathRootedShim file) then - match ccuOfItem g h with - | Some ccu -> + if not (FileSystem.IsPathRootedShim file) then + match ccuOfItem g h with + | Some ccu -> Path.Combine(ccu.SourceCodeDirectory, file) - | None -> - match qualProjectDir with + | None -> + match qualProjectDir with | None -> file | Some dir -> Path.Combine(dir, file) else file - let ParamNameAndTypesOfUnaryCustomOperation g minfo = - match minfo with - | FSMeth(_, _, vref, _) -> - let argInfos = ArgInfosOfMember g vref |> List.concat + let ParamNameAndTypesOfUnaryCustomOperation g minfo = + match minfo with + | FSMeth(_, _, vref, _) -> + let argInfos = ArgInfosOfMember g vref |> List.concat // Drop the first 'seq' argument representing the computation space let argInfos = if argInfos.IsEmpty then [] else argInfos.Tail [ for ty, argInfo in argInfos do @@ -258,12 +258,12 @@ module internal SymbolHelpers = |> Option.map FSharpXmlDoc.FromXmlText |> Option.defaultValue xmlDoc - /// This function gets the signature to pass to Visual Studio to use its lookup functions for .NET stuff. + /// This function gets the signature to pass to Visual Studio to use its lookup functions for .NET stuff. let rec GetXmlDocHelpSigOfItemForLookup (infoReader: InfoReader) m d = let g = infoReader.g match d with - | Item.ActivePatternCase (APElemRef(_, vref, _, _)) - | Item.Value vref | Item.CustomBuilder (_, vref) -> + | Item.ActivePatternCase (APElemRef(_, vref, _, _)) + | Item.Value vref | Item.CustomBuilder (_, vref) -> mkXmlComment (GetXmlDocSigOfValRef g vref) | Item.UnionCase (ucinfo, _) -> @@ -311,7 +311,7 @@ module internal SymbolHelpers = mkXmlComment (GetXmlDocSigOfMethInfo infoReader m minfo) | Item.OtherName(container = Some argContainer) -> - match argContainer with + match argContainer with | ArgumentContainer.Method minfo -> mkXmlComment (GetXmlDocSigOfMethInfo infoReader m minfo) | ArgumentContainer.Type tcref -> mkXmlComment (GetXmlDocSigOfEntityRef infoReader m tcref) @@ -321,7 +321,7 @@ module internal SymbolHelpers = | Item.SetterArg (_, item) -> GetXmlDocHelpSigOfItemForLookup infoReader m item - // These do not have entires in XML doc files + // These do not have entries in XML doc files | Item.CustomOperation _ | Item.OtherName _ | Item.ActivePatternResult _ @@ -340,38 +340,38 @@ module internal SymbolHelpers = |> GetXmlDocFromLoader infoReader /// Produce an XmlComment with a signature or raw text, given the F# comment and the item - let GetXmlCommentForItemAux (xmlDoc: XmlDoc option) (infoReader: InfoReader) m d = - match xmlDoc with - | Some xmlDoc when not xmlDoc.IsEmpty -> + let GetXmlCommentForItemAux (xmlDoc: XmlDoc option) (infoReader: InfoReader) m d = + match xmlDoc with + | Some xmlDoc when not xmlDoc.IsEmpty -> FSharpXmlDoc.FromXmlText xmlDoc | _ -> GetXmlDocHelpSigOfItemForLookup infoReader m d - let GetXmlCommentForMethInfoItem infoReader m d (minfo: MethInfo) = + let GetXmlCommentForMethInfoItem infoReader m d (minfo: MethInfo) = if minfo.HasDirectXmlComment || minfo.XmlDoc.NonEmpty then - GetXmlCommentForItemAux (Some minfo.XmlDoc) infoReader m d + GetXmlCommentForItemAux (Some minfo.XmlDoc) infoReader m d else mkXmlComment (GetXmlDocSigOfMethInfo infoReader m minfo) - let FormatTyparMapping denv (prettyTyparInst: TyparInstantiation) = - [ for tp, ty in prettyTyparInst -> + let FormatTyparMapping denv (prettyTyparInst: TyparInstantiation) = + [ for tp, ty in prettyTyparInst -> wordL (tagTypeParameter ("'" + tp.DisplayName)) ^^ wordL (tagText (FSComp.SR.descriptionWordIs())) ^^ NicePrint.layoutType denv ty ] [] - let (|ItemWhereTypIsPreferred|_|) item = - match item with + let (|ItemWhereTypIsPreferred|_|) item = + match item with | Item.DelegateCtor ty | Item.CtorGroup(_, [DefaultStructCtor(_, ty)]) | 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 + /// 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 /// if this is what we want to show to the user, because we're comparing just the name // for some cases e.g. when using 'fullDisplayTextOfModRef') - let ItemDisplayPartialEquality g = - { new IPartialEqualityComparer<_> with - member x.InEqualityRelation item = - match item with + let ItemDisplayPartialEquality g = + { new IPartialEqualityComparer<_> with + member x.InEqualityRelation item = + match item with | Item.Trait _ -> true | Item.Types(_, _ :: _) -> true | Item.ILField(_) -> true @@ -385,7 +385,7 @@ module internal SymbolHelpers = | Item.ActivePatternCase _ -> true | Item.DelegateCtor _ -> true | Item.UnionCase _ -> true - | Item.ExnCase _ -> true + | Item.ExnCase _ -> true | Item.Event _ -> true | Item.Property _ -> true | Item.CtorGroup _ -> true @@ -404,15 +404,15 @@ module internal SymbolHelpers = | Item.ModuleOrNamespaces [] -> false //| _ -> false - - member x.Equals(item1, item2) = + + member x.Equals(item1, item2) = match item1,item2 with | null,null -> true | null,_ | _,null -> false | item1,item2 -> // This may explore assemblies that are not in the reference set. // In this case just bail out and assume items are not equal - protectAssemblyExploration false (fun () -> + protectAssemblyExploration false (fun () -> let equalHeadTypes(ty1, ty2) = match tryTcrefOfAppTy g ty1 with | ValueSome tcref1 -> @@ -421,41 +421,41 @@ module internal SymbolHelpers = | _ -> typeEquiv g ty1 ty2 | _ -> typeEquiv g ty1 ty2 - ItemsAreEffectivelyEqual g item1 item2 || + ItemsAreEffectivelyEqual g item1 item2 || // Much of this logic is already covered by 'ItemsAreEffectivelyEqual' - match item1, item2 with + match item1, item2 with | Item.DelegateCtor ty1, Item.DelegateCtor ty2 -> equalHeadTypes(ty1, ty2) | Item.Types(dn1, ty1 :: _), Item.Types(dn2, ty2 :: _) -> // Bug 4403: We need to compare names as well, because 'int' and 'Int32' are physically the same type, but we want to show both - dn1 = dn2 && equalHeadTypes(ty1, ty2) - - // Prefer a type to a DefaultStructCtor, a DelegateCtor and a FakeInterfaceCtor - | ItemWhereTypIsPreferred ty1, ItemWhereTypIsPreferred ty2 -> equalHeadTypes(ty1, ty2) + dn1 = dn2 && equalHeadTypes(ty1, ty2) + + // Prefer a type to a DefaultStructCtor, a DelegateCtor and a FakeInterfaceCtor + | ItemWhereTypIsPreferred ty1, ItemWhereTypIsPreferred ty2 -> equalHeadTypes(ty1, ty2) | Item.ExnCase tcref1, Item.ExnCase tcref2 -> tyconRefEq g tcref1 tcref2 | Item.ILField(fld1), Item.ILField(fld2) -> ILFieldInfo.ILFieldInfosUseIdenticalDefinitions fld1 fld2 - | Item.CustomOperation (_, _, Some minfo1), Item.CustomOperation (_, _, Some minfo2) -> + | Item.CustomOperation (_, _, Some minfo1), Item.CustomOperation (_, _, Some minfo2) -> MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2 - | Item.TypeVar (nm1, tp1), Item.TypeVar (nm2, tp2) -> + | Item.TypeVar (nm1, tp1), Item.TypeVar (nm2, tp2) -> (nm1 = nm2) && typarRefEq tp1 tp2 | Item.ModuleOrNamespaces(modref1 :: _), Item.ModuleOrNamespaces(modref2 :: _) -> fullDisplayTextOfModRef modref1 = fullDisplayTextOfModRef modref2 | Item.SetterArg(id1, _), Item.SetterArg(id2, _) -> Range.equals id1.idRange id2.idRange && id1.idText = id2.idText - | Item.MethodGroup(_, meths1, _), Item.MethodGroup(_, meths2, _) -> + | Item.MethodGroup(_, meths1, _), Item.MethodGroup(_, meths2, _) -> Seq.zip meths1 meths2 |> Seq.forall (fun (minfo1, minfo2) -> MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2) - | (Item.Value vref1 | Item.CustomBuilder (_, vref1)), (Item.Value vref2 | Item.CustomBuilder (_, vref2)) -> + | (Item.Value vref1 | Item.CustomBuilder (_, vref1)), (Item.Value vref2 | Item.CustomBuilder (_, vref2)) -> valRefEq g vref1 vref2 | Item.ActivePatternCase(APElemRef(_apinfo1, vref1, idx1, _)), Item.ActivePatternCase(APElemRef(_apinfo2, vref2, idx2, _)) -> idx1 = idx2 && valRefEq g vref1 vref2 - | Item.UnionCase(UnionCaseInfo(_, ur1), _), Item.UnionCase(UnionCaseInfo(_, ur2), _) -> + | Item.UnionCase(UnionCaseInfo(_, ur1), _), Item.UnionCase(UnionCaseInfo(_, ur2), _) -> g.unionCaseRefEq ur1 ur2 - | Item.RecdField(RecdFieldInfo(_, RecdFieldRef(tcref1, n1))), Item.RecdField(RecdFieldInfo(_, RecdFieldRef(tcref2, n2))) -> + | Item.RecdField(RecdFieldInfo(_, RecdFieldRef(tcref1, n1))), Item.RecdField(RecdFieldInfo(_, RecdFieldRef(tcref2, n2))) -> (tyconRefEq g tcref1 tcref2) && (n1 = n2) // there is no direct function as in the previous case - | Item.Property(info = pi1s), Item.Property(info = pi2s) -> + | Item.Property(info = pi1s), Item.Property(info = pi2s) -> (pi1s, pi2s) ||> List.forall2 PropInfo.PropInfosUseIdenticalDefinitions - | Item.Event evt1, Item.Event evt2 -> + | Item.Event evt1, Item.Event evt2 -> EventInfo.EventInfosUseIdenticalDefinitions evt1 evt2 | Item.AnonRecdField(anon1, _, i1, _), Item.AnonRecdField(anon2, _, i2, _) -> anonInfoEquiv anon1 anon2 && i1 = i2 @@ -470,13 +470,13 @@ module internal SymbolHelpers = | Item.Types(_, [AbbrevOrAppTy(tcref1, _)]), Item.UnqualifiedType([tcref2]) -> tyconRefEq g tcref1 tcref2 | Item.UnqualifiedType([tcref1]), Item.Types(_, [AbbrevOrAppTy(tcref2, _)]) -> tyconRefEq g tcref1 tcref2 | _ -> false) - + member x.GetHashCode item = // This may explore assemblies that are not in the reference set. // In this case just bail out and use a random hash code - protectAssemblyExploration 1027 (fun () -> - match item with - | ItemWhereTypIsPreferred ty -> + protectAssemblyExploration 1027 (fun () -> + match item with + | ItemWhereTypIsPreferred ty -> match tryTcrefOfAppTy g ty with | ValueSome tcref -> hash tcref.LogicalName | _ -> 1010 @@ -485,7 +485,7 @@ module internal SymbolHelpers = | Item.TypeVar (nm, _tp) -> hash nm | Item.CustomOperation (_, _, Some minfo) -> minfo.ComputeHashCode() | Item.CustomOperation (_, _, None) -> 1 - | Item.ModuleOrNamespaces(modref :: _) -> hash (fullDisplayTextOfModRef modref) + | Item.ModuleOrNamespaces(modref :: _) -> hash (fullDisplayTextOfModRef modref) | Item.SetterArg(id, _) -> hash (id.idRange, id.idText) | Item.MethodGroup(_, meths, _) -> meths |> List.fold (fun st a -> st + a.ComputeHashCode()) 0 | Item.CtorGroup(name, meths) -> name.GetHashCode() + (meths |> List.fold (fun st a -> st + a.ComputeHashCode()) 0) @@ -512,30 +512,30 @@ module internal SymbolHelpers = | Item.DelegateCtor _ | Item.ModuleOrNamespaces [] -> 0 ) } - + /// Remove all duplicate items - let RemoveDuplicateItems g (items: ItemWithInst list) = + let RemoveDuplicateItems g (items: ItemWithInst list) = if isNil items then items else items |> IPartialEqualityComparer.partialDistinctBy (IPartialEqualityComparer.On (fun item -> item.Item) (ItemDisplayPartialEquality g)) - let IsExplicitlySuppressed (g: TcGlobals) (item: Item) = + let IsExplicitlySuppressed (g: TcGlobals) (item: Item) = // This may explore assemblies that are not in the reference set. // In this case just assume the item is not suppressed. - protectAssemblyExploration true (fun () -> - match item with - | Item.Types(it, [ty]) -> + protectAssemblyExploration true (fun () -> + match item with + | Item.Types(it, [ty]) -> match tryTcrefOfAppTy g ty with | ValueSome tcr1 -> - g.suppressed_types + g.suppressed_types |> List.exists (fun supp -> let generalizedSupp = generalizedTyconRef g supp // check the display name is precisely the one we're suppressing match tryTcrefOfAppTy g generalizedSupp with | ValueSome tcr2 -> it = supp.DisplayName && - // check if they are the same logical type (after removing all abbreviations) + // check if they are the same logical type (after removing all abbreviations) tyconRefEq g tcr1 tcr2 - | _ -> false) + | _ -> false) | _ -> false | _ -> false) @@ -543,7 +543,7 @@ module internal SymbolHelpers = let RemoveExplicitlySuppressed (g: TcGlobals) (items: ItemWithInst list) = items |> List.filter (fun item -> not (IsExplicitlySuppressed g item.Item)) - let SimplerDisplayEnv denv = + let SimplerDisplayEnv denv = { denv with shortConstraints=true showStaticallyResolvedTyparAnnotations=false showNullnessAnnotations = Some true @@ -551,7 +551,7 @@ module internal SymbolHelpers = suppressNestedTypes=true maxMembers=Some EnvMisc2.maxMembers } - let rec FullNameOfItem g item = + let rec FullNameOfItem g item = let denv = DisplayEnv.Empty g match item with | Item.ImplicitOp(_, { contents = Some(TraitConstraintSln.FSMethSln(vref=vref)) }) @@ -559,7 +559,7 @@ module internal SymbolHelpers = | Item.UnionCase (ucinfo, _) -> fullDisplayTextOfUnionCaseRef ucinfo.UnionCaseRef | Item.ActivePatternResult(apinfo, _ty, idx, _) -> apinfo.DisplayNameByIdx idx | Item.ActivePatternCase apref -> FullNameOfItem g (Item.Value apref.ActivePatternVal) + "." + apref.DisplayName - | Item.ExnCase ecref -> fullDisplayTextOfExnRef ecref + | Item.ExnCase ecref -> fullDisplayTextOfExnRef ecref | Item.AnonRecdField(anon, _argTys, i, _) -> anon.DisplayNameByIdx i | Item.RecdField rfinfo -> fullDisplayTextOfRecdFieldRef rfinfo.RecdFieldRef | Item.NewDef id -> id.idText @@ -568,11 +568,11 @@ module internal SymbolHelpers = | Item.Property(info = pinfo :: _) -> buildString (fun os -> NicePrint.outputTyconRef denv os pinfo.DeclaringTyconRef; bprintf os ".%s" pinfo.PropertyName) | Item.CustomOperation (customOpName, _, _) -> customOpName | Item.CtorGroup(_, minfo :: _) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef) - | Item.MethodGroup(_, _, Some minfo) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName) - | Item.MethodGroup(_, minfo :: _, _) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName) + | Item.MethodGroup(_, _, Some minfo) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName) + | Item.MethodGroup(_, minfo :: _, _) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName) | Item.UnqualifiedType (tcref :: _) -> buildString (fun os -> NicePrint.outputTyconRef denv os tcref) - | Item.DelegateCtor ty - | Item.Types(_, ty :: _) -> + | Item.DelegateCtor ty + | Item.Types(_, ty :: _) -> match tryTcrefOfAppTy g ty with | ValueSome tcref -> buildString (fun os -> NicePrint.outputTyconRef denv os tcref) | _ -> "" @@ -585,16 +585,16 @@ module internal SymbolHelpers = | Item.SetterArg (_, item) -> FullNameOfItem g item | Item.ImplicitOp(id, _) -> id.idText | Item.UnionCaseField (UnionCaseInfo (_, ucref), fieldIndex) -> ucref.FieldByIndex(fieldIndex).DisplayName - // unreachable - | Item.UnqualifiedType([]) - | Item.Types(_, []) - | Item.CtorGroup(_, []) - | Item.MethodGroup(_, [], _) + // unreachable + | Item.UnqualifiedType([]) + | Item.Types(_, []) + | Item.CtorGroup(_, []) + | Item.MethodGroup(_, [], _) | Item.ModuleOrNamespaces [] | Item.Property(info = []) -> "" /// Output the description of a language item - let rec GetXmlCommentForItem (infoReader: InfoReader) m item = + let rec GetXmlCommentForItem (infoReader: InfoReader) m item = let g = infoReader.g match item with | Item.ImplicitOp(_, sln) -> @@ -609,19 +609,19 @@ module internal SymbolHelpers = | None -> GetXmlCommentForItemAux None infoReader m item - | Item.Value vref | Item.CustomBuilder (_, vref) -> + | Item.Value vref | Item.CustomBuilder (_, vref) -> let doc = if valRefInThisAssembly g.compilingFSharpCore vref || vref.XmlDoc.NonEmpty then Some vref.XmlDoc else None GetXmlCommentForItemAux doc infoReader m item - | Item.UnionCase(ucinfo, _) -> + | Item.UnionCase(ucinfo, _) -> let doc = if tyconRefUsesLocalXmlDoc g.compilingFSharpCore ucinfo.TyconRef || ucinfo.UnionCase.XmlDoc.NonEmpty then Some ucinfo.UnionCase.XmlDoc else None GetXmlCommentForItemAux doc infoReader m item - | Item.ActivePatternCase apref -> + | Item.ActivePatternCase apref -> let doc = Some apref.ActivePatternVal.XmlDoc GetXmlCommentForItemAux doc infoReader m item - | Item.ExnCase ecref -> + | Item.ExnCase ecref -> let doc = if tyconRefUsesLocalXmlDoc g.compilingFSharpCore ecref || ecref.XmlDoc.NonEmpty then Some ecref.XmlDoc else None GetXmlCommentForItemAux doc infoReader m item @@ -641,13 +641,13 @@ module internal SymbolHelpers = let doc = if einfo.HasDirectXmlComment || einfo.XmlDoc.NonEmpty then Some einfo.XmlDoc else None GetXmlCommentForItemAux doc infoReader m item - | Item.Property(info = pinfos) -> + | Item.Property(info = pinfos) -> let pinfo = pinfos.Head let doc = if pinfo.HasDirectXmlComment || pinfo.XmlDoc.NonEmpty then Some pinfo.XmlDoc else None GetXmlCommentForItemAux doc infoReader m item - | Item.CustomOperation (_, _, Some minfo) - | Item.CtorGroup(_, minfo :: _) + | Item.CustomOperation (_, _, Some minfo) + | Item.CtorGroup(_, minfo :: _) | Item.MethodGroup(_, minfo :: _, _) -> GetXmlCommentForMethInfoItem infoReader m item minfo @@ -673,7 +673,7 @@ module internal SymbolHelpers = | _ -> None GetXmlCommentForItemAux doc infoReader m item - | Item.ModuleOrNamespaces(modref :: _ as modrefs) -> + | Item.ModuleOrNamespaces(modref :: _ as modrefs) -> let definiteNamespace = modrefs |> List.forall (fun modref -> modref.IsNamespace) if not definiteNamespace then let doc = if entityRefInThisAssembly g.compilingFSharpCore modref || modref.XmlDoc.NonEmpty then Some modref.XmlDoc else None @@ -685,7 +685,7 @@ module internal SymbolHelpers = let doc = match argContainer with | Some(ArgumentContainer.Method minfo) -> - if minfo.HasDirectXmlComment || minfo.XmlDoc.NonEmpty then Some minfo.XmlDoc else None + if minfo.HasDirectXmlComment || minfo.XmlDoc.NonEmpty then Some minfo.XmlDoc else None | Some(ArgumentContainer.Type tcref) -> if tyconRefUsesLocalXmlDoc g.compilingFSharpCore tcref || tcref.XmlDoc.NonEmpty then Some tcref.XmlDoc else None | _ -> None @@ -699,9 +699,9 @@ module internal SymbolHelpers = None GetXmlCommentForItemAux doc infoReader m item - | Item.SetterArg (_, item) -> + | Item.SetterArg (_, item) -> GetXmlCommentForItem infoReader m item - + // In all these cases, there is no direct XML documentation from F# comments | Item.MethodGroup (_, [], _) | Item.CtorGroup (_, []) @@ -735,7 +735,7 @@ module internal SymbolHelpers = #if !NO_TYPEPROVIDERS - /// Determine if an item is a provided type + /// Determine if an item is a provided type [] let (|ItemIsProvidedType|_|) g item = match item with @@ -757,11 +757,11 @@ module internal SymbolHelpers = match tys with | [AppTy g (tcref, _typeInst)] -> if tcref.IsProvidedErasedTycon || tcref.IsProvidedGeneratedTycon then - let typeBeforeArguments = - match tcref.TypeReprInfo with + let typeBeforeArguments = + match tcref.TypeReprInfo with | TProvidedTypeRepr info -> info.ProvidedType | _ -> failwith "unreachable" - let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m) + let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m) let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters", m) ValueSome staticParameters else @@ -774,11 +774,11 @@ module internal SymbolHelpers = match item with // Prefer the static parameters from the uninstantiated method info | Item.MethodGroup(_, _, Some minfo) -> - match minfo.ProvidedStaticParameterInfo with + match minfo.ProvidedStaticParameterInfo with | Some (_, staticParameters) -> ValueSome staticParameters | _ -> ValueNone | Item.MethodGroup(_, [minfo], _) -> - match minfo.ProvidedStaticParameterInfo with + match minfo.ProvidedStaticParameterInfo with | Some (_, staticParameters) -> ValueSome staticParameters | _ -> ValueNone | _ -> ValueNone @@ -794,20 +794,20 @@ module internal SymbolHelpers = #endif /// Get the "F1 Keyword" associated with an item, for looking up documentation help indexes on the web - let rec GetF1Keyword (g: TcGlobals) item = + let rec GetF1Keyword (g: TcGlobals) item = let rec getKeywordForMethInfo (minfo : MethInfo) = - match minfo with + match minfo with | FSMeth(_, _, vref, _) -> match vref.TryDeclaringEntity with | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef) + "." + vref.CompiledName g.CompilerGlobalState |> Some | ParentNone -> None - + | ILMeth (_, minfo, _) -> let typeString = minfo.DeclaringTyconRef |> ticksAndArgCountTextOfTyconRef let paramString = - let nGenericParams = minfo.RawMetadata.GenericParams.Length + let nGenericParams = minfo.RawMetadata.GenericParams.Length if nGenericParams > 0 then "``"+(nGenericParams.ToString()) else "" sprintf "%s.%s%s" typeString minfo.RawMetadata.Name paramString |> Some @@ -816,17 +816,17 @@ module internal SymbolHelpers = #if !NO_TYPEPROVIDERS | ProvidedMeth _ -> None #endif - + match item with - | Item.Value vref | Item.CustomBuilder (_, vref) -> + | Item.Value vref | Item.CustomBuilder (_, vref) -> let v = vref.Deref if v.IsModuleBinding && v.HasDeclaringEntity then let tyconRef = v.DeclaringEntity let paramsString = match v.Typars with | [] -> "" - | l -> "``"+(List.length l).ToString() - + | l -> "``"+(List.length l).ToString() + sprintf "%s.%s%s" (tyconRef |> ticksAndArgCountTextOfTyconRef) (v.CompiledName g.CompilerGlobalState) paramsString |> Some else None @@ -839,39 +839,39 @@ module internal SymbolHelpers = | Item.RecdField rfi -> (rfi.TyconRef |> ticksAndArgCountTextOfTyconRef) + "." + rfi.DisplayName |> Some - + | Item.AnonRecdField _ -> None - + | Item.ILField finfo -> - match finfo with - | ILFieldInfo(tinfo, fdef) -> + match finfo with + | ILFieldInfo(tinfo, fdef) -> (tinfo.TyconRefOfRawMetadata |> ticksAndArgCountTextOfTyconRef) + "." + fdef.Name |> Some #if !NO_TYPEPROVIDERS | ProvidedField _ -> None #endif - | Item.Types(_, AppTy g (tcref, _) :: _) + | Item.Types(_, AppTy g (tcref, _) :: _) | Item.DelegateCtor(AppTy g (tcref, _)) | Item.UnqualifiedType (tcref :: _) - | Item.ExnCase tcref -> + | Item.ExnCase tcref -> // strip off any abbreviation - match generalizedTyconRef g tcref with + match generalizedTyconRef g tcref with | AppTy g (tcref, _) -> Some (ticksAndArgCountTextOfTyconRef tcref) | _ -> None // Pathological cases of the above - | Item.Types _ + | Item.Types _ | Item.DelegateCtor _ - | Item.UnqualifiedType [] -> + | Item.UnqualifiedType [] -> None - | Item.ModuleOrNamespaces modrefs -> - match modrefs with - | modref :: _ -> + | Item.ModuleOrNamespaces modrefs -> + match modrefs with + | modref :: _ -> // namespaces from type providers need to be handled separately because they don't have compiled representation // otherwise we'll fail at tast.fs match modref.Deref.TypeReprInfo with -#if !NO_TYPEPROVIDERS - | TProvidedNamespaceRepr _ -> +#if !NO_TYPEPROVIDERS + | TProvidedNamespaceRepr _ -> modref.CompilationPathOpt |> Option.bind (fun path -> // works similar to generation of xml-docs at tastops.fs, probably too similar @@ -884,17 +884,17 @@ module internal SymbolHelpers = | _ -> modref.Deref.CompiledRepresentationForNamedType.FullName |> Some | [] -> None // Pathological case of the above - | Item.Property(info = pinfo :: _) -> - match pinfo with - | FSProp(_, _, Some vref, _) - | FSProp(_, _, _, Some vref) -> + | Item.Property(info = pinfo :: _) -> + match pinfo with + | FSProp(_, _, Some vref, _) + | FSProp(_, _, _, Some vref) -> // per spec, extension members in F1 keywords are qualified with definition class - match vref.TryDeclaringEntity with + match vref.TryDeclaringEntity with | Parent tcref -> - (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some + (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some | ParentNone -> None - | ILProp(ILPropInfo(tinfo, pdef)) -> + | ILProp(ILPropInfo(tinfo, pdef)) -> let tcref = tinfo.TyconRefOfRawMetadata (tcref |> ticksAndArgCountTextOfTyconRef)+"."+pdef.Name |> Some | FSProp _ -> None @@ -902,25 +902,25 @@ module internal SymbolHelpers = | ProvidedProp _ -> None #endif | Item.Property(info = []) -> None // Pathological case of the above - - | Item.Event einfo -> - match einfo with + + | Item.Event einfo -> + match einfo with | ILEvent _ -> let tcref = einfo.DeclaringTyconRef (tcref |> ticksAndArgCountTextOfTyconRef)+"."+einfo.EventName |> Some | FSEvent(_, pinfo, _, _) -> - match pinfo.ArbitraryValRef with + match pinfo.ArbitraryValRef with | Some vref -> // per spec, members in F1 keywords are qualified with definition class - match vref.TryDeclaringEntity with - | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some + match vref.TryDeclaringEntity with + | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some | ParentNone -> None | None -> None #if !NO_TYPEPROVIDERS - | ProvidedEvent _ -> None + | ProvidedEvent _ -> None #endif | Item.CtorGroup(_, minfos) -> - match minfos with + match minfos with | [] -> None | FSMeth(_, _, vref, _) :: _ -> match vref.TryDeclaringEntity with @@ -935,14 +935,14 @@ module internal SymbolHelpers = | Item.CustomOperation (_, _, Some minfo) -> getKeywordForMethInfo minfo | Item.MethodGroup(_, _, Some minfo) -> getKeywordForMethInfo minfo | Item.MethodGroup(_, minfo :: _, _) -> getKeywordForMethInfo minfo - | Item.SetterArg (_, propOrField) -> GetF1Keyword g propOrField - | Item.MethodGroup(_, [], _) + | Item.SetterArg (_, propOrField) -> GetF1Keyword g propOrField + | Item.MethodGroup(_, [], _) | Item.CustomOperation (_, _, None) // "into" | Item.NewDef _ // "let x$yz = ..." - no keyword - | Item.OtherName _ // no keyword on named parameters + | Item.OtherName _ // no keyword on named parameters | Item.Trait _ | Item.UnionCaseField _ - | Item.TypeVar _ + | Item.TypeVar _ | Item.ImplicitOp _ | Item.ActivePatternResult _ // "let (|Foo|Bar|) = .. Fo$o ..." - no keyword -> None @@ -954,21 +954,21 @@ module internal SymbolHelpers = // the VS integration. let SelectMethodGroupItems2 g (m: range) (item: ItemWithInst) : ItemWithInst list = ignore m - match item.Item with + match item.Item with | Item.MethodGroup(nm, minfos, orig) -> minfos |> List.map (fun minfo -> { Item = Item.MethodGroup(nm, [minfo], orig); TyparInstantiation = item.TyparInstantiation }) | Item.CtorGroup(nm, cinfos) -> - cinfos |> List.map (fun minfo -> { Item = Item.CtorGroup(nm, [minfo]); TyparInstantiation = item.TyparInstantiation }) + cinfos |> List.map (fun minfo -> { Item = Item.CtorGroup(nm, [minfo]); TyparInstantiation = item.TyparInstantiation }) | Item.DelegateCtor _ -> [item] - | Item.NewDef _ + | Item.NewDef _ | Item.ILField _ -> [] | Item.Event _ -> [] | Item.RecdField rfinfo -> if isForallFunctionTy g rfinfo.FieldType then [item] else [] | Item.Value v -> if isForallFunctionTy g v.Type then [item] else [] | Item.UnionCase(ucr, _) -> if not ucr.UnionCase.IsNullary then [item] else [] | Item.ExnCase ecr -> if isNil (recdFieldsOfExnDefRef ecr) then [] else [item] - | Item.Property(info = pinfos) -> - let pinfo = List.head pinfos + | Item.Property(info = pinfos) -> + let pinfo = List.head pinfos if pinfo.IsIndexer then [item] else [] #if !NO_TYPEPROVIDERS | ItemIsWithStaticArguments m g _ -> [item] // we pretend that provided-types-with-static-args are method-like in order to get ParamInfo for them diff --git a/src/Compiler/Utilities/range.fsi b/src/Compiler/Utilities/range.fsi index 40a52efa879..90deb76d976 100755 --- a/src/Compiler/Utilities/range.fsi +++ b/src/Compiler/Utilities/range.fsi @@ -6,7 +6,7 @@ namespace FSharp.Compiler.Text open System.Collections.Generic /// An index into a global tables of filenames -type internal FileIndex = int32 +type internal FileIndex = int32 [] type internal NotedSourceConstruct = @@ -59,10 +59,10 @@ type Position = /// Check if the position is adjacent to another position member internal IsAdjacentTo: otherPos: Position -> bool - /// Decode a position fro a 64-bit integer + /// Decode a position for a 64-bit integer static member internal Decode: int64 -> pos - /// The maximum number of bits needed to store an encoded position + /// The maximum number of bits needed to store an encoded position static member internal EncodingSize: int /// Represents a position in a file @@ -105,7 +105,7 @@ type Range = /// Synthetic marks ranges which are produced by intermediate compilation phases. This /// bit signifies that the range covers something that should not be visible to language /// service operations like dot-completion. - member IsSynthetic: bool + member IsSynthetic: bool /// Convert a range to be synthetic member internal MakeSynthetic: unit -> range @@ -122,13 +122,13 @@ type Range = /// The range where all values are zero static member Zero: range - + /// Represents a range within a file and range = Range /// Represents a line number when using zero-based line counting (used by Visual Studio) #if CHECK_LINE0_TYPES -// Visual Studio uses line counts starting at 0, F# uses them starting at 1 +// Visual Studio uses line counts starting at 0, F# uses them starting at 1 [] type ZeroBasedLineAnnotation type Line0 = int @@ -158,7 +158,7 @@ module Position = /// Compare positions for greater-than-or-equal-to val posGeq: pos -> pos -> bool - /// Convert a position from zero-based line counting (used by Visual Studio) to one-based line counting (used internally in the F# compiler and in F# error messages) + /// Convert a position from zero-based line counting (used by Visual Studio) to one-based line counting (used internally in the F# compiler and in F# error messages) val fromZ: line:Line0 -> column:int -> pos /// Convert a position from one-based line counting (used internally in the F# compiler and in F# error messages) to zero-based line counting (used by Visual Studio) @@ -188,10 +188,10 @@ module Range = /// Ordering on positions val posOrder: IComparer - /// This view of range marks uses file indexes explicitly + /// This view of range marks uses file indexes explicitly val mkFileIndexRange: FileIndex -> pos -> pos -> range - /// This view hides the use of file indexes and just uses filenames + /// This view hides the use of file indexes and just uses filenames val mkRange: string -> pos -> pos -> range /// Make a range for the first non-whitespace line of the file if any. Otherwise use line 1 chars 0-80. @@ -211,21 +211,21 @@ module Range = /// Union two ranges, taking their first occurring start position and last occurring end position val unionRanges: range -> range -> range - + // Create a new range with the given start and end positions val withStartEnd: Position -> Position -> range -> range - + // Create a new range with the given start position val withStart: Position -> range -> range - + // Create a new range with the given end position val withEnd: Position -> range -> range - + // Create a new range with the start position shifted by the given deltas val shiftStart: int -> int -> range -> range - + // Create a new range with the end position shifted by the given deltas - val shiftEnd: int -> int -> range -> range + val shiftEnd: int -> int -> range -> range /// Test to see if one range contains another range val rangeContainsRange: range -> range -> bool @@ -247,7 +247,7 @@ module Range = /// A range associated with a dummy file for the command line arguments val rangeCmdArgs: range - + /// Convert a range to a string val stringOfRange: range -> string @@ -263,10 +263,8 @@ module Range = /// Functions related to converting between lines indexed at 0 and 1 module Line = - /// Convert a line number from zero-based line counting (used by Visual Studio) to one-based line counting (used internally in the F# compiler and in F# error messages) + /// Convert a line number from zero-based line counting (used by Visual Studio) to one-based line counting (used internally in the F# compiler and in F# error messages) val fromZ: Line0 -> int /// Convert a line number from one-based line counting (used internally in the F# compiler and in F# error messages) to zero-based line counting (used by Visual Studio) - val toZ: int -> Line0 - - + val toZ: int -> Line0 diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index c6346cb30f2..e21079818d7 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -462,7 +462,7 @@ module rec Compiler = let FsxFromPath (path: string) : CompilationUnit = fsFromString (SourceFromPath path) |> FS - + let Fs (source: string) : CompilationUnit = fsFromString (FsSource source) |> FS @@ -1049,7 +1049,7 @@ module rec Compiler = let compilation = Compilation.Compilation([], CompileOutput.Exe,Array.empty, TargetFramework.Current, references, None, None) evaluateReferences outputDirectory fsSource.IgnoreWarnings compilation |> fst - + let options = [| yield! fsSource.Options |> Array.ofList @@ -1211,7 +1211,7 @@ module rec Compiler = CompilationResult.Success (mkResult output) else let err = (errors |> String.concat "\n").Replace("\r\n","\n") - let output = + let output = ExecutionOutput {Outcome = NoExitCode; StdOut = String.Empty; StdErr = err } CompilationResult.Failure (mkResult output) @@ -1243,7 +1243,7 @@ Actual: elif FileSystem.FileExistsShim baseline.FilePath then FileSystem.FileDeleteShim baseline.FilePath - + let private createBaselineErrors (baselineFile: BaselineFile) (actualErrors: string) : unit = printfn $"creating baseline error file for convenience: {baselineFile.FilePath}, expected: {baselineFile.BslSource}" let file = FileSystem.OpenFileForWriteShim(baselineFile.FilePath) @@ -1300,7 +1300,7 @@ Actual: | Some p -> match ILChecker.verifyILAndReturnActual [] p expected with | true, _, _ -> result - | false, errorMsg, _actualIL -> + | false, errorMsg, _actualIL -> CompilationResult.Failure( {s with Output = Some (ExecutionOutput {Outcome = NoExitCode; StdOut = errorMsg; StdErr = ""})} ) | CompilationResult.Failure f -> printfn "Failure:" @@ -1614,7 +1614,7 @@ Actual: // For lists longer than 100 errors: expectedErrors |> List.iter System.Diagnostics.Debug.WriteLine - // TODO: Check all "categories", collect all results and print alltogether. + // TODO: Check all "categories", collect all results and print all together. checkEqual "Errors count" expectedErrors.Length sourceErrors.Length (sourceErrors, expectedErrors) @@ -1832,10 +1832,10 @@ Actual: let m = Regex(pattern, RegexOptions.Multiline).Match(input) if m.Success then m.Index - else + else -1 else - input.IndexOf(pattern) + input.IndexOf(pattern) let private checkOutputInOrderCore useWildcards (category: string) (substrings: string list) (selector: ExecutionOutput -> string) (result: CompilationResult) : CompilationResult = match result.RunOutput with @@ -1944,10 +1944,9 @@ Actual: let printSignatures cUnit = printSignaturesImpl None cUnit let printSignaturesWith pageWidth cUnit = printSignaturesImpl (Some pageWidth) cUnit - let getImpliedSignatureHash cUnit = + let getImpliedSignatureHash cUnit = let tcResults = cUnit |> typecheckResults let hash = tcResults.CalculateSignatureHash() match hash with | Some h -> h | None -> failwith "Implied signature hash returned 'None' which should not happen" - diff --git a/tests/fsharp/core/members/absil.fsi b/tests/fsharp/core/members/absil.fsi index 11d322553a2..c7755fa4222 100644 --- a/tests/fsharp/core/members/absil.fsi +++ b/tests/fsharp/core/members/absil.fsi @@ -6,13 +6,13 @@ open System type Guid = Option - type Document = + type Document = { Language: Option; Vendor: Option; Type: Option; File: string; } - type SourceAnnotation = + type SourceAnnotation = { Document: Document; Line: int; Column: int; @@ -23,43 +23,43 @@ open System type ModuleName = string type Locale = string - type PublicKeyInfo = + type PublicKeyInfo = | PublicKey of Bytes | PublicKeyToken of Bytes type VersionInfo = UInt16 * UInt16 * UInt16 * UInt16 - type AssemblyRef = + type AssemblyRef = { Name: string; Hash: Option; PublicKeyInfo: Option; - Version: Option; - Locale: Option; } + Version: Option; + Locale: Option; } - type ModuleRef = + type ModuleRef = { Name: string; NoMetadata: bool; - Hash: Option; } + Hash: Option; } - type ScopeRef = - | Local - | Module of ModuleRef - | Assembly of AssemblyRef + type ScopeRef = + | Local + | Module of ModuleRef + | Assembly of AssemblyRef - type BasicCallconv = + type BasicCallconv = | Default - | Cdecl - | Stdcall - | Thiscall - | Fastcall + | Cdecl + | Stdcall + | Thiscall + | Fastcall | Vararg - - type HasThis = + + type HasThis = | Instance (* accepts an implicit 'this' pointer *) | InstanceExplicit (* any 'this' pointer is made explicit (C++ only) *) | Static (* no 'this' pointer is passed *) - type Callconv + type Callconv static member InstanceCallconv: Callconv static member StaticCallconv: Callconv member IsVararg: bool @@ -72,7 +72,7 @@ open System val is_static_callconv: Callconv -> bool type ArrayShape - member Details: (Int32 option * Int32 option) list + member Details: (Int32 option * Int32 option) list member Rank: Int32 static member SingleDimensional: ArrayShape @@ -84,7 +84,7 @@ open System - type TypeRef + type TypeRef member TypeName: string member FullTypeName: string member EnclosingTypeNames: List @@ -95,17 +95,17 @@ open System val enclosing_tnames_of_tref: TypeRef -> List val scoref_of_tref: TypeRef -> ScopeRef - type TypeSpec + type TypeSpec member TypeRef: TypeSpec -> TypeRef member TypeName: TypeSpec -> string member FullTypeName: TypeSpec -> string member ScopeRef: TypeSpec -> ScopeRef member EnclosingTypeNames: TypeSpec -> List - - and Type + + and Type // member Details: (?k:TypeKind. TypeDetails) // These properties let you access the contents of a type in a - // semi-safe way - they may throw exceptions. They could be + // semi-safe way - they may throw exceptions. They could be // given different names. member Shape: ArrayShape member ElementType: Type @@ -125,14 +125,14 @@ open System static member Tyvar: Callsig -> Type static member Modified: bool * Type * Type -> Type - and TypeKind = - | Void - | Array - | Value - | Boxed - | Ptr + and TypeKind = + | Void + | Array + | Value + | Boxed + | Ptr | Byref - | Fptr + | Fptr | Tyvar | Modified @@ -179,7 +179,7 @@ open System val is_tyvar_ty: Type -> bool - type CallSig = + type CallSig = { Callconv: Callconv; ArgTypes: List; ReturnType: Type } @@ -192,11 +192,11 @@ open System // F# library signature: //------------------------------------------------------------------------- - // This is the primitive interface for implementing events corresponding to + // This is the primitive interface for implementing events corresponding to // any delegate type. // // Note 'a and 'args must correspond - if they do not runtime exceptions will arise. - // We could add a constraint of the form + // We could add a constraint of the form // when 'a :> delegate(object * 'arg -> void) type EventForDelegateType<'a> = { Add: 'a -> unit; @@ -205,7 +205,7 @@ open System type ListenerListForDelegateType<'a,'arg> = { Fire: 'arg -> unit; AsEvent: EventForDelegateType<'a> } - + val ListenerListForDelegateType: unit -> ListenerListForDelegateType<'a,'arg> when 'a :> System.Delegate // This is for the common case for F# where the event type is EventHandler @@ -215,26 +215,26 @@ open System { Fire: 'a -> unit; AsEvent: Event<'a> } - val NewListenerList: unit -> ListenerList<'a> - + val NewListenerList: unit -> ListenerList<'a> + // A component signature: type NoiseLevel = Double - - type MyComponent + + type MyComponent member OnNoise: Event member OnPaint: EventForDelegateType - + val NewMyComponent: unit -> MyComponent - - - type MethodRef + + + type MethodRef member Name: string member Callconv: Callconv member Return: Type member ArgTypes: List - member Parent: TypeRef + member Parent: TypeRef member GenericArity: int member CallSig: CallSig member Rename: MethodRef -> MethodRef @@ -245,14 +245,14 @@ open System val callconv_of_mref: MethodRef -> Callconv val ret_of_mref: MethodRef -> Type val args_of_mref: MethodRef -> List - val tref_of_mref: MethodRef -> TypeRef + val tref_of_mref: MethodRef -> TypeRef val parent_of_mref: MethodRef -> TypeRef (* same as tref_of_mref *) val genarity_of_mref: MethodRef -> int val callsig_of_mref: MethodRef -> CallSig val rename_mref: string -> MethodRef -> MethodRef val relocate_mref: Type -> MethodRef -> MethodRef - type FieldRef + type FieldRef member Type: FieldRef member Name: string member TypeRef: TypeRef @@ -318,7 +318,7 @@ open System type CodeLabel = string - type BasicType = + type BasicType = | DT_R | DT_I1 | DT_U1 @@ -334,91 +334,91 @@ open System | DT_U | DT_REF - type LdtokenInfo = - | Token_type of Type - | Token_method of MethodSpec + type LdtokenInfo = + | Token_type of Type + | Token_method of MethodSpec | Token_field of FieldSpec - type LdcInfo = + type LdcInfo = | NUM_I4 of Int32 | NUM_I8 of Int64 | NUM_R4 of Single | NUM_R8 of Double - type Tailness = + type Tailness = | Tailcall | Normalcall - type Alignment = + type Alignment = | Aligned | Unaligned_1 | Unaligned_2 | Unaligned_4 - type Volatility = + type Volatility = | Volatile | Nonvolatile - type Readonly = + type Readonly = | ReadonlyAddress | NormalAddress type VarargTypes = Option< List > type CompareOp = - | BI_beq - | BI_bge - | BI_bge_un - | BI_bgt - | BI_bgt_un - | BI_ble - | BI_ble_un - | BI_blt - | BI_blt_un - | BI_bne_un - | BI_brfalse - | BI_brtrue + | BI_beq + | BI_bge + | BI_bge_un + | BI_bgt + | BI_bgt_un + | BI_ble + | BI_ble_un + | BI_blt + | BI_blt_un + | BI_bne_un + | BI_brfalse + | BI_brtrue type ArithmeticOp = - | AI_add + | AI_add | AI_add_ovf | AI_add_ovf_un - | AI_and - | AI_div + | AI_and + | AI_div | AI_div_un - | AI_ceq - | AI_cgt - | AI_cgt_un - | AI_clt - | AI_clt_un + | AI_ceq + | AI_cgt + | AI_cgt_un + | AI_clt + | AI_clt_un | AI_conv of BasicType | AI_conv_ovf of BasicType | AI_conv_ovf_un of BasicType - | AI_mul - | AI_mul_ovf + | AI_mul + | AI_mul_ovf | AI_mul_ovf_un - | AI_rem - | AI_rem_un - | AI_shl - | AI_shr + | AI_rem + | AI_rem_un + | AI_shl + | AI_shr | AI_shr_un - | AI_sub - | AI_sub_ovf - | AI_sub_ovf_un - | AI_xor - | AI_or - | AI_neg - | AI_not - | AI_ldnull - | AI_dup + | AI_sub + | AI_sub_ovf + | AI_sub_ovf_un + | AI_xor + | AI_or + | AI_neg + | AI_not + | AI_ldnull + | AI_dup | AI_pop - | AI_ckfinite + | AI_ckfinite | AI_nop | AI_ldc of BasicType * LdcInfo // A discriminated union automatically defines a kind and a "details"? - type Instr = + type Instr = (* Basic *) | I_arith of ArithmeticOp | I_ldarg of UInt16 @@ -435,7 +435,7 @@ open System | I_jmp of MethodSpec | I_brcmp of CompareOp * CodeLabel * CodeLabel (* second label is fall-through *) | I_switch of (CodeLabel list * CodeLabel) (* last label is fallthrough *) - | I_ret + | I_ret (* Method call *) | I_call of Tailness * MethodSpec * VarargTypes @@ -444,7 +444,7 @@ open System | I_calli of Tailness * CallSig * VarargTypes | I_ldftn of MethodSpec | I_newobj of MethodSpec * VarargTypes - + (* Exceptions *) | I_throw | I_endfinally @@ -455,7 +455,7 @@ open System | I_ldsfld of Volatility * FieldSpec | I_ldfld of Alignment * Volatility * FieldSpec | I_ldsflda of FieldSpec - | I_ldflda of FieldSpec + | I_ldflda of FieldSpec | I_stsfld of Volatility * FieldSpec | I_stfld of Alignment * Volatility * FieldSpec | I_ldstr of Bytes (* Beware! This is a unicode encoding of the string! *) @@ -483,21 +483,21 @@ open System | I_ldlen | I_mkrefany of Type - | I_refanytype + | I_refanytype | I_refanyval of Type | I_rethrow - | I_break - | I_seqpoint of SourceAnnotation + | I_break + | I_seqpoint of SourceAnnotation - | I_arglist + | I_arglist | I_localloc | I_cpblk of Alignment * Volatility | I_initblk of Alignment * Volatility -type basic_block = +type basic_block = { bblockLabel: CodeLabel; bblockInstrs: Instr array } @@ -512,11 +512,11 @@ val instr_is_tailcall: Instr -> bool -type local_debug_info = +type local_debug_info = { localNum: int; localName: string; } -type Code = +type Code = | BasicBlock of basic_block | GroupBlock of local_debug_info list * Code list | RestrictBlock of List * Code @@ -524,12 +524,12 @@ type Code = member Name: string member X : int - + and seh = - | FaultBlock of Code + | FaultBlock of Code | FinallyBlock of Code | FilterCatchBlock of (filter * Code) list -and filter = +and filter = | TypeFilter of Type | CodeFilter of Code @@ -538,11 +538,11 @@ val exits_of_code: Code -> List val unique_entry_of_code: Code -> CodeLabel val unique_exit_of_code: Code -> CodeLabel -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Field Init * -------------------------------------------------------------------- *) -type FieldInit = +type FieldInit = | FieldInit_Bytes of Bytes | FieldInit_bool of bool | FieldInit_char of UInt16 @@ -558,10 +558,10 @@ type FieldInit = | FieldInit_Double of Double | FieldInit_ref -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Native Types, for marshalling to the native C interface. * These are taken directly from the ILASM syntax, and don't really - * correspond yet to the ECMA Spec (Partition II, 7.4). + * correspond yet to the ECMA Spec (Partition II, 7.4). * -------------------------------------------------------------------- *) type native_type = @@ -598,76 +598,76 @@ type native_type = | (* COM interop *) NativeType_iunknown | (* COM interop *) NativeType_idispatch | (* COM interop *) NativeType_interface - | (* COM interop *) NativeType_error - | (* COM interop *) NativeType_safe_array of variant_type * string option + | (* COM interop *) NativeType_error + | (* COM interop *) NativeType_safe_array of variant_type * string option | (* COM interop *) NativeType_ansi_bstr | (* COM interop *) NativeType_variant_bool -and variant_type = +and variant_type = | VariantType_empty | VariantType_null | VariantType_variant | VariantType_currency - | VariantType_decimal - | VariantType_date - | VariantType_bstr - | VariantType_lpstr - | VariantType_lpwstr - | VariantType_iunknown - | VariantType_idispatch - | VariantType_safearray - | VariantType_error - | VariantType_hresult - | VariantType_carray - | VariantType_userdefined - | VariantType_record + | VariantType_decimal + | VariantType_date + | VariantType_bstr + | VariantType_lpstr + | VariantType_lpwstr + | VariantType_iunknown + | VariantType_idispatch + | VariantType_safearray + | VariantType_error + | VariantType_hresult + | VariantType_carray + | VariantType_userdefined + | VariantType_record | VariantType_filetime - | VariantType_blob - | VariantType_stream - | VariantType_storage - | VariantType_streamed_object - | VariantType_stored_object - | VariantType_blob_object - | VariantType_cf + | VariantType_blob + | VariantType_stream + | VariantType_storage + | VariantType_streamed_object + | VariantType_stored_object + | VariantType_blob_object + | VariantType_cf | VariantType_clsid - | VariantType_void + | VariantType_void | VariantType_bool | VariantType_Int8 - | VariantType_Int16 - | VariantType_Int32 - | VariantType_Int64 - | VariantType_Single - | VariantType_Double - | VariantType_unsigned_Int8 - | VariantType_unsigned_Int16 - | VariantType_unsigned_Int32 - | VariantType_unsigned_Int64 - | VariantType_ptr - | VariantType_array of variant_type - | VariantType_vector of variant_type - | VariantType_byref of variant_type - | VariantType_int - | VariantType_unsigned_int - - -(* -------------------------------------------------------------------- + | VariantType_Int16 + | VariantType_Int32 + | VariantType_Int64 + | VariantType_Single + | VariantType_Double + | VariantType_unsigned_Int8 + | VariantType_unsigned_Int16 + | VariantType_unsigned_Int32 + | VariantType_unsigned_Int64 + | VariantType_ptr + | VariantType_array of variant_type + | VariantType_vector of variant_type + | VariantType_byref of variant_type + | VariantType_int + | VariantType_unsigned_int + + +(* -------------------------------------------------------------------- * Local variables * -------------------------------------------------------------------- *) -type local = +type local = { localType: Type; localPinned: bool } - :> Object + :> Object :> IComparable val typ_of_local: local -> Type -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * IL method bodies * -------------------------------------------------------------------- *) -type CILMethodBody = +type CILMethodBody = { ilZeroInit: bool; ilMaxStack: Int32; (* strictly speaking should be a UInt16 *) ilNoInlining: bool; @@ -678,26 +678,26 @@ type CILMethodBody = val locals_of_ilmbody: CILMethodBody -> local list val code_of_ilmbody: CILMethodBody -> Code -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Member Access * -------------------------------------------------------------------- *) -type MemberAccess = +type MemberAccess = | MemAccess_assembly | MemAccess_compilercontrolled | MemAccess_famandassem | MemAccess_famorassem | MemAccess_family - | MemAccess_private - | MemAccess_public + | MemAccess_private + | MemAccess_public (* -------------------------------------------------------------------- - * Custom attributes: @todo: provide a helper to parse the Bytes - * to CustomAttribute_elem's as best as possible. + * Custom attributes: @todo: provide a helper to parse the Bytes + * to CustomAttribute_elem's as best as possible. * -------------------------------------------------------------------- *) -type CustomAttributeElement = - | String of String +type CustomAttributeElement = + | String of String | Bool of Boolean | Char of Char | Int8 of SByte @@ -710,25 +710,25 @@ type CustomAttributeElement = | UInt64 of UInt64 | Single of Single | Double of Double - | Type of TypeRef + | Type of TypeRef | Enum of Type * CustomAttributeElement type CustomAttribute = - { customMethod: MethodSpec; + { customMethod: MethodSpec; customData: Bytes } type CustomAttributes (* Equivalent to CustomAttribute list - use helpers below to construct/destruct these *) val dest_CustomAttributes: CustomAttributes -> CustomAttribute list -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Method parameters and return values * -------------------------------------------------------------------- *) -type param = +type param = { Name: string option; Type: Type; - Default: Option; + Default: Option; Marshal: native_type option; (* Marshalling map for parameters. COM Interop only. *) In: bool; Out: bool; @@ -738,29 +738,29 @@ type param = val name_of_param: param -> string option val typ_of_param: param -> Type -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Method return values * -------------------------------------------------------------------- *) -type ReturnSpec = +type ReturnSpec = { returnMarshal: native_type option; returnType: Type; } val typ_of_return: ReturnSpec -> Type -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Security Permissions - * + * * Attached to various structures... * -------------------------------------------------------------------- *) -type SecurityAction = - | Request +type SecurityAction = + | Request | Demand | Assert | Deny | Permitonly - | Linkcheck + | Linkcheck | Inheritcheck | Reqmin | Reqopt @@ -771,7 +771,7 @@ type SecurityAction = | Noncaslinkdemand | Noncasinheritance -type PermissionValue = +type PermissionValue = Bool of bool | Int32 of Int32 | String of string @@ -779,7 +779,7 @@ type PermissionValue = | EnumInt16 of TypeRef * Int16 | EnumInt32 of TypeRef * Int32 -type permission = +type permission = | Permission of SecurityAction * Type * (string * PermissionValue) list | PermissionSet of SecurityAction * Bytes @@ -787,11 +787,11 @@ type SecurityDecls (* Opaque type equivalent to permission list - use helpers be val dest_SecurityDecls: SecurityDecls -> permission list -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * PInvoke attributes. * -------------------------------------------------------------------- *) -type pinvoke_Callconv = +type pinvoke_Callconv = | PInvoke_CC_none | PInvoke_CC_cdecl | PInvoke_CC_stdcall @@ -799,13 +799,13 @@ type pinvoke_Callconv = | PInvoke_CC_fastcall | PInvoke_CC_winapi -type pinvoke_encoding = +type pinvoke_encoding = | PInvoke_Encoding_none | PInvoke_Encoding_ansi | PInvoke_Encoding_unicode | PInvoke_Encoding_autochar -type pinvoke_attr = +type pinvoke_attr = { pinvokeWhere: ModuleRef; pinvokeName: string; pinvokeCallconv: pinvoke_Callconv; @@ -827,20 +827,20 @@ val formal_CallSig_of_ospec: OverridesSpec -> CallSig val actual_CallSig_of_ospec: OverridesSpec -> CallSig -type virtual_info = - { Final: bool; - Newslot: bool; +type virtual_info = + { Final: bool; + Newslot: bool; Abstract: bool; Overrides: OverridesSpec option; } -type method_kind = - | Static - | Cctor - | Ctor - | Nonvirtual +type method_kind = + | Static + | Cctor + | Ctor + | Nonvirtual | Virtual of virtual_info -type MethodBody_details = +type MethodBody_details = | MethodBody_il of CILMethodBody | MethodBody_pinvoke of pinvoke_attr (* platform invoke to native *) | MethodBody_abstract @@ -853,17 +853,17 @@ type method_code_kind = type MethodBody (* isomorphic to MethodBody_details *) -val dest_mbody : MethodBody -> MethodBody_details +val dest_mbody : MethodBody -> MethodBody_details -type MethodDef = +type MethodDef = { mdName: string; mdKind: method_kind; mdCallconv: Callconv; mdParams: List; mdReturn: ReturnSpec; mdAccess: MemberAccess; - mdBody: MethodBody; - mdCodeKind: method_code_kind; + mdBody: MethodBody; + mdCodeKind: method_code_kind; mdInternalCall: bool; mdManaged: bool; mdForwardRef: bool; @@ -876,9 +876,9 @@ type MethodDef = mdSynchronized: bool; mdPreserveSig: bool; mdMustRun: bool; (* Whidbey feature: SafeHandle finalizer must be run *) - mdExport: (Int32 * string option) option; + mdExport: (Int32 * string option) option; mdVtableEntry: (Int32 * Int32) option; - + (* MS-GENERICS *) mdGenericParams: GenericParams; mdCustomAttrs: CustomAttributes; } @@ -893,9 +893,9 @@ val code_of_mdef: MethodDef -> Code val entry_of_mdef: MethodDef -> CodeLabel val CallSig_of_mdef: MethodDef -> CallSig -(* -------------------------------------------------------------------- - * Delegates. Derived functions for telling if a method/class definition - * is really a delegate. Also for telling if method signatures refer to +(* -------------------------------------------------------------------- + * Delegates. Derived functions for telling if a method/class definition + * is really a delegate. Also for telling if method signatures refer to * delegate methods. * -------------------------------------------------------------------- *) @@ -907,9 +907,9 @@ val is_delegate_begin_invoke: MethodDef -> bool val is_delegate_end_invoke: MethodDef -> bool val dest_delegate_begin_end_invoke: MethodDef -> MethodDef -> List * Type -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Tables of methods. Logically equivalent to a list of methods but - * the table is kept in a form optimized for looking up methods by + * the table is kept in a form optimized for looking up methods by * name and arity. * -------------------------------------------------------------------- *) @@ -919,20 +919,20 @@ val dest_mdefs: MethodDefs -> MethodDef list val filter_mdefs: (MethodDef -> bool) -> MethodDefs -> MethodDefs val find_mdefs_by_arity: string * int -> MethodDefs -> MethodDef list -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Field definitions * -------------------------------------------------------------------- *) -type FieldDef = +type FieldDef = { Name: string; Type: Type; Static: bool; Access: MemberAccess; Data: Option; - Init: Option; + Init: Option; Offset: Int32 option; (* The explicit offset in Bytes when explicit layout is used. *) SpecialName: bool; - Marshal: native_type option; + Marshal: native_type option; NotSerialized: bool; Literal: bool ; InitOnly: bool; @@ -941,9 +941,9 @@ type FieldDef = val typ_of_fdef : FieldDef -> Type val name_of_fdef: FieldDef -> string -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Tables of FieldDefs. Logically equivalent to a list of FieldDefs but - * the table is kept in a form optimized for looking up FieldDefs by + * the table is kept in a form optimized for looking up FieldDefs by * name. * -------------------------------------------------------------------- *) @@ -953,22 +953,22 @@ val dest_fdefs: FieldDefs -> FieldDef list val filter_fdefs: (FieldDef -> bool) -> FieldDefs -> FieldDefs val find_fdef: string -> FieldDefs -> FieldDef list -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Event definitions * -------------------------------------------------------------------- *) -type EventDef = - { eventType: Type option; +type EventDef = + { eventType: Type option; eventName: string; eventRTSpecialName: bool; eventSpecialName: bool; - eventAddOn: MethodRef; + eventAddOn: MethodRef; eventRemoveOn: MethodRef; eventFire: Option; eventOther: MethodRef list; eventCustomAttrs: CustomAttributes; } -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Table of those events in a type definition. * -------------------------------------------------------------------- *) @@ -977,23 +977,23 @@ type EventDefs val dest_events: EventDefs -> EventDef list val filter_events: (EventDef -> bool) -> EventDefs -> EventDefs -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Property definitions * -------------------------------------------------------------------- *) -type PropertyDef = +type PropertyDef = { propName: string; propRTSpecialName: bool; propSpecialName: bool; propSet: Option; propGet: Option; propCallconv: HasThis; - propType: Type; + propType: Type; propInit: Option; propArgs: List; propCustomAttrs: CustomAttributes; } -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Table of those properties in a type definition. * -------------------------------------------------------------------- *) @@ -1002,15 +1002,15 @@ type ILPropertyDefs val dest_properties: properties -> PropertyDef list val filter_properties: (PropertyDef -> bool) -> ILPropertyDefs -> ILPropertyDefs -(* ------------------------------------------------------------------ +(* ------------------------------------------------------------------ * Method Impls - * - * If there is an entry (pms --> ms) in this table, then method [ms] - * is used to implement method [pms] for the purposes of this class - * and its subclasses. + * + * If there is an entry (pms --> ms) in this table, then method [ms] + * is used to implement method [pms] for the purposes of this class + * and its subclasses. * ------------------------------------------------------------------ *) -type MethodImpl = +type MethodImpl = { mimplOverrides: OverridesSpec; mimplOverrideBy: MethodSpec } @@ -1018,18 +1018,18 @@ type MethodImpls val dest_mimpls: MethodImpls -> MethodImpl list -(* ------------------------------------------------------------------ +(* ------------------------------------------------------------------ * Type Access, Layout etc. * ------------------------------------------------------------------ *) type TypeLayout = | TypeLayout_auto | TypeLayout_sequential of TypeLayout_info - | TypeLayout_explicit of TypeLayout_info + | TypeLayout_explicit of TypeLayout_info and TypeLayout_info = { typeSize: Int32 option; - typePack: UInt16 option } + typePack: UInt16 option } type TypeInit = | TypeInit_beforefield @@ -1040,26 +1040,26 @@ type TypeEncoding = | TypeEncoding_autochar | TypeEncoding_unicode -type TypeDefAccess = - | TypeAccess_public +type TypeDefAccess = + | TypeAccess_public | TypeAccess_private - | TypeAccess_nested of MemberAccess + | TypeAccess_nested of MemberAccess type delegate_kind = Multicast | Singlecast -type delegate_info = - { delKind: delegate_kind; +type delegate_info = + { delKind: delegate_kind; delAsync: bool; delArgs: List; delRet: Type } -type enum_info = - { enumValues: (string * FieldInit) list; +type enum_info = + { enumValues: (string * FieldInit) list; enumType: Type } val values_of_enum_info: enum_info -> (string * FieldInit) list val typ_of_enum_info: enum_info -> Type -type TypeDefKind = +type TypeDefKind = | TypeDef_class | TypeDef_valuetype | TypeDef_interface @@ -1070,21 +1070,21 @@ type TypeDefKind = val split_type_name: string -> List * string -type TypeDef = +type TypeDef = { tdKind: TypeDefKind; - tdName: string; + tdName: string; tdGenericParams: GenericParams; - tdAccess: TypeDefAccess; + tdAccess: TypeDefAccess; tdAbstract: bool; - tdSealed: bool; - tdSerializable: bool; - tdComInterop: bool; (* Class or interface generated for COM interop *) + tdSealed: bool; + tdSerializable: bool; + tdComInterop: bool; (* Class or interface generated for COM interop *) tdLayout: TypeLayout; tdSpecialName: bool; tdEncoding: TypeEncoding; tdNested: TypeDefs; - tdImplements: List; - tdExtends: Type option; + tdImplements: List; + tdExtends: Type option; tdMethodDefs: MethodDefs; tdSecurityDecls: SecurityDecls; tdFieldDefs: FieldDefs; @@ -1132,50 +1132,49 @@ val iter_lazy_tdefs: (string -> TypeDef Lazy.t -> unit) -> TypeDefs -> unit val tname_for_toplevel: string val is_toplevel_tname: string -> bool val dest_tdefs_with_toplevel_first: TypeDefs -> TypeDef list - -(* -------------------------------------------------------------------- - * "Classes Elsewhere" - classes in auxillary modules. +(* -------------------------------------------------------------------- + * "Classes Elsewhere" - classes in auxiliary modules. * - * Manifests include declarations for all the classes in an + * Manifests include declarations for all the classes in an * assembly, regardless of which module they are in. * - * The ".class extern" construct describes so-called exported Types -- - * these are public classes defined in the auxillary modules of this assembly, - * i.e. modules other than the manifest-carrying module. - * - * For example, if you have a two-module - * assembly (A.DLL and B.DLL), and the manifest resides in the A.DLL, + * The ".class extern" construct describes so-called exported Types -- + * these are public classes defined in the auxiliary modules of this assembly, + * i.e. modules other than the manifest-carrying module. + * + * For example, if you have a two-module + * assembly (A.DLL and B.DLL), and the manifest resides in the A.DLL, * then in the manifest all the public classes declared in B.DLL should - * be defined as exported Types, i.e., as ".class extern". The public classes - * defined in A.DLL should not be defined as ".class extern" -- they are - * already available in the manifest-carrying module. The union of all - * public classes defined in the manifest-carrying module and all - * exported Types defined there is the set of all classes exposed by - * this assembly. Thus, by analysing the metadata of the manifest-carrying - * module of an assembly, you can identify all the classes exposed by + * be defined as exported Types, i.e., as ".class extern". The public classes + * defined in A.DLL should not be defined as ".class extern" -- they are + * already available in the manifest-carrying module. The union of all + * public classes defined in the manifest-carrying module and all + * exported Types defined there is the set of all classes exposed by + * this assembly. Thus, by analysing the metadata of the manifest-carrying + * module of an assembly, you can identify all the classes exposed by * this assembly, and where to find them. * - * Nested classes found in external modules should also be located in + * Nested classes found in external modules should also be located in * this table, suitably nested inside another "class_elsewhere" * definition. * -------------------------------------------------------------------- *) (* these are only found in the "Nested" field of class_elsewhere objects *) -type nested_class_elsewhere = +type nested_class_elsewhere = { Name: string; Access: MemberAccess; Nested: nested_classes_elsewhere; - CustomAttrs: CustomAttributes } + CustomAttrs: CustomAttributes } and nested_classes_elsewhere (* these are only found in the classes_elsewhere table in the manifest *) -type class_elsewhere = +type class_elsewhere = { Module: ModuleRef; Name: string; Access: TypeDefAccess; Nested: nested_classes_elsewhere; - CustomAttrs: CustomAttributes } + CustomAttrs: CustomAttributes } type classes_elsewhere @@ -1183,28 +1182,28 @@ val dest_nested_classes_elsewhere: nested_classes_elsewhere -> nested_class_else val dest_classes_elsewhere: classes_elsewhere -> class_elsewhere list val find_class_elsewhere: string -> classes_elsewhere -> class_elsewhere -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * "Manifest Resources" are chunks of resource data, being one of: - * - the data section of the current module (Bytes of resource given directly) - * - in an external file in this assembly (offset given in the resource_where field) - * - as a resources in another assembly of the same name. + * - the data section of the current module (Bytes of resource given directly) + * - in an external file in this assembly (offset given in the resource_where field) + * - as a resources in another assembly of the same name. * -------------------------------------------------------------------- *) -type resource_access = - | Public - | Private -type resource_where = - | Local of Bytes +type resource_access = + | Public + | Private +type resource_where = + | Local of Bytes | File of ModuleRef * Int32 | Assembly of AssemblyRef -type Resource = +type Resource = { Name: string; Where: resource_where; Access: resource_access; CustomAttrs: CustomAttributes } -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Table of resources in a module * -------------------------------------------------------------------- *) @@ -1212,7 +1211,7 @@ type Resources val dest_resources: Resources -> Resource list -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Fixups are pretty obscure stuff for C++ code. These are not * yet correctly represented in the AbstractIL syntax. * -------------------------------------------------------------------- *) @@ -1220,20 +1219,20 @@ val dest_resources: Resources -> Resource list (* type fixup = Fixup of (Int32 * List * data_label) *) (* type fixups = fixup list *) -(* -------------------------------------------------------------------- - * Manifests, The "main" module of an assembly, and Assemblies. - * +(* -------------------------------------------------------------------- + * Manifests, The "main" module of an assembly, and Assemblies. + * * The main module of an assembly is a module plus some manifest information. * - * An assembly is built by joining together a "main" module plus - * several auxiliary modules. + * An assembly is built by joining together a "main" module plus + * several auxiliary modules. * -------------------------------------------------------------------- *) -type manifest = +type manifest = { Name: string; - AuxModuleHashAlgorithm: Int32; + AuxModuleHashAlgorithm: Int32; SecurityDecls: SecurityDecls; - PublicKey: Option; + PublicKey: Option; Version: VersionInfo option; Locale: Locale option; CustomAttrs: CustomAttributes; @@ -1244,9 +1243,9 @@ type manifest = NoMachine: bool; ClassesElsewhere: classes_elsewhere; EntrypointElsewhere: ModuleRef option; - } + } -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * One module in the "current" assembly, either a main-module or * an auxiliary module. The main module will have a manifest. * @@ -1254,7 +1253,7 @@ type manifest = * code because "module" is a reserved word in OCaml. * -------------------------------------------------------------------- *) -type modul = +type modul = { Manifest: manifest option; CustomAttrs: CustomAttributes; Name: string; @@ -1265,7 +1264,7 @@ type modul = VirtAlignment: Int32; PhysAlignment: Int32; ImageBase: Int32; - Resources: Resources; + Resources: Resources; NativeResources: Bytes Lazy.t option; (* e.g. win86 resources, as the exact contents of a .res or .obj file *) } @@ -1275,33 +1274,33 @@ val assemblyName_of_mainmod: modul -> AssemblyName (* ==================================================================== * PART 2 - * - * Making metadata. Where no explicit static member - * is given, you should create the concrete datatype directly, + * + * Making metadata. Where no explicit static member + * is given, you should create the concrete datatype directly, * e.g. by filling in all appropriate record FieldDefs. * ==================================================================== *) -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Generate references to existing assemblies and modules * -------------------------------------------------------------------- *) val mk_simple_assemblyRef: AssemblyName -> AssemblyRef val mk_simple_modref: ModuleName -> ModuleRef -val mk_simple_scoref_from_assemblyName: AssemblyName -> ScopeRef -val mk_simple_scoref_from_assemblyRef: AssemblyRef -> ScopeRef +val mk_simple_scoref_from_assemblyName: AssemblyName -> ScopeRef +val mk_simple_scoref_from_assemblyRef: AssemblyRef -> ScopeRef val assemblyRef_for_manifest: manifest -> AssemblyRef val assemblyRef_for_mainmod: modul -> AssemblyRef -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Take apart MethodSpecs * -------------------------------------------------------------------- *) val rename_mspec: string -> MethodSpec -> MethodSpec val relocate_mspec: Type -> MethodSpec -> MethodSpec (* deprecated *) -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Make type refs * -------------------------------------------------------------------- *) @@ -1314,7 +1313,7 @@ val mk_nested_tref: ScopeRef * List * string -> TypeRef val mk_tref: ScopeRef * string -> TypeRef val mk_tref_in_tref: TypeRef * string -> TypeRef -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Make type specs * -------------------------------------------------------------------- *) @@ -1322,7 +1321,7 @@ val mk_nongeneric_tspec: TypeRef -> TypeSpec val mk_tspec: TypeRef * Instantiation -> TypeSpec val mk_Callconv: HasThis -> Callconv -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Make Types * -------------------------------------------------------------------- *) @@ -1336,7 +1335,7 @@ val mk_nongeneric_value_typ: TypeRef -> Type val mk_array_ty: Type * ArrayShape -> Type val mk_sdarray_ty: Type -> Type -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Make method references and specs * -------------------------------------------------------------------- *) @@ -1399,7 +1398,7 @@ val mk_mspec_to_mdef: Type * MethodDef * Instantiation -> MethodSpec val mk_CallSig: Callconv * List * Type -> CallSig -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Make generalized versions of possibly-generic Types, * e.g. Given the TypeDef for List, return the type "List". * -------------------------------------------------------------------- *) @@ -1413,17 +1412,17 @@ val gparam_of_gactual: Type -> GenericParam val gparams_of_inst: Instantiation -> GenericParam list val generalize_gparams: GenericParam list -> List -(* -------------------------------------------------------------------- - * Custom attributes +(* -------------------------------------------------------------------- + * Custom attributes * -------------------------------------------------------------------- *) -val mk_CustomAttributeibute: - TypeRef * - List (* fixed args: values and implicit Types *) * - List<(FieldSpec * bool * CustomAttributeElement)> (* named args: vluaes and flags indicating if they are FieldDefs or properties *) +val mk_CustomAttributeibute: + TypeRef * + List (* fixed args: values and implicit Types *) * + List<(FieldSpec * bool * CustomAttributeElement)> (* named args: vluaes and flags indicating if they are FieldDefs or properties *) -> CustomAttribute -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Making code. * -------------------------------------------------------------------- *) @@ -1451,7 +1450,7 @@ type ('a, 'b) choice = Choice1of2 of 'a | Choice2of2 of 'b val mk_try_multi_filter_catch_block: Code * (((CodeLabel * Code), typ) choice * (CodeLabel * Code)) list -> Code -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Injecting code into existing code blocks. A branch will * be added from the given instructions to the (unique) entry of * the code, and the first instruction will be the new entry @@ -1466,7 +1465,7 @@ val prepend_instrs_to_code: Instr list -> Code -> Code val prepend_instrs_to_ilmbody: Instr list -> CILMethodBody -> CILMethodBody val prepend_instrs_to_mdef: Instr list -> MethodDef -> MethodDef -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Default values for some of the strange flags in a module. * -------------------------------------------------------------------- *) @@ -1475,13 +1474,13 @@ val default_modulVirtAlignment: Int32 val default_modulPhysAlignment: Int32 val default_modulImageBase: Int32 -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Helper to check a class is really an enum * -------------------------------------------------------------------- *) val check_enum_FieldDefs: TypeRef -> FieldDef list -> Type * FieldDef list -(* -------------------------------------------------------------------- +(* -------------------------------------------------------------------- * Derived functions for making some instructions * -------------------------------------------------------------------- *) @@ -1543,7 +1542,7 @@ val tspec_for_nested_tdef: ScopeRef -> TypeDef list * TypeDef -> TypeSpec val prepend_instrs_to_cctor: Instr list -> Option -> TypeDef -> TypeDef -type tmps = { num_old_locals: int; mutable newlocals: local list; } +type tmps = { num_old_locals: int; mutable newlocals: local list; } val alloc_tmp: tmps -> local -> UInt16 val mk_storage_ctor: Option -> Instr list -> TypeSpec -> (string * typ) list -> MethodDef @@ -1551,7 +1550,7 @@ val mk_simple_storage_ctor: Option -> TypeSpec option -> TypeS val and_Tailness: Tailness -> bool -> Tailness -val mk_ctor_mspec_for_delegate_tdef: ScopeRef * TypeDef * Instantiation -> MethodSpec +val mk_ctor_mspec_for_delegate_tdef: ScopeRef * TypeDef * Instantiation -> MethodSpec val tref_for_toplevel: ScopeRef -> TypeRef val tspec_for_toplevel: ScopeRef -> TypeSpec @@ -1622,31 +1621,31 @@ val rescope_tspec: ScopeRef -> TypeSpec -> TypeSpec val rescope_typ: ScopeRef -> Type -> Type val rescope_mspec: ScopeRef -> MethodSpec -> MethodSpec val rescope_ospec: ScopeRef -> OverridesSpec -> OverridesSpec -val rescope_mref: ScopeRef -> MethodRef -> MethodRef +val rescope_mref: ScopeRef -> MethodRef -> MethodRef val rescope_fref: ScopeRef -> FieldRef -> FieldRef val rescope_fspec: ScopeRef -> FieldSpec -> FieldSpec -type seh_clause = +type seh_clause = | SEH_finally of (CodeLabel * CodeLabel) | SEH_fault of (CodeLabel * CodeLabel) | SEH_filter_catch of (CodeLabel * CodeLabel) * (CodeLabel * CodeLabel) | SEH_type_catch of Type * (CodeLabel * CodeLabel) -type exception_spec = +type exception_spec = { exnRange: (CodeLabel * CodeLabel); exnClauses: seh_clause list } -type local_spec = +type local_spec = { locRange: (CodeLabel * CodeLabel); locInfos: local_debug_info list } val build_code: string -> - (CodeLabel -> int) -> - Instr array -> - exception_spec list -> - local_spec list -> + (CodeLabel -> int) -> + Instr array -> + exception_spec list -> + local_spec list -> Code val inst_tspec_aux: int -> Instantiation -> TypeSpec -> TypeSpec @@ -1821,7 +1820,7 @@ val mspec_Object_Equals: MethodSpec val mspec_Object_GetHashCode: MethodSpec val mspec_IComparable_CompareTo: MethodSpec val mspec_Console_WriteLine: MethodSpec -val mspec_RuntimeHelpers_InitializeArray: MethodSpec +val mspec_RuntimeHelpers_InitializeArray: MethodSpec val mk_DebuggableAttribute: bool (* debug tracking *) * bool (* disable JIT optimizations *) -> CustomAttribute @@ -1849,11 +1848,10 @@ val intern_tspec: TypeSpec -> TypeSpec val intern_typ: Type -> Type val intern_instr: Instr -> Instr -type refs = - { refsAssembly: AssemblyRef list; +type refs = + { refsAssembly: AssemblyRef list; refsModul: ModuleRef list; } val refs_of_module: modul -> refs val combine_refs: refs -> refs -> refs val empty_refs: refs - diff --git a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fs b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fs index 6285f89c2ec..d2c6b7da964 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fs @@ -1,12 +1,12 @@ -// #Regression #Conformance #LexFilter +// #Regression #Conformance #LexFilter #indent "off" // Regression test for FSHARP1.0:1078 -// The opposit of #light is (for now) #indent "off" +// The opposite of #light is (for now) #indent "off" //This value is not a function and cannot be applied let SimpleSample() = let x = 10 + 12 - 3 in - let y = x * 2 + 1 in + let y = x * 2 + 1 in let r1,r2 = x/3, x%3 in (x,y,r1,r2) diff --git a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsi b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsi index 244dcae5e55..a37b71dc6c5 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsi +++ b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsi @@ -1,7 +1,7 @@ -// #Regression #Conformance #LexFilter +// #Regression #Conformance #LexFilter #indent "off" // Regression test for FSHARP1.0:1078 -// The opposit of #light is (for now) #indent "off" +// The opposite of #light is (for now) #indent "off" //The signature file 'Indent_off_01' does not have a corresponding implementation file\. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match type R diff --git a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsscript b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsscript index 3fe10bcccc5..059332d9484 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsscript +++ b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsscript @@ -1,11 +1,11 @@ -// #Regression #Conformance #LexFilter +// #Regression #Conformance #LexFilter #indent "off" // Regression test for FSHARP1.0:1078 -// The opposit of #light is (for now) #indent "off" +// The opposite of #light is (for now) #indent "off" //Main module of program is empty let SimpleSample() = let x = 10 + 12 - 3 in - let y = x * 2 + 1 in + let y = x * 2 + 1 in let r1,r2 = x/3, x%3 in (x,y,r1,r2) diff --git a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsx b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsx index 893df008972..794b7288ab2 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsx +++ b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_01.fsx @@ -1,11 +1,11 @@ -// #Regression #Conformance #LexFilter +// #Regression #Conformance #LexFilter #indent "off" // Regression test for FSHARP1.0:1078 -// The opposit of #light is (for now) #indent "off" +// The opposite of #light is (for now) #indent "off" //Main module of program is empty let SimpleSample() = let x = 10 + 12 - 3 in - let y = x * 2 + 1 in + let y = x * 2 + 1 in let r1,r2 = x/3, x%3 in (x,y,r1,r2) diff --git a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_after_comment01.fs b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_after_comment01.fs index 6ba9a667f22..bcfe12fdd79 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_after_comment01.fs +++ b/tests/fsharpqa/Source/Conformance/LexicalFiltering/HashLight/indent_off_after_comment01.fs @@ -1,11 +1,11 @@ -// #Regression #Conformance #LexFilter +// #Regression #Conformance #LexFilter // Regression test for FSHARP1.0:1078 -// The opposit of #light is (for now) #indent "off" +// The opposite of #light is (for now) #indent "off" // #indent "off" module M let SimpleSample() = let x = 10 + 12 - 3 in - let y = x * 2 + 1 in + let y = x * 2 + 1 in let r1,r2 = x/3, x%3 in (x,y,r1,r2)