@@ -25,7 +25,6 @@ type Type =
2525 | List of genericArg : Type
2626 | FunctionType of FunctionTypeKind * returnType : Type
2727 | GenericParam of name : string
28- | ErasedUnion of genericArgs : Type list
2928 | DeclaredType of FSharpEntity * genericArgs : Type list
3029 | AnonymousRecordType of fieldNames : string [] * genericArgs : Type list
3130
@@ -37,7 +36,6 @@ type Type =
3736 | FunctionType ( LambdaType argType, returnType) -> [ argType; returnType ]
3837 | FunctionType ( DelegateType argTypes, returnType) -> argTypes @ [ returnType ]
3938 | Tuple gen -> gen
40- | ErasedUnion gen -> gen
4139 | DeclaredType (_, gen) -> gen
4240 | _ -> []
4341
@@ -53,64 +51,71 @@ type Type =
5351 let argTypes , returnType = List.splitLast newGen
5452 FunctionType( DelegateType argTypes, returnType)
5553 | Tuple _ -> Tuple newGen
56- | ErasedUnion _ -> ErasedUnion newGen
5754 | DeclaredType ( ent, _) -> DeclaredType( ent, newGen)
5855 | t -> t
5956
60- type ModuleMemberInfo =
61- { Name: string
62- IsValue: bool
63- IsPublic: bool
64- IsMutable: bool
65- IsEntryPoint: bool
66- HasSpread: bool
67- Range: SourceLocation option }
57+ type MemberInfo ( name , ? declaringEntity , ? hasSpread , ? isValue , ? range ) =
58+ member _.Name : string = name
59+ member _.IsValue = defaultArg isValue false
60+ member _.HasSpread = defaultArg hasSpread false
61+ member _.DeclaringEntity : FSharpEntity option = declaringEntity
62+ member _.Range : SourceLocation option = range
63+
64+ type ModuleMemberInfo ( name , ? declaringEntity , ? hasSpread , ? isValue , ? isPublic ,
65+ ?isInstance, ?isMutable, ?isEntryPoint, ?range) =
66+ inherit MemberInfo( name, ?declaringEntity= declaringEntity, ?hasSpread= hasSpread, ?isValue= isValue, ?range= range)
67+
68+ member _.IsPublic = defaultArg isPublic false
69+ member _.IsInstance = defaultArg isInstance false
70+ member _.IsMutable = defaultArg isMutable false
71+ member _.IsEntryPoint = defaultArg isEntryPoint false
72+
73+ type AttachedMemberInfo ( name , declaringEntity , ? hasSpread , ? isValue ,
74+ ?isGetter, ?isSetter, ?isEnumerator, ?range) =
75+ inherit MemberInfo( name, ?declaringEntity= declaringEntity, ?hasSpread= hasSpread, ?isValue= isValue, ?range= range)
76+
77+ member _.IsGetter = defaultArg isGetter false
78+ member _.IsSetter = defaultArg isSetter false
79+ member _.IsEnumerator = defaultArg isEnumerator false
6880
69- type AttachedMemberInfo =
70- { Name: string
71- EntityName: string
72- IsValue: bool
73- IsGetter: bool
74- IsSetter: bool
75- IsEnumerator: bool
76- HasSpread: bool
77- Range: SourceLocation option }
7881 member this.IsMethod =
7982 not this.IsValue && not this.IsGetter && not this.IsSetter && not this.IsEnumerator
8083
81- type ClassImplicitConstructorInfo =
82- { Name: string
83- Entity: FSharpEntity
84- EntityName: string
85- IsEntityPublic: bool
86- IsConstructorPublic: bool
87- HasSpread: bool
88- Base: Expr option
89- Arguments: Ident list
90- BoundConstructorThis: Ident
91- Body: Expr }
92-
93- type UnionConstructorInfo =
94- { Entity: FSharpEntity
95- EntityName: string
96- IsPublic: bool }
97-
98- type CompilerGeneratedConstructorInfo =
99- { Entity: FSharpEntity
100- EntityName: string
101- IsPublic: bool }
102-
103- type ConstructorKind =
104- | ClassImplicitConstructor of ClassImplicitConstructorInfo
105- | UnionConstructor of UnionConstructorInfo
106- | CompilerGeneratedConstructor of CompilerGeneratedConstructorInfo
84+ type ConstructorInfo ( entity , entityName , ? isEntityPublic , ? isUnion , ? range ) =
85+ member _.Entity : FSharpEntity = entity
86+ member _.EntityName : string = entityName
87+ member _.IsEntityPublic = defaultArg isEntityPublic false
88+ member _.IsUnion = defaultArg isUnion false
89+ member _.Range : SourceLocation option = range
90+
91+ type ClassImplicitConstructorInfo ( entity , constructorName , entityName ,
92+ arguments, boundThis, body, baseCall,
93+ ?hasSpread, ?isConstructorPublic,
94+ ?isEntityPublic, ?range) =
95+ inherit ConstructorInfo( entity, entityName, ?isEntityPublic= isEntityPublic, ?range= range)
96+
97+ member _.ConstructorName : string = constructorName
98+ member _.Arguments : Ident list = arguments
99+ member _.BoundThis : Ident = boundThis
100+ member _.Body : Expr = body
101+ member _.BaseCall : Expr option = baseCall
102+ member _.IsConstructorPublic = defaultArg isConstructorPublic false
103+ member _.HasSpread = defaultArg hasSpread false
104+
105+ member _.WithBodyAndBaseCall ( body , baseCall ) =
106+ ClassImplicitConstructorInfo( entity, constructorName, entityName, arguments, boundThis,
107+ body, baseCall, ?hasSpread= hasSpread, ?isConstructorPublic= isConstructorPublic,
108+ ?isEntityPublic= isEntityPublic, ?range= range)
107109
108110type Declaration =
109111 | ActionDeclaration of Expr
110112 /// Note: Non-attached type members become module members
111113 | ModuleMemberDeclaration of args : Ident list * body : Expr * ModuleMemberInfo
112- | AttachedMemberDeclaration of args : Ident list * body : Expr * AttachedMemberInfo
113- | ConstructorDeclaration of ConstructorKind * SourceLocation option
114+ /// Interface and abstract class implementations
115+ | AttachedMemberDeclaration of args : Ident list * body : Expr * AttachedMemberInfo * declaringEntity : FSharpEntity
116+ /// For unions, records and structs
117+ | CompilerGeneratedConstructorDeclaration of ConstructorInfo
118+ | ClassImplicitConstructorDeclaration of ClassImplicitConstructorInfo
114119
115120type File ( sourcePath , decls , ? usedVarNames , ? inlineDependencies ) =
116121 member __.SourcePath : string = sourcePath
@@ -179,7 +184,6 @@ type ValueKind =
179184 | NewTuple of Expr list
180185 | NewRecord of Expr list * NewRecordKind * genArgs : Type list
181186 | NewUnion of Expr list * FSharpUnionCase * FSharpEntity * genArgs : Type list
182- | NewErasedUnion of Expr list * genericArgs : Type list
183187 member this.Type =
184188 match this with
185189 | TypeInfo _ -> MetaType
@@ -200,7 +204,6 @@ type ValueKind =
200204 | DeclaredRecord ent -> DeclaredType( ent, genArgs)
201205 | AnonymousRecord fieldNames -> AnonymousRecordType( fieldNames, genArgs)
202206 | NewUnion (_, _, ent, genArgs) -> DeclaredType( ent, genArgs)
203- | NewErasedUnion (_, genArgs) -> ErasedUnion genArgs
204207
205208type LoopKind =
206209 | While of guard : Expr * body : Expr
@@ -210,55 +213,32 @@ type FunctionKind =
210213 | Lambda of arg : Ident
211214 | Delegate of args : Ident list
212215
213- type SpreadKind =
214- | NoSpread
215- /// The ... spread operator will be applied to last argument
216- | SeqSpread
217- /// If the argument is a tuple apply its members as separate arguments
218- /// (Used for dynamic calls like `foo?bar(4, 5, 6)`)
219- | TupleSpread
220-
221- type CallKind =
222- /// Constructor calls will add the `new` keyword in JS
223- | ConstructorCall of Expr
224- /// Static calls contain a direct reference to the function and will pass `ThisArg` as first argument
225- | StaticCall of Expr
226- /// Instance calls will be applied to `ThisArg` (optionally through member access)
227- | InstanceCall of memb : Expr option
228-
229- type SignatureKind =
230- /// Argument expected types will be checked for the uncurrying optimization
231- | Typed of Type list
232- /// Nested function arguments will be automatically uncurried
233- | AutoUncurrying
234- /// Arguments won't be uncurried
235- | NoUncurrying
236-
237- type ArgInfo =
216+ type CallInfo =
238217 { ThisArg: Expr option
239218 Args: Expr list
240219 /// Argument types as defined in the method signature, this may be slightly different to types of actual argument expressions.
241220 /// E.g.: signature accepts 'a->'b->'c (2-arity) but we pass int->int->int->int (3-arity)
242- SignatureArgTypes: SignatureKind
243- Spread: SpreadKind
244- IsBaseCall: bool
245- IsSelfConstructorCall: bool }
221+ SignatureArgTypes: Type list
222+ HasSpread: bool
223+ AutoUncurrying: bool
224+ /// Must apply `new` keyword when converted to JS
225+ IsJsConstructor: bool }
246226
247227type ReplaceCallInfo =
248228 { CompiledName: string
249229 OverloadSuffix: Lazy < string >
250230 /// See ArgIngo.SignatureArgTypes
251231 SignatureArgTypes: Type list
252- Spread : SpreadKind
232+ HasSpread : bool
253233 IsModuleValue: bool
254234 IsInterface: bool
255235 DeclaringEntityFullName: string
256236 GenericArgs: ( string * Type ) list }
257237
258238type OperationKind =
259- | Call of kind : CallKind * info : ArgInfo
239+ | Call of callee : Expr * info : CallInfo
260240 | CurriedApply of applied : Expr * args : Expr list
261- | Emit of macro : string * args : ArgInfo option
241+ | Emit of macro : string * args : CallInfo option
262242 | UnaryOperation of UnaryOperator * Expr
263243 | BinaryOperation of BinaryOperator * left : Expr * right : Expr
264244 | LogicalOperation of LogicalOperator * left : Expr * right : Expr
0 commit comments