@@ -213,6 +213,69 @@ class LocalSourceNode extends Node {
213213
214214 /** Gets a call to a method named `name`, where this node flows to the receiver. */
215215 CallNode getAMethodCall ( string name ) { Cached:: hasMethodCall ( this , result , name ) }
216+
217+ /** Gets a call `obj.name` with no arguments, where this node flows to `obj`. */
218+ CallNode getAnAttributeRead ( string name ) {
219+ result = this .getAMethodCall ( name ) and
220+ result .getNumberOfArguments ( ) = 0
221+ }
222+
223+ /**
224+ * Gets a value assigned to `name` on this object, such as the `x` in `obj.name = x`.
225+ *
226+ * Concretely, this gets the argument of any call to `name=` where this node flows to the receiver.
227+ */
228+ Node getAnAttributeWriteValue ( string name ) {
229+ result = this .getAMethodCall ( name + "=" ) .getArgument ( 0 )
230+ }
231+
232+ /**
233+ * Gets an access to an element on this node, such as `obj[key]`.
234+ *
235+ * Concretely this gets a call to `[]` with 1 argument, where this node flows to the receiver.
236+ */
237+ CallNode getAnElementRead ( ) {
238+ result = this .getAMethodCall ( "[]" ) and result .getNumberOfArguments ( ) = 1
239+ }
240+
241+ /**
242+ * Gets an access to the element `key` on this node, such as `obj[:key]`.
243+ *
244+ * Concretely this gets a call to `[]` where this node flows to the receiver
245+ * and the first and only argument has the constant value `key`.
246+ */
247+ CallNode getAnElementRead ( ConstantValue key ) {
248+ result = this .getAnElementRead ( ) and
249+ key = result .getArgument ( 0 ) .getConstantValue ( )
250+ }
251+
252+ /**
253+ * Gets a value stored as an element on this node, such as the `x` in `obj[key] = x`.
254+ *
255+ * Concretely, this gets the second argument from any call to `[]=` where this node flows to the receiver.
256+ */
257+ Node getAnElementWriteValue ( ) {
258+ exists ( CallNode call |
259+ call = this .getAMethodCall ( "[]=" ) and
260+ call .getNumberOfArguments ( ) = 2 and
261+ result = call .getArgument ( 1 )
262+ )
263+ }
264+
265+ /**
266+ * Gets the `x` in `obj[key] = x`, where this node flows to `obj`.
267+ *
268+ * Concretely, this gets the second argument from any call to `[]=` where this node flows to the receiver
269+ * and the first argument has constant value `key`.
270+ */
271+ Node getAnElementWriteValue ( ConstantValue key ) {
272+ exists ( CallNode call |
273+ call = this .getAMethodCall ( "[]=" ) and
274+ call .getNumberOfArguments ( ) = 2 and
275+ call .getArgument ( 0 ) .getConstantValue ( ) = key and
276+ result = call .getArgument ( 1 )
277+ )
278+ }
216279}
217280
218281/**
0 commit comments