SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools



selectT(#id, #parent, #encl, 'name', #selected, #typeRef)

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

Arguments

#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: typeinst
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" 

Sample Java Code


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”.

Its PEF Representation

     
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 Specification

ast_node_type_spec(selectT,[
     ast_arg(id,      mult(1,1,no ), id,  [selectT]),
     ast_arg(parent,  mult(1,1,no ), id,  [id]),
     ast_arg(encl,    mult(1,1,no ), id,  [methodT, constructorT, classInitializerT, fieldT, annotationMemberT, packageT, classT]),
     ast_arg(name,    mult(1,1,no ), attr,[atomic]),
     ast_arg(selected,mult(1,1,no ), id,  [type_inst]),
     ast_arg(typeRef, mult(1,1,no ), id,  [classT])
]).
research/jtransformer/api/java/pefs/4.2/selectt.txt · Last modified: 2018/12/11 13:24 by Günter Kniesel

SEWiki, © 2024