Skip to content

Commit 13db461

Browse files
dsymebaronfel
authored andcommitted
cleanup to minimize diff for RFC FS-1087 (#8867)
* cleanup to minimize diff for RFC FS-1087 * a little more cleanup * a little more cleanup * a little more cleanup * trim length of names in FSHarp.Core.UnitTests * min diff * min diff
1 parent da3ab36 commit 13db461

File tree

8 files changed

+569
-419
lines changed

8 files changed

+569
-419
lines changed

src/fsharp/IlxGen.fs

Lines changed: 249 additions & 221 deletions
Large diffs are not rendered by default.

src/fsharp/InnerLambdasToTopLevelFuncs.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,12 +1129,12 @@ module Pass4_RewriteAssembly =
11291129

11301130
// ilobj - has implicit lambda exprs and recursive/base references
11311131
| Expr.Obj (_, ty, basev, basecall, overrides, iimpls, m) ->
1132-
let basecall, z = TransExpr penv z basecall
1133-
let overrides, z = List.mapFold (TransMethod penv) z overrides
1134-
let (iimpls:(TType*ObjExprMethod list)list), (z: RewriteState) =
1135-
List.mapFold (fun z (tType, objExprs) ->
1132+
let basecall, z = TransExpr penv z basecall
1133+
let overrides, z = List.mapFold (TransMethod penv) z overrides
1134+
let iimpls, z =
1135+
(z, iimpls) ||> List.mapFold (fun z (tType, objExprs) ->
11361136
let objExprs', z' = List.mapFold (TransMethod penv) z objExprs
1137-
(tType, objExprs'), z') z iimpls
1137+
(tType, objExprs'), z')
11381138
let expr = Expr.Obj (newUnique(), ty, basev, basecall, overrides, iimpls, m)
11391139
let pds, z = ExtractPreDecs z
11401140
MakePreDecs m pds expr, z (* if TopLevel, lift preDecs over the ilobj expr *)

src/fsharp/LowerCallsAndSeqs.fs

Lines changed: 103 additions & 102 deletions
Large diffs are not rendered by default.

src/fsharp/LowerCallsAndSeqs.fsi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ val LowerImplFile: g: TcGlobals -> assembly: TypedImplFile -> TypedImplFile
1919
/// a program counter (pc) that records the current state, and a current generated value (current).
2020
/// All these variables are then represented as fields in a hosting closure object along with any additional
2121
/// free variables of the sequence expression.
22-
val LowerSeqExpr: g: TcGlobals -> amap: ImportMap -> overallExpr: Expr -> (ValRef * ValRef * ValRef * ValRef list * Expr * Expr * Expr * TType * range) option
22+
val ConvertSequenceExprToObject: g: TcGlobals -> amap: ImportMap -> overallExpr: Expr -> (ValRef * ValRef * ValRef * ValRef list * Expr * Expr * Expr * TType * range) option
23+
24+
val IsPossibleSequenceExpr: g: TcGlobals -> overallExpr: Expr -> bool

src/fsharp/TypedTree.fs

Lines changed: 92 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4116,7 +4116,7 @@ type AttribNamedArg =
41164116
override x.ToString() = sprintf "AttribNamedArg(...)"
41174117

41184118
/// Constants in expressions
4119-
[<RequireQualifiedAccess>]
4119+
[<RequireQualifiedAccess; StructuredFormatDisplay("{DebugText}")>]
41204120
type Const =
41214121
| Bool of bool
41224122
| SByte of sbyte
@@ -4137,6 +4137,30 @@ type Const =
41374137
| Unit
41384138
| Zero // null/zero-bit-pattern
41394139

4140+
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
4141+
member x.DebugText = x.ToString()
4142+
4143+
override c.ToString() =
4144+
match c with
4145+
| Bool b -> (if b then "true" else "false")
4146+
| SByte x -> string x + "y"
4147+
| Byte x -> string x + "uy"
4148+
| Int16 x -> string x + "s"
4149+
| UInt16 x -> string x + "us"
4150+
| Int32 x -> string x
4151+
| UInt32 x -> string x + "u"
4152+
| Int64 x -> string x + "L"
4153+
| UInt64 x -> string x + "UL"
4154+
| IntPtr x -> string x + "n"
4155+
| UIntPtr x -> string x + "un"
4156+
| Single x -> string x + "f"
4157+
| Double x -> string x
4158+
| Char x -> "'" + string x + "'"
4159+
| String x -> "\"" + x + "\""
4160+
| Decimal x -> string x + "M"
4161+
| Unit -> "()"
4162+
| Zero -> "Const.Zero"
4163+
41404164
/// Decision trees. Pattern matching has been compiled down to
41414165
/// a decision tree by this point. The right-hand-sides (actions) of
41424166
/// a decision tree by this point. The right-hand-sides (actions) of
@@ -4235,7 +4259,7 @@ type DecisionTreeTest =
42354259
/// A target of a decision tree. Can be thought of as a little function, though is compiled as a local block.
42364260
[<NoEquality; NoComparison; StructuredFormatDisplay("{DebugText}")>]
42374261
type DecisionTreeTarget =
4238-
| TTarget of Vals * Expr * DebugPointForTarget
4262+
| TTarget of Val list * Expr * DebugPointForTarget
42394263

42404264
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
42414265
member x.DebugText = x.ToString()
@@ -4359,7 +4383,7 @@ type Exprs = Expr list
43594383
type Vals = Val list
43604384

43614385
/// Represents an expression in the typed abstract syntax
4362-
[<NoEquality; NoComparison; RequireQualifiedAccess (* ; StructuredFormatDisplay("{DebugText}") *) >]
4386+
[<NoEquality; NoComparison; RequireQualifiedAccess; StructuredFormatDisplay("{DebugText}")>]
43634387
type Expr =
43644388
/// A constant expression.
43654389
| Const of
@@ -4496,13 +4520,32 @@ type Expr =
44964520
/// appropriate type instantiation. These are immediately eliminated on subsequent rewrites.
44974521
| Link of Expr ref
44984522

4499-
// Prefer to use the default formatting of this union type
4500-
//[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
4501-
//member x.DebugText = x.ToString()
4502-
//
4503-
//override __.ToString() = "Expr(...)"
4504-
4505-
[<NoEquality; NoComparison; RequireQualifiedAccess (* ; StructuredFormatDisplay("{DebugText}") *) >]
4523+
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
4524+
member expr.DebugText = expr.ToDebugString(3)
4525+
4526+
override expr.ToString() = expr.ToDebugString(3)
4527+
4528+
member expr.ToDebugString(depth: int) =
4529+
if depth = 0 then ".." else
4530+
let depth = depth - 1
4531+
match expr with
4532+
| Const (c, _, _) -> c.ToString()
4533+
| Val (v, _, _) -> v.LogicalName
4534+
| Sequential (e1, e2, _, _, _) -> "Sequential(" + e1.ToDebugString(depth) + ", " + e2.ToDebugString(depth) + ")"
4535+
| Lambda (_, _, _, vs, body, _, _) -> sprintf "Lambda(%+A, " vs + body.ToDebugString(depth) + ")"
4536+
| TyLambda (_, tps, body, _, _) -> sprintf "TyLambda(%+A, " tps + body.ToDebugString(depth) + ")"
4537+
| App (f, _, _, args, _) -> "App(" + f.ToDebugString(depth) + ", [" + String.concat ", " (args |> List.map (fun e -> e.ToDebugString(depth))) + "])"
4538+
| LetRec _ -> "LetRec(..)"
4539+
| Let (bind, body, _, _) -> "Let(" + bind.Var.DisplayName + ", " + bind.Expr.ToDebugString(depth) + ", " + body.ToDebugString(depth) + ")"
4540+
| Obj (_, _objTy, _, _, _, _, _) -> "Obj(..)"
4541+
| Match (_, _, _dt, _tgs, _, _) -> "Match(..)"
4542+
| StaticOptimization (_, _, _, _) -> "StaticOptimization(..)"
4543+
| Op (op, _, args, _) -> "Op(" + op.ToString() + ", " + String.concat ", " (args |> List.map (fun e -> e.ToDebugString(depth))) + ")"
4544+
| Quote _ -> "Quote(..)"
4545+
| TyChoose _ -> "TyChoose(..)"
4546+
| Link e -> "Link(" + e.Value.ToDebugString(depth) + ")"
4547+
4548+
[<NoEquality; NoComparison; RequireQualifiedAccess; StructuredFormatDisplay("{DebugText}") >]
45064549
type TOp =
45074550

45084551
/// An operation representing the creation of a union value of the particular union case
@@ -4619,11 +4662,45 @@ type TOp =
46194662
/// retTy -- the types of pushed values, if any
46204663
| ILCall of bool * bool * bool * bool * ValUseFlag * bool * bool * ILMethodRef * TypeInst * TypeInst * TTypes
46214664

4622-
// Prefer to use the default formatting of this union type
4623-
//[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
4624-
//member x.DebugText = x.ToString()
4625-
//
4626-
//override __.ToString() = "TOp(...)"
4665+
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
4666+
member x.DebugText = x.ToString()
4667+
4668+
override op.ToString() =
4669+
match op with
4670+
| UnionCase ucref -> "UnionCase(" + ucref.CaseName + ")"
4671+
| ExnConstr ecref -> "ExnConstr(" + ecref.LogicalName + ")"
4672+
| Tuple _tupinfo -> "Tuple"
4673+
| AnonRecd _anonInfo -> "AnonRecd(..)"
4674+
| AnonRecdGet _ -> "AnonRecdGet(..)"
4675+
| Array -> "NewArray"
4676+
| Bytes _ -> "Bytes(..)"
4677+
| UInt16s _ -> "UInt16s(..)"
4678+
| While _ -> "While"
4679+
| For _ -> "For"
4680+
| TryCatch _ -> "TryCatch"
4681+
| TryFinally _ -> "TryFinally"
4682+
| Recd (_, tcref) -> "Recd(" + tcref.LogicalName + ")"
4683+
| ValFieldSet rfref -> "ValFieldSet(" + rfref.FieldName + ")"
4684+
| ValFieldGet rfref -> "ValFieldGet(" + rfref.FieldName + ")"
4685+
| ValFieldGetAddr (rfref, _) -> "ValFieldGetAddr(" + rfref.FieldName + ",..)"
4686+
| UnionCaseTagGet tcref -> "UnionCaseTagGet(" + tcref.LogicalName + ")"
4687+
| UnionCaseProof ucref -> "UnionCaseProof(" + ucref.CaseName + ")"
4688+
| UnionCaseFieldGet (ucref, _) -> "UnionCaseFieldGet(" + ucref.CaseName + ",..)"
4689+
| UnionCaseFieldGetAddr (ucref, _, _) -> "UnionCaseFieldGetAddr(" + ucref.CaseName + ",..)"
4690+
| UnionCaseFieldSet (ucref, _) -> "UnionCaseFieldSet(" + ucref.CaseName + ",..)"
4691+
| ExnFieldGet (tcref, _) -> "ExnFieldGet(" + tcref.LogicalName + ",..)"
4692+
| ExnFieldSet (tcref, _) -> "ExnFieldSet(" + tcref.LogicalName + ",..)"
4693+
| TupleFieldGet _ -> "TupleFieldGet(..)"
4694+
| ILAsm _ -> "ILAsm(..)"
4695+
| RefAddrGet _ -> "RefAddrGet(..)"
4696+
| Coerce -> "Coerce"
4697+
| Reraise -> "Reraise"
4698+
| Return -> "Return"
4699+
| Goto n -> "Goto(" + string n + ")"
4700+
| Label n -> "Label(" + string n + ")"
4701+
| TraitCall info -> "TraitCall(" + info.MemberName + ")"
4702+
| LValueOp (op, vref) -> sprintf "%+A(%s)" op vref.LogicalName
4703+
| ILCall (_,_,_,_,_,_,_,m,_,_,_) -> "ILCall(" + m.ToString() + ",..)"
46274704

46284705
/// Represents the kind of record construction operation.
46294706
type RecordConstructionInfo =

0 commit comments

Comments
 (0)