Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 10 additions & 51 deletions src/absil/illib.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions src/fsharp/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/TastOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5107,7 +5107,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)

Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/ast.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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>"]
Expand Down