SDA SE Wiki

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

User Tools

Site Tools



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 fact) omits the explicit array instantiation in the orginal source code, being written as

int[] a = {1,2,3}; 

instead of

int[] a = new int[] {1,2,3} 

Arguments

#id: newArrayT
ID of the newArrayT element.

Example: Array initialisation with implicit array instantiation

The source code

        int[] a = {1,2,3}; 

is represented in JTransformer as


	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').

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

        int[] a = new int[] {1,2,3} 

is represented in JTransformer as

        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').

AST Specification

ast_relation('Java',omitArrayDeclarationT,[
     ast_arg(id,     mult(1,1,no ), id,   [newArrayT]) 
]).
research/jtransformer/api/java/pefs/2.9/omitarraydeclarationt.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019