Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0fd7cdf

Browse files
authored
Cleanup and comments and ToString implementations (#4892)
* rename and cleanup* rename and cleanup and docs
1 parente4cd160 commit0fd7cdf

File tree

6 files changed

+228
-100
lines changed

6 files changed

+228
-100
lines changed

‎src/absil/il.fs‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,6 @@ and
633633

634634
static memberCreate(tref,inst)={ tspecTypeRef=tref; tspecInst=inst}
635635

636-
overridex.ToString()= x.TypeRef.ToString()+if isNil x.GenericArgsthen""else"<...>"
637-
638636
memberx.BasicQualifiedName=
639637
lettc= x.TypeRef.BasicQualifiedName
640638
if isNil x.GenericArgsthen
@@ -647,6 +645,8 @@ and
647645

648646
memberx.FullName=x.TypeRef.FullName
649647

648+
overridex.ToString()= x.TypeRef.ToString()+if isNil x.GenericArgsthen""else"<...>"
649+
650650
and [<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
651651
ILType=
652652
| Void
@@ -685,34 +685,34 @@ and [<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
685685
x.AddQualifiedNameExtension(x.BasicQualifiedName)
686686

687687
memberx.TypeSpec=
688-
match xwith
689-
| ILType.Boxed tr| ILType.Value tr-> tr
690-
|_-> invalidOp"not a nominal type"
688+
match xwith
689+
| ILType.Boxed tr| ILType.Value tr-> tr
690+
|_-> invalidOp"not a nominal type"
691691

692692
memberx.Boxity=
693-
match xwith
694-
| ILType.Boxed_-> AsObject
695-
| ILType.Value_-> AsValue
696-
|_-> invalidOp"not a nominal type"
693+
match xwith
694+
| ILType.Boxed_-> AsObject
695+
| ILType.Value_-> AsValue
696+
|_-> invalidOp"not a nominal type"
697697

698698
memberx.TypeRef=
699-
match xwith
700-
| ILType.Boxed tspec| ILType.Value tspec-> tspec.TypeRef
701-
|_-> invalidOp"not a nominal type"
699+
match xwith
700+
| ILType.Boxed tspec| ILType.Value tspec-> tspec.TypeRef
701+
|_-> invalidOp"not a nominal type"
702702

703703
memberx.IsNominal=
704-
match xwith
705-
| ILType.Boxed_| ILType.Value_->true
706-
|_->false
704+
match xwith
705+
| ILType.Boxed_| ILType.Value_->true
706+
|_->false
707707

708708
memberx.GenericArgs=
709-
match xwith
710-
| ILType.Boxed tspec| ILType.Value tspec-> tspec.GenericArgs
711-
|_->[]
709+
match xwith
710+
| ILType.Boxed tspec| ILType.Value tspec-> tspec.GenericArgs
711+
|_->[]
712712

713713
memberx.IsTyvar=
714-
match xwith
715-
| ILType.TypeVar_->true|_->false
714+
match xwith
715+
| ILType.TypeVar_->true|_->false
716716

717717
and [<StructuralEquality; StructuralComparison>]
718718
ILCallingSignature=

‎src/fsharp/Optimizer.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,9 +1261,9 @@ and OpHasEffect g op =
12611261
| TOp.Recd(ctor, tcref)->
12621262
match ctorwith
12631263
| RecdExprIsObjInit->true
1264-
| RecdExpr->isRecdOrUnionOrStructTyconRefAllocObservable g tcref
1265-
| TOp.UnionCase ucref->isRecdOrUnionOrStructTyconRefAllocObservable g ucref.TyconRef
1266-
| TOp.ExnConstr ecref->isExnAllocObservable ecref
1264+
| RecdExpr->isRecdOrUnionOrStructTyconRefDefinitelyMutable g tcref
1265+
| TOp.UnionCase ucref->isRecdOrUnionOrStructTyconRefDefinitelyMutable g ucref.TyconRef
1266+
| TOp.ExnConstr ecref->isExnDefinitelyMutable ecref
12671267
| TOp.Bytes_| TOp.UInt16s_| TOp.Array->true(* alloc observable*)
12681268
| TOp.UnionCaseTagGet_->false
12691269
| TOp.UnionCaseProof_->false

‎src/fsharp/TastOps.fs‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5217,27 +5217,28 @@ and remarkBind m (TBind(v, repr, _)) =
52175217

52185218

52195219
//--------------------------------------------------------------------------
5220-
//Reference semantics?
5220+
//Mutability analysis
52215221
//--------------------------------------------------------------------------
52225222

5223-
letisRecdOrStructFieldAllocObservable(f:RecdField)=not f.IsStatic&& f.IsMutable
5224-
letisUnionCaseAllocObservable(uc:UnionCase)= uc.FieldTable.FieldsByIndex|> Array.existsisRecdOrStructFieldAllocObservable
5225-
letisUnionCaseRefAllocObservable(uc:UnionCaseRef)= uc.UnionCase|>isUnionCaseAllocObservable
5223+
letisRecdOrStructFieldDefinitelyMutable(f:RecdField)=not f.IsStatic&& f.IsMutable
5224+
letisUnionCaseDefinitelyMutable(uc:UnionCase)= uc.FieldTable.FieldsByIndex|> Array.existsisRecdOrStructFieldDefinitelyMutable
5225+
letisUnionCaseRefDefinitelyMutable(uc:UnionCaseRef)= uc.UnionCase|>isUnionCaseDefinitelyMutable
52265226

5227-
letisRecdOrUnionOrStructTyconAllocObservable(_g:TcGlobals)(tycon:Tycon)=
5227+
/// This is an incomplete check for .NET struct types. Returning 'false' doesn't mean the thing is immutable.
5228+
letisRecdOrUnionOrStructTyconDefinitelyMutable(_g:TcGlobals)(tycon:Tycon)=
52285229
if tycon.IsUnionTyconthen
5229-
tycon.UnionCasesArray|> Array.existsisUnionCaseAllocObservable
5230+
tycon.UnionCasesArray|> Array.existsisUnionCaseDefinitelyMutable
52305231
elif tycon.IsRecordTycon|| tycon.IsStructOrEnumTyconthen
5231-
tycon.AllFieldsArray|> Array.existsisRecdOrStructFieldAllocObservable
5232+
tycon.AllFieldsArray|> Array.existsisRecdOrStructFieldDefinitelyMutable
52325233
else
52335234
false
52345235

5235-
letisRecdOrUnionOrStructTyconRefAllocObservable g(tcr:TyconRef)=isRecdOrUnionOrStructTyconAllocObservable g tcr.Deref
5236+
letisRecdOrUnionOrStructTyconRefDefinitelyMutable g(tcr:TyconRef)=isRecdOrUnionOrStructTyconDefinitelyMutable g tcr.Deref
52365237

52375238
// Although from the pure F# perspective exception values cannot be changed, the .NET
52385239
// implementation of exception objects attaches a whole bunch of stack information to
52395240
// each raised object. Hence we treat exception objects as if they have identity
5240-
letisExnAllocObservable(_ecref:TyconRef)=true
5241+
letisExnDefinitelyMutable(_ecref:TyconRef)=true
52415242

52425243
// Some of the implementations of library functions on lists use mutation on the tail
52435244
// of the cons cell. These cells are always private, i.e. not accessible by any other
@@ -5556,11 +5557,11 @@ let mkAndSimplifyMatch spBind exprm matchm ty tree targets =
55565557
typeMutates= DefinitelyMutates| PossiblyMutates| NeverMutates
55575558
exception DefensiveCopyWarningofstring*range
55585559

5559-
letisRecdOrStructTyImmutable g ty=
5560+
letisRecdOrStructTyReadOnly g ty=
55605561
match tryDestAppTy g tywith
55615562
| None->false
55625563
| Some tcref->
5563-
not(isRecdOrUnionOrStructTyconRefAllocObservable g tcref)||
5564+
not(isRecdOrUnionOrStructTyconRefDefinitelyMutable g tcref)||
55645565
tyconRefEq g tcref g.decimal_tcr||
55655566
tyconRefEq g tcref g.date_tcr
55665567

@@ -5575,7 +5576,7 @@ let isRecdOrStructTyImmutable g ty =
55755576
// let g1 = A.G(1)
55765577
// (fun () -> g1.x1)
55775578
//
5578-
// Note:isRecdOrStructTyImmutable implies PossiblyMutates or NeverMutates
5579+
// Note:isRecdOrStructTyReadOnly implies PossiblyMutates or NeverMutates
55795580
//
55805581
// We only do this for true local or closure fields because we can't take addresses of immutable static
55815582
// fields across assemblies.
@@ -5586,7 +5587,7 @@ let CanTakeAddressOfImmutableVal g (v:ValRef) mut =
55865587
not v.IsMemberOrModuleBinding&&
55875588
(match mutwith
55885589
| NeverMutates->true
5589-
| PossiblyMutates->isRecdOrStructTyImmutable g v.Type
5590+
| PossiblyMutates->isRecdOrStructTyReadOnly g v.Type
55905591
| DefinitelyMutates->false)
55915592

55925593
letMustTakeAddressOfVal(g:TcGlobals)(v:ValRef)=
@@ -5605,13 +5606,13 @@ let CanTakeAddressOfRecdFieldRef (g:TcGlobals) (rfref: RecdFieldRef) mut tinst =
56055606
mut<> DefinitelyMutates&&
56065607
// We only do this if the field is defined in this assembly because we can't take addresses across assemblies for immutable fields
56075608
entityRefInThisAssembly g.compilingFslib rfref.TyconRef&&
5608-
isRecdOrStructTyImmutable g(actualTyOfRecdFieldRef rfref tinst)
5609+
isRecdOrStructTyReadOnly g(actualTyOfRecdFieldRef rfref tinst)
56095610

56105611
letCanTakeAddressOfUnionFieldRef(g:TcGlobals)(uref:UnionCaseRef)mut tinst cidx=
56115612
mut<> DefinitelyMutates&&
56125613
// We only do this if the field is defined in this assembly because we can't take addresses across assemblies for immutable fields
56135614
entityRefInThisAssembly g.compilingFslib uref.TyconRef&&
5614-
isRecdOrStructTyImmutable g(actualTyOfUnionFieldRef uref cidx tinst)
5615+
isRecdOrStructTyReadOnly g(actualTyOfUnionFieldRef uref cidx tinst)
56155616

56165617

56175618
let recmkExprAddrOfExprAux g mustTakeAddress useReadonlyForGenericArrayAddress mut e addrExprVal m=

‎src/fsharp/TastOps.fsi‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,9 @@ val TypeHasDefaultValue : TcGlobals -> range -> TType -> bool
10911091

10921092
val isAbstractTycon: Tycon-> bool
10931093

1094-
valisUnionCaseRefAllocObservable: UnionCaseRef-> bool
1095-
valisRecdOrUnionOrStructTyconRefAllocObservable: TcGlobals-> TyconRef-> bool
1096-
valisExnAllocObservable: TyconRef-> bool
1094+
valisUnionCaseRefDefinitelyMutable: UnionCaseRef-> bool
1095+
valisRecdOrUnionOrStructTyconRefDefinitelyMutable: TcGlobals-> TyconRef-> bool
1096+
valisExnDefinitelyMutable: TyconRef-> bool
10971097
val isUnionCaseFieldMutable: TcGlobals-> UnionCaseRef-> int-> bool
10981098
val isExnFieldMutable: TyconRef-> int-> bool
10991099

‎src/fsharp/TypeChecker.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,13 +2169,13 @@ module GeneralizationHelpers =
21692169
| Expr.Op(op, _, args, _) ->
21702170
match op with
21712171
| TOp.Tuple _ -> true
2172-
| TOp.UnionCase uc -> not (isUnionCaseRefAllocObservable uc)
2172+
| TOp.UnionCase uc -> not (isUnionCaseRefDefinitelyMutable uc)
21732173
| TOp.Recd(ctorInfo, tcref) ->
21742174
match ctorInfo with
2175-
| RecdExpr -> not (isRecdOrUnionOrStructTyconRefAllocObservable g tcref)
2175+
| RecdExpr -> not (isRecdOrUnionOrStructTyconRefDefinitelyMutable g tcref)
21762176
| RecdExprIsObjInit -> false
21772177
| TOp.Array -> isNil args
2178-
| TOp.ExnConstr ec -> not (isExnAllocObservable ec)
2178+
| TOp.ExnConstr ec -> not (isExnDefinitelyMutable ec)
21792179

21802180
| TOp.ILAsm([], _) -> true
21812181

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp