SDA SE Wiki

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

User Tools

Site Tools



switchT(#id, #parent, #enclMethod, #expr, [#statement_1, ...])

Represents the switch statement.

Arguments

#id: id
the unique ID assigned to this fact.

#parent: id
ID of the parent node.

#encl: methodT, constructorT, classInitializerT
ID of the enclosing method declaration.

#expr: expression
ID of the selection expression (the variable used to switch).

[#statement_1, …]: statement
list of the statements in the switch. Cases (caseT) are a special kind of statement here, much like labels. The default statement is a case statement with the label 'null'.

Sample Java Code

void mySwitch() {
	int month = 1;
	switch (month) {// corresponding code line to switchT
	case 1:     //caseT                     
	   System.out.println("January");
	   break;   //breakT
	default:    //caseT
	   System.out.println("Invalid month.");
	   break;   //breakT
	}
}

Its PEF Representation

switchT(#id, #parent, #enclMethod, #expr, [#state_1, #state_2, #state_3, #state_4, #state_5, #state_6]).
blockT(#parent, #enclMethod, #enclMethod, [..., #id]).
methodT(#enclMethod, ..., 'mySwitch', [], type(basic, void, 0), [], #parent).
identT(#expr, #id, #enclMethod, 'month', ...).
caseT(#state_1, #id, #enclMethod, ...).
execT(#state_2, #id, #enclMethod, ...).
breakT(#state_3, #id, #enclMethod, 'null', #id).
caseT(#state_4, #id, #enclMethod, 'null').
execT(#state_5, #id, #enclMethod, #parent1).
breakT(#state_6, #id, #enclMethod, 'null', #id).

AST Specification

ast_node_def('Java',switchT,[
     ast_arg(id,     mult(1,1,no ), id,  [switchT]), % <-- convention!!!
     ast_arg(parent, mult(1,1,no ), id,  [id]), % <-- convention!!!
     ast_arg(encl,   mult(1,1,no ), id,  [methodT, constructorT, classInitializerT]),
     ast_arg(cond,   mult(1,1,no ), id,  [expressionType]),
     ast_arg(stmts,  mult(0,*,ord), id,  [statementType]) % caseT,...,breakT,...,defaultT
]).
research/jtransformer/api/java/pefs/2.9/switcht.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019