objectIdentifier

The "object identifier" of a node can be used to differentiate different "objects" that a node (most likely a Reference) refers to.

In the most basic use-case the objectIdentifier of a simple variable reference is the hash-code of its VariableDeclaration. Consider the following code:

int a = 1;
printf(a);

In this case, the "object identifier" of the Reference a in the second line is the hash-code of the VariableDeclaration a in the first line.

However, we also need to differentiate between different objects that are used as fields as well as different instances of the fields. Consider the second example:

struct myStruct {
int field;
};

struct myStruct a;
a.field = 1;

struct myStruct b;
b.field = 2;

In this case, the objectIdentifier of the MemberExpression a is a combination of the hash-code of the VariableDeclaration a as well as the FieldDeclaration of field. The same applies for b. If we would only rely on the VariableDeclaration, we would not be sensitive to fields, if we would only rely on the FieldDeclaration, we would not be sensitive to different object instances. Therefore, we consider both.

Please note however, that this current, very basic implementation does not consider perform any kind of pointer or alias analysis. This means that even though the "contents" of two variables that are the same (for example, because one is assigned into the other), they will be considered different "objects".


Implements Node.objectIdentifier for a MemberExpression.


Implements Node.objectIdentifier for a Reference.