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:omitarraydeclarationt [2018/05/09 01:59] (current)
Line 1: Line 1:
 +{{page>​prologast_bodypef_index&​fullpage&​nofooter}}
 +----
  
 +=== omitArrayDeclarationT(#​id) ===
 +
 +This fact is only used for preserving the original appearance of the source code after transformations. It declares that an array initialization (represented by a [[newarrayt|newarrayt]] fact) omits the explicit array instantiation in the orginal source code, being written as 
 +<Code lang-java>​int[] a = {1,2,3}; </​Code>​
 +instead of
 +<Code lang-java>​int[] a = new int[] {1,2,3} </​Code>​
 +
 +=== Arguments ===
 +== ==
 +**#id:** [[newArrayT|newArrayT]]\\ ​
 +ID of the newArrayT element.
 +
 +=== Example: Array initialisation with implicit array instantiation ===
 +==  ==
 +
 +The source code 
 +<Code lang-java>​
 +        int[] a = {1,​2,​3}; ​
 +</​Code>​
 +is represented in JTransformer as
 +<Code lang-prolog>​
 +
 + localT(#​ID,​ #ParentID, _, type(basic, int, 1), '​a',​ #​newArrayT).
 + newArrayT(#​newArrayT,​ #ID, _, [], [IDa0, IDa1, IDa2], type(basic, int, 1)).
 + omitArrayDeclarationT(#​newArrayT). **<​----**
 + literalT(IDa0,​ #newArrayT, _, type(basic, int, 0), '​1'​).
 + literalT(IDa1,​ #newArrayT, _, type(basic, int, 0), '​2'​).
 + literalT(IDa2,​ #newArrayT, _, type(basic, int, 0), '​3'​).
 +
 +</​Code>​
 +Note that the use of the omitArrayDeclarationT(V3). fact is the only difference
 +to the case when an explicit array initialisation is used in the source code (see below).
 +
 +=== Example: Explicit array instantiation ===
 +==  ==
 +
 +The source code 
 +<Code lang-java>​
 +        int[] a = new int[] {1,​2,​3} ​
 +</​Code>​
 +is represented in JTransformer as
 +<Code lang-prolog>​
 +        localT(#ID, #ParentID, _, type(basic, int, 1), '​a',​ #​newArrayT).
 + newArrayT(#​newArrayT,​ #ID, _, [], [IDa0, IDa1, IDa2], type(basic, int, 1)).
 + literalT(IDa0,​ #newArrayT, _, type(basic, int, 0), '​1'​).
 + literalT(IDa1,​ #newArrayT, _, type(basic, int, 0), '​2'​).
 + literalT(IDa2,​ #newArrayT, _, type(basic, int, 0), '​3'​).
 +</​Code>​
 +
 +=== AST Specification ===
 +== ==
 +<​Code>​
 +ast_relation('​Java',​omitArrayDeclarationT,​[
 +     ​ast_arg(id, ​    ​mult(1,​1,​no ), id,   ​[newArrayT]) ​
 +]).
 +</​Code>​
research/jtransformer/api/java/pefs/2.9/omitarraydeclarationt.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019