SDA SE WikiSoftware Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
Represents the access to enclosing instances in inner and anonymous classes
OuterClassName.this.f(); // invoke method f() from the enclosing instance OuterClassName.super.f(); // invoke method f() from the superclass of the enclosing instance
and the access to class literals:
TypeName.class; // get the object representing the type TypeName
#id: id
the unique ID assigned to this fact.
#parent: id
ID of the parent node.
#encl: methodT, constructorT, classInitializerT, fieldT, annotationMemberT, annotationT
ID of the method declaration that contains this statement or of the field declaration whose initializer contains this statement.
'name': atom
either 'this' or 'super' or 'class'.
#selected: Type reference
the id of the reference to the enclosing type, for instance, “OuterClassName” in the following example
OuterClassName.this.f(); // invoke method f() from the enclosing instance OuterClassName.super.f(); // invoke method f() from the superclass of the enclosing instance
or the type accessed by a class literal, e.g. “TypeName”:
TypeName.class; // get the object representing the type TypeName
#type: classT
ID of the class declaration representing the selected type. See comments below:
OuterClassName.this.f(); // Selected type = Id of fact for class "OuterClassName" OuterClassName.super.f(); // Selected type = Id of fact for superclass of class "OuterClassName"
or the type accessed by a class literal, e.g. “TypeName”:
TypeName.class; // Selected type = Id of fact for class "TypeName"
class Outer {
int x = 5;
class Inner {
int x = 10;
public void test() {
System.out.println( Outer.this.x );
}
}
}
By instantiating a new Inner object myinnerobject and calling myinnerobject.test();
the result would be “5”.
classT(outerId, Pckg, 'Outer',_),
execT(V15, V14, VV12, V16),
callT(V16, V15, VV12, V17, 'println', [V18], V19),
getFieldT(V17, V16, VV12, V20, 'out', V21),
typeRefT(V20, V17, VV12, V22),
getFieldT(V18, V16, VV12, selectId, 'x', V24),
selectT(selectId, V18, VV12, this, typeRefId, outerId).
typeRefT(typeRefId, _, _, outerId).
ast_node_def('Java',selectT,[
ast_arg(id, mult(1,1,no ), id, [selectT]), % <-- convention!!!
ast_arg(parent, mult(1,1,no ), id, [id]), % <-- convention!!!
ast_arg(encl, mult(1,1,no ), id, [methodT, constructorT, classInitializerT, fieldT, annotationMemberT, classT]),
ast_arg(name, mult(1,1,no ), attr,[atom]),
ast_arg(selected,mult(1,1,no ), id, [typeInst]),
ast_arg(typeRef, mult(1,1,no ), id, [classT])
]).