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
48 changes: 15 additions & 33 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,6 @@ let mkLdfldMethodDef (ilMethName, iLAccess, isStatic, ilTy, ilFieldName, ilPropT

ilMethodDef.With(customAttrs = mkILCustomAttrs customAttrs).WithSpecialName

/// Make a method that simply stores a field
let mkStsfldMethodDef (ilMethName, iLAccess, isStatic, ilTy, ilFieldName, ilPropType, customAttrs) =
let ilFieldSpec = mkILFieldSpecInTy (ilTy, ilFieldName, ilPropType)
let ilParams = [ mkILParamNamed ("value", ilPropType) ]
let ilReturn = mkILReturn ILType.Void

let ilMethodDef =
if isStatic then
let body =
mkMethodBody (true, [], 2, nonBranchingInstrsToCode [ mkLdarg0; mkNormalStsfld ilFieldSpec ], None, None)

mkILNonGenericStaticMethod (ilMethName, iLAccess, ilParams, ilReturn, body)

else
let body =
mkMethodBody (true, [], 2, nonBranchingInstrsToCode [ mkLdarg0; mkLdarg 1us; mkNormalStfld ilFieldSpec ], None, None)

mkILNonGenericInstanceMethod (ilMethName, iLAccess, ilParams, ilReturn, body)

ilMethodDef.With(customAttrs = mkILCustomAttrs customAttrs).WithSpecialName

/// Choose the constructor parameter names for fields
let ChooseParamNames fieldNamesAndTypes =
let takenFieldNames = fieldNamesAndTypes |> List.map p23 |> Set.ofList
Expand Down Expand Up @@ -634,12 +613,12 @@ let mkLocalPrivateAttributeWithDefaultConstructor (cenv: cenv, name: string) =
ILTypeInit.BeforeField
)

let mkILNonGenericInstanceProperty (name, ilTypeRef, ilType, propertyAttribute, customAttributes) =
let mkILNonGenericInstanceProperty (name, ilType, propertyAttribute, customAttributes, getMethod, setMethod) =
ILPropertyDef(
name = name,
attributes = propertyAttribute,
setMethod = Some(mkILMethRef (ilTypeRef, ILCallingConv.Instance, "set_" + name, 0, [ ilType ], ILType.Void)),
getMethod = Some(mkILMethRef (ilTypeRef, ILCallingConv.Instance, "get_" + name, 0, [], ilType)),
setMethod = setMethod,
getMethod = getMethod,
callingConv = ILThisConvention.Instance,
propertyType = ilType,
init = None,
Expand All @@ -661,11 +640,15 @@ let mkLocalPrivateAttributeWithPropertyConstructors (cenv, name: string, attrPro
(cenv.g.AddMethodGeneratedAttributes(
mkLdfldMethodDef ($"get_{name}", ILMemberAccess.Public, false, ilTy, fieldName, ilType, [])
)),
(cenv.g.AddMethodGeneratedAttributes(
mkStsfldMethodDef ($"set_{name}", ILMemberAccess.Private, false, ilTy, fieldName, ilType, [])
)),
(cenv.g.AddPropertyGeneratedAttributes(
mkILNonGenericInstanceProperty (name, ilTypeRef, ilType, PropertyAttributes.None, emptyILCustomAttrs)
mkILNonGenericInstanceProperty (
name,
ilType,
PropertyAttributes.None,
emptyILCustomAttrs,
Some(mkILMethRef (ilTypeRef, ILCallingConv.Instance, "get_" + name, 0, [], ilType)),
None
)
)),
(name, fieldName, ilType))

Expand All @@ -676,7 +659,7 @@ let mkLocalPrivateAttributeWithPropertyConstructors (cenv, name: string, attrPro
Some cenv.g.ilg.typ_Attribute.TypeSpec,
ilTy,
[],
(ilElements |> List.map (fun (_, _, _, _, fieldInfo) -> fieldInfo)),
(ilElements |> List.map (fun (_, _, _, fieldInfo) -> fieldInfo)),
ILMemberAccess.Public,
None,
None
Expand All @@ -691,12 +674,11 @@ let mkLocalPrivateAttributeWithPropertyConstructors (cenv, name: string, attrPro
ILTypes.Empty,
mkILMethods (
ilCtorDef
:: (ilElements
|> List.fold (fun acc (_, getter, setter, _, _) -> getter :: (setter :: acc)) [])
:: (ilElements |> List.fold (fun acc (_, getter, _, _) -> getter :: acc) [])
),
mkILFields (ilElements |> List.map (fun (field, _, _, _, _) -> field)),
mkILFields (ilElements |> List.map (fun (field, _, _, _) -> field)),
emptyILTypeDefs,
mkILProperties (ilElements |> List.map (fun (_, _, _, property, _) -> property)),
mkILProperties (ilElements |> List.map (fun (_, _, property, _) -> property)),
emptyILEvents,
emptyILCustomAttrs,
ILTypeInit.BeforeField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,19 +586,6 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_Type(class [runtime]System.Type 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@
IL_0007: ret
}

.method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
get_MemberType() cil managed
{
Expand All @@ -611,33 +598,18 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@
IL_0007: ret
}

.property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
MemberType()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes)
.get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType()
}
.property instance class [runtime]System.Type
Type()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_Type(class [runtime]System.Type)
.get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,19 +588,6 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_Type(class [runtime]System.Type 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@
IL_0007: ret
}

.method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
get_MemberType() cil managed
{
Expand All @@ -613,33 +600,18 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@
IL_0007: ret
}

.property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
MemberType()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes)
.get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType()
}
.property instance class [runtime]System.Type
Type()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_Type(class [runtime]System.Type)
.get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,19 +576,6 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_Type(class [runtime]System.Type 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@
IL_0007: ret
}

.method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
get_MemberType() cil managed
{
Expand All @@ -601,33 +588,18 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@
IL_0007: ret
}

.property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
MemberType()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes)
.get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType()
}
.property instance class [runtime]System.Type
Type()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_Type(class [runtime]System.Type)
.get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,19 +653,6 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_Type(class [runtime]System.Type 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@
IL_0007: ret
}

.method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
get_MemberType() cil managed
{
Expand All @@ -678,33 +665,18 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@
IL_0007: ret
}

.property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
MemberType()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes)
.get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType()
}
.property instance class [runtime]System.Type
Type()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_Type(class [runtime]System.Type)
.get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,19 +587,6 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_Type(class [runtime]System.Type 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@
IL_0007: ret
}

.method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
get_MemberType() cil managed
{
Expand All @@ -612,33 +599,18 @@
IL_0006: ret
}

.method private hidebysig specialname instance void
set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@
IL_0007: ret
}

.property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
MemberType()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes)
.get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType()
}
.property instance class [runtime]System.Type
Type()
{
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
.set instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::set_Type(class [runtime]System.Type)
.get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type()
}
}
Expand Down
Loading