@@ -40,14 +40,6 @@ internal abstract class DeclarationsProvider
40
40
41
41
public virtual string GetWorkloadMethodCall ( string passArguments ) => $ "{ Descriptor . WorkloadMethod . Name } ({ passArguments } )";
42
42
43
- public virtual string ConsumeField => null ;
44
-
45
- protected abstract Type OverheadMethodReturnType { get ; }
46
-
47
- public string OverheadMethodReturnTypeName => OverheadMethodReturnType . GetCorrectCSharpTypeName ( ) ;
48
-
49
- public abstract string OverheadImplementation { get ; }
50
-
51
43
private string GetMethodName ( MethodInfo method )
52
44
{
53
45
if ( method == null )
@@ -73,62 +65,21 @@ internal class VoidDeclarationsProvider : DeclarationsProvider
73
65
public VoidDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
74
66
75
67
public override string ReturnsDefinition => "RETURNS_VOID" ;
76
-
77
- protected override Type OverheadMethodReturnType => typeof ( void ) ;
78
-
79
- public override string OverheadImplementation => string . Empty ;
80
68
}
81
69
82
70
internal class NonVoidDeclarationsProvider : DeclarationsProvider
83
71
{
84
72
public NonVoidDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
85
73
86
- public override string ConsumeField
87
- => ! Consumer . IsConsumable ( WorkloadMethodReturnType ) && Consumer . HasConsumableField ( WorkloadMethodReturnType , out var field )
88
- ? $ ".{ field . Name } "
89
- : null ;
90
-
91
- protected override Type OverheadMethodReturnType
92
- => Consumer . IsConsumable ( WorkloadMethodReturnType )
93
- ? WorkloadMethodReturnType
94
- : ( Consumer . HasConsumableField ( WorkloadMethodReturnType , out var field )
95
- ? field . FieldType
96
- : typeof ( int ) ) ; // we return this simple type because creating bigger ValueType could take longer than benchmarked method itself
97
-
98
- public override string OverheadImplementation
99
- {
100
- get
101
- {
102
- string value ;
103
- var type = OverheadMethodReturnType ;
104
- if ( type . GetTypeInfo ( ) . IsPrimitive )
105
- value = $ "default({ type . GetCorrectCSharpTypeName ( ) } )";
106
- else if ( type . GetTypeInfo ( ) . IsClass || type . GetTypeInfo ( ) . IsInterface )
107
- value = "null" ;
108
- else
109
- value = SourceCodeHelper . ToSourceCode ( Activator . CreateInstance ( type ) ) + ";" ;
110
- return $ "return { value } ;";
111
- }
112
- }
113
-
114
- public override string ReturnsDefinition
115
- => Consumer . IsConsumable ( WorkloadMethodReturnType ) || Consumer . HasConsumableField ( WorkloadMethodReturnType , out _ )
116
- ? "RETURNS_CONSUMABLE"
117
- : "RETURNS_NON_CONSUMABLE_STRUCT" ;
74
+ public override string ReturnsDefinition => "RETURNS_NON_VOID" ;
118
75
}
119
76
120
77
internal class ByRefDeclarationsProvider : NonVoidDeclarationsProvider
121
78
{
122
79
public ByRefDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
123
80
124
- protected override Type OverheadMethodReturnType => typeof ( IntPtr ) ;
125
-
126
81
public override string WorkloadMethodReturnTypeName => base . WorkloadMethodReturnTypeName . Replace ( "&" , string . Empty ) ;
127
82
128
- public override string ConsumeField => null ;
129
-
130
- public override string OverheadImplementation => $ "return default(System.{ nameof ( IntPtr ) } );";
131
-
132
83
public override string ReturnsDefinition => "RETURNS_BYREF" ;
133
84
134
85
public override string WorkloadMethodReturnTypeModifiers => "ref" ;
@@ -138,8 +89,6 @@ internal class ByReadOnlyRefDeclarationsProvider : ByRefDeclarationsProvider
138
89
{
139
90
public ByReadOnlyRefDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
140
91
141
- public override string ReturnsDefinition => "RETURNS_BYREF_READONLY" ;
142
-
143
92
public override string WorkloadMethodReturnTypeModifiers => "ref readonly" ;
144
93
}
145
94
0 commit comments