@@ -17,10 +17,7 @@ public bool GetParent<T>(out T @out)
17
17
{
18
18
@out = default ( T ) ;
19
19
20
- if ( Parent == null )
21
- return false ;
22
-
23
- var v = Parent . Object ;
20
+ var v = Parent ? . Object ;
24
21
if ( ! ( v is T ) )
25
22
return false ;
26
23
@@ -45,8 +42,7 @@ public bool GetAncestors<T>(ref Stack<object> ancestors)
45
42
{
46
43
ancestors . Push ( this ) ;
47
44
48
- T value ;
49
- if ( GetParent ( out value ) )
45
+ if ( GetParent ( out T value ) )
50
46
{
51
47
ancestors . Push ( value ) ;
52
48
return true ;
@@ -59,10 +55,7 @@ public bool GetAncestors<T>(ref Stack<object> ancestors)
59
55
60
56
public class ASTRecord < T > : ASTRecord
61
57
{
62
- public T Value
63
- {
64
- get { return ( T ) Object ; }
65
- }
58
+ public T Value => ( T ) Object ;
66
59
67
60
public override string ToString ( )
68
61
{
@@ -130,12 +123,10 @@ static class ASTRecordExtensions
130
123
{
131
124
public static bool IsBaseClass ( this ASTRecord record )
132
125
{
133
- Class decl ;
134
- if ( ! record . GetParent ( out decl ) )
126
+ if ( ! record . GetParent ( out Class decl ) )
135
127
return false ;
136
128
137
- var recordDecl = record . Object as Class ;
138
- return recordDecl != null && recordDecl == decl . BaseClass ;
129
+ return record . Object is Class recordDecl && recordDecl == decl . BaseClass ;
139
130
}
140
131
141
132
public static bool IsFieldValueType ( this ASTRecord record )
@@ -145,25 +136,22 @@ public static bool IsFieldValueType(this ASTRecord record)
145
136
return false ;
146
137
147
138
var field = ( Field ) ancestors . Pop ( ) ;
148
-
149
- Class decl ;
150
- return field . Type . Desugar ( ) . TryGetClass ( out decl ) && decl . IsValueType ;
139
+ return field . Type . Desugar ( ) . TryGetClass ( out var decl ) && decl . IsValueType ;
151
140
}
152
141
153
142
public static bool IsEnumNestedInClass ( this ASTRecord < Declaration > record )
154
143
{
155
- Enumeration @enum = record . Value as Enumeration ;
144
+ var @enum = record . Value as Enumeration ;
156
145
var typedDecl = record . Value as ITypedDecl ;
157
- if ( @enum != null
158
- || ( typedDecl ? . Type ? . TryGetEnum ( out @enum ) ) . GetValueOrDefault ( ) )
146
+ if ( @enum != null || ( typedDecl ? . Type ? . TryGetEnum ( out @enum ) ) . GetValueOrDefault ( ) )
159
147
{
160
- return @enum . Namespace is Class ;
148
+ return @enum ? . Namespace is Class ;
161
149
}
162
150
163
151
return false ;
164
152
}
165
153
166
- public static bool IsClassReturn ( this ASTRecord record )
154
+ public static bool FunctionReturnsClassByValue ( this ASTRecord record )
167
155
{
168
156
var ancestors = new Stack < object > ( ) ;
169
157
if ( ! record . GetAncestors < Function > ( ref ancestors ) )
@@ -177,8 +165,7 @@ public static bool IsClassReturn(this ASTRecord record)
177
165
178
166
public static bool IsDelegate ( this ASTRecord record )
179
167
{
180
- var typedef = record . Object as TypedefDecl ;
181
- return typedef != null && typedef . Type . GetPointee ( ) is FunctionType ;
168
+ return record . Object is TypedefDecl typedef && typedef . Type . GetPointee ( ) is FunctionType ;
182
169
}
183
170
}
184
171
@@ -223,7 +210,7 @@ public override bool VisitType(Type type, TypeQualifiers quals)
223
210
return false ;
224
211
}
225
212
226
- public bool ShouldVisitChilds ( Declaration decl )
213
+ private bool ShouldVisitChilds ( Declaration decl )
227
214
{
228
215
if ( decl == translationUnit )
229
216
return true ;
0 commit comments