@@ -50,6 +50,11 @@ class MethodImplementation extends EntryPoint, @cil_method_implementation {
5050 int getStackSize ( ) { cil_method_stack_size ( this , result ) }
5151
5252 override string toString ( ) { result = getMethod ( ) .toString ( ) }
53+
54+ /** Gets a string representing the disassembly of this implementation. */
55+ string getDisassembly ( ) {
56+ result = concat ( Instruction i | i = this .getAnInstruction ( ) | i .toString ( ) , ", " order by i .getIndex ( ) )
57+ }
5358}
5459
5560/**
@@ -63,6 +68,11 @@ class Method extends DotNet::Callable, Element, Member, TypeContainer, DataFlowN
6368 */
6469 MethodImplementation getAnImplementation ( ) { result .getMethod ( ) = this }
6570
71+ /** Gets the "best" implementation of this method, if any. */
72+ BestImplementation getImplementation ( ) {
73+ result = getAnImplementation ( )
74+ }
75+
6676 override Method getMethod ( ) { result = this }
6777
6878 override string getName ( ) { cil_method ( this , result , _, _) }
@@ -102,7 +112,7 @@ class Method extends DotNet::Callable, Element, Member, TypeContainer, DataFlowN
102112 int getCallPopCount ( ) { result = count ( getRawParameter ( _) ) }
103113
104114 /** Gets a method called by this method. */
105- Method getACallee ( ) { result = getAnImplementation ( ) .getAnInstruction ( ) .( Call ) .getTarget ( ) }
115+ Method getACallee ( ) { result = getImplementation ( ) .getAnInstruction ( ) .( Call ) .getTarget ( ) }
106116
107117 /** Holds if this method is `virtual`. */
108118 predicate isVirtual ( ) { cil_virtual ( this ) }
@@ -168,10 +178,10 @@ class Method extends DotNet::Callable, Element, Member, TypeContainer, DataFlowN
168178 /** Gets a method that overrides this method, if any. */
169179 final Method getAnOverrider ( ) { result .getOverriddenMethod ( ) = this }
170180
171- override predicate hasBody ( ) { exists ( getAnImplementation ( ) ) }
181+ override predicate hasBody ( ) { exists ( getImplementation ( ) ) }
172182
173183 override predicate canReturn ( DotNet:: Expr expr ) {
174- exists ( Return ret | ret .getImplementation ( ) . getMethod ( ) = this and expr = ret .getExpr ( ) )
184+ exists ( Return ret | ret .getImplementation ( ) = this . getImplementation ( ) and expr = ret .getExpr ( ) )
175185 }
176186}
177187
@@ -198,7 +208,7 @@ class InstanceConstructor extends Constructor {
198208/** A method that always returns the `this` parameter. */
199209class ChainingMethod extends Method {
200210 ChainingMethod ( ) {
201- forex ( Return ret | ret = getAnImplementation ( ) .getAnInstruction ( ) |
211+ forex ( Return ret | ret = getImplementation ( ) .getAnInstruction ( ) |
202212 ret .getExpr ( ) instanceof ThisAccess
203213 )
204214 }
@@ -232,7 +242,7 @@ class TrivialGetter extends Method {
232242
233243 /** Gets the underlying field of this getter. */
234244 Field getField ( ) {
235- getAnImplementation ( ) .getAnInstruction ( ) .( FieldReadAccess ) .getTarget ( ) = result
245+ getImplementation ( ) .getAnInstruction ( ) .( FieldReadAccess ) .getTarget ( ) = result
236246 }
237247}
238248
@@ -249,7 +259,7 @@ class Setter extends Accessor {
249259 */
250260class TrivialSetter extends Method {
251261 TrivialSetter ( ) {
252- exists ( MethodImplementation impl | impl = getAnImplementation ( ) |
262+ exists ( MethodImplementation impl | impl = getImplementation ( ) |
253263 impl .getInstruction ( 0 ) instanceof ThisAccess and
254264 impl .getInstruction ( 1 ) .( ParameterReadAccess ) .getTarget ( ) .getIndex ( ) = 1 and
255265 impl .getInstruction ( 2 ) instanceof FieldWriteAccess
@@ -258,7 +268,7 @@ class TrivialSetter extends Method {
258268
259269 /** Gets the underlying field of this setter. */
260270 Field getField ( ) {
261- result = getAnImplementation ( ) .getAnInstruction ( ) .( FieldWriteAccess ) .getTarget ( )
271+ result = getImplementation ( ) .getAnInstruction ( ) .( FieldWriteAccess ) .getTarget ( )
262272 }
263273}
264274
0 commit comments