@@ -19,13 +19,23 @@ class Node extends TNode {
1919 * if any.
2020 */
2121 Expr asExprAtNode ( ControlFlow:: Nodes:: ElementNode cfn ) {
22- this = TExprNode ( cfn ) and
23- result = cfn .getElement ( )
22+ result = this .( ExprNode ) .getExprAtNode ( cfn )
2423 }
2524
2625 /** Gets the parameter corresponding to this node, if any. */
2726 DotNet:: Parameter asParameter ( ) { result = this .( ParameterNode ) .getParameter ( ) }
2827
28+ /** Gets the definition corresponding to this node, if any. */
29+ AssignableDefinition asDefinition ( ) { result = this .asDefinitionAtNode ( _) }
30+
31+ /**
32+ * Gets the definition corresponding to this node, at control flow node `cfn`,
33+ * if any.
34+ */
35+ AssignableDefinition asDefinitionAtNode ( ControlFlow:: Node cfn ) {
36+ result = this .( AssignableDefinitionNode ) .getDefinitionAtNode ( cfn )
37+ }
38+
2939 /** Gets the type of this node. */
3040 cached
3141 DotNet:: Type getType ( ) { none ( ) }
@@ -140,6 +150,22 @@ class ParameterNode extends Node {
140150 predicate isParameterOf ( DataFlowCallable c , int i ) { none ( ) }
141151}
142152
153+ /** A definition, viewed as a node in a data flow graph. */
154+ class AssignableDefinitionNode extends Node , TSsaDefinitionNode {
155+ private Ssa:: ExplicitDefinition edef ;
156+
157+ AssignableDefinitionNode ( ) { this = TSsaDefinitionNode ( edef ) }
158+
159+ /** Gets the underlying definition. */
160+ AssignableDefinition getDefinition ( ) { result = this .getDefinitionAtNode ( _) }
161+
162+ /** Gets the underlying definition, at control flow node `cfn`, if any. */
163+ AssignableDefinition getDefinitionAtNode ( ControlFlow:: Node cfn ) {
164+ result = edef .getADefinition ( ) and
165+ cfn = edef .getControlFlowNode ( )
166+ }
167+ }
168+
143169/** Gets a node corresponding to expression `e`. */
144170ExprNode exprNode ( DotNet:: Expr e ) { result .getExpr ( ) = e }
145171
@@ -148,6 +174,11 @@ ExprNode exprNode(DotNet::Expr e) { result.getExpr() = e }
148174 */
149175ParameterNode parameterNode ( DotNet:: Parameter p ) { result .getParameter ( ) = p }
150176
177+ /** Gets a node corresponding to the definition `def`. */
178+ AssignableDefinitionNode assignableDefinitionNode ( AssignableDefinition def ) {
179+ result .getDefinition ( ) = def
180+ }
181+
151182/**
152183 * Holds if data flows from `nodeFrom` to `nodeTo` in exactly one local
153184 * (intra-procedural) step.
0 commit comments