SDA SE Wiki

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

User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

research:jtransformer:api:java:pefs:2.9:selectt [2018/05/09 01:59] (current)
Line 1: Line 1:
 +{{page>​prologast_bodypef_index&​fullpage&​nofooter}}
  
 +----
 +
 +=== selectT(#​id,​ #parent, #encl, '​name',​ ENCLOSING_TYPE,​ #​selectedType) ​ ===
 +
 +Represents the access to [[http://​www.j2ee.me/​docs/​books/​tutorial/​java/​javaOO/​nested.html|enclosing instances]] in inner and anonymous classes ​
 +
 +<Code lang-java>​
 +OuterClassName.this.f(); ​  // invoke method f() from the enclosing instance
 +OuterClassName.super.f(); ​ // invoke method f() from the superclass of the enclosing instance ​
 +</​Code>​
 +
 +and the access to class literals:
 +
 +<Code lang-java>​
 +TypeName.class; ​          // get the object representing the type TypeName
 +</​Code>​
 +
 +
 +/* Was formerly used for field and method accesses, which are now represented by [[getfieldt|getFieldT]] and [[callt|callT]]. ​ */
 +
 +=== Arguments ===
 +== ==
 +**#id:** id\\ 
 +the unique ID assigned to this fact.
 +
 +**#​parent:​** id\\ 
 +ID of the parent node. 
 +
 +**#encl:** [[methodT|methodT]],​ [[constructorT|constructorT]],​ [[classInitializerT|classInitializerT]],​ [[fieldt|fieldT]],​ [[annotationMemberT|annotationMemberT]],​ [[annotationT|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:​** [[typeterm|typeterm]]\\ ​
 +the enclosing type, for instance, "​OuterClassName"​ in the following example
 +
 +<Code lang-java>​
 +OuterClassName.this.f(); ​  // invoke method f() from the enclosing instance
 +OuterClassName.super.f(); ​ // invoke method f() from the superclass of the enclosing instance ​
 +</​Code>​
 +
 +or the type accessed by a class literal, e.g. "​TypeName":​
 +
 +<Code lang-java>​
 +TypeName.class; ​          // get the object representing the type TypeName
 +</​Code>​
 +
 +**#type:** [[classt|classT]]\\ ​
 +ID of the class declaration representing the selected type. See comments below:
 +
 +<Code lang-java>​
 +OuterClassName.this.f(); ​  // Selected type = Id of fact for class "​OuterClassName"​
 +OuterClassName.super.f(); ​ // Selected type = Id of fact for superclass of class "​OuterClassName" ​
 +</​Code>​
 +
 +or the type accessed by a class literal, e.g. "​TypeName":​
 +
 +<Code lang-java>​
 +TypeName.class; ​          // Selected type = Id of fact for class "​TypeName" ​
 +</​Code>​
 +  ​
 +
 +=== Sample Java Code ===
 +== ==
 +<Code lang-java>​
 +
 +class Outer {
 +     int x = 5;
 +     class Inner {
 +         int x = 10;
 +         public void test() {
 +             System.out.println( Outer.this.x );
 +         }
 +     }
 +}  ​
 +</​Code>​
 +By instantiating a new Inner object myinnerobject and calling ''​myinnerobject.test();'' ​
 +the result would be "​5"​.
 +
 +
 +
 +=== Its PEF Representation ===
 +== ==
 +<Code lang-prolog>​
 +     
 +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, type(class, V22, 0)),
 + ​getFieldT(V18,​ V16, VV12, selectId, '​x',​ V24),
 + ​selectT(selectId,​ V18, VV12, this, type(class, outerId, 0), outerId).
 +</​Code>​
 +
 +=== AST Specification ===
 +== ==
 +<​Code>​
 +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 ), attr,​[typeTermType]),​
 +     ​ast_arg(type, ​   mult(1,1,no ), id,  [classT]) ​
 +]).
 +</​Code>​
research/jtransformer/api/java/pefs/2.9/selectt.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019