-
Notifications
You must be signed in to change notification settings - Fork 860
Expand file tree
/
Copy pathCheckIncrementalClasses.fsi
More file actions
165 lines (136 loc) · 6.28 KB
/
CheckIncrementalClasses.fsi
File metadata and controls
165 lines (136 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
module internal FSharp.Compiler.CheckIncrementalClasses
open Internal.Utilities.Collections
open FSharp.Compiler.CheckExpressions
open FSharp.Compiler.CheckBasics
open FSharp.Compiler.CompilerGlobalState
open FSharp.Compiler.Syntax
open FSharp.Compiler.TcGlobals
open FSharp.Compiler.Text
open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.Xml
exception ParameterlessStructCtor of range: range
/// Typechecked info for implicit static constructor
type StaticCtorInfo =
{
/// The TyconRef for the type being defined
TyconRef: TyconRef
/// The copy of the type parameters allocated for implicit construction
IncrCtorDeclaredTypars: Typars
/// The value representing the static implicit constructor.
/// Lazy to ensure the static ctor value is only published if needed.
StaticCtorValInfo: Lazy<Val list * Val * ValScheme>
/// The name generator used to generate the names of fields etc. within the type.
NameGenerator: NiceNameGenerator
}
/// Typechecked info for implicit instance constructor and it's arguments
type IncrClassCtorInfo =
{
/// The value representing the implicit constructor.
InstanceCtorVal: Val
/// The type of the implicit constructor, representing as a ValScheme.
InstanceCtorValScheme: ValScheme
/// The values representing the arguments to the implicit constructor.
InstanceCtorArgs: Val list
/// The reference cell holding the 'this' parameter within the implicit constructor so it can be referenced in the
/// arguments passed to the base constructor
InstanceCtorSafeThisValOpt: Val option
/// Data indicating if safe-initialization checks need to be inserted for this type.
InstanceCtorSafeInitInfo: SafeInitData
/// The value representing the 'base' variable within the implicit instance constructor.
InstanceCtorBaseValOpt: Val option
/// The value representing the 'this' variable within the implicit instance constructor.
InstanceCtorThisVal: Val
}
/// Indicates how is a 'let' bound value in a class with implicit construction is represented in
/// the TAST ultimately produced by type checking.
type IncrClassValRepr =
// e.g representation for 'let v = 3' if it is not used in anything given a method representation
| InVar of isArg: bool
// e.g representation for 'let v = 3'
| InField of isStatic: bool * staticCountForSafeInit: int * fieldRef: RecdFieldRef
// e.g representation for 'let f x = 3'
| InMethod of isStatic: bool * value: Val * valReprInfo: ValReprInfo
/// IncrClassReprInfo represents the decisions we make about the representation of 'let' and 'do' bindings in a
/// type defined with implicit class construction.
type IncrClassReprInfo =
{
/// Indicates the set of field names taken within one incremental class
TakenFieldNames: Set<string>
RepInfoTcGlobals: TcGlobals
/// vals mapped to representations
ValReprs: Zmap<Val, IncrClassValRepr>
/// vals represented as fields or members from this point on
ValsWithRepresentation: Zset<Val>
}
static member IsMethodRepr: cenv: TcFileState -> bind: Binding -> bool
// Publish the fields of the representation to the type
member PublishIncrClassFields:
cenv: TcFileState *
denv: DisplayEnv *
cpath: CompilationPath *
staticCtorInfo: StaticCtorInfo *
safeStaticInitInfo: SafeInitData ->
unit
/// Given localRep saying how locals have been represented, e.g. as fields.
/// Given an expr under a given thisVal context.
member FixupIncrClassExprPhase2C:
cenv: TcFileState ->
thisValOpt: Val option ->
safeStaticInitInfo: SafeInitData ->
thisTyInst: TypeInst ->
expr: Expr ->
Expr
/// Represents a single group of bindings in a class with an implicit constructor
type IncrClassBindingGroup =
| IncrClassBindingGroup of bindings: Binding list * isStatic: bool * isRecursive: bool
| IncrClassDo of expr: Expr * isStatic: bool * range: Range
type IncrClassConstructionBindingsPhase2C =
| Phase2CBindings of IncrClassBindingGroup list
| Phase2CCtorJustAfterSuperInit
| Phase2CCtorJustAfterLastLet
/// Check and elaborate the "left hand side" of the implicit class construction
/// syntax.
val TcStaticImplicitCtorInfo_Phase2A:
cenv: TcFileState * env: TcEnv * tcref: TyconRef * m: range * copyOfTyconTypars: Typar list -> StaticCtorInfo
/// Check and elaborate the "left hand side" of the implicit class construction
/// syntax.
val TcImplicitCtorInfo_Phase2A:
cenv: TcFileState *
env: TcEnv *
tpenv: UnscopedTyparEnv *
tcref: TyconRef *
vis: SynAccess option *
attrs: SynAttribute list *
pat: SynPat *
thisIdOpt: Ident option *
baseValOpt: Val option *
safeInitInfo: SafeInitData *
m: range *
copyOfTyconTypars: Typar list *
objTy: TType *
thisTy: TType *
xmlDoc: PreXmlDoc ->
IncrClassCtorInfo
/// <summary>
/// Given a set of 'let' bindings (static or not, recursive or not) that make up a class,
/// generate their initialization expression(s).
/// </summary>
/// <param name='cenv'></param>
/// <param name='env'></param>
/// <param name='staticCtorInfo'>The information about the static implicit constructor</param>
/// <param name='instanceInfo'>The lhs information about the implicit constructor, the call to the super class constructor and whether we should we place a sequence point at the 'inheritedTys call?</param>
/// <param name='decs'>The declarations</param>
/// <param name='memberBinds'></param>
/// <param name='generalizedTyparsForRecursiveBlock'>Record any unconstrained type parameters generalized for the outer members as "free choices" in the let bindings</param>
/// <param name='safeStaticInitInfo'></param>
val MakeCtorForIncrClassConstructionPhase2C:
cenv: TcFileState *
env: TcEnv *
staticCtorInfo: StaticCtorInfo *
instanceInfo: (IncrClassCtorInfo * Expr * bool) option *
decs: IncrClassConstructionBindingsPhase2C list *
memberBinds: Binding list *
generalizedTyparsForRecursiveBlock: Typar list *
safeStaticInitInfo: SafeInitData ->
Expr option * Expr option * Binding list * IncrClassReprInfo