提交 d7274c6c 编写于 作者: S Steffen Forkmann 提交者: Don Syme

Clean up illib (#4428)

* clean option module in illib

* Update NicePrint.fs

* Update NicePrint.fs

* Update NicePrint.fs

* Update NicePrint.fs

* Update NicePrint.fs
上级 3fb44a4b
......@@ -37,14 +37,14 @@ let inline isSingleton l =
let inline isNonNull x = not (isNull x)
let inline nonNull msg x = if isNull x then failwith ("null: " ^ msg) else x
let (===) x y = LanguagePrimitives.PhysicalEquality x y
let inline (===) x y = LanguagePrimitives.PhysicalEquality x y
//---------------------------------------------------------------------
// Library: ReportTime
//---------------------------------------------------------------------
let reportTime =
let tFirst = ref None
let tPrev = ref None
let tFirst = ref None
let tPrev = ref None
fun showTimes descr ->
if showTimes then
let t = System.Diagnostics.Process.GetCurrentProcess().UserProcessorTime.TotalSeconds
......@@ -237,36 +237,12 @@ module Option =
let mapFold f s opt =
match opt with
| None -> None,s
| Some x -> let x',s' = f s x in Some x',s'
let otherwise opt dflt =
match opt with
| None -> dflt
| Some x -> x
let fold f z x =
match x with
| None -> z
| Some x -> f z x
let attempt (f: unit -> 'T) = try Some (f()) with _ -> None
let orElseWith f opt =
match opt with
| None -> f()
| x -> x
let orElse v opt =
match opt with
| None -> v
| x -> x
let defaultValue v opt =
match opt with
| None -> v
| Some x -> x
| Some x ->
let x',s' = f s x
Some x',s'
let attempt (f: unit -> 'T) = try Some (f()) with _ -> None
module List =
//let item n xs = List.nth xs n
......@@ -442,9 +418,6 @@ module List =
| x::xs -> if i=n then f x::xs else x::mn (i+1) xs
mn 0 xs
let rec until p l = match l with [] -> [] | h::t -> if p h then [] else h :: until p t
let count pred xs = List.fold (fun n x -> if pred x then n+1 else n) 0 xs
// WARNING: not tail-recursive
......@@ -521,23 +494,9 @@ module String =
if s.Length = 0 then s
else lowercase s.[0..0] + s.[ 1.. s.Length - 1 ]
let dropPrefix (s:string) (t:string) = s.[t.Length..s.Length - 1]
let tryDropPrefix (s:string) (t:string) =
if s.StartsWith t then
Some s.[t.Length..s.Length - 1]
else
None
let tryDropSuffix (s:string) (t:string) =
if s.EndsWith t then
Some s.[0..s.Length - t.Length - 1]
else
None
let hasPrefix s t = Option.isSome (tryDropPrefix s t)
let dropPrefix s t = match (tryDropPrefix s t) with Some(res) -> res | None -> failwith "dropPrefix"
let dropSuffix s t = match (tryDropSuffix s t) with Some(res) -> res | None -> failwith "dropSuffix"
let dropSuffix (s:string) (t:string) = s.[0..s.Length - t.Length - 1]
open System
open System.IO
......
......@@ -71,9 +71,10 @@ module internal PrintUtilities =
tcref.DisplayName // has no static params
else
tcref.DisplayName+"<...>" // shorten
if isAttribute then
defaultArg (String.tryDropSuffix name "Attribute") name
else name
if isAttribute && name.EndsWith "Attribute" then
String.dropSuffix name "Attribute"
else
name
let tyconTextL =
tagEntityRefName tcref demangled
|> mkNav tcref.DefinitionRange
......@@ -654,9 +655,10 @@ module private PrintTypes =
| ILAttrib ilMethRef ->
let trimmedName =
let name = ilMethRef.DeclaringTypeRef.Name
match String.tryDropSuffix name "Attribute" with
| Some shortName -> shortName
| None -> name
if name.EndsWith "Attribute" then
String.dropSuffix name "Attribute"
else
name
let tref = ilMethRef.DeclaringTypeRef
let tref = ILTypeRef.Create(scope= tref.Scope, enclosing=tref.Enclosing, name=trimmedName)
PrintIL.layoutILTypeRef denv tref ++ argsL
......@@ -1275,7 +1277,7 @@ module InfoMemberPrinting =
let paramDatas = minfo.GetParamDatas(amap, m, minst)
let layout =
layout ^^
if isNil (List.concat paramDatas) then
if List.forall isNil paramDatas then
WordL.structUnit
else
sepListL WordL.arrow (List.map ((List.map (layoutParamData denv)) >> sepListL WordL.star) paramDatas)
......
......@@ -1451,7 +1451,7 @@ let tryDestRefTupleTy g ty =
type UncurriedArgInfos = (TType * ArgReprInfo) list
type CurriedArgInfos = (TType * ArgReprInfo) list list
// A 'tau' type is one with its type paramaeters stripped off
// A 'tau' type is one with its type parameters stripped off
let GetTopTauTypeInFSharpForm g (curriedArgInfos: ArgReprInfo list list) tau m =
let nArgInfos = curriedArgInfos.Length
let argtys, rty = stripFunTyN g nArgInfos tau
......
......@@ -5112,7 +5112,7 @@ and TcPatBindingName cenv env id ty isMemberThis vis1 topValData (inlineFlag, de
// isLeftMost indicates we are processing the left-most path through a disjunctive or pattern.
// For those binding locations, CallNameResolutionSink is called in MakeAndPublishValue, like all other bindings
// For non-left-most paths, we register the name resolutions here
if not isLeftMost && not vspec.IsCompilerGenerated && not (String.hasPrefix vspec.LogicalName "_") then
if not isLeftMost && not vspec.IsCompilerGenerated && not (vspec.LogicalName.StartsWith "_") then
let item = Item.Value(mkLocalValRef vspec)
CallNameResolutionSink cenv.tcSink (id.idRange, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights)
......
......@@ -100,7 +100,7 @@ type XmlDoc =
| (lineA::rest) as lines ->
let lineAT = lineA.TrimStart([|' '|])
if lineAT = "" then processLines rest
else if String.hasPrefix lineAT "<" then lines
else if lineAT.StartsWith "<" then lines
else ["<summary>"] @
(lines |> List.map (fun line -> Microsoft.FSharp.Core.XmlAdapters.escape(line))) @
["</summary>"]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册