diff --git a/org.eclipse.titan.codegenerator/.classpath b/org.eclipse.titan.codegenerator/.classpath
index e4b88f61ade8caa2f622f0b35c7bb828123f4388..64ed6b3795d75e0abea0ea78285f4f7a2d3c8c64 100644
--- a/org.eclipse.titan.codegenerator/.classpath
+++ b/org.eclipse.titan.codegenerator/.classpath
@@ -3,7 +3,5 @@
-
-
diff --git a/org.eclipse.titan.codegenerator/META-INF/MANIFEST.MF b/org.eclipse.titan.codegenerator/META-INF/MANIFEST.MF
index ff12eaf27da231f24f4672dd7f6da55b00c4fa4e..285808be31d6c5df062eaa4495f121473d0150ef 100644
--- a/org.eclipse.titan.codegenerator/META-INF/MANIFEST.MF
+++ b/org.eclipse.titan.codegenerator/META-INF/MANIFEST.MF
@@ -10,23 +10,6 @@ Require-Bundle: org.eclipse.titan.designer;bundle-version="5.4.0",
org.eclipse.jface;bundle-version="3.10.1",
org.eclipse.ui;bundle-version="3.106.0",
org.eclipse.ui.ide;bundle-version="3.10.0",
- org.eclipse.titan.common;bundle-version="5.4.0"
-Bundle-ClassPath: .
+ org.eclipse.ui.console;bundle-version="3.5.300",
+ org.junit
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: org.eclipse.titan.designer,
- org.eclipse.titan.designer.AST,
- org.eclipse.titan.designer.AST.ASN1,
- org.eclipse.titan.designer.AST.ASN1.Object,
- org.eclipse.titan.designer.AST.ASN1.definitions,
- org.eclipse.titan.designer.AST.ASN1.types,
- org.eclipse.titan.designer.AST.ASN1.values,
- org.eclipse.titan.designer.AST.TTCN3,
- org.eclipse.titan.designer.AST.TTCN3.attributes,
- org.eclipse.titan.designer.AST.TTCN3.definitions,
- org.eclipse.titan.designer.AST.TTCN3.statements,
- org.eclipse.titan.designer.AST.TTCN3.templates,
- org.eclipse.titan.designer.AST.TTCN3.types,
- org.eclipse.titan.designer.AST.TTCN3.types.subtypes,
- org.eclipse.titan.designer.AST.TTCN3.values,
- org.eclipse.titan.designer.AST.TTCN3.values.expressions
-
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Additional_Class_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Additional_Class_Writer.java
index 9c7a753c4e807e2ea270109131f1d1e01f912b3e..4781c28d56fbc0ee9e0f5b69e1c4ea4559375162 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Additional_Class_Writer.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Additional_Class_Writer.java
@@ -47,6 +47,7 @@ public class Additional_Class_Writer {
hcTypeString.append("public class HCType {" + "\r\n");
hcTypeString.append(" " + "\r\n");
hcTypeString.append(" boolean waitingforconnect;" + "\r\n");
+ hcTypeString.append(" boolean waitingformap;" + "\r\n");
hcTypeString.append(" Socket sock;" + "\r\n");
hcTypeString.append(" BufferedWriter writer;" + "\r\n");
hcTypeString.append(" BufferedReader reader;" + "\r\n");
@@ -61,6 +62,7 @@ public class Additional_Class_Writer {
// sockets
hcTypeString.append(" public boolean debugmode; " + "\r\n");
hcTypeString.append(" " + "\r\n");
+
hcTypeString.append(" public HCType(){" + "\r\n");
hcTypeString.append(" componentpool = new Vector();"
+ "\r\n");
@@ -69,6 +71,7 @@ public class Additional_Class_Writer {
hcTypeString.append(" this.debugmode=debugmode;"+ "\r\n");
hcTypeString.append(" }" + "\r\n");
hcTypeString.append(" " + "\r\n");
+
hcTypeString
.append(" public void connect(String comp1, String port1, String comp2, String port2){"
+ "\r\n");
@@ -84,6 +87,17 @@ public class Additional_Class_Writer {
hcTypeString.append(" }" + "\r\n");
hcTypeString.append(" }" + "\r\n");
hcTypeString.append(" " + "\r\n");
+
+ hcTypeString.append("public void map(String comp1, String port1, String comp2, String port2){" + "\r\n");
+ hcTypeString.append(" this.waitingformap=true;" + "\r\n");
+ hcTypeString.append(" sendtomc(\"map \"+comp1+\" \"+ port1+\" \"+comp2+\" \"+port2);" + "\r\n");
+ hcTypeString.append(" for(;this.waitingformap;){" + "\r\n");
+ hcTypeString.append(" try{" + "\r\n");
+ hcTypeString.append(" Thread.sleep(100);" + "\r\n");
+ hcTypeString.append(" }catch(Exception e){}" + "\r\n");
+ hcTypeString.append(" }" + "\r\n");
+ hcTypeString.append("}" + "\r\n");
+
hcTypeString
.append(" public void start(String component, String function){"
+ "\r\n");
@@ -101,20 +115,7 @@ public class Additional_Class_Writer {
+ "\r\n");
hcTypeString.append(" }" + "\r\n");
hcTypeString.append(" " + "\r\n");
- hcTypeString.append(" public void sendtomc(String message){" + "\r\n"); // hc.sendtomc-kent
- // hivodik,
- // igy
- // nem
- // hc.writer-kent
- // hivatkozik
- // a
- // writerre.
- // itt
- // mar
- // hc-ban
- // (az
- // instance-ban)
- // vagyunk
+ hcTypeString.append(" public void sendtomc(String message){" + "\r\n");
hcTypeString.append(" try{" + "\r\n");
hcTypeString.append(" writer.write(message + \"\\r\\n\");" + "\r\n");
hcTypeString.append(" writer.flush();" + "\r\n");
@@ -129,9 +130,9 @@ public class Additional_Class_Writer {
hcTypeString
.append(" TTCN3Logger.writeLog(\"hc\", \"EXECUTOR\", \"Creating PTC \" + name + \" with ID \" + ID, false);"+ "\r\n");
- for (int i = 0; i < myASTVisitor.componentList.size(); i++) {
- hcTypeString.append(" if(type.equals(\"" + myASTVisitor.componentList.get(i)
- + "\")) componentpool.add(new " + myASTVisitor.componentList.get(i)
+ for (int i = 0; i < AstWalkerJava.componentList.size(); i++) {
+ hcTypeString.append(" if(type.equals(\"" + AstWalkerJava.componentList.get(i)
+ + "\")) componentpool.add(new " + AstWalkerJava.componentList.get(i)
+ "(this,name,ID));" + "\r\n");
}
hcTypeString.append(" }" + "\r\n");
@@ -183,7 +184,7 @@ public class Additional_Class_Writer {
+ "\r\n");
hcTypeString
.append(" writer = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));"
- + "\r\n"); // ezt bekommentezed, elszall
+ + "\r\n");
hcTypeString
.append(" reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));"
+ "\r\n");
@@ -199,6 +200,9 @@ public class Additional_Class_Writer {
hcTypeString.append(" if(msg.equals(\"connected\")){" + "\r\n");
hcTypeString.append(" this.waitingforconnect=false;" + "\r\n");
hcTypeString.append(" }" + "\r\n");
+ hcTypeString.append(" if(msg.equals(\"mapped\")){" + "\r\n");
+ hcTypeString.append(" this.waitingformap=false;" + "\r\n");
+ hcTypeString.append(" }" + "\r\n");
hcTypeString.append(" String command = msg.split(\" \")[0];"
+ "\r\n");
hcTypeString.append(" //logged on receiver side instead of default sender side (because a test case might be the entry point of execution)"+ "\r\n");
@@ -208,21 +212,15 @@ public class Additional_Class_Writer {
- for (int i = 0; i < myASTVisitor.testCaseList.size(); i++) {
+ for (int i = 0; i < AstWalkerJava.testCaseList.size(); i++) {
hcTypeString.append(" if(tcasename.equals(\""
- + myASTVisitor.testCaseList.get(i) + "\")){" + "\r\n"); // minden egyes
- // testcase-re
- // kell ez az if
+ + AstWalkerJava.testCaseList.get(i) + "\")){" + "\r\n");
hcTypeString.append(" if(debugmode)TTCN3Logger.writeLog(\"hc\", \"EXECUTOR\", \"Creating MTC\", false);" + "\r\n");
hcTypeString.append(" registercomponent(\"mtc\", \""
- + myASTVisitor.testCaseRunsOnList.get(i) + "\", \"2\");" + "\r\n"); // masodik//TODO ezmi
- // parameter
- // az adott
- // tc
- // runsonja
+ + AstWalkerJava.testCaseRunsOnList.get(i) + "\", \"2\");" + "\r\n");
hcTypeString.append(" if(debugmode)TTCN3Logger.writeLog(\"hc\", \"EXECUTOR\", \"Starting new Thread for MTC\", false);" + "\r\n");
hcTypeString.append(" Thread testcasethread = new Thread(new "
- + myASTVisitor.testCaseList.get(i) + "((" + myASTVisitor.testCaseRunsOnList.get(i)
+ + AstWalkerJava.testCaseList.get(i) + "((" + AstWalkerJava.testCaseRunsOnList.get(i)
+ ")getcomponent(\"mtc\")));" + "\r\n");
hcTypeString
.append(" getcomponent(\"mtc\").thread=testcasethread;"
@@ -271,10 +269,20 @@ public class Additional_Class_Writer {
hcTypeString.append(" if(debugmode)TTCN3Logger.writeLog(\"hc\", \"EXECUTOR\", \"Connecting to component \" + component + \" port \" + port + \" on \" + ip + \":\" + portnum, false);"+ "\r\n");
hcTypeString
.append(" getcomponent(component).connect(port,ip,portnum);"
- + "\r\n"); // cast az adott nevu komponens tipusara megy
- // mindig
+ + "\r\n");
hcTypeString.append(" sendtomc(\"connected\");" + "\r\n");
hcTypeString.append(" }" + "\r\n");
+
+ hcTypeString.append("if(command.equals(\"map\")){" + "\r\n");
+ hcTypeString.append(" String thiscomp = msg.split(\" \")[1];" + "\r\n");
+ hcTypeString.append(" String thisport = msg.split(\" \")[2];" + "\r\n");
+ hcTypeString.append(" String remotecomp = msg.split(\" \")[3];" + "\r\n");
+ hcTypeString.append(" String remoteport = msg.split(\" \")[4];" + "\r\n");
+ hcTypeString.append(" getcomponent(thiscomp).domap(thisport, remotecomp, remoteport);" + "\r\n");
+ hcTypeString.append(" sendtomc(\"mapped\");" + "\r\n");
+ hcTypeString.append("}" + "\r\n");
+
+
hcTypeString.append(" if(command.equals(\"start\")){" + "\r\n");
hcTypeString
.append(" ComponentDef component = getcomponent(msg.split(\" \")[1]);"
@@ -283,17 +291,14 @@ public class Additional_Class_Writer {
+ "\r\n");
- for (int i = 0; i < myASTVisitor.functionList.size(); i++) {
+ for (int i = 0; i < AstWalkerJava.functionList.size(); i++) {
hcTypeString.append(" if(function.equals(\""
- + myASTVisitor.functionList.get(i) + "\")){ " + "\r\n");// minden letezo
- // fuggvenynevre
- // kell ilyen if
+ + AstWalkerJava.functionList.get(i) + "\")){ " + "\r\n");
hcTypeString
.append(" if(component.thread!=null) component.thread.join();"
- + "\r\n"); // ha fut rajta valami, előbb joinolni
- // kell
+ + "\r\n");
hcTypeString.append(" Thread functionthread = new Thread(new "
- + myASTVisitor.functionList.get(i) + "((" + myASTVisitor.functionRunsOnList.get(i)
+ + AstWalkerJava.functionList.get(i) + "((" + AstWalkerJava.functionRunsOnList.get(i)
+ ")component));" + "\r\n");
hcTypeString.append(" component.thread=functionthread;"
+ "\r\n");
@@ -313,7 +318,7 @@ public class Additional_Class_Writer {
hcTypeString
.append(" TTCN3Logger.writeLog(\"hc\", \"EXECUTOR\", \"Waiting for component \" + c.name + \" to be done\", false);"
+ "\r\n");
- hcTypeString.append(" c.thread.join();" + "\r\n");
+ hcTypeString.append(" if(c.thread!=null) c.thread.join();" + "\r\n");
hcTypeString.append(" //logged by mc too" + "\r\n");
hcTypeString
.append(" if(debugmode)TTCN3Logger.writeLog(\"hc\", \"EXECUTOR\", \"Component \" + c.name + \" is done\", false);"
@@ -364,4 +369,58 @@ public class Additional_Class_Writer {
return hcTypeString.toString();
}
+ public static void writeExternalPortClass(String nodeName) {
+ StringBuilder externalPort=new StringBuilder();
+
+ externalPort.append("package org.eclipse.titan.codegenerator.javagen;"+"\r\n");
+ externalPort.append("import java.io.ObjectInputStream;"+"\r\n");
+ externalPort.append("import java.io.ObjectOutputStream;"+"\r\n");
+ externalPort.append("import java.net.ServerSocket;"+"\r\n");
+ externalPort.append("import java.net.Socket;"+"\r\n");
+ externalPort.append("import java.util.Scanner; "+"\r\n");
+
+ externalPort.append("import org.eclipse.titan.codegenerator.TTCN3JavaAPI.*;"+"\r\n");
+
+ externalPort.append("public class TP_"+nodeName+" {"+"\r\n");
+ externalPort.append(" private "+nodeName+" port;"+"\r\n");
+ externalPort.append(" public TP_"+nodeName+"("+nodeName+" p){"+"\r\n");
+ externalPort.append(" port=p;"+"\r\n");
+ externalPort.append(" }"+"\r\n");
+
+ externalPort.append(" //must block until map is done"+"\r\n");
+ externalPort.append(" public void user_map(String remotecomp, String remoteport){"+"\r\n");
+ externalPort.append(" new TestPortDaemon(this).start();"+"\r\n");
+ externalPort.append(" }"+"\r\n");
+
+ externalPort.append(" //must block until unmap is done"+"\r\n");
+ externalPort.append(" public void user_unmap(String remotecomp, String remoteport){ "+"\r\n");
+ externalPort.append(" }"+"\r\n");
+
+ externalPort.append(" public void user_send(Object o){"+"\r\n");
+ externalPort.append(" System.out.println(\"TESTPORT OUTPUT \" + ((CHARSTRING)o).toString());"+"\r\n"); //TODO fix logging
+ externalPort.append(" }"+"\r\n");
+
+ externalPort.append(" class TestPortDaemon extends Thread{"+"\r\n");
+ externalPort.append(" private TP_"+nodeName+" testport;"+"\r\n");
+ externalPort.append(" public TestPortDaemon(TP_"+nodeName+" p){"+"\r\n");
+ externalPort.append(" testport = p;"+"\r\n");
+ externalPort.append(" }"+"\r\n");
+ externalPort.append(" public void run(){"+"\r\n");
+ externalPort.append(" testport.port.mapped=true;"+"\r\n");
+ externalPort.append(" Scanner scanner = new Scanner(System.in);"+"\r\n");
+ externalPort.append(" for(;;){"+"\r\n");
+ externalPort.append(" String inmsg = scanner.nextLine();"+"\r\n");
+ externalPort.append(" testport.port.enqueue(new CHARSTRING(inmsg));"+"\r\n");
+ externalPort.append(" }"+"\r\n");
+ externalPort.append(" }"+"\r\n");
+ externalPort.append(" }"+"\r\n");
+ externalPort.append("}"+"\r\n");
+
+ String backupFilename=myASTVisitor.currentFileName;
+ myASTVisitor.currentFileName="TP_"+nodeName;
+ myASTVisitor.visualizeNodeToJava(externalPort.toString());
+ myASTVisitor.currentFileName=backupFilename;
+
+ }
+
}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/AstWalkerJava.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/AstWalkerJava.java
index 2dba5283fc0e1ecb249aee9857f0da5328e3e3e7..9b6594cf22e11ac03cfbb8d9e55a51f578e7cf61 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/AstWalkerJava.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/AstWalkerJava.java
@@ -18,9 +18,11 @@ package org.eclipse.titan.codegenerator;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -32,7 +34,6 @@ import java.util.logging.SimpleFormatter;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
-
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
@@ -48,6 +49,13 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.IConsoleView;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.titan.designer.AST.Module;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Definitions;
@@ -55,46 +63,39 @@ import org.eclipse.titan.designer.AST.TTCN3.definitions.ImportModule;
import org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module;
import org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3Analyzer;
-public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
+public final class AstWalkerJava implements IWorkbenchWindowActionDelegate {
- IWorkbenchWindow window;
+ private static IWorkbenchWindow window;
private static Logger logger;
- private ISelection selection;
- private IProject selectedProject;
- public static Properties props;
- private List fileNames;
- private List files;
- private TTCN3Module currentTTCN3module;
+ private static IProject selectedProject;
+ public static Properties props;
+ private static List fileNames;
+ private static List files;
+ private static TTCN3Module currentTTCN3module;
public static String moduleElementName = "";
- public static boolean areCommentsAllowed=true;
-
- //public static String currentFileName = "";
-
-
-
+ public static boolean areCommentsAllowed = true;
+ public static List componentList = new ArrayList();
+ public static List testCaseList = new ArrayList();
+ public static List testCaseRunsOnList = new ArrayList();
+ public static List functionList = new ArrayList();
+ public static List functionRunsOnList = new ArrayList();
- // copied from ttcn-3
-
static {
try {
boolean append = true;
props = new Properties();
props.load(AstWalkerJava.class
.getResourceAsStream("walker.properties"));
- // props.list(System.err);
- // FileHandler fh = new
- // FileHandler("D:\\temp\\GenerateModelActionDelegate.log", append);
FileHandler fh = new FileHandler(props.getProperty("log.path"),
append);
- // fh.setFormatter(new XMLFormatter());
fh.setFormatter(new SimpleFormatter());
logger = Logger.getLogger(AstWalkerJava.class.getName());
logger.addHandler(fh);
@@ -107,15 +108,42 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
new AstWalkerJava().run(null);
}
+ @SuppressWarnings("unchecked")
public void run(IAction action) {
- // logger.severe(hu.bme.tmit.catg.data.model.System.getSystem().getModelNames());
- // hu.bme.tmit.catg.data.model.System.getSystem().reset();
- // logger.severe(hu.bme.tmit.catg.data.model.System.getSystem().getModelNames());
-
- this.files.clear();
- this.fileNames.clear();
+ AstWalkerJava.files.clear();
+ AstWalkerJava.fileNames.clear();
+ AstWalkerJava.componentList.clear();
+ AstWalkerJava.testCaseList.clear();
+ AstWalkerJava.testCaseRunsOnList.clear();
+ AstWalkerJava.functionList.clear();
+ AstWalkerJava.functionRunsOnList.clear();
+ //initialize folder
+ //clear if exists
+ Path outputPath=Paths.get(props.getProperty("javafile.path"));
+ if(Files.exists(outputPath)){
+ System.out.println("");
+ File folder = new File(outputPath.toUri());
+ File[] listOfFiles = folder.listFiles();
+ for(int i=0;i 0) {
for (int i = 0, num = files.size(); i < num; i++) {
-
- //process files
+
+ // process files
currentTTCN3module = (TTCN3Module) doAnalysis(files.get(i),
null);
modules.put(fileNames.get(i), currentTTCN3module);
@@ -222,7 +262,7 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
+ currentTTCN3module.getIdentifier()
.getDisplayName());
if (currentTTCN3module.getOutlineChildren().length > 1) {
- for (ImportModule mm : (List) currentTTCN3module
+ for (@SuppressWarnings("unused") ImportModule mm : (List) currentTTCN3module
.getOutlineChildren()[0]) {
logger.severe(currentTTCN3module.getName()
+ " imported "
@@ -236,10 +276,11 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
Object[] modulestart = modules.get(fileNames.get(i))
.getOutlineChildren();
-
- //start AST processing
+ logToConsole("Version built on 2016.08.04.");
+ logToConsole("Starting to generate files into: " + props.getProperty("javafile.path"));
+ // start AST processing
walkChildren(modulestart);
-
+ logToConsole("Files generated into: "+props.getProperty("javafile.path"));
}
} else {
@@ -253,27 +294,22 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
return;
}
-
-
- //write additional classes
- Additional_Class_Writer additional_class=new Additional_Class_Writer();
+ // write additional classes
+ Additional_Class_Writer additional_class = new Additional_Class_Writer();
myASTVisitor.currentFileName = "HC";
-
- myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
+
+ myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
myASTVisitor.visualizeNodeToJava(additional_class.writeHCClass());
-
+
myASTVisitor.currentFileName = "HCType";
- myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
- myASTVisitor.visualizeNodeToJava(additional_class.writeHCTypeClass());
-
- //clear lists
- myASTVisitor.componentList.clear();
- myASTVisitor.testCaseList.clear();
- myASTVisitor.testCaseRunsOnList.clear();
- myASTVisitor.functionList.clear();
- myASTVisitor.functionRunsOnList.clear();
+ myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
+ myASTVisitor.visualizeNodeToJava(additional_class
+ .writeHCTypeClass());
+
+ // clear lists
+
+
-
logger.severe("analysis complete");
} finally {
@@ -295,7 +331,7 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
public void init(IWorkbenchWindow window) {
fileNames = new ArrayList();
files = new ArrayList();
- this.window = window;
+ AstWalkerJava.window = window;
try {
FileOutputStream fos = new FileOutputStream(
props.getProperty("log.path"));
@@ -332,7 +368,7 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
private final Module doAnalysis(IFile file, String code) {
TTCN3Analyzer ttcn3Analyzer = new TTCN3Analyzer();
- // try {
+
if (file != null) {
logger.severe("Calling TTCN3 parser with " + file.getName()
+ " and " + null + "\n");
@@ -347,10 +383,6 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
return module;
- /*
- * } catch (FileNotFoundException e) { // TODO Auto-generated catch
- * block e.printStackTrace(); } return null;
- */
}
public void walkChildren(Object[] uncastedChildren) {
@@ -363,12 +395,34 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
moduleElementName = castedChildren.getFullName().toString();
-
+ logToConsole("Starting processing: " + moduleElementName );
myASTVisitor v = new myASTVisitor();
+ myASTVisitor.myFunctionTestCaseVisitHandler.clearEverything();
+ //myASTVisitor.templateIdValuePairs.clear();
+
castedChildren.accept(v);
+ logToConsole("Finished processing: " + moduleElementName );
}
}
}
+ private static MessageConsole findConsole(String name) {
+ ConsolePlugin plugin = ConsolePlugin.getDefault();
+ IConsoleManager conMan = plugin.getConsoleManager();
+ IConsole[] existing = conMan.getConsoles();
+ for (int i = 0; i < existing.length; i++)
+ if (name.equals(existing[i].getName()))
+ return (MessageConsole) existing[i];
+ // no console found, so create a new one
+ MessageConsole myConsole = new MessageConsole(name, null);
+ conMan.addConsoles(new IConsole[] { myConsole });
+ return myConsole;
+ }
+
+ public static void logToConsole(String msg) {
+ MessageConsole myConsole = findConsole("myLogger");
+ MessageConsoleStream consoleLogger = myConsole.newMessageStream();
+ consoleLogger.println(msg);
+ }
}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_AltStatement_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_AltStatement_Writer.java
new file mode 100644
index 0000000000000000000000000000000000000000..bf06073bfdf30046f50e7ec97d39e2e89f756398
--- /dev/null
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_AltStatement_Writer.java
@@ -0,0 +1,490 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Keremi, Andras
+ * Eros, Levente
+ * Kovacs, Gabor
+ *
+ ******************************************************************************/
+
+package org.eclipse.titan.codegenerator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard;
+import org.eclipse.titan.designer.AST.TTCN3.statements.AltGuards;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Repeat_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Timeout_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value;
+
+public class Def_AltStatement_Writer {
+ private Alt_Statement altStatement;
+ private StringBuilder altString = new StringBuilder("");
+
+ private String currentTimerName = null;
+ private String nodeName = null;
+
+ private int altReceiveCounter = -1;
+ private int timeOutCounter = -1;
+
+ private boolean isFunction = false;
+ private boolean isTestCase = false;
+
+ public List altGuardConditions = new ArrayList();
+ public List altGuardPortReference = new ArrayList();
+ public List altGuardReceiveValue = new ArrayList();
+ public List altGuardReceiveType = new ArrayList();
+ public List altGuardTimeout = new ArrayList();
+
+ private boolean isThereAStartedTimer = false;
+ public List altGuardReceiveAnyValValue = new ArrayList();
+
+ Def_Testcase_Writer testcaseParent;
+ Def_Function_Writer functionParent;
+
+ public Def_AltStatement_Writer(Alt_Statement altStatement,
+ String parentNodeName) {
+ this.altStatement = altStatement;
+ this.nodeName = parentNodeName;
+ }
+
+ public void writeTestCaseAltStatement(Alt_Statement altStatement) {
+
+ AltGuards currentAltGuards = altStatement.getAltGuards();
+
+ String[] negativeConditions = new String[currentAltGuards
+ .getNofAltguards()];
+ String[] positiveConditions = new String[currentAltGuards
+ .getNofAltguards()];
+
+ // initialize values
+ for (int i = 0; i < currentAltGuards.getNofAltguards(); i++) {
+
+ AltGuard currentAltGuard = currentAltGuards.getAltguardByIndex(i);
+ if (currentAltGuard instanceof Operation_Altguard) {
+
+ Statement currentStatement = ((Operation_Altguard) currentAltGuard)
+ .getGuardStatement();
+
+ if (currentStatement instanceof Receive_Port_Statement) {
+
+ altReceiveCounter++;
+ if (altGuardConditions.get(i) != null) {// alt guard present
+
+ // alt guard present && any port receive
+ if (altGuardPortReference.get(altReceiveCounter)
+ .equals("any port")) {
+ positiveConditions[i] = altGuardConditions.get(altReceiveCounter)
+ + ".getValue()" + "&&("
+ + "anyPortReceive(true))";
+
+ negativeConditions[i] = altGuardConditions.get(altReceiveCounter)
+ + ".getValue()" + "&&("
+ + "anyPortReceive(false))";
+
+ } else {// alt guard present && normal port receive
+ positiveConditions[i] = altGuardConditions.get(altReceiveCounter)
+ + ".getValue()"
+ + "&&("
+ + altGuardPortReference
+ .get(altReceiveCounter)
+ + ".receive("
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + ",true)!=null)";
+
+ negativeConditions[i] = altGuardConditions.get(altReceiveCounter)
+ + ".getValue()"
+ + "&&("
+ + altGuardPortReference
+ .get(altReceiveCounter)
+ + ".receive("
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + ",false)!=null)";
+
+ if (altGuardReceiveValue.get(altReceiveCounter)
+ .startsWith("Templates")) {
+ altGuardReceiveType.set(altReceiveCounter, "Templates");
+ }
+ }
+
+ } else {// no alt guard
+
+ // no alt guard && any port recieve
+ if (altGuardPortReference.get(altReceiveCounter)
+ .equals("any port")) {
+ positiveConditions[i] = "anyPortReceive(true)";
+ negativeConditions[i] = "anyPortReceive(false)";
+ } else {
+ // no alt guard && typed port recieve
+ if (altGuardReceiveType.get(altReceiveCounter).equals(
+ "_TYPED_PARAM_")) {
+ negativeConditions[i] = altGuardPortReference
+ .get(altReceiveCounter)
+ + ".receive_"
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + "(false)!=null";
+
+ if (altGuardReceiveAnyValValue.get(altReceiveCounter) != null) {
+ positiveConditions[i] = "("
+ + altGuardReceiveAnyValValue.get(altReceiveCounter)
+ + "="
+ + altGuardPortReference
+ .get(altReceiveCounter)
+ + ".receive_"
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + "(true))!=null";
+
+ } else {
+
+ }
+
+ } else { // no alt guard && normal port recieve
+ positiveConditions[i] = altGuardPortReference
+ .get(altReceiveCounter)
+ + ".receive("
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + ",true)!=null";
+
+ negativeConditions[i] = altGuardPortReference
+ .get(altReceiveCounter)
+ + ".receive("
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + ",false)!=null";
+ }
+ if (altGuardReceiveValue.get(altReceiveCounter)
+ .startsWith("Templates")) {
+ altGuardReceiveType.set(altReceiveCounter, "Templates");
+ }
+ }
+ }
+ }
+
+ if (currentStatement instanceof Timeout_Statement) {
+ timeOutCounter++;
+ if (altGuardConditions.get(i) != null) {
+ positiveConditions[i] = altGuardConditions.get(i)
+ + "&&(" + altGuardTimeout.get(timeOutCounter)
+ + ".timeout()";
+ negativeConditions[i] = altGuardConditions.get(i)
+ + "&&(!" + altGuardTimeout.get(i)
+ + ".timeout()";
+
+ } else {
+ positiveConditions[i] = altGuardTimeout
+ .get(timeOutCounter) + ".timeout()";
+ negativeConditions[i] = "!"
+ + altGuardTimeout.get(timeOutCounter)
+ + ".timeout()";
+ }
+
+ }
+
+ }
+ }
+
+ // write
+ altString.append("rownum=" + altStatement.getLocation().getLine()
+ + ";\r\n");
+ altString.append("for(;;){" + "\r\n");
+
+ altString.append("if(!(");
+ for (int j = 0; j < negativeConditions.length; j++) {
+ altString.append(negativeConditions[j]);
+ if (j + 1 < negativeConditions.length) {
+ altString.append("||");
+ }
+ }
+
+ altString.append(")){" + "\r\n");
+
+ // timer
+ if (isThereAStartedTimer) {
+ altString.append("long timeout = -1;" + "\r\n");
+ altString.append("long newtimeout;" + "\r\n");
+
+ altString
+ .append("if("
+ + currentTimerName
+ + ".running)if((newtimeout=(long)("
+ + currentTimerName
+ + ".read().value*1000.0))0) try{queue.poll(timeout,TimeUnit.MILLISECONDS);}catch(InterruptedException e){} "
+ + "\r\n");
+
+ } else {
+
+ altString
+ .append("try{queue.take();}catch(InterruptedException e){}"
+ + "\r\n");
+
+ }
+ // endoftimer
+
+ altString.append("}" + "\r\n");
+ altString.append("this.lock();" + "\r\n");
+ // ifwriter
+
+ altReceiveCounter = -1;
+ boolean isFirstIf = true;
+ for (int i = 0; i < currentAltGuards.getNofAltguards(); i++) {
+
+ AltGuard currentAltGuard = currentAltGuards.getAltguardByIndex(i);
+ if (currentAltGuard instanceof Operation_Altguard) {
+
+ Statement currentStatement = ((Operation_Altguard) currentAltGuard)
+ .getGuardStatement();
+ StatementBlock currentStatementBlock = ((Operation_Altguard) currentAltGuard)
+ .getStatementBlock();
+
+ if (isFirstIf) {
+ altString.append("if(" + positiveConditions[i] + "){\r\n");
+ isFirstIf = false;
+ } else {
+ altString.append("else if(" + positiveConditions[i]
+ + "){\r\n");
+ }
+
+ if (currentStatement instanceof Receive_Port_Statement) {
+ altReceiveCounter++;
+
+ altString.append("rownum="
+ + currentStatement.getLocation().getLine()
+ + ";\r\n");
+
+ if (altGuardReceiveType.get(altReceiveCounter).equals(
+ "Templates")) {
+ String methodName = altGuardReceiveValue
+ .get(altReceiveCounter);
+ if (methodName.endsWith("()")
+ && methodName.startsWith("Templates.")) {
+
+ methodName = (String) methodName.subSequence(10,
+ methodName.length() - 2);
+ }
+
+ altString
+ .append(" TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"RECEIVE event on port "
+ + altGuardPortReference
+ .get(altReceiveCounter)
+ + ":\\n "
+ + methodName
+ + ":=\" + "
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + ".toString(), true);" + "\r\n");
+ } else if (altGuardReceiveType.get(altReceiveCounter)
+ .equals("any port")) {
+ altString
+ .append(" TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"RECEIVE event on port any port\", true);"
+ + "\r\n");
+ } else if (altGuardReceiveType.get(altReceiveCounter)
+ .equals("_TYPED_PARAM_")) {
+ altString
+ .append(" TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"RECEIVE event on port "
+ + altGuardPortReference
+ .get(altReceiveCounter)
+ + ": type "
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + "\", true);" + "\r\n");
+
+ } else {
+ altString
+ .append(" TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"RECEIVE event on port "
+ + altGuardPortReference
+ .get(altReceiveCounter)
+ + ":\" + "
+ + altGuardReceiveValue
+ .get(altReceiveCounter)
+ + ".toString(), true);" + "\r\n");
+ }
+ } else if (currentStatement instanceof Timeout_Statement) {
+ altString
+ .append("rownum="
+ + currentStatement.getLocation().getLine()
+ + ";\r\n"
+ + "TTCN3Logger.writeLog(compid, \"TIMEROP\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"Timeout on timer "
+ + currentTimerName + ".\", false);"
+ + "\r\n");
+
+ }
+
+ boolean isThereARepeatStatement = false;
+ for (int j = 0; j < currentStatementBlock.getSize(); j++) {
+ Statement currentStatementBlockStatement = currentStatementBlock
+ .getStatementByIndex(j);
+
+ if (currentStatementBlockStatement instanceof Setverdict_Statement) {
+ Setverdict_Statement setVerdictStatement = (Setverdict_Statement) currentStatementBlockStatement;
+ String verdict = "";
+
+ if (setVerdictStatement.getVerdictValue() instanceof Verdict_Value) {
+ Verdict_Value verdictValue = (Verdict_Value) setVerdictStatement
+ .getVerdictValue();
+ if (verdictValue.getValue().toString()
+ .equals("PASS")) {
+ verdict = "pass";
+ } else if (verdictValue.getValue().toString()
+ .equals("INCONC")) {
+ verdict = "inconc";
+ } else {
+ verdict = "fail";
+ }
+ }
+ altString.append("rownum="
+ + setVerdictStatement.getLocation().getLine()
+ + ";\r\n");
+ altString
+ .append("TTCN3Logger.writeLog(compid, \"VERDICTOP\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"setverdict("
+ + verdict
+ + "): \" + getVerdict() + \" -> "
+ + verdict + "\", true);" + "\r\n");
+ altString.append("setVerdict(\"" + verdict + "\");"
+ + "\r\n");
+
+ }
+
+ if (currentStatementBlockStatement instanceof Assignment_Statement) {
+
+ if (isFunction) {
+ functionParent.assignCounter++;
+
+ altString
+ .append(functionParent
+ .writeAssignmentStatement((Assignment_Statement) currentStatementBlockStatement));
+
+ String test = "";
+ test.toString();
+
+ } else if (isTestCase) {
+ testcaseParent.assignCounter++;
+ altString
+ .append(testcaseParent
+ .writeAssignmentStatement((Assignment_Statement) currentStatementBlockStatement));
+
+ }
+
+ }
+
+ if (currentStatementBlockStatement instanceof Send_Statement) {
+
+ if (isFunction) {
+ functionParent.sendCounter++;
+
+ altString
+ .append(functionParent
+ .writeSendStatement((Send_Statement) currentStatementBlockStatement));
+
+ } else if (isTestCase) {
+ testcaseParent.sendCounter++;
+ altString
+ .append(testcaseParent
+ .writeSendStatement((Send_Statement) currentStatementBlockStatement));
+
+ }
+ }
+
+ if (currentStatementBlockStatement instanceof Repeat_Statement) {
+ isThereARepeatStatement = true;
+ }
+
+ }
+ if (isThereARepeatStatement) {
+ isThereARepeatStatement = false;
+ } else {
+ altString.append("break;\r\n");
+ }
+
+ altString.append("}\r\n");
+
+ }
+ }
+
+ altString.append("this.unlock();" + "\r\n");
+ altString.append("}" + "\r\n");
+
+ }
+
+ public void clearLists() {
+ altGuardConditions.clear();
+ altGuardPortReference.clear();
+ altGuardReceiveValue.clear();
+ altGuardReceiveType.clear();
+ altGuardTimeout.clear();
+
+ altReceiveCounter = -1;
+ timeOutCounter = -1;
+
+ }
+
+ public String getJavaSource() {
+
+ this.writeTestCaseAltStatement(altStatement);
+
+ String returnString = altString.toString();
+ altString.setLength(0);
+ clearLists();
+
+ return returnString;
+ }
+
+
+ public void setTimerInfo(boolean isThereAStartedTimer2,
+ String currentTimerName2) {
+ isThereAStartedTimer = isThereAStartedTimer2;
+ currentTimerName = currentTimerName2;
+
+ }
+
+
+ public void setType(String string) {
+ if (string.equals("Function")) {
+ isFunction = true;
+ } else if (string.equals("TestCase")) {
+ isTestCase = true;
+ }
+ }
+
+ public void setParent(Object parent) {
+ if (parent instanceof Def_Function_Writer) {
+ functionParent = (Def_Function_Writer) parent;
+ } else if (parent instanceof Def_Testcase_Writer) {
+ testcaseParent = (Def_Testcase_Writer) parent;
+ }
+ }
+
+}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Const_Visit_Handler.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Const_Visit_Handler.java
new file mode 100644
index 0000000000000000000000000000000000000000..fdc4ab25d342edee0a54ac2fe3802883e292332b
--- /dev/null
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Const_Visit_Handler.java
@@ -0,0 +1,538 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Keremi, Andras
+ * Eros, Levente
+ * Kovacs, Gabor
+ *
+ ******************************************************************************/
+
+package org.eclipse.titan.codegenerator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.titan.designer.AST.IVisitableNode;
+import org.eclipse.titan.designer.AST.Identifier;
+import org.eclipse.titan.designer.AST.Reference;
+import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const;
+import org.eclipse.titan.designer.AST.TTCN3.types.BitString_Type;
+import org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type;
+import org.eclipse.titan.designer.AST.TTCN3.types.CharString_Type;
+import org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type;
+import org.eclipse.titan.designer.AST.TTCN3.types.OctetString_Type;
+import org.eclipse.titan.designer.AST.TTCN3.types.subtypes.Range_ParsedSubType;
+import org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Omit_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.AddExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.DivideExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.EqualsExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.GreaterThanExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.GreaterThanOrEqualExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.LessThanExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.LessThanOrEqualExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.Log2StrExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.ModuloExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.MultiplyExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.NotExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.NotequalesExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.RemainderExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.Str2IntExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.SubstractExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.ValueofExpression;
+
+public class Def_Const_Visit_Handler {
+
+ public static String constNodeType = null;
+ private static String lastConstName = null;
+
+ private static boolean waitForConstValues = false;
+ private static boolean constValueIsAReference = false;
+
+ // counts the members for each setof
+ // has to be -3 because the node's name and type increases it by 2
+ // should be increased to 0 only at the first constant value
+ private static int constParamCounter = -3;
+
+
+ private static List constValues = new ArrayList();
+ private static List constParamCount = new ArrayList();
+ private static List expressionValue = new ArrayList();
+
+ public void visit(IVisitableNode node) {
+
+ if (!myASTVisitor.myFunctionTestCaseVisitHandler.waitForDefStatement
+ && (node instanceof Def_Const)) {
+ myASTVisitor.currentFileName = "Constants";
+
+ Def_Const_Writer.getInstance(((Def_Const) node));
+ myASTVisitor.nodeNameNodeTypeHashMap.put(((Def_Const) node)
+ .getIdentifier().toString(), "constant");
+ waitForConstValues = true;
+ constParamCount.add(0);
+ }
+
+ // constants
+ visitConstantNodes(node);
+ }
+
+ public void visitConstantNodes(IVisitableNode node) {
+
+ if (waitForConstValues && (node instanceof Identifier)) {
+ constParamCounter++;
+ if (constParamCounter > 0) {
+ constParamCount.add(0);
+ }
+ lastConstName = ((Identifier) node).toString();
+ }
+
+ if (waitForConstValues && (node instanceof Charstring_Value)) {
+ String value=((Charstring_Value) node).getValue();
+
+ expressionValue.add(value);
+
+ constValueIsAReference = false;
+
+ if (constParamCounter == -1) {
+ constParamCounter = 0;
+ }
+ if (constParamCounter == -2) {
+ constParamCounter = 0;
+ }
+
+ constParamCount.set(constParamCounter,
+ constParamCount.get(constParamCounter) + 1);
+ }
+
+ if (waitForConstValues && (node instanceof Integer_Value)) {
+
+ String value=((Integer_Value) node).toString();
+
+ if (myASTVisitor.isNextIntegerNegative) {
+ value="-" + value;
+ }
+
+ expressionValue.add(value);
+
+ constValueIsAReference = false;
+
+ if (constParamCounter == -1) {
+ constParamCounter = 0;
+ }
+ if (constParamCounter == -2) {
+ constParamCounter = 0;
+ }
+
+ constParamCount.set(constParamCounter,
+ constParamCount.get(constParamCounter) + 1);
+ myASTVisitor.isNextIntegerNegative = false;
+
+ }
+
+ if (waitForConstValues && (node instanceof Bitstring_Value)) {
+
+ String value=((Bitstring_Value) node).getValue();
+
+ expressionValue.add(value);
+
+ constValueIsAReference = false;
+
+ if (constParamCounter == -1) {
+ constParamCounter = 0;
+ }
+ if (constParamCounter == -2) {
+ constParamCounter = 0;
+ }
+
+ constParamCount.set(constParamCounter,
+ constParamCount.get(constParamCounter) + 1);
+
+ }
+
+ if (waitForConstValues && (node instanceof Octetstring_Value)) {
+
+
+ String value=((Octetstring_Value) node).getValue();
+
+ expressionValue.add(value);
+
+ constValueIsAReference = false;
+
+ if (constParamCounter == -1) {
+ constParamCounter = 0;
+ }
+ if (constParamCounter == -2) {
+ constParamCounter = 0;
+ }
+
+ constParamCount.set(constParamCounter,
+ constParamCount.get(constParamCounter) + 1);
+
+ }
+
+ if (waitForConstValues && (node instanceof Boolean_Value)) {
+
+ String value=Boolean.toString(((Boolean_Value) node).getValue());
+
+ expressionValue.add(value);
+
+ constValueIsAReference = false;
+
+ if (constParamCounter == -1) {
+ constParamCounter = 0;
+ }
+ if (constParamCounter == -2) {
+ constParamCounter = 0;
+ }
+
+ constParamCount.set(constParamCounter,
+ constParamCount.get(constParamCounter) + 1);
+
+ }
+
+ if (waitForConstValues && (node instanceof Omit_Value)) {
+
+ expressionValue.add("omit");
+
+ constValueIsAReference = false;
+
+ if (constParamCounter == -1) {
+ constParamCounter = 0;
+ }
+
+ constParamCount.set(constParamCounter,
+ constParamCount.get(constParamCounter) + 1);
+
+ myASTVisitor.constOmitHashes.add(lastConstName);
+
+ }
+
+ if (waitForConstValues && (node instanceof Undefined_LowerIdentifier_Value)) {
+
+ String value=((Undefined_LowerIdentifier_Value) node).getIdentifier().toString();
+
+ expressionValue.add(value);
+
+ constValueIsAReference = true;
+
+ if (constParamCounter == -1) {
+ constParamCounter = 0;
+ }
+ if (constParamCounter == -2) {
+ constParamCounter = 0;
+ }
+
+ constParamCount.set(constParamCounter,
+ constParamCount.get(constParamCounter) + 1);
+
+ }
+
+ if(waitForConstValues){
+ setType(node);
+ visitExpressionTypeSelectors(node);
+ }
+ /*
+ // AddExpression
+ if (waitForConstValues && (node instanceof AddExpression)) {
+ waitForConstAddFirstValue = true;
+ }
+
+ if (waitForConstAddSecondValue
+ && (node instanceof Undefined_LowerIdentifier_Value)) {
+
+ String valueIdentifier = ((Undefined_LowerIdentifier_Value) node)
+ .getIdentifier().toString();
+ if (myASTVisitor.nodeNameNodeTypeHashMap
+ .containsKey(valueIdentifier)) {
+ if (myASTVisitor.nodeNameNodeTypeHashMap.get(valueIdentifier)
+ .equals("constant")) {
+ valueIdentifier = valueIdentifier + "()";
+ }
+ }
+
+ constValueIsAReference = true;
+
+ constValues.set(constAddValueIndex,
+ constValues.get(constAddValueIndex) + ".plus("
+ + valueIdentifier + ")");
+
+ waitForConstAddSecondValue = false;
+ waitForConstValues = false;
+ }
+
+ if (waitForConstAddFirstValue
+ && (node instanceof Undefined_LowerIdentifier_Value)) {
+ waitForConstAddFirstValue = false;
+ waitForConstAddSecondValue = true;
+
+ String valueIdentifier = ((Undefined_LowerIdentifier_Value) node)
+ .getIdentifier().toString();
+ if (myASTVisitor.nodeNameNodeTypeHashMap
+ .containsKey(valueIdentifier)) {
+ if (myASTVisitor.nodeNameNodeTypeHashMap.get(valueIdentifier)
+ .equals("constant")) {
+ valueIdentifier = valueIdentifier + "()";
+ }
+
+ }
+
+ constAddValueIndex = constValues.size();
+ constValues.add(valueIdentifier);
+
+ if (constParamCounter == -1) {
+ constParamCounter = 0;
+ }
+ if (constParamCounter == -2) {
+ constParamCounter = 0;
+ }
+
+ constParamCount.set(constParamCounter,
+ constParamCount.get(constParamCounter) + 1);
+
+ }*/
+
+ }
+
+ public void setType(IVisitableNode node){
+
+ if (node instanceof Reference) {
+ constNodeType = ((Reference) node).getId().toString();
+ }
+
+ if (node instanceof Integer_Type) {
+ constNodeType = "INTEGER";
+ }
+
+ if (node instanceof CharString_Type) {
+ constNodeType = "CHARSTRING";
+ }
+
+ if (node instanceof BitString_Type) {
+ constNodeType = "BITSTRING";
+ }
+
+ if (node instanceof OctetString_Type) {
+ constNodeType = "OCTETSTRING";
+ }
+
+ if (node instanceof Boolean_Type) {
+ constNodeType = "BOOLEAN";
+ }
+ }
+
+ public void evaluateExpression() {
+ int size = expressionValue.size() - 1;
+ boolean operatorFound = false;
+ boolean unaryOperatorFound = false;
+ String rightHand = "";
+ String leftHand = "";
+
+ for (int i = size; i >= 0; i--) {
+
+ if (myASTVisitor.nodeNameNodeTypeHashMap.containsKey(expressionValue.get(i))) {
+
+ if (myASTVisitor.nodeNameNodeTypeHashMap.get(expressionValue.get(i)).equals("constant")) {
+ expressionValue.set(i, "Constants." + expressionValue.get(i) + "().value");
+
+ } else if (myASTVisitor.nodeNameNodeTypeHashMap.get(expressionValue.get(i)).equals("template")) {
+ expressionValue.set(i, "Templates." + expressionValue.get(i) + "()");
+
+ }
+ }
+
+ if (i <= size - 2) {
+ leftHand = expressionValue.get(i + 1);
+ rightHand = expressionValue.get(i + 2);
+ }
+
+ //
+ if (expressionValue.get(i).equals("Str2IntExpression")) {
+ expressionValue.set(i, "(" + expressionValue.get(i + 1) + "str2int())");
+ unaryOperatorFound = true;
+ } else if (expressionValue.get(i).equals("Log2StrExpression")) {
+ expressionValue.set(i, "(" + expressionValue.get(i + 1) + "log2str())");
+ unaryOperatorFound = true;
+ } else if (expressionValue.get(i).equals("ValueofExpression")) {
+ expressionValue.set(i, "(" + expressionValue.get(i + 1) + ").value");
+ unaryOperatorFound = true;
+ } else if (expressionValue.get(i).equals("NotExpression")) {
+ expressionValue.set(i, "(" + expressionValue.get(i + 1) + ").not()");
+ unaryOperatorFound = true;
+ } else if (expressionValue.get(i).equals("AddExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").plus(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("SubstractExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").minus(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("MultiplyExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").multipleBy(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("DivideExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").divideBy(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("ModuloExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").mod(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("RemainderExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").rem(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("NotequalesExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").equalsWith(" + rightHand + ").not()");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("LessThanExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").isLessThan(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("LessThanOrEqualExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").isLessOrEqualThan(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("GreaterThanExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").isGreaterThan(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("GreaterThanOrEqualExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").isGreaterOrEqualThan(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("EqualsExpression")) {
+ expressionValue.set(i, "(" + leftHand + ").equals(" + rightHand + ")");
+ operatorFound = true;
+ } else if (expressionValue.get(i).equals("Range_ParsedSubType")) {
+ expressionValue.set(i, "new SubTypeInterval(" + expressionValue.get(i + 1) + ","
+ + expressionValue.get(i + 2) + ")");
+ operatorFound = true;
+ }
+
+ if (unaryOperatorFound) {
+ unaryOperatorFound = false;
+ expressionValue.remove(i + 1);
+ size = expressionValue.size() - 1;
+ i = size;
+ } else if (operatorFound) {
+ operatorFound = false;
+ expressionValue.remove(i + 2);
+ expressionValue.remove(i + 1);
+ size = expressionValue.size() - 1;
+ i = size;
+ }
+
+ }
+
+ constValues.addAll(expressionValue);
+
+ expressionValue.clear();
+ }
+
+
+ public void visitExpressionTypeSelectors(IVisitableNode node) {
+
+ if (node instanceof AddExpression) {
+ expressionValue.add("AddExpression");
+ }
+
+ if (node instanceof SubstractExpression) {
+ expressionValue.add("SubstractExpression");
+ }
+
+ if (node instanceof MultiplyExpression) {
+ expressionValue.add("MultiplyExpression");
+ }
+
+ if (node instanceof DivideExpression) {
+ expressionValue.add("DivideExpression");
+ }
+
+ if (node instanceof ModuloExpression) {
+ expressionValue.add("ModuloExpression");
+ }
+
+ if (node instanceof RemainderExpression) {
+ expressionValue.add("RemainderExpression");
+ }
+
+ if (node instanceof NotequalesExpression) {
+ expressionValue.add("NotequalesExpression");
+ }
+
+ if (node instanceof LessThanExpression) {
+ expressionValue.add("LessThanExpression");
+ }
+
+ if (node instanceof LessThanOrEqualExpression) {
+ expressionValue.add("LessThanOrEqualExpression");
+ }
+
+ if (node instanceof GreaterThanExpression) {
+ expressionValue.add("GreaterThanExpression");
+ }
+
+ if (node instanceof GreaterThanOrEqualExpression) {
+ expressionValue.add("GreaterThanOrEqualExpression");
+ }
+
+ if (node instanceof EqualsExpression) {
+ expressionValue.add("EqualsExpression");
+ }
+
+ if (node instanceof NotExpression) {
+ expressionValue.add("NotExpression");
+ }
+
+ if (node instanceof Range_ParsedSubType) {
+ expressionValue.add("Range_ParsedSubType");
+ }
+
+ if (node instanceof Str2IntExpression) {
+ expressionValue.add("Str2IntExpression");
+ }
+
+ if (node instanceof Log2StrExpression) {
+ expressionValue.add("Log2StrExpression");
+ }
+
+ if (node instanceof ValueofExpression) {
+ expressionValue.add("ValueofExpression");
+ }
+
+ }
+
+ public void leave(IVisitableNode node) {
+ if (!myASTVisitor.myFunctionTestCaseVisitHandler.waitForDefStatement
+ && (node instanceof Def_Const)) {
+ evaluateExpression();
+ handleConst(node);
+
+ }
+ }
+
+ public void handleConst(IVisitableNode node) {
+ Def_Const_Writer constNode = Def_Const_Writer
+ .getInstance(((Def_Const) node));
+ constNode.clearLists();
+
+ constNode.setConstNodeType(constNodeType);
+ constNode.constValues.addAll(constValues);
+ constNode.constParamCount.addAll(constParamCount);
+ constNode.constValueIsAReference = constValueIsAReference;
+
+ constValues.clear();
+ constValueIsAReference = false;
+ waitForConstValues = false;
+ constParamCounter = -3;
+ constParamCount.clear();
+
+
+ myASTVisitor.deleteLastBracket(myASTVisitor.currentFileName);
+ myASTVisitor.visualizeNodeToJava(constNode.getJavaSource() + "\r\n}");
+ myASTVisitor.constOmitHashes.clear();
+ }
+
+}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Const_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Const_Writer.java
index bf3eeaa45b3e709819c452c1b5ee80aeb2c41707..d8ab467b74a98eca89f8a05d852e7a8995b12b0a 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Const_Writer.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Const_Writer.java
@@ -20,38 +20,29 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.titan.designer.AST.ASTNode;
-import org.eclipse.titan.designer.AST.IVisitableNode;
-import org.eclipse.titan.designer.AST.Value;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const;
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
-import org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value;
-import org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value;
-import org.eclipse.titan.designer.AST.TTCN3.values.Omit_Value;
-import org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value;
-import org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value;
-import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
public class Def_Const_Writer {
private Def_Const constNode;
private StringBuilder constString = new StringBuilder("");
- private CompilationTimeStamp compilationCounter = CompilationTimeStamp
- .getNewCompilationCounter();
+
private String nodeName = null;
- private List constValues = new ArrayList();
+ public List constValues = new ArrayList();
private String constNodeType = null;
private int valueCounter = 0;
- private List constSetOfAmount = new ArrayList();
- private boolean isSetOf = false;
+ public List constParamCount = new ArrayList();
+ public boolean constValueIsAReference = false;
+ private boolean isSetOf = false;
private static Map constHashes = new LinkedHashMap();
+
private Def_Const_Writer(Def_Const node) {
super();
this.constNode = node;
- nodeName = node.getIdentifier().toString();
+ nodeName = constNode.getIdentifier().toString();
}
public static Def_Const_Writer getInstance(Def_Const node) {
@@ -63,20 +54,15 @@ public class Def_Const_Writer {
.toString());
}
- public void addConstValues(String value) {
- constValues.add(value);
- }
+
public void setConstNodeType(String value) {
constNodeType = value;
}
- public void setConstSetOfAmount(int num) {
- this.constSetOfAmount.add(num);
- }
-
public void writeConstConstructor(String rootNodeType,
String prefix) {
+ //type with children, child values need to be assigned
if (myASTVisitor.nodeNameChildrenNamesHashMap.containsKey(rootNodeType)) {
if (!isSetOf) {
@@ -107,6 +93,7 @@ public class Def_Const_Writer {
valueCounter++;
} else if (childrenNodeTypes[i].equals("INTEGER")) {
+
// printvalue
if (constValues.get(valueCounter).equals("omit")) {
constString.append(prefix + "." + childrenNodeNames[i]
@@ -115,9 +102,11 @@ public class Def_Const_Writer {
.append(prefix + "." + "omitField=true;\r\n");
} else {
+
constString.append(prefix + "." + childrenNodeNames[i]
- + "= new " + childrenNodeTypes[i] + "("
- + constValues.get(valueCounter) + ");\r\n");
+ + "= new " + childrenNodeTypes[i] + "(new BigInteger(\""
+ + constValues.get(valueCounter) + "\"));\r\n");
+
}
valueCounter++;
@@ -181,24 +170,87 @@ public class Def_Const_Writer {
}
}
- } else {
+ } else { //simple type, no child value assignments
if (myASTVisitor.nodeNameNodeTypeHashMap.containsKey(rootNodeType)) {
String type = myASTVisitor.nodeNameNodeTypeHashMap
.get(rootNodeType);
+
+
if (type.equals("CHARSTRING") || type.equals("INTEGER")) {
- constString.append("value=new " + constNodeType + "(new "
- + type + "(" + constValues.get(valueCounter)
- + "));\r\n");
+ if(constValueIsAReference){
+ if(myASTVisitor.nodeNameNodeTypeHashMap.containsKey(constValues.get(valueCounter))){
+ if(myASTVisitor.nodeNameNodeTypeHashMap.get(constValues.get(valueCounter)).equals("constant")){
+ constString.append("value = new "+constNodeType+"("+constValues.get(valueCounter)+".value)"
+ + ";\r\n");
+ }
+ }
+
+
+ constString.append("value="+constValues.get(valueCounter)
+ + ";\r\n");
+ }else{
+
+ constString.append("value=new " + constNodeType + "(new "
+ + type + "(new BigInteger(\"" + constValues.get(valueCounter)
+ + "\")));\r\n");
+ }
valueCounter++;
}
+ } else if(constNodeType.equals("INTEGER")){
+
+ if(constValueIsAReference){
+ constString.append("value="+constValues.get(valueCounter)
+ + ";\r\n");
+ }else{
+ constString.append("value=new " + constNodeType + "(new BigInteger(\"" + constValues.get(valueCounter)
+ + "\"));\r\n");
+ }
+
+ valueCounter++;
+ } else if(constNodeType.equals("BITSTRING")){
+ constString.append("value=new "
+ + "BITSTRING" + "(\"" + constValues.get(valueCounter)
+ + "\");\r\n");
+
+ valueCounter++;
+ } else if(constNodeType.equals("CHARSTRING")){
+ constString.append("value=new "
+ + "CHARSTRING" + "(\"" + constValues.get(valueCounter)
+ + "\");\r\n");
+
+ valueCounter++;
+ } else if(constNodeType.equals("OCTETSTRING")){
+ constString.append("value=new "
+ + "OCTETSTRING" + "(\"" + constValues.get(valueCounter)
+ + "\");\r\n");
+
+ valueCounter++;
+ } else if(constNodeType.equals("BOOLEAN")){
+ constString.append("value=new "
+ + "BOOLEAN" + "(" + constValues.get(valueCounter)
+ + ");\r\n");
+
+ valueCounter++;
}
}
}
+
+ public void clearLists(){
+ valueCounter = 0;
+
+ constValueIsAReference = false;
+ isSetOf = false;
+
+ constParamCount.clear();
+ constValues.clear();
+ }
public String getJavaSource() {
+ AstWalkerJava.logToConsole(" Starting processing: Constant " + nodeName );
+
constString.append("public static " + constNodeType + " " + nodeName
+ "(){\r\n");
constString.append(constNodeType + " value;\r\n");
@@ -209,9 +261,8 @@ public class Def_Const_Writer {
String returnString = constString.toString();
valueCounter = 0;
constString.setLength(0);
- constSetOfAmount.clear();
- constValues.clear();
-
+
+ AstWalkerJava.logToConsole(" Finished processing: Constant " + nodeName );
return returnString;
}
}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Function_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Function_Writer.java
index cdf5b8830644c2c0cfa1f11e942981c7d9af1d37..340ad48a542a611106fd47a2edd6e8f6a3f47c82 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Function_Writer.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Function_Writer.java
@@ -15,7 +15,6 @@
package org.eclipse.titan.codegenerator;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@@ -23,40 +22,35 @@ import java.util.Map;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer;
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var;
import org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement;
-import org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard;
import org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement;
-import org.eclipse.titan.designer.AST.TTCN3.statements.Repeat_Statement;
-import org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock;
-import org.eclipse.titan.designer.AST.TTCN3.statements.Timeout_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Start_Statement;
import org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template;
-import org.eclipse.titan.designer.AST.TTCN3.types.CompField;
-import org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type;
-import org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type;
+import org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.expressions.AddExpression;
-import org.eclipse.titan.designer.AST.TTCN3.values.expressions.Int2StrExpression;
-import org.eclipse.titan.designer.declarationsearch.Declaration;
-import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.DivideExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.ModuloExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.MultiplyExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.RemainderExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.SubstractExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.UnaryMinusExpression;
public class Def_Function_Writer {
private Def_Function functionNode;
private StringBuilder functionString = new StringBuilder("");
- private CompilationTimeStamp compilationCounter = CompilationTimeStamp
- .getNewCompilationCounter();
- private String nodeName = null;
+ public String nodeName = null;
private static Map functionHashes = new LinkedHashMap();
@@ -65,33 +59,49 @@ public class Def_Function_Writer {
private String currentTimerName = null;
public String returnStatementValue = null;
- private String runsOnValue = null;
- private String returnType = null;
- private String timerValue = null;
- private String unknownStartReference = null;
- private List sendPortReference = new ArrayList();
- private List sendParameter = new ArrayList();
- private List sendParameterType = new ArrayList();
- private int sendCounter = -1;
- private List recievePortReference = new ArrayList();
- private List recieveParameter = new ArrayList();
- private List recieveParameterType = new ArrayList();
- private int recieveCounter = -1;
- private List addValues = new ArrayList();
+ public String runsOnValue = null;
+ public String returnType = null;
+
+ public String unknownStartReference = null;
+ public String unknownStopReference = null;
+ public static List sendPortReference = new ArrayList();
+ public static List sendParameter = new ArrayList();
+ public static List sendParameterType = new ArrayList();
+ public int sendCounter = -1;
+
+ public List altStatements = new ArrayList();
+ private int altStatementCounter = -1;
+
+ public List functionVars = new ArrayList();
+ public List functionVarTypes = new ArrayList();
+ public List functionVarValues = new ArrayList();
+ public List functionAssignIdentifiers = new ArrayList();
+ public List functionAssignValues = new ArrayList();
+
+ public int receiveCounter = -1;
+
+ public List receivePortReference = new ArrayList();
+ public List receiveValue = new ArrayList();
+ public List receiveAnyValValue = new ArrayList();
+ public List receiveType = new ArrayList();
+ public List receiveStatements = new ArrayList();
+
+ public List functionValueIsAValueReference = new ArrayList();
+ public List functionVarIsConstant = new ArrayList();
+ private int defCounter = -1;
+ public int assignCounter = -1;
private Def_Function_Writer(Def_Function typeNode) {
super();
this.functionNode = typeNode;
- nodeName = typeNode.getIdentifier().toString();
+ nodeName = functionNode.getIdentifier().toString();
}
public static Def_Function_Writer getInstance(Def_Function typeNode) {
if (!functionHashes.containsKey(typeNode.getIdentifier().toString())) {
- functionHashes.put(typeNode.getIdentifier().toString(),
- new Def_Function_Writer(typeNode));
+ functionHashes.put(typeNode.getIdentifier().toString(), new Def_Function_Writer(typeNode));
}
- return (Def_Function_Writer) functionHashes.get(typeNode
- .getIdentifier().toString());
+ return (Def_Function_Writer) functionHashes.get(typeNode.getIdentifier().toString());
}
public void setStatementBlock(StatementBlock statementBlock) {
@@ -100,575 +110,435 @@ public class Def_Function_Writer {
public void writeFunction() {
- functionString.append("public void " + nodeName + "(){\r\n");
+ if (returnType != null) {
+ if (returnType.equals("Integer_Type")) {
+ functionString.append("public static INTEGER " + nodeName + "(){\r\n");
+ } else if (returnType.equals("Boolean_Type")) {
+ functionString.append("public static BOOLEAN " + nodeName + "(){\r\n");
+ }
+ } else {
+ functionString.append("public void " + nodeName + "(){\r\n");
- /*
- * if (AstWalkerJava.areCommentsAllowed) {
- * functionString.append("System.out.println(\"" + nodeName +
- * " started\");" + "\r\n"); }
- */
+ functionString.append("String sourcefilename = \""
+ + statementBlock.getLocation().getFile().getFullPath().lastSegment() + "\";" + "\r\n");
+ functionString.append("int rownum=" + statementBlock.getLocation().getLine() + ";\r\n");
+ functionString.append("if(!created) return;" + "\r\n");
- functionString.append("String sourcefilename = \""
- + statementBlock.getLocation().getFile().getFullPath()
- .lastSegment() + "\";" + "\r\n");
- functionString.append("int rownum=" + functionNode.getLocation().getLine()
- + ";\r\n");
- functionString.append("if(!created) return;" + "\r\n");
+ functionString.append("TTCN3Logger.writeLog(compid, \"PARALLEL\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"Function started on \" + compid + \".\", false);" + "\r\n");
- functionString
- .append("TTCN3Logger.writeLog(compid, \"PARALLEL\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"Function started on \" + compid + \".\", false);"
- + "\r\n");
+ }
for (int i = 0; i < statementBlock.getSize(); i++) {
if (statementBlock.getStatementByIndex(i) instanceof Definition_Statement) {
- writeDefinitionStatement((Definition_Statement) statementBlock
- .getStatementByIndex(i));
+ writeDefinitionStatement((Definition_Statement) statementBlock.getStatementByIndex(i));
+ } else if (statementBlock.getStatementByIndex(i) instanceof Assignment_Statement) {
+ assignCounter++;
+
+ functionString
+ .append(writeAssignmentStatement((Assignment_Statement) statementBlock.getStatementByIndex(i)));
+
} else if (statementBlock.getStatementByIndex(i) instanceof Send_Statement) {
sendCounter++;
- writeSendStatement((Send_Statement) statementBlock
- .getStatementByIndex(i));
+ functionString.append(writeSendStatement((Send_Statement) statementBlock.getStatementByIndex(i)));
} else if (statementBlock.getStatementByIndex(i) instanceof Unknown_Start_Statement) {
- writeUnknownStartStatement((Unknown_Start_Statement) statementBlock
- .getStatementByIndex(i));
+ writeUnknownStartStatement((Unknown_Start_Statement) statementBlock.getStatementByIndex(i));
} else if (statementBlock.getStatementByIndex(i) instanceof Alt_Statement) {
- writeAltStatement((Alt_Statement) statementBlock
- .getStatementByIndex(i));
+
+ altStatementCounter++;
+
+ altStatements.get(altStatementCounter).setTimerInfo(isThereAStartedTimer, currentTimerName);
+ functionString.append(altStatements.get(altStatementCounter).getJavaSource());
+
} else if (statementBlock.getStatementByIndex(i) instanceof Setverdict_Statement) {
- writeSetVerdictStatement((Setverdict_Statement) statementBlock
- .getStatementByIndex(i));
+ writeSetVerdictStatement((Setverdict_Statement) statementBlock.getStatementByIndex(i));
}
}
+ if (returnStatementValue != null) {
+ functionString.append("return " + returnStatementValue + ";\r\n");
+ }
+
}
- public String[] writeAltCommands(Operation_Altguard altGuard) {
- int rownum = 0;
- StringBuilder altString = new StringBuilder();
-
- int guardBlockSize = altGuard.getStatementBlock().getSize();
- for (int j = 0; j < guardBlockSize; j++) {
-
- if (altGuard.getStatementBlock().getStatementByIndex(j) instanceof Setverdict_Statement) {
-
- if (altGuard.getStatementBlock().getStatementByIndex(j) instanceof Setverdict_Statement) {
- Setverdict_Statement verdictAltGuard = (Setverdict_Statement) altGuard
- .getStatementBlock().getStatementByIndex(j);
-
- String verdict = "";
- if (verdictAltGuard.getVerdictValue() instanceof Verdict_Value) {
- Verdict_Value verdictValue = (Verdict_Value) verdictAltGuard
- .getVerdictValue();
- if (verdictValue.getValue().toString().equals("PASS")) {
- verdict = "pass";
- } else if (verdictValue.getValue().toString()
- .equals("INCONC")) {
- verdict = "inconc";
- } else {
- verdict = "fail";
-
- }
- altString.append("rownum="
- + verdictValue.getLocation().getLine()
- + ";\r\n");
- altString
- .append("TTCN3Logger.writeLog(compid, \"VERDICTOP\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"setverdict("
- + verdict
- + "): \" + getVerdict() + \" -> "
- + verdict + "\", true);" + "\r\n");
-
- altString.append("setVerdict(\"" + verdict
- + "\");break;" + "\r\n");
- rownum = verdictValue.getLocation().getLine();
- }
- }
+ // updated
+ public void writeDefinitionStatement(Definition_Statement tc_defStatement) {
+
+ defCounter++;
+ if (tc_defStatement.getDefinition() instanceof Def_Timer) {
+ Def_Timer def_Timer = (Def_Timer) tc_defStatement.getDefinition();
+
+ functionString.append("rownum=" + def_Timer.getLocation().getLine() + ";\r\n");
+ functionString.append("Timer " + def_Timer.getIdentifier().toString() + " = new Timer (new FLOAT("
+ + functionVarValues.get(defCounter) + "));\r\n");
+
+ functionString.append("TTCN3Logger.writeLog(compid, \"TIMEROP\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"Timer " + def_Timer.getIdentifier().toString() + " set to "
+ + functionVarValues.get(defCounter) + ".\", false);" + "\r\n");
+
+ } else if (functionVarTypes.get(defCounter).equals("BITSTRING")) {
+ functionString.append("rownum=" + tc_defStatement.getLocation().getLine() + ";\r\n");
+
+ if (functionVarIsConstant.get(defCounter)) {
+ functionString.append("final ");
}
- if (altGuard.getStatementBlock().getStatementByIndex(j) instanceof Assignment_Statement) {
- Assignment_Statement assignmentGuard = (Assignment_Statement) altGuard
- .getStatementBlock().getStatementByIndex(j);
+ if (functionVarValues.get(defCounter).equals("null")) {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter)
+ + "=new BITSTRING();\r\n");
- String assignmentName = assignmentGuard.getReference()
- .getSubreferences().get(0).getId().toString();
+ } else if (functionValueIsAValueReference.get(defCounter)) {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter) + "="
+ + functionVarValues.get(defCounter) + ";\r\n");
- if (assignmentGuard.getTemplate().getValue() instanceof AddExpression) {
- altString.append("rownum="+assignmentGuard.getLocation().getLine()+";\r\n");
- altString.append(assignmentName + "=" + addValues.get(0)
- + ".plus(new INTEGER(" + addValues.get(1) + ")); \r\n");
- }
+ } else {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter)
+ + "=new BITSTRING(\"" + functionVarValues.get(defCounter) + "\");\r\n");
}
+ // TODO: add logging here
- if (altGuard.getStatementBlock().getStatementByIndex(j) instanceof Repeat_Statement) {
- // TODO
+ } else if (functionVarTypes.get(defCounter).equals("INTEGER")) {
+
+ functionString.append("rownum=" + tc_defStatement.getLocation().getLine() + ";\r\n");
+ if (functionVarIsConstant.get(defCounter)) {
+ functionString.append("final ");
}
- if (altGuard.getStatementBlock().getStatementByIndex(j) instanceof Send_Statement) {
- sendCounter++;
- Send_Statement sendAltGuard = (Send_Statement) altGuard
- .getStatementBlock().getStatementByIndex(j);
+ if (functionVarValues.get(defCounter).equals("null")) {
+ functionString.append(
+ functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter) + "=new INTEGER();\r\n");
- String portReferenceName = sendPortReference.get(sendCounter);
- String parameterName = null;
- String parameterType = null;
- String valueType = sendParameterType.get(sendCounter);
- String valueName = sendParameter.get(sendCounter);
+ } else if (functionValueIsAValueReference.get(defCounter)) {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter) + "="
+ + functionVarValues.get(defCounter) + ";\r\n");
- if (valueType.equals("Undefined_LowerIdentifier_Value")) {
+ } else {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter)
+ + "=new INTEGER(new BigInteger(\"" + functionVarValues.get(defCounter) + "\"));\r\n");
- parameterName = valueName;
- }
+ }
+ // TODO: add logging here
- if (valueType.equals("Charstring_Value")) {
- parameterName = "new CHARSTRING(\"" + valueName + "\")";
- }
+ } else if (functionVarTypes.get(defCounter).equals("CHARSTRING")) {
- if (valueType.equals("Int2StrExpression")) {
- parameterName = valueName+".int2str()";
- }
+ functionString.append("rownum=" + tc_defStatement.getLocation().getLine() + ";\r\n");
- altString.append("rownum="+sendAltGuard.getLocation().getLine()+";\r\n");
- altString.append(portReferenceName + ".send(" + parameterName
- + ");" + "\r\n");
+ if (functionVarIsConstant.get(defCounter)) {
+ functionString.append("final ");
+ }
- altString.append("TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""+nodeName+"\", \"SEND event on port "+portReferenceName+":\" + "+parameterName+".toString(), true);"+"\r\n");
+ if (functionVarValues.get(defCounter).equals("null")) {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter)
+ + "=new CHARSTRING();\r\n");
+
+ } else if (functionValueIsAValueReference.get(defCounter)) {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter) + "="
+ + functionVarValues.get(defCounter) + ";\r\n");
+
+ } else {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter)
+ + "=new CHARSTRING(\"" + functionVarValues.get(defCounter) + "\");\r\n");
+
+ }
+ // TODO: add logging here
+
+ } else if (functionVarTypes.get(defCounter).equals("BOOLEAN")) {
+
+ functionString.append("rownum=" + tc_defStatement.getLocation().getLine() + ";\r\n");
+
+ if (functionVarIsConstant.get(defCounter)) {
+ functionString.append("final ");
+ }
+
+ if (functionVarValues.get(defCounter).equals("null")) {
+ functionString.append(
+ functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter) + "=new BOOLEAN();\r\n");
+
+ } else if (functionValueIsAValueReference.get(defCounter)) {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter) + "="
+ + functionVarValues.get(defCounter) + ";\r\n");
+
+ } else {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter)
+ + "=new BOOLEAN(" + functionVarValues.get(defCounter) + ");\r\n");
+
+ }
+ // TODO: add logging here
+ } else if (myASTVisitor.nodeNameNodeTypeHashMap.containsKey(functionVarTypes.get(defCounter))) {
+ functionString.append("rownum=" + tc_defStatement.getLocation().getLine() + ";\r\n");
+ if (functionVarValues.get(defCounter) != null) {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter) + "= new "
+ + functionVarTypes.get(defCounter) + "(" + functionVarValues.get(defCounter) + ")" + ";\r\n");
+ } else {
+ functionString.append(functionVarTypes.get(defCounter) + " " + functionVars.get(defCounter) + ";\r\n");
}
}
- String[] returnvalue = new String[2];
- returnvalue[0] = altString.toString();
- returnvalue[1] = Integer.toString(rownum);
- return returnvalue;
}
- public void writeDefinitionStatement(
- Definition_Statement definitionStatement) {
+ // updated
+ public String writeAssignmentStatement(Assignment_Statement tc_assignStatement) {
- if (definitionStatement.getDefinition() instanceof Def_Timer) {
- String statementName = definitionStatement.getDefinition()
- .getIdentifier().toString();
- Def_Timer currentTimer = (Def_Timer) definitionStatement
- .getDefinition();
+ StringBuilder functionString = new StringBuilder("");
- functionString.append("rownum="
- + definitionStatement.getDefinition().getLocation()
- .getLine() + ";\r\n");
- functionString.append("Timer " + statementName
- + " = new Timer (new FLOAT(" + timerValue + "));\r\n");
+ if (tc_assignStatement.getTemplate() instanceof SpecificValue_Template) {
+ SpecificValue_Template specValTemplate = (SpecificValue_Template) tc_assignStatement.getTemplate();
- functionString
- .append("TTCN3Logger.writeLog(compid, \"TIMEROP\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"Timer "
- + statementName
- + " set to " + timerValue + ".\", false);" + "\r\n");
+ if (specValTemplate.getSpecificValue() instanceof Bitstring_Value) {
- }
+ functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
- if (definitionStatement.getDefinition() instanceof Def_Var) {
- String variableType = "";
- String variableName = "";
- String variableValue = "";
-
- Def_Var currentVar = (Def_Var) definitionStatement.getDefinition();
- variableName = definitionStatement.getDefinition().getIdentifier()
- .toString();
-
- if (currentVar.getType(compilationCounter) instanceof Referenced_Type) {
- Referenced_Type ref = (Referenced_Type) currentVar
- .getType(compilationCounter);
- variableType = ref.getReference().getSubreferences().get(0)
- .getId().toString();
-
-
- }
+ functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new BITSTRING(\""
+ + functionAssignValues.get(assignCounter) + "\");\r\n");
- if (currentVar.getType(compilationCounter) instanceof Integer_Type) {
- Integer_Type ref = (Integer_Type) currentVar
- .getType(compilationCounter);
- variableType = "INTEGER";
- if (currentVar.getInitialValue() instanceof Integer_Value) {
- Integer_Value varValue = (Integer_Value) currentVar
- .getInitialValue();
- variableValue = " = new INTEGER(" + varValue.getValueValue().toString()+")";
- }
+ // TODO: add logging here
}
- functionString.append("rownum="
- + currentVar.getLocation().getLine() + ";\r\n");
- functionString.append(variableType + " " + variableName
- + variableValue + ";\r\n");
- }
+ if (specValTemplate.getSpecificValue() instanceof Integer_Value) {
- }
+ functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
- public void writeSendStatement(Send_Statement sendStatement) {
+ functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new INTEGER(new BigInteger(\""
+ + functionAssignValues.get(assignCounter) + "\"));\r\n");
- String portReferenceName = sendPortReference.get(sendCounter);
- String parameterName = null;
- String parameterType = null;
- String valueType = sendParameterType.get(sendCounter);
- String valueName = sendParameter.get(sendCounter);
+ // TODO: add logging here
- if (valueType.equals("Undefined_LowerIdentifier_Value")) {
+ }
+
+ if (specValTemplate.getSpecificValue() instanceof Charstring_Value) {
+
+ functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
+
+ functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new CHARSTRING(\""
+ + functionAssignValues.get(assignCounter) + "\");\r\n");
+
+ // TODO: add logging here
- if (myASTVisitor.nodeNameNodeTypeHashMap.containsKey(valueName)) {
- parameterType = myASTVisitor.nodeNameNodeTypeHashMap
- .get(valueName);
}
- if (parameterType.equals("template")) {
- parameterType = "Templates";
+ if (specValTemplate.getSpecificValue() instanceof Boolean_Value) {
+
+ functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
+
+ functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new BOOLEAN("
+ + functionAssignValues.get(assignCounter) + ");\r\n");
+
+ // TODO: add logging here
+
}
- parameterName = parameterType + "." + valueName + "()";
-
- functionString.append("rownum=" + sendStatement.getLocation().getLine()
- + ";\r\n");
- functionString.append(portReferenceName + ".send(" + parameterName
- + ");" + "\r\n");
- functionString
- .append("TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"SEND event on port "
- + portReferenceName
- + ": "
- + valueName
- + ":=\" + "
- + parameterName + ".toString(), true);" + "\r\n");
-
- }
+ if (specValTemplate.getSpecificValue() instanceof Undefined_LowerIdentifier_Value) {
- if (valueType.equals("Charstring_Value")) {
- parameterName = "new CHARSTRING(\"" + valueName + "\")";
- functionString.append("rownum=" + sendStatement.getLocation().getLine()
- + ";\r\n");
- functionString.append(portReferenceName + ".send(" + parameterName
- + ");" + "\r\n");
- functionString
- .append("TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"SEND event on port "
- + portReferenceName
- + ":\"+"
- + parameterName + ".toString(), false);" + "\r\n");
-
-
-
-
-
- }
-
+ functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
- }
+ functionString.append(functionAssignIdentifiers.get(assignCounter) + "="
+ + functionAssignValues.get(assignCounter) + ";\r\n");
- public void writeUnknownStartStatement(
- Unknown_Start_Statement unknownStartStatement) {
- functionString.append("rownum="
- + unknownStartStatement.getLocation().getLine() + ";\r\n");
- functionString.append(unknownStartReference + ".start();" + "\r\n");
- isThereAStartedTimer = true;
- currentTimerName = unknownStartReference;
- functionString
- .append("TTCN3Logger.writeLog(compid, \"TIMEROP\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"Timer "
- + unknownStartReference
- + " started.\", false);" + "\r\n");
+ // TODO: add logging here
+ }
- }
+ if (specValTemplate.getSpecificValue() instanceof Referenced_Value) {
- public void writeAltStatement(Alt_Statement altStatement) {
- functionString.append("rownum=" + altStatement.getLocation().getLine()
- + ";\r\n");
- functionString.append("for(;;){" + "\r\n");
-
- int altSize = altStatement.getAltGuards().getNofAltguards();
-
- String[] allPortname = new String[altSize];
- String[] allPortRecieveType = new String[altSize];
- String[] negativeConditions = new String[altSize];
- String[] positiveConditions = new String[altSize];
- String[] altCommands = new String[altSize];
- String[] altRowNum = new String[altSize];
- String[] logReceiveType = new String[altSize];
- String[] logReceiveValue = new String[altSize];
- boolean[] isTheRecieveTyped = new boolean[altSize];
- int[] receiveRowNum = new int[altSize];
- String[] logTimeout = new String[altSize];
-
- // portsetter
- for (int i = 0; i < altSize; i++) {
-
- String[] portType = new String[altSize];
-
- if (altStatement.getAltGuards().getAltguardByIndex(i) instanceof Operation_Altguard) {
-
- Operation_Altguard altGuard = (Operation_Altguard) altStatement
- .getAltGuards().getAltguardByIndex(i);
-
- // if recieves from a specific prot
- if (altGuard.getGuardStatement() instanceof Receive_Port_Statement) {
- recieveCounter++;
- Receive_Port_Statement recievePortAltGuard = (Receive_Port_Statement) altGuard
- .getGuardStatement();
- if (recieveParameterType.get(recieveCounter).equals(
- "Any_Value_Template")) {
- recieveCounter++;
- }
- if ((!recievePortReference.get(recieveCounter).equals(
- "_ANY_"))) {
+ functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
- String valueType = recieveParameterType
- .get(recieveCounter);
- String valueName = recieveParameter.get(recieveCounter);
+ functionString.append(functionAssignIdentifiers.get(assignCounter) + "="
+ + functionAssignValues.get(assignCounter) + ";\r\n");
- if (valueType.equals("Undefined_LowerIdentifier_Value")) {
+ // TODO: add logging here
+ }
- String parameterType = null;
+ if ((specValTemplate.getSpecificValue() instanceof AddExpression)
+ || (specValTemplate.getSpecificValue() instanceof SubstractExpression)
+ || (specValTemplate.getSpecificValue() instanceof MultiplyExpression)
+ || (specValTemplate.getSpecificValue() instanceof DivideExpression)
+ || (specValTemplate.getSpecificValue() instanceof ModuloExpression)
+ || (specValTemplate.getSpecificValue() instanceof RemainderExpression)) {
- if (myASTVisitor.nodeNameNodeTypeHashMap
- .containsKey(valueName)) {
- parameterType = myASTVisitor.nodeNameNodeTypeHashMap
- .get(valueName);
- }
+ functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
- if (parameterType.equals("template")) {
- parameterType = "Templates";
- }
+ functionString.append(functionAssignIdentifiers.get(assignCounter)
+ + functionAssignValues.get(assignCounter) + ";\r\n");
- allPortRecieveType[i] = parameterType + "."
- + valueName + "()";
- logReceiveValue[i] = valueName;
- }
- if (valueType.equals("Charstring_Value")) {
+ // TODO: add logging here
- allPortRecieveType[i] = "new CHARSTRING(" + "\""
- + valueName + "\")";
- }
- receiveRowNum[i]=recievePortAltGuard.getLocation().getLine();
- allPortname[i] = recievePortAltGuard.getPort()
- .getSubreferences().get(0).getId().toString();
+ }
- } else {
- receiveRowNum[i]=recievePortAltGuard.getLocation().getLine();
- allPortname[i] = "any port";
+ if (specValTemplate.getSpecificValue() instanceof UnaryMinusExpression) {
- }
+ functionString.append("rownum=" + specValTemplate.getLocation().getLine() + ";\r\n");
- }
+ functionString.append(functionAssignIdentifiers.get(assignCounter) + "=new INTEGER(new BigInteger(\""
+ + functionAssignValues.get(assignCounter) + "\"));\r\n");
+
+ // TODO: add logging here
}
+
}
- int recieveParamCounter = -1;
- for (int i = 0; i < altSize; i++) {
- String portname = allPortname[i];
- String portRecieveType = allPortRecieveType[i];
- String verdict = "";
- String timerName = "";
- String portType = "";
-
- if (altStatement.getAltGuards().getAltguardByIndex(i) instanceof Operation_Altguard) {
- Operation_Altguard altGuard = (Operation_Altguard) altStatement
- .getAltGuards().getAltguardByIndex(i);
-
- // if recieves from a specific prot
- if (altGuard.getGuardStatement() instanceof Receive_Port_Statement) {
- Receive_Port_Statement recievePortAltGuard = (Receive_Port_Statement) altGuard
- .getGuardStatement();
- recieveParamCounter++;
-
- if (!recievePortReference.get(recieveParamCounter).equals(
- "_ANY_")) {
-
- if (recieveParameterType.get(recieveParamCounter)
- .equals("_TYPED_PARAM_")) {
- portType = recieveParameter
- .get(recieveParamCounter);
- recieveCounter++;
- }
- }
+ return functionString.toString();
+ }
- if (recievePortAltGuard.getPort() != null) {
- portname = recievePortAltGuard.getPort()
- .getSubreferences().get(0).getId().toString();
- // if the port is set
-
- if (portType.equals("")) {
- negativeConditions[i] = portname + ".receive("
- + portRecieveType + ",false)!=null";
- positiveConditions[i] = portname + ".receive("
- + portRecieveType + ",true)!=null";
-
- isTheRecieveTyped[i] = false;
- } else {
- negativeConditions[i] = portname + ".receive" + "_"
- + portType + "(false)!=null";
-
- String redirectString = recievePortAltGuard
- .getRedirectValue().getSubreferences()
- .get(0).getId().toString();
- positiveConditions[i] = "(" + redirectString + "="
- + portname + ".receive" + "_" + portType
- + "(true))!=null";
- isTheRecieveTyped[i] = true;
- logReceiveType[i] = portType;
- }
+ public String writeSendStatement(Send_Statement sendStatement) {
- } else {
- // if no port is set
- negativeConditions[i] = "anyPortReceive(false)";
- positiveConditions[i] = "anyPortReceive(true)";
+ StringBuilder functionString = new StringBuilder("");
- }
+ String portReferenceName = sendPortReference.get(sendCounter);
+ String parameterName = null;
+ String parameterType = null;
+ String valueType = sendParameterType.get(sendCounter);
+ String valueName = sendParameter.get(sendCounter);
- }
+ if (valueType.equals("IDENTIFIER")) {
- if (altGuard.getGuardStatement() instanceof Timeout_Statement) {
- Timeout_Statement timeOutAltGuard = (Timeout_Statement) altGuard
- .getGuardStatement();
-
- isThereAStartedTimer = true;
- negativeConditions[i] = ("!" + currentTimerName + ".timeout()");
- positiveConditions[i] = ("" + currentTimerName + ".timeout()");
-
- logTimeout[i]="rownum="+timeOutAltGuard.getLocation().getLine()+";\r\n"+"TTCN3Logger.writeLog(compid, \"TIMEROP\", sourcefilename, rownum, \"function\", \""+nodeName+"\", \"Timeout on timer "+currentTimerName+".\", false);"+"\r\n";
-
-
- }
- String[] commandBlock=writeAltCommands(altGuard);
- altCommands[i] = commandBlock[0];
- altRowNum[i] = commandBlock[1];
+ if (myASTVisitor.nodeNameNodeTypeHashMap.containsKey(valueName)) {
+ parameterType = myASTVisitor.nodeNameNodeTypeHashMap.get(valueName);
+ if (parameterType.equals("template")) {
+ parameterType = "Templates";
+ }
+ parameterName = parameterType + "." + valueName + "()";
+ } else {
+ parameterName = valueName;
}
+ functionString.append("rownum=" + sendStatement.getLocation().getLine() + ";\r\n");
+ functionString.append(portReferenceName + ".send(" + parameterName + ");" + "\r\n");
+ functionString.append("TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"SEND event on port " + portReferenceName + ": " + valueName + ":=\" + "
+ + parameterName + ".toString(), true);" + "\r\n");
+
}
- functionString.append("if(!(");
- for (int condStepper = 0; condStepper < altSize; condStepper++) {
- functionString.append(negativeConditions[condStepper]);
- if (condStepper + 1 < altSize) {
- functionString.append("||");
- }
+ if (valueType.equals("CHARSTRING")) {
+ parameterName = valueName;
+ functionString.append("rownum=" + sendStatement.getLocation().getLine() + ";\r\n");
+ functionString.append(portReferenceName + ".send(" + parameterName + ");" + "\r\n");
+ functionString.append("TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"SEND event on port " + portReferenceName + ":\"+" + parameterName
+ + ".toString(), false);" + "\r\n");
+
}
- functionString.append(")){" + "\r\n");
-
- // timer
- if (isThereAStartedTimer) {
- functionString.append("long timeout = -1;" + "\r\n");
- functionString.append("long newtimeout;" + "\r\n");
-
- functionString
- .append("if("
- + currentTimerName
- + ".running)if((newtimeout=(long)("
- + currentTimerName
- + ".read().value*1000.0))0) try{queue.poll(timeout,TimeUnit.MILLISECONDS);}catch(InterruptedException e){} "
- + "\r\n");
- functionString.append("this.lock();" + "\r\n");
+
+ return functionString.toString();
+
+ }
+
+ public String writeReceiveStatement(Receive_Port_Statement currentStatement) {
+ StringBuilder testCaseString = new StringBuilder("");
+ String receiveStatement = "";
+
+ // no alt guard && any port recieve
+ if (receivePortReference.get(receiveCounter).equals("any port")) {
+ receiveStatement = "anyPortReceive(true)";
+
} else {
+ // no alt guard && typed port recieve
+ if (receiveType.get(receiveCounter).equals("_TYPED_PARAM_")) {
+
+ if (receiveAnyValValue.get(receiveCounter) != null) {
+ receiveStatement = "(" + receiveAnyValValue.get(receiveCounter) + "="
+ + receivePortReference.get(receiveCounter) + ".receive_" + receiveValue.get(receiveCounter)
+ + "(true))!=null";
+
+ } else {
- functionString
- .append("try{queue.take();}catch(InterruptedException e){}"
- + "\r\n");
- functionString.append("this.lock();" + "\r\n");
+ }
+ } else { // no alt guard && normal port recieve
+ receiveStatement = receivePortReference.get(receiveCounter) + ".receive("
+ + receiveValue.get(receiveCounter) + ",true)!=null";
+ }
+ if (receiveValue.get(receiveCounter).startsWith("Templates")) {
+ receiveType.set(receiveCounter, "Templates");
+ }
}
- // endoftimer
- functionString.append("}" + "\r\n");
+ testCaseString.append("if(" + receiveStatement + "){\r\n");
+ testCaseString.append("rownum=" + currentStatement.getLocation().getLine() + ";\r\n");
- // ifwriter
- for (int condCounter = 0; condCounter < altSize; condCounter++) {
+ if (receiveType.get(receiveCounter).equals("Templates")) {
+ String methodName = receiveValue.get(receiveCounter);
+ if (methodName.endsWith("()") && methodName.startsWith("Templates.")) {
- if (condCounter > 0) {
- functionString.append("else ");
+ methodName = (String) methodName.subSequence(10, methodName.length() - 2);
}
- functionString.append("if(");
- functionString.append(positiveConditions[condCounter]);
- functionString.append("){" + "\r\n");
-
- if (allPortname[condCounter] != null) {
- if (!isTheRecieveTyped[condCounter]) {
- if (logReceiveValue[condCounter] != null) {
- functionString.append("rownum="+receiveRowNum[condCounter]+";\r\n");
- functionString
- .append("TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"RECEIVE event on port "
- + allPortname[condCounter]
- + ":\\n "
- + logReceiveValue[condCounter]
- + ":=\" + "
- + allPortRecieveType[condCounter]
- + ".toString(), true);" + "\r\n");
+
+ testCaseString
+ .append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"RECEIVE event on port " + receivePortReference.get(receiveCounter)
+ + ":\\n " + methodName + ":=\" + " + receiveValue.get(receiveCounter)
+ + ".toString(), true);" + "\r\n");
+ } else if (receiveType.get(receiveCounter).equals("any port")) {
+ testCaseString
+ .append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"RECEIVE event on port any port\", true);" + "\r\n");
+ } else if (receiveType.get(receiveCounter).equals("_TYPED_PARAM_")) {
+ testCaseString
+ .append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"RECEIVE event on port " + receivePortReference.get(receiveCounter)
+ + ": type " + receiveValue.get(receiveCounter) + "\", true);" + "\r\n");
+
+ } else {
+ testCaseString
+ .append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"RECEIVE event on port " + receivePortReference.get(receiveCounter)
+ + ":\" + " + receiveValue.get(receiveCounter) + ".toString(), true);" + "\r\n");
+ }
+
+ for (int i = 0; i < receiveStatements.get(receiveCounter).getSize(); i++) {
+ if (receiveStatements.get(receiveCounter).getStatementByIndex(i) instanceof Setverdict_Statement) {
+
+ Setverdict_Statement setVerdictStatement = (Setverdict_Statement) receiveStatements.get(receiveCounter)
+ .getStatementByIndex(i);
+ String verdict = "";
+
+ if (setVerdictStatement.getVerdictValue() instanceof Verdict_Value) {
+ Verdict_Value verdictValue = (Verdict_Value) setVerdictStatement.getVerdictValue();
+ if (verdictValue.getValue().toString().equals("PASS")) {
+ verdict = "pass";
+ } else if (verdictValue.getValue().toString().equals("INCONC")) {
+ verdict = "inconc";
} else {
- if (allPortRecieveType[condCounter] != null) {
- functionString.append("rownum="+receiveRowNum[condCounter]+";\r\n");
- functionString
- .append(" TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"RECEIVE event on port "
- + allPortname[condCounter]
- + ":\" + "
- + allPortRecieveType[condCounter]
- + ".toString(), true);" + "\r\n");
- } else {
- functionString.append("rownum="+receiveRowNum[condCounter]+";\r\n");
- functionString
- .append("TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"RECEIVE event on port "
- + allPortname[condCounter]
- + "\", true);" + "\r\n");
- }
+ verdict = "fail";
}
- } else {
- functionString.append("rownum="+receiveRowNum[condCounter]+";\r\n");
- functionString
- .append("TTCN3Logger.writeLog(compid, \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"RECEIVE event on port "
- + allPortname[condCounter]
- + ": type "
- + logReceiveType[condCounter]
- + "\", true);" + "\r\n");
}
+ testCaseString.append("rownum=" + setVerdictStatement.getLocation().getLine() + ";\r\n");
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"VERDICTOP\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"setverdict(" + verdict + "): \" + getVerdict() + \" -> " + verdict
+ + "\", true);" + "\r\n");
+ testCaseString.append("setVerdict(\"" + verdict + "\");" + "\r\n");
+
}
-
- if(logTimeout[condCounter]!=null){
- functionString.append(logTimeout[condCounter]);
- }
+ }
- // TODO: ide jön az if log
- functionString.append(altCommands[condCounter]);
+ testCaseString.append("}\r\n");
- functionString.append("}" + "\r\n");
+ return testCaseString.toString();
+ }
- }
- functionString.append("this.unlock();" + "\r\n");
- functionString.append("}" + "\r\n");
+ // updated
+ public void writeUnknownStartStatement(Unknown_Start_Statement unknownStartStatement) {
+ functionString.append("rownum=" + unknownStartStatement.getLocation().getLine() + ";\r\n");
+ functionString.append(unknownStartReference + ".start();" + "\r\n");
+ isThereAStartedTimer = true;
+ currentTimerName = unknownStartReference;
+ functionString.append("TTCN3Logger.writeLog(compid, \"TIMEROP\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"Timer " + unknownStartReference + " started.\", false);" + "\r\n");
}
- public void writeSetVerdictStatement(
- Setverdict_Statement setVerdictStatement) {
+ public void writeSetVerdictStatement(Setverdict_Statement setVerdictStatement) {
String verdict = "";
if (setVerdictStatement.getVerdictValue() instanceof Verdict_Value) {
- Verdict_Value verdictValue = (Verdict_Value) setVerdictStatement
- .getVerdictValue();
+ Verdict_Value verdictValue = (Verdict_Value) setVerdictStatement.getVerdictValue();
if (verdictValue.getValue().toString().equals("PASS")) {
verdict = "pass";
} else if (verdictValue.getValue().toString().equals("INCONC")) {
@@ -677,16 +547,10 @@ public class Def_Function_Writer {
verdict = "fail";
}
}
- functionString.append("rownum="
- + setVerdictStatement.getLocation().getLine() + ";\r\n");
- functionString
- .append("TTCN3Logger.writeLog(compid, \"VERDICTOP\", sourcefilename, rownum, \"function\", \""
- + nodeName
- + "\", \"setverdict("
- + verdict
- + "): \" + getVerdict() + \" -> "
- + verdict
- + "\", true);" + "\r\n");
+ functionString.append("rownum=" + setVerdictStatement.getLocation().getLine() + ";\r\n");
+ functionString.append("TTCN3Logger.writeLog(compid, \"VERDICTOP\", sourcefilename, rownum, \"function\", \""
+ + nodeName + "\", \"setverdict(" + verdict + "): \" + getVerdict() + \" -> " + verdict + "\", true);"
+ + "\r\n");
functionString.append("setVerdict(\"" + verdict + "\");" + "\r\n");
}
@@ -694,12 +558,9 @@ public class Def_Function_Writer {
StringBuilder functionFileString = new StringBuilder();
- functionFileString.append("class " + nodeName + " implements Runnable{"
- + "\r\n");
- functionFileString.append("private " + runsOnValue + " component;"
- + "\r\n");
- functionFileString.append("public " + nodeName + "(" + runsOnValue
- + " c){" + "\r\n");
+ functionFileString.append("class " + nodeName + " implements Runnable{" + "\r\n");
+ functionFileString.append("private " + runsOnValue + " component;" + "\r\n");
+ functionFileString.append("public " + nodeName + "(" + runsOnValue + " c){" + "\r\n");
functionFileString.append("component = c;" + "\r\n");
functionFileString.append("}" + "\r\n");
functionFileString.append("public void run(){" + "\r\n");
@@ -711,97 +572,60 @@ public class Def_Function_Writer {
}
public String getJavaSource() {
- recieveCounter = -1;
+ AstWalkerJava.logToConsole(" Starting processing: Function " + nodeName);
+
sendCounter = -1;
+
this.writeFunction();
functionString.append("\r\n}");
String returnString = functionString.toString();
functionString.setLength(0);
- return returnString;
- }
-
- private void writeFunctionWithoutRunsOn() {
- BigInteger currentValue = BigInteger.ZERO;
-
- if (returnType.equals("Integer_Type")) {
- functionString.append("public static INTEGER " + nodeName
- + "(){\r\n");
-
- functionString.append("return new INTEGER (" + returnStatementValue
- + ");\r\n");
- functionString.append("}\r\n");
- }
-
- }
+ sendPortReference.clear();
+ sendParameter.clear();
+ sendParameterType.clear();
- public String getJavaSourceWithoutRunOn() {
-
- this.writeFunctionWithoutRunsOn();
- functionString.append("\r\n}");
- String returnString = functionString.toString();
- functionString.setLength(0);
+ AstWalkerJava.logToConsole(" Finished processing: Function " + nodeName);
+ clearLists();
return returnString;
}
- public void setRunsOnValue(String runsOnValue) {
- this.runsOnValue = runsOnValue;
-
- }
-
- public void setReturnType(String returnType) {
- this.returnType = returnType;
-
- }
-
- public void setReturnStatementValue(String returnStatementValue) {
- this.returnStatementValue = returnStatementValue;
+ public void clearAltLists() {
+ altStatements.clear();
+ altStatementCounter = -1;
}
- public void setTimerValue(String timerValue) {
- this.timerValue = timerValue;
-
- }
-
- public void addPortReference(String portRef) {
- sendPortReference.add(portRef);
-
- }
-
- public void addParameter(String param) {
- sendParameter.add(param);
-
- }
-
- public void addParameterType(String string) {
- sendParameterType.add(string);
-
- }
-
- public void setUnknownStartReference(String unknownStartReference) {
- this.unknownStartReference = unknownStartReference;
-
- }
-
- public void addRecievePortReference(String portRef) {
- recievePortReference.add(portRef);
+ public void clearLists() {
+ functionString.setLength(0);
+ returnType = null;
+ returnStatementValue = null;
- }
+ isThereAStartedTimer = false;
- public void addRecieveParameter(String param) {
- recieveParameter.add(param);
+ sendCounter = -1;
- }
+ sendPortReference.clear();
+ sendParameter.clear();
+ sendParameterType.clear();
- public void addRecieveParameterType(String string) {
- recieveParameterType.add(string);
+ receivePortReference.clear();
+ receiveValue.clear();
+ receiveAnyValValue.clear();
+ receiveType.clear();
- }
+ functionVars.clear();
+ functionVarTypes.clear();
+ functionVarValues.clear();
+ functionAssignIdentifiers.clear();
+ functionAssignValues.clear();
- public void addAddValues(String string) {
- addValues.add(string);
+ functionValueIsAValueReference.clear();
+ functionVarIsConstant.clear();
+ defCounter = -1;
+ assignCounter = -1;
+ receiveStatements.clear();
}
}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_ModulePar_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_ModulePar_Writer.java
new file mode 100644
index 0000000000000000000000000000000000000000..e8b78b6989736f5901c2b28b9b2fe7ce51367741
--- /dev/null
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_ModulePar_Writer.java
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Keremi, Andras
+ * Eros, Levente
+ * Kovacs, Gabor
+ *
+ ******************************************************************************/
+
+package org.eclipse.titan.codegenerator;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_ModulePar;
+
+public class Def_ModulePar_Writer {
+ private Def_ModulePar moduleParNode;
+
+ private StringBuilder moduleParString = new StringBuilder("");
+
+ private String nodeName = null;
+
+ public List moduleParValues = new ArrayList();
+ private String moduleParNodeType = null;
+
+ private static Map moduleParHashes = new LinkedHashMap();
+
+ private Def_ModulePar_Writer(Def_ModulePar node) {
+ super();
+ this.moduleParNode = node;
+ nodeName = moduleParNode.getIdentifier().toString();
+ }
+
+
+
+ public static Def_ModulePar_Writer getInstance(Def_ModulePar node) {
+ if (!moduleParHashes.containsKey(node.getIdentifier().toString())) {
+ moduleParHashes.put(node.getIdentifier().toString(),
+ new Def_ModulePar_Writer(node));
+ }
+ return (Def_ModulePar_Writer) moduleParHashes.get(node.getIdentifier()
+ .toString());
+ }
+
+ public void setModuleParNodeType(String value) {
+ moduleParNodeType = value;
+ }
+
+ public void writeModuleParConstructor(String rootNodeType,
+ String prefix) {
+
+ if(moduleParValues.size()>0){
+ for(int i=0;i templateListValues = new ArrayList();
+ private static List templateAllIdentifiers = new ArrayList();
+ private static List templateRefdVals = new ArrayList();
+ private boolean waitForTemplateList = false;
+ private boolean blockTemplateListing = false;
+
+
+ public void visit(IVisitableNode node) {
+
+ if (node instanceof Def_Template) {
+ myASTVisitor.currentFileName = "Templates";
+
+ Def_Template_Writer.getInstance(((Def_Template) node));
+
+ myASTVisitor.nodeNameNodeTypeHashMap.put(((Def_Template) node)
+ .getIdentifier().toString(), "template");
+
+ waitForModifierValue = true;
+ waitForTemplateValues = true;
+
+ }
+
+ visitTemplateNodes(node);
+ }
+
+ public void visitTemplateNodes(IVisitableNode node) {
+ if (waitForTemplateValues && (node instanceof Reference)) {
+ Def_Const_Visit_Handler.constNodeType = ((Reference) node).getId()
+ .toString();
+ }
+
+ //ListOfTemplates is returned twice, should be recorded only once
+ if (waitForTemplateValues && !blockTemplateListing&&(node instanceof ListOfTemplates)) {
+ waitForTemplateList = true;
+ }
+
+ if (waitForTemplateValues && (node instanceof SpecificValue_Template)) {
+ waitForSepcValTemplate = true;
+
+ }
+ if (waitForTemplateValues
+ && (node instanceof Undefined_LowerIdentifier_Value)) {
+ String value = ((Undefined_LowerIdentifier_Value) node)
+ .getIdentifier().toString();
+
+ if (waitForTemplateList) {
+ templateListValues.add(value);
+ } else {
+ myASTVisitor.templateIdValuePairs.put(lastTemplateName, value);
+ }
+ myASTVisitor.blockIdListing = true;
+ }
+
+ if (waitForTemplateValues && (node instanceof Charstring_Value)) {
+
+ String value = ((Charstring_Value) node).getValue();
+
+ if (waitForTemplateList) {
+ templateListValues.add(value);
+ } else {
+ myASTVisitor.templateIdValuePairs.put(lastTemplateName, value);
+ }
+
+ myASTVisitor.blockIdListing = true;
+ }
+
+ if (waitForTemplateValues && (node instanceof Integer_Value)) {
+
+ String value = ((Integer_Value) node).toString();
+
+ if (waitForTemplateList) {
+ templateListValues.add(value);
+ } else {
+ myASTVisitor.templateIdValuePairs.put(lastTemplateName, value);
+ }
+
+ myASTVisitor.blockIdListing = true;
+ }
+
+
+ if (waitForTemplateValues && (node instanceof Omit_Value)) {
+
+ if (waitForTemplateList) {
+ templateListValues.add("omit");
+ } else {
+ myASTVisitor.templateIdValuePairs.put(lastTemplateName, "omit");
+ }
+ myASTVisitor.blockIdListing = true;
+ }
+
+ if (waitForTemplateValues && (node instanceof Any_Value_Template)) {
+
+ if (waitForTemplateList) {
+ templateListValues.add("?");
+ } else {
+ myASTVisitor.templateIdValuePairs.put(lastTemplateName, "?");
+ }
+ myASTVisitor.blockIdListing = true;
+ }
+
+ if (waitForTemplateValues && (node instanceof AnyOrOmit_Template)) {
+
+ if (waitForTemplateList) {
+ templateListValues.add("*");
+ } else {
+ myASTVisitor.templateIdValuePairs.put(lastTemplateName, "*");
+ }
+ myASTVisitor.blockIdListing = true;
+ }
+
+ if (waitForTemplateValues && (node instanceof Reference)) {
+
+ String value = ((Reference) node).toString().toString();
+
+ if (waitForTemplateList) {
+ templateListValues.add(value);
+ } else if (!waitForSepcValTemplate) {
+ myASTVisitor.templateIdValuePairs.put(lastTemplateName, value);
+ }
+
+ myASTVisitor.blockIdListing = true;
+ }
+
+ if (waitForTemplateValues && (node instanceof Identifier)
+ && !myASTVisitor.blockIdListing) {
+ templateAllIdentifiers.add(((Identifier) node).toString());
+ lastTemplateName = ((Identifier) node).toString();
+ myASTVisitor.templateIDs.add(lastTemplateName);
+
+ if (!isTemplateNameSet) {
+ currentTemplateNodeName = ((Identifier) node).toString();
+ isTemplateNameSet = true;
+ }
+
+ }
+
+ if (waitForSepcValTemplate && (node instanceof Referenced_Value)) {
+ templateRefdValCounter++;
+ waitForTemplateRefdVals = true;
+
+ }// Referenced_Value Reference
+
+ if (waitForTemplateRefdVals && (node instanceof FieldSubReference)) {
+ if (templateRefdVals.size() == templateRefdValCounter) {
+ templateRefdVals.add(((FieldSubReference) node).getId()
+ .toString());
+ } else {
+ templateRefdVals
+ .set(templateRefdValCounter,
+ templateRefdVals.get(templateRefdValCounter)
+ + "."
+ + ((FieldSubReference) node).getId()
+ .toString());
+ }
+ }
+
+ if (waitForTemplateValues && (node instanceof Integer_Value)) {
+
+ String value = ((Integer_Value) node).toString();
+
+ if (myASTVisitor.isNextIntegerNegative) {
+ value = "-" + value;
+ }
+
+ if (waitForTemplateList) {
+ templateListValues.add(value);
+ } else {
+ myASTVisitor.templateIdValuePairs.put(lastTemplateName, value);
+ }
+
+ myASTVisitor.isNextIntegerNegative = false;
+ }
+
+ if (waitForModifierValue && (node instanceof Named_Template_List)) {
+ waitForModifierValue = false;
+ }
+
+ if (waitForModifierValue && (node instanceof Reference)) {
+ modifierValue = ((Reference) node).getId().toString();
+ }
+ }
+
+ public void leave(IVisitableNode node) {
+ if (node instanceof Def_Template) {
+ handleTemplate(node);
+ }
+
+ if (waitForTemplateValues
+ && ((node instanceof Undefined_LowerIdentifier_Value)
+ || (node instanceof Charstring_Value)
+ || (node instanceof Omit_Value)
+ || (node instanceof Any_Value_Template)
+ || (node instanceof AnyOrOmit_Template) || (node instanceof Reference))) {
+ myASTVisitor.blockIdListing = false;
+ }
+
+ if (waitForTemplateValues && (node instanceof ListOfTemplates)) {
+ waitForTemplateList = false;
+ //ListOfTemplates is returned twice, should be recorded only once
+ blockTemplateListing= true;
+
+ }
+
+ if (waitForSepcValTemplate && (node instanceof Referenced_Value)) {
+ myASTVisitor.templateIdValuePairs.put(currentTemplateNodeName,
+ templateRefdVals.get(templateRefdValCounter));
+
+ waitForSepcValTemplate = false;
+ // waitForTemplateRefdVals = false;
+
+ }
+ }
+
+ public void handleTemplate(IVisitableNode node) {
+ Def_Template_Writer tempNode = Def_Template_Writer
+ .getInstance(((Def_Template) node));
+
+ tempNode.clearLists();
+ tempNode.init();
+ myASTVisitor.blockIdListing = false;
+
+ tempNode.templateIdentifiers.addAll(templateAllIdentifiers);
+ tempNode.templateRefdVals.addAll(templateRefdVals);
+ tempNode.templateListValues.addAll(templateListValues);
+
+ if (modifierValue != null) {
+ tempNode.setModifierValue(modifierValue);
+ }
+
+ templateAllIdentifiers.clear();
+ templateListValues.clear();
+ templateRefdVals.clear();
+ isTemplateNameSet = false;
+ waitForTemplateValues = false;
+ waitForModifierValue = false;
+ templateRefdValCounter = -1;
+ waitForTemplateRefdVals = false;
+ blockTemplateListing= false;
+
+ myASTVisitor.deleteLastBracket(myASTVisitor.currentFileName);
+ myASTVisitor.visualizeNodeToJava(tempNode.getJavaSource() + "\r\n}");
+ myASTVisitor.templateIDs.clear();
+ myASTVisitor.templateIdValuePairs.clear();
+ }
+
+}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Template_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Template_Writer.java
index 1352c87ece84029cbe678519f289d2de76cc0e09..95a5c867f0ab6dc5d0cc5a978835bd8abca72666 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Template_Writer.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Template_Writer.java
@@ -20,20 +20,10 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.titan.designer.AST.ASTNode;
-import org.eclipse.titan.designer.AST.IVisitableNode;
-import org.eclipse.titan.designer.AST.Value;
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template;
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
+import org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type;
import org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type;
-import org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value;
-import org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value;
-import org.eclipse.titan.designer.AST.TTCN3.values.Omit_Value;
-import org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value;
-import org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
-import org.eclipse.titan.designer.AST.Reference;
public class Def_Template_Writer {
private Def_Template templateNode;
@@ -43,50 +33,33 @@ public class Def_Template_Writer {
.getNewCompilationCounter();
private String nodeName = null;
- private List templateIdentifiers = new ArrayList();
+ public List templateListValues = new ArrayList();
+ public List templateIdentifiers = new ArrayList();
+ public List templateRefdVals = new ArrayList();
private String templateNodeType = null;
private String modifierValue = null;
- private int idCounter = 0;
private int firstIdentifier = 0;
private int paramCount = 0;
private List paramNames = new ArrayList();
private List paramTypes = new ArrayList();
- private Map idValuePairs = new LinkedHashMap();
-
private static Map templateHashes = new LinkedHashMap();
private Def_Template_Writer(Def_Template node) {
super();
this.templateNode = node;
- if (node.getType(compilationCounter) instanceof Referenced_Type) {
- templateNodeType = ((Referenced_Type) node
+ if (this.templateNode.getType(compilationCounter) instanceof Referenced_Type) {
+ templateNodeType = ((Referenced_Type) this.templateNode
.getType(compilationCounter)).getReference().getId()
.toString();
- }
- firstIdentifier = 1;
- if (node.getFormalParameterList() != null) {
- paramCount = node.getFormalParameterList().getNofParameters();
- for (int i = 0; i < paramCount; i++) {
- paramNames.add(node.getFormalParameterList()
- .getParameterByIndex(i).getIdentifier().toString());
- if (node.getFormalParameterList().getParameterByIndex(i)
- .getType(compilationCounter) instanceof Referenced_Type) {
+ } else if (this.templateNode.getType(compilationCounter) instanceof Integer_Type) {
+ templateNodeType = "INTEGER";
- paramTypes.add(((Referenced_Type) node
- .getFormalParameterList().getParameterByIndex(i)
- .getType(compilationCounter)).getReference()
- .getId().toString());
- }
- firstIdentifier++;
- }
}
- idCounter = firstIdentifier;
-
nodeName = node.getIdentifier().toString();
}
@@ -99,11 +72,7 @@ public class Def_Template_Writer {
.toString());
}
- public void addTemplateIdentifiers(String value) {
- templateIdentifiers.add(value);
- }
-
- public void writeTempltaeConstructor(String rootNodeType, String prefix) {
+ public void writeTemplateConstructor(String rootNodeType, String prefix) {
if (myASTVisitor.nodeNameChildrenNamesHashMap.containsKey(rootNodeType)) {
if (myASTVisitor.nodeNameNodeTypeHashMap.get(rootNodeType).equals(
@@ -125,6 +94,10 @@ public class Def_Template_Writer {
prefix = "((SC_" + unionElementId + "_" + rootNodeType
+ ")value)";
+ } else if (myASTVisitor.nodeNameNodeTypeHashMap.get(rootNodeType).equals(
+ "record")){
+ templateString.append(prefix + "= new " + rootNodeType + "();\r\n");
+
}
String[] childrenNodeNames = myASTVisitor.nodeNameChildrenNamesHashMap
@@ -148,7 +121,7 @@ public class Def_Template_Writer {
String prefixBackup = prefix;
prefix = prefix.concat("." + childrenNodeNames[i]);
- writeTempltaeConstructor(childrenNodeTypes[i], prefix);
+ writeTemplateConstructor(childrenNodeTypes[i], prefix);
prefix = prefixBackup;
@@ -159,6 +132,8 @@ public class Def_Template_Writer {
.containsKey(childrenNodeNames[i])) {
String currentvalue = myASTVisitor.templateIdValuePairs
.get(childrenNodeNames[i]);
+
+
if (myASTVisitor.nodeNameNodeTypeHashMap
.containsKey(currentvalue)) {
if (myASTVisitor.nodeNameNodeTypeHashMap.get(
@@ -183,7 +158,14 @@ public class Def_Template_Writer {
}
}
}
+ } else if (childrenNodeTypes[i].equals("INTEGER")){
+ templateString.append(prefix + "."
+ + childrenNodeNames[i]
+ + "= new INTEGER(new BigInteger(\"" + currentvalue
+ + "\"));\r\n");
}
+
+
}
// everything else
@@ -301,13 +283,27 @@ public class Def_Template_Writer {
}
}
}
+ } if(templateListValues.size() > 0 ){
+ if (childrenNodeTypes[i].equals("INTEGER")){
+ templateString.append(prefix + "."
+ + childrenNodeNames[i]
+ + "= new INTEGER(new BigInteger(\"" + templateListValues.get(i)
+ + "\"));\r\n");
+ }
}
+
+
}
+ } else if (rootNodeType.equals("INTEGER")) {
+ String integerValue = myASTVisitor.templateIdValuePairs
+ .get(nodeName);
+ templateString.append("value=new INTEGER(new BigInteger(\""
+ + integerValue + "\"));\r\n");
}
}
- public void writeModifierTempltaeConstructor(String rootNodeType,
+ public void writeModifierTemplateConstructor(String rootNodeType,
String prefix) {
if (myASTVisitor.nodeNameChildrenNamesHashMap.containsKey(rootNodeType)) {
@@ -325,9 +321,8 @@ public class Def_Template_Writer {
}
}
- templateString.append(prefix + "= "
- + modifierValue
- + "();\r\n");
+ templateString
+ .append(prefix + "= " + modifierValue + "();\r\n");
prefix = "((SC_" + unionElementId + "_" + rootNodeType
+ ")value)";
@@ -368,7 +363,7 @@ public class Def_Template_Writer {
String prefixBackup = prefix;
prefix = prefix.concat("." + childrenNodeNames[i]);
- writeModifierTempltaeConstructor(childrenNodeTypes[i],
+ writeModifierTemplateConstructor(childrenNodeTypes[i],
prefix);
prefix = prefixBackup;
@@ -425,15 +420,7 @@ public class Def_Template_Writer {
} else if (myASTVisitor.nodeNameNodeTypeHashMap.get(
childrenNodeTypes[i]).equals("CHARSTRING")) {
- /*
- * templateString.append(prefix + "." +
- * childrenNodeNames[i] + "=new " +
- * childrenNodeTypes[i] + "(new " +
- * myASTVisitor.nodeNameNodeTypeHashMap
- * .get(childrenNodeTypes[i]) + "(\"" +
- * myASTVisitor.templateIdValuePairs
- * .get(childrenNodeNames[i]) + "\"));" + "\r\n");
- */
+ // TODO CHARSTRING
}
@@ -456,14 +443,7 @@ public class Def_Template_Writer {
childrenNodeNames[i], true, false, false,
true);
} else {
-
- /*
- * templateString.append(prefix + "." +
- * childrenNodeNames[i] + "=new " +
- * childrenNodeTypes[i] + "(\"" +
- * myASTVisitor.templateIdValuePairs
- * .get(childrenNodeNames[i]) + "\");" + "\r\n");
- */
+ // TODO rest
}
}
if (myASTVisitor.nodeNameChildrenNamesHashMap
@@ -487,6 +467,15 @@ public class Def_Template_Writer {
}
}
}
+ } else if (rootNodeType.equals("INTEGER")) {
+ String integerValue = myASTVisitor.templateIdValuePairs
+ .get(nodeName);
+
+ // if (paramCount > 0) {
+ templateString.append("value=new INTEGER(new BigInteger(\""
+ + integerValue + "\"));\r\n");
+ // }
+
}
}
@@ -533,8 +522,42 @@ public class Def_Template_Writer {
}
}
+ public void clearLists() {
+ templateListValues.clear();
+ templateIdentifiers.clear();
+ templateRefdVals.clear();
+ paramNames.clear();
+ paramTypes.clear();
+
+ }
+
+ public void init() {
+
+ firstIdentifier = 1;
+ if (templateNode.getFormalParameterList() != null) {
+ paramCount = templateNode.getFormalParameterList()
+ .getNofParameters();
+ for (int i = 0; i < paramCount; i++) {
+ paramNames.add(templateNode.getFormalParameterList()
+ .getParameterByIndex(i).getIdentifier().toString());
+ if (templateNode.getFormalParameterList()
+ .getParameterByIndex(i).getType(compilationCounter) instanceof Referenced_Type) {
+
+ paramTypes.add(((Referenced_Type) templateNode
+ .getFormalParameterList().getParameterByIndex(i)
+ .getType(compilationCounter)).getReference()
+ .getId().toString());
+ }
+ firstIdentifier++;
+ }
+ }
+ }
+
public String getJavaSource() {
+ AstWalkerJava.logToConsole(" Starting processing: Template "
+ + nodeName);
+
templateString.append("public static " + templateNodeType + " "
+ nodeName + "(");
@@ -547,20 +570,24 @@ public class Def_Template_Writer {
templateString.append(templateNodeType + " value;\r\n");
if ((modifierValue == null)) {
- writeTempltaeConstructor(templateNodeType, "value");
+ writeTemplateConstructor(templateNodeType, "value");
} else {
- writeModifierTempltaeConstructor(templateNodeType, "value");
-
+ writeModifierTemplateConstructor(templateNodeType, "value");
+
}
templateString.append("return value;\r\n");
templateString.append("}\r\n");
String returnString = templateString.toString();
- modifierValue=null;
- idCounter = firstIdentifier;
+ modifierValue = null;
+
templateString.setLength(0);
+ AstWalkerJava.logToConsole(" Finished processing: Template "
+ + nodeName);
+
return returnString;
+
}
public void setModifierValue(String modifierValue) {
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Testcase_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Testcase_Writer.java
index 4e7e8fe0c240b721b57e9cbae9d2c1fff4c3c1d5..9f4b8d0f885801c91925d0472a39937d1d72b9b3 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Testcase_Writer.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Testcase_Writer.java
@@ -20,62 +20,134 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.titan.designer.AST.Reference;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase;
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
+import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Done_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock;
+import org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock_Statement;
import org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Start_Statement;
+import org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Stop_Statement;
import org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template;
-import org.eclipse.titan.designer.AST.TTCN3.types.CompField;
-import org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type;
+import org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.AddExpression;
import org.eclipse.titan.designer.AST.TTCN3.values.expressions.ComponentCreateExpression;
-import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.DivideExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.ModuloExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.MultiplyExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.RemainderExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.SubstractExpression;
+import org.eclipse.titan.designer.AST.TTCN3.values.expressions.UnaryMinusExpression;
public class Def_Testcase_Writer {
private Def_Testcase testCaseNode;
private StringBuilder testCaseString = new StringBuilder("");
- private CompilationTimeStamp compilationCounter = CompilationTimeStamp
- .getNewCompilationCounter();
+ /*
+ * private CompilationTimeStamp compilationCounter = CompilationTimeStamp
+ * .getNewCompilationCounter();
+ */
+
+ public String nodeName = null;
- private String nodeName=null;
-
private static Map testcaseHashes = new LinkedHashMap();
- private String testCaseRunsOn=null;
- private StatementBlock tcStatementBlock;
-
- private List tcVars = new ArrayList();
- private List tcVarTypes = new ArrayList();
- private List tcAssignValues = new ArrayList();
- private List tcCreateValues = new ArrayList();
- private List tcCreateCounter = new ArrayList();
-
- private int createCounter=-1;
-
- private List tcConnectValues = new ArrayList();
- private List tcConnectCounter = new ArrayList();
- private int connectCounter=-1;
-
- private List tcStartValues = new ArrayList();
- private List tcStartCounter = new ArrayList();
- private int startCounter=-1;
+ public String testCaseRunsOn = null;
+ private String currentTimerName = null;
+
+ public StatementBlock tcMainStatementBlock;
+
+ public int sendCounter = -1;
+ public int assignCounter = -1;
+ private int createCounter = -1;
+ private int startStatementCounter = -1;
+ private int stopStatementCounter = -1;
+ private int connectCounter = -1;
+ private int currentCounterValue = 0;
+ private int logCreateCounter = 0;
+ private int currentMapValueIndex = 0;
+ private int defCounter = -1;
+ private int defValueCounter = -1;
+ private int mapCounter = 0;
+ private int tcIfConditionCounter = -1;
+
+ private int disconnectCounter = -1;
+ private int altStatementCounter = -1;
+
+ private boolean blockWriter = false;
+ private boolean isThereAStartedTimer = false;
+
+ public static List sendPortReference = new ArrayList();
+ public static List sendParameter = new ArrayList();
+ public static List sendParameterType = new ArrayList();
+ public List tcVars = new ArrayList();
+ public List tcVarTypes = new ArrayList();
+ public List tcVarValues = new ArrayList();
+ public List tcAssignIdentifiers = new ArrayList();
+ public List tcAssignValues = new ArrayList();
+ public List tcCreateValues = new ArrayList();
+ public List tcCreateCounter = new ArrayList();
+ public List tcConnectValues = new ArrayList();
+ public List tcStartIdentifiers = new ArrayList();
+ public List tcStartCounter = new ArrayList();
+ public List tcMapValues = new ArrayList();
+ public List tcMapCounter = new ArrayList();
+ public List tcIfConditions = new ArrayList();
+ public List testCaseStartValueParameters = new ArrayList();
+ public List tcDisconnectValues = new ArrayList();
+ public List tcVarIsConstant = new ArrayList();
+ public List tcVarIsTemplate = new ArrayList();
+ public List tcValueIsAValueReference = new ArrayList();
+ public List tcValueTypeIsAReference = new ArrayList();
+
+ public List tcStopIdentifiers = new ArrayList();
+ public List tcStopCounter = new ArrayList();
+ public List testCaseStopValueParameters = new ArrayList();
+
+ public List altStatements = new ArrayList();
+
+ public int receiveCounter = -1;
+
+ public List receivePortReference = new ArrayList();
+ public List receiveValue = new ArrayList();
+ public List receiveAnyValValue = new ArrayList();
+ public List receiveType = new ArrayList();
+ public List receiveStatements = new ArrayList();
+
+ public List nodeVarIsRecord = new ArrayList();
+
+ public int structSize = 0;
+ public int currentRecordCounter = 0;
+ private boolean blockStatementBlockStatementWriter = false;
private Def_Testcase_Writer(Def_Testcase typeNode) {
super();
this.testCaseNode = typeNode;
nodeName = typeNode.getIdentifier().toString();
+
}
public static Def_Testcase_Writer getInstance(Def_Testcase typeNode) {
if (!testcaseHashes.containsKey(typeNode.getIdentifier().toString())) {
- testcaseHashes.put(typeNode.getIdentifier().toString(), new Def_Testcase_Writer(typeNode));
+ testcaseHashes.put(typeNode.getIdentifier().toString(),
+ new Def_Testcase_Writer(typeNode));
}
- return (Def_Testcase_Writer) testcaseHashes.get(typeNode.getIdentifier().toString());
+ return (Def_Testcase_Writer) testcaseHashes.get(typeNode
+ .getIdentifier().toString());
}
public String writeTestcaseFile(Def_Testcase testNode) {
@@ -84,16 +156,14 @@ public class Def_Testcase_Writer {
testCaseString.append("public class " + nodeName
+ " implements Runnable{ " + "\r\n");
testCaseString.append(" " + "\r\n");
- testCaseString.append(" private " + testCaseRunsOn
- + " component;" + "\r\n");
- testCaseString.append(" public "
- + nodeName + "("
- + testCaseRunsOn + " c){" + "\r\n");
+ testCaseString.append(" private " + testCaseRunsOn + " component;"
+ + "\r\n");
+ testCaseString.append(" public " + nodeName + "(" + testCaseRunsOn
+ + " c){" + "\r\n");
testCaseString.append(" component = c;" + "\r\n");
testCaseString.append(" }" + "\r\n");
testCaseString.append(" public void run(){" + "\r\n");
- testCaseString.append(" component."
- + nodeName + "();" + "\r\n");
+ testCaseString.append(" component." + nodeName + "();" + "\r\n");
testCaseString.append(" component.hc.finished(component, \""
+ nodeName + "\");" + "\r\n");
testCaseString.append(" }" + "\r\n");
@@ -101,258 +171,956 @@ public class Def_Testcase_Writer {
return testCaseString.toString();
}
-
- public String writeTestCaseFunction() {
-
- String createLocation = "";
- String createName = "";
- String createType = "";
- testCaseString.append("public void " + nodeName
- + "(){" + "\r\n");
+ public void writeTestCaseFunctionHeader(StatementBlock tcStatementBlock) {
+ testCaseString.append("\r\n");
+ testCaseString.append("public void " + nodeName + "(){" + "\r\n");
testCaseString.append("String sourcefilename = \""
+ testCaseNode.getLocation().getFile().getFullPath()
.lastSegment() + "\";" + "\r\n");
- testCaseString.append("int rownum=" +tcStatementBlock.getLocation().getLine()+ ";\r\n");
+ testCaseString.append("int rownum="
+ + tcStatementBlock.getLocation().getLine() + ";\r\n");
testCaseString.append("while(!created);" + "\r\n");
-
- testCaseString.append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""+nodeName+"\", \"Testcase started on mtc\", false);"+ "\r\n");
- int currentCounterValue=0;
- int logCreateCounter=0;
-
- int currentConnectValue=0;
- int logConnectCounter=0;
-
- int currentStartValue=0;
- int logStartCounter=0;
- int testcaseSize = tcStatementBlock.getSize();
- for (int j = 0; j < testcaseSize; j++) {
-
- if (tcStatementBlock.getStatementByIndex(j) instanceof Definition_Statement) {
- //TODO: tcVars and tcVarTypes hold the def statement values
- }
- if (tcStatementBlock.getStatementByIndex(j) instanceof Assignment_Statement) {
- Assignment_Statement tc_assignStatement = (Assignment_Statement) tcStatementBlock
- .getStatementByIndex(j);
-
- if (tc_assignStatement.getTemplate() instanceof SpecificValue_Template) {
- SpecificValue_Template specValTemplate = (SpecificValue_Template) tc_assignStatement
- .getTemplate();
- if (specValTemplate.getSpecificValue() instanceof ComponentCreateExpression) {
- ComponentCreateExpression componenetCreateExp = (ComponentCreateExpression) specValTemplate
- .getSpecificValue();
-
- createCounter++;
- logCreateCounter++;
- int logSizeValue=1;
- while(tcCreateCounter.get(logCreateCounter).equals(String.valueOf(createCounter))){
- logCreateCounter++;
- logSizeValue++;
- if(tcCreateCounter.size()==(logCreateCounter)){
- break;}
-
- }
- String[] logValues=new String[logSizeValue];
- int logWriteCounter=0;
- testCaseString.append("rownum="+componenetCreateExp.getLocation().getLine()+";\r\n");
- testCaseString.append("hc.create("+"\"" +tcCreateValues.get(currentCounterValue)+"\"");
- logValues[logWriteCounter]=tcCreateValues.get(currentCounterValue);
- currentCounterValue++;
-
- logWriteCounter++;
- while(tcCreateCounter.get(currentCounterValue).equals(String.valueOf(createCounter))){
- testCaseString.append(",\"" +tcCreateValues.get(currentCounterValue)+"\"");
-
- logValues[logWriteCounter]=tcCreateValues.get(currentCounterValue);
- logWriteCounter++;
- currentCounterValue++;
-
- if(tcCreateCounter.size()==(currentCounterValue)){
- break;}
-
- }
- testCaseString.append( "); "+ "\r\n");
-
- testCaseString.append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""+nodeName+"\", \"Starting PTC "+logValues[0]+" type "+logValues[1]+" on "+logValues[2]+"\", false);"+"\r\n");
-
-
- }
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""
+ + nodeName
+ + "\", \"Testcase started on mtc\", false);"
+ + "\r\n");
+ }
- }
+ public String getJavaSource() {
+ testCaseString.setLength(0);
+ AstWalkerJava.logToConsole(" Starting processing: Testcase "
+ + nodeName);
+
+ this.writeTestCaseFunctionHeader(tcMainStatementBlock);
+
+ this.writeTestCaseFunction(tcMainStatementBlock);
+
+ String returnString = testCaseString.toString();
+ testCaseString.setLength(0);
+
+ AstWalkerJava.logToConsole(" Finished processing: Testcase "
+ + nodeName);
+
+ return returnString;
+ }
+
+ public String writeTestCaseFunction(StatementBlock tcStatementBlock) {
+
+ int testcaseSize = tcStatementBlock.getSize();
+
+ for (int j = 0; j < testcaseSize; j++) {
+
+ if (tcStatementBlock.getStatementByIndex(j) instanceof Definition_Statement) {
+
+ Definition_Statement tc_defStatement = (Definition_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+ defCounter++;
+ defValueCounter++;
+ writeDefinitionStatement(tc_defStatement);
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Assignment_Statement) {
+ Assignment_Statement tc_assignStatement = (Assignment_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+
+ assignCounter++;
+
+ testCaseString
+ .append(writeAssignmentStatement(tc_assignStatement));
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Connect_Statement) {
+ Connect_Statement tc_connectStatement = (Connect_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+ connectCounter++;
+
+ writeConnectStatement(tc_connectStatement);
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Unknown_Start_Statement) {
+ Unknown_Start_Statement tc_startStatement = (Unknown_Start_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+
+ writeUnknownStartStatement(tc_startStatement);
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Done_Statement) {
+
+ testCaseString.append("hc.done(\"all component\");" + "\r\n");
+ // TODO: where is all coming from?
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Map_Statement) {
+ Map_Statement tc_mapStatement = (Map_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+ mapCounter++;
+
+ writeMapStatement(tc_mapStatement);
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof If_Statement) {
+ If_Statement tc_ifStatement = (If_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+
+ tcIfConditionCounter++;
+
+ writeIfStatement(tc_ifStatement);
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Setverdict_Statement) {
+
+ Setverdict_Statement tc_setVerdictStatement = (Setverdict_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+
+ writeSetVerdictStatement(tc_setVerdictStatement);
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Send_Statement) {
+ Send_Statement tc_SendStatement = (Send_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+
+ sendCounter++;
+
+ testCaseString.append(writeSendStatement(tc_SendStatement));
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Receive_Port_Statement) {
+ Receive_Port_Statement tc_ReceiveStatement = (Receive_Port_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+
+ receiveCounter++;
+
+ blockStatementBlockStatementWriter = true;
+
+ testCaseString
+ .append(writeReceiveStatement(tc_ReceiveStatement));
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Unknown_Stop_Statement) {
+ Unknown_Stop_Statement tc_StopStatement = (Unknown_Stop_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+
+ writeUnknownStopStatement(tc_StopStatement);
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Alt_Statement) {
+
+ altStatementCounter++;
+ altStatements.get(altStatementCounter).setTimerInfo(
+ isThereAStartedTimer, currentTimerName);
+
+ testCaseString.append(altStatements.get(altStatementCounter)
+ .getJavaSource());
+
+ } else if (tcStatementBlock.getStatementByIndex(j) instanceof Disconnect_Statement) {
+ Disconnect_Statement tc_disconnectStatement = (Disconnect_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+ disconnectCounter++;
+
+ writeDisconnectStatement(tc_disconnectStatement);
+
+ } else if ((tcStatementBlock.getStatementByIndex(j) instanceof StatementBlock_Statement)
+ && !blockStatementBlockStatementWriter) {
+ StatementBlock_Statement tc_statementBlockStatement = (StatementBlock_Statement) tcStatementBlock
+ .getStatementByIndex(j);
+ blockStatementBlockStatementWriter = false;
+ testCaseString.append("{\r\n");
+ blockWriter = true;
+ writeTestCaseFunction(tc_statementBlockStatement
+ .getStatementBlock());
+ blockWriter = false;
+ testCaseString.append("}\r\n");
+
+ }
+ }
+
+ if (!blockWriter) {
+ testCaseString.append("}" + "\r\n");
+ }
+
+ return testCaseString.toString();
+ }
+
+ public void writeDefinitionStatement(Definition_Statement tc_defStatement) {
+ if (tc_defStatement.getDefinition() instanceof Def_Timer) {
+ Def_Timer def_Timer = (Def_Timer) tc_defStatement.getDefinition();
+
+ testCaseString.append("rownum=" + def_Timer.getLocation().getLine()
+ + ";\r\n");
+ testCaseString.append("Timer "
+ + def_Timer.getIdentifier().toString()
+ + " = new Timer (new FLOAT(" + tcVarValues.get(defCounter)
+ + "));\r\n");
+
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"TIMEROP\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"Timer "
+ + def_Timer.getIdentifier().toString()
+ + " set to "
+ + tcVarValues.get(defCounter) + ".\", false);" + "\r\n");
+
+ } else if (tcVarTypes.get(defCounter).equals("BITSTRING")) {
+
+ testCaseString.append("rownum="
+ + tc_defStatement.getLocation().getLine() + ";\r\n");
+
+ if (tcVarIsConstant.get(defCounter)) {
+ testCaseString.append("final ");
+ }
+
+ if (tcVarIsTemplate.get(defCounter)) {
+ testCaseString.append("template ");
+ }
+
+ if (tcVarValues.get(defValueCounter) == null) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new BITSTRING();\r\n");
+ // TODO: add logging here
+ } else if (tcValueIsAValueReference.get(defCounter)) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "="
+ + tcVarValues.get(defValueCounter) + ";\r\n");
+ // TODO: add logging here
+ } else {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new BITSTRING(\""
+ + tcVarValues.get(defValueCounter) + "\");\r\n");
+ // TODO: add logging here
+ }
+
+ } else if (tcVarTypes.get(defCounter).equals("INTEGER")) {
+
+ testCaseString.append("rownum="
+ + tc_defStatement.getLocation().getLine() + ";\r\n");
+ if (tcVarIsConstant.get(defCounter)) {
+ testCaseString.append("final ");
+ }
+
+ if (tcVarIsTemplate.get(defCounter)) {
+ testCaseString.append("template ");
+ }
+
+ if (tcVarValues.get(defValueCounter) == null) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new INTEGER();\r\n");
+ // TODO: add logging here
+ } else if (tcValueIsAValueReference.get(defCounter)) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "="
+ + tcVarValues.get(defValueCounter) + ";\r\n");
+ // TODO: add logging here
+ } else {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter)
+ + "=new INTEGER(new BigInteger(\""
+ + tcVarValues.get(defValueCounter) + "\"));\r\n");
+ // TODO: add logging here
+ }
+
+ } else if (tcVarTypes.get(defCounter).equals("CHARSTRING")) {
+
+ testCaseString.append("rownum="
+ + tc_defStatement.getLocation().getLine() + ";\r\n");
+
+ if (tcVarIsConstant.get(defCounter)) {
+ testCaseString.append("final ");
+ }
+
+ if (tcVarIsTemplate.get(defCounter)) {
+ testCaseString.append("template ");
+ }
+
+ if (tcVarValues.get(defValueCounter) == null) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new CHARSTRING();\r\n");
+ // TODO: add logging here
+ } else if (tcValueIsAValueReference.get(defCounter)) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "="
+ + tcVarValues.get(defValueCounter) + ";\r\n");
+ // TODO: add logging here
+ } else {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new CHARSTRING(\""
+ + tcVarValues.get(defValueCounter) + "\");\r\n");
+ // TODO: add logging here
+ }
+
+ } else if (tcVarTypes.get(defCounter).equals("OCTETSTRING")) {
+ testCaseString
+ .append("rownum = ")
+ .append(tc_defStatement.getLocation().getLine())
+ .append(";")
+ .append("\r\n");
+ // TODO : replace each "\r\n" with System.lineSeparator() to make it cross-platform
+
+ if (tcVarIsConstant.get(defCounter)) {
+ testCaseString.append("final ");
+ }
+
+ if (tcVarIsTemplate.get(defCounter)) {
+ testCaseString.append("template ");
+ }
+
+ if (tcVarValues.get(defValueCounter) == null) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new OCTETSTRING();\r\n");
+ // TODO: add logging here
+ } else if (tcValueIsAValueReference.get(defCounter)) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "="
+ + tcVarValues.get(defValueCounter) + ";\r\n");
+ // TODO: add logging here
+ } else {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new OCTETSTRING(\""
+ + tcVarValues.get(defValueCounter) + "\");\r\n");
+ // TODO: add logging here
+ }
+
+ } else if (tcVarTypes.get(defCounter).equals("BOOLEAN")) {
+
+ testCaseString.append("rownum="
+ + tc_defStatement.getLocation().getLine() + ";\r\n");
+
+ if (tcVarIsConstant.get(defCounter)) {
+ testCaseString.append("final ");
+ }
+
+ if (tcVarIsTemplate.get(defCounter)) {
+ testCaseString.append("template ");
+ }
+
+ if (tcVarValues.get(defValueCounter) == null) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new BOOLEAN();\r\n");
+ // TODO: add logging here
+ } else if (tcValueIsAValueReference.get(defCounter)) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "="
+ + tcVarValues.get(defValueCounter) + ";\r\n");
+ // TODO: add logging here
+ } else {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "=new BOOLEAN("
+ + tcVarValues.get(defValueCounter) + ");\r\n");
+ // TODO: add logging here
+ }
+
+ } else if (nodeVarIsRecord.get(defCounter)) {
+
+ testCaseString.append("rownum="
+ + tc_defStatement.getLocation().getLine() + ";\r\n");
+
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "= new "
+ + tcVarTypes.get(defCounter) + "();\r\n");
-
+ int childSize = myASTVisitor.nodeNameChildrenNamesHashMap
+ .get(tcVarTypes.get(defCounter)).length;
+ for (int i = 0; i < childSize; i++) {
+
+ String childType = myASTVisitor.nodeNameChildrenTypesHashMap
+ .get(tcVarTypes.get(defCounter))[i];
+ String childName = myASTVisitor.nodeNameChildrenNamesHashMap
+ .get(tcVarTypes.get(defCounter))[i];
+
+ testCaseString.append("rownum="
+ + tc_defStatement.getLocation().getLine() + ";\r\n");
+
+ writeRecordChildren(childType, childName);
+
+ if (i + 1 < childSize) {
+ defValueCounter++;
}
+ }
- if (tcStatementBlock.getStatementByIndex(j) instanceof Connect_Statement) {
- Connect_Statement tc_connectStatement = (Connect_Statement) tcStatementBlock
- .getStatementByIndex(j);
- connectCounter++;
- logConnectCounter++;
- int logSizeValue=1;
- while(tcConnectCounter.get(logConnectCounter).equals(String.valueOf(connectCounter))){
- logConnectCounter++;
- logSizeValue++;
- if(tcConnectCounter.size()==(logConnectCounter)){
- break;}
-
- }
-
- String[] logValues=new String[logSizeValue];
- int logWriteCounter=0;
- testCaseString.append("rownum="+tc_connectStatement.getLocation().getLine()+";\r\n");
- testCaseString.append("hc.connect("+"\"" +tcConnectValues.get(currentConnectValue)+"\"");
-
- logValues[logWriteCounter]=tcConnectValues.get(currentConnectValue);
- currentConnectValue++;
+ } else if (tcValueTypeIsAReference.get(defCounter)) {
+ testCaseString.append("rownum="
+ + tc_defStatement.getLocation().getLine() + ";\r\n");
- logWriteCounter++;
+ if (tcVarIsConstant.get(defCounter)) {
+ testCaseString.append("final ");
+ }
- while(tcConnectCounter.get(currentConnectValue).equals(String.valueOf(connectCounter))){
- testCaseString.append(",\"" +tcConnectValues.get(currentConnectValue)+"\"");
-
- logValues[logWriteCounter]=tcConnectValues.get(currentConnectValue);
- logWriteCounter++;
- currentConnectValue++;
- if(tcConnectCounter.size()==(currentConnectValue)){break;}
-
+ if (tcVarIsTemplate.get(defCounter)) {
+ testCaseString.append("template ");
+ }
+
+ if (tcVarValues.get(defValueCounter) == null) {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + ";\r\n");
+ // TODO: add logging here
+ } else if (tcValueIsAValueReference.get(defCounter)) {
+
+ if (myASTVisitor.nodeNameNodeTypeHashMap.containsKey(tcVarTypes
+ .get(defCounter))) {
+ if (myASTVisitor.nodeNameNodeTypeHashMap.get(
+ tcVarTypes.get(defCounter)).equals("enum")) {
+ testCaseString
+ .append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "= new "
+ + tcVarTypes.get(defCounter) + "(\""
+ + tcVarValues.get(defValueCounter)
+ + "\");\r\n");
}
-
- testCaseString.append( "); "+ "\r\n");
-
-
- testCaseString.append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""+nodeName+"\", \"Connecting port "+logValues[1]+" of "+logValues[0]+" to port "+logValues[3]+" of "+logValues[2]+"\", false);"+"\r\n");
-
-
-
-
+ } else {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "="
+ + tcVarValues.get(defValueCounter) + ";\r\n");
}
+ // TODO: add logging here
+ } else {
+ testCaseString.append(tcVarTypes.get(defCounter) + " "
+ + tcVars.get(defCounter) + "="
+ + tcVarValues.get(defValueCounter) + ";\r\n");
+ // TODO: add logging here
+ }
+ }
+
+ }
- if (tcStatementBlock.getStatementByIndex(j) instanceof Unknown_Start_Statement) {
- Unknown_Start_Statement tc_startStatement = (Unknown_Start_Statement) tcStatementBlock.getStatementByIndex(j);
- startCounter++;
- logStartCounter++;
- int logSizeValue=1;
- while(tcStartCounter.get(logStartCounter).equals(String.valueOf(startCounter))){
- logStartCounter++;
- logSizeValue++;
- if(tcStartCounter.size()==(logStartCounter)){
- break;}
-
+ public void writeRecordChildren(String childType, String childName) {
+
+ if (childType.equals("INTEGER")) {
+ testCaseString.append(tcVars.get(defCounter) + "." + childName
+ + "="
+ + tcVarValues.get(defValueCounter) + ";\r\n");
+ } else if (childType.equals("CHARSTRING")) {
+
+ } else if (childType.equals("BITSTRING")) {
+
+ } else if (childType.equals("BOOLEAN")) {
+
+ }
+ }
+
+ public String writeAssignmentStatement(
+ Assignment_Statement tc_assignStatement) {
+
+ StringBuilder testCaseString = new StringBuilder("");
+
+ if (tc_assignStatement.getTemplate() instanceof SpecificValue_Template) {
+ SpecificValue_Template specValTemplate = (SpecificValue_Template) tc_assignStatement
+ .getTemplate();
+ if (specValTemplate.getSpecificValue() instanceof ComponentCreateExpression) {
+ ComponentCreateExpression componenetCreateExp = (ComponentCreateExpression) specValTemplate
+ .getSpecificValue();
+
+ createCounter++;
+ logCreateCounter++;
+ int logSizeValue = 1;
+ while (tcCreateCounter.get(logCreateCounter).equals(
+ String.valueOf(createCounter))) {
+ logCreateCounter++;
+ logSizeValue++;
+ if (tcCreateCounter.size() == (logCreateCounter)) {
+ break;
}
-
- String[] logValues=new String[logSizeValue];
- int logWriteCounter=0;
- testCaseString.append("rownum="+tc_startStatement.getLocation().getLine()+";\r\n");
- testCaseString.append("hc.start("+"\"" +tcStartValues.get(currentStartValue)+"\"");
-
- logValues[logWriteCounter]=tcStartValues.get(currentStartValue);
- currentStartValue++;
+ }
+ String[] logValues = new String[logSizeValue];
+ int logWriteCounter = 0;
+ testCaseString
+ .append("rownum="
+ + componenetCreateExp.getLocation().getLine()
+ + ";\r\n");
+ testCaseString.append("hc.create(" + "\""
+ + tcCreateValues.get(currentCounterValue) + "\"");
+ logValues[logWriteCounter] = tcCreateValues
+ .get(currentCounterValue);
+ currentCounterValue++;
+
+ logWriteCounter++;
+ while (tcCreateCounter.get(currentCounterValue).equals(
+ String.valueOf(createCounter))) {
+ testCaseString.append(",\""
+ + tcCreateValues.get(currentCounterValue) + "\"");
+
+ logValues[logWriteCounter] = tcCreateValues
+ .get(currentCounterValue);
logWriteCounter++;
-
- while(tcStartCounter.get(currentStartValue).equals(String.valueOf(startCounter))){
- testCaseString.append(",\"" +tcStartValues.get(currentStartValue)+"\"");
-
- logValues[logWriteCounter]=tcStartValues.get(currentStartValue);
- logWriteCounter++;
- currentStartValue++;
- if(tcStartCounter.size()==(currentStartValue)){break;}
-
+ currentCounterValue++;
+
+ if (tcCreateCounter.size() == (currentCounterValue)) {
+ break;
}
-
- testCaseString.append( "); "+ "\r\n");
- testCaseString.append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""+nodeName+"\", \"Starting function "+logValues[1]+" on component "+logValues[0]+"\", false);"+"\r\n");
}
+ testCaseString.append("); " + "\r\n");
- if (tcStatementBlock.getStatementByIndex(j) instanceof Done_Statement) {
- Done_Statement tc_doneStatement = (Done_Statement) tcStatementBlock
- .getStatementByIndex(j);
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""
+ + nodeName
+ + "\", \"Starting PTC "
+ + logValues[0]
+ + " type "
+ + logValues[1]
+ + " on "
+ + logValues[2]
+ + "\", false);"
+ + "\r\n");
- testCaseString.append("hc.done(\"all component\");"
- + "\r\n");// TODO: all honnan jön?
+ } else if ((specValTemplate.getSpecificValue() instanceof Bitstring_Value)
+ || (specValTemplate.getSpecificValue() instanceof Integer_Value)
+ || (specValTemplate.getSpecificValue() instanceof Charstring_Value)
+ || (specValTemplate.getSpecificValue() instanceof Boolean_Value)
+ ||(specValTemplate.getSpecificValue() instanceof Octetstring_Value)
+ || (specValTemplate.getSpecificValue() instanceof Undefined_LowerIdentifier_Value)
+ || (specValTemplate.getSpecificValue() instanceof Referenced_Value)
+ || (specValTemplate.getSpecificValue() instanceof AddExpression)
+ || (specValTemplate.getSpecificValue() instanceof SubstractExpression)
+ || (specValTemplate.getSpecificValue() instanceof MultiplyExpression)
+ || (specValTemplate.getSpecificValue() instanceof DivideExpression)
+ || (specValTemplate.getSpecificValue() instanceof ModuloExpression)
+ || (specValTemplate.getSpecificValue() instanceof RemainderExpression)
+ ||(specValTemplate.getSpecificValue() instanceof UnaryMinusExpression)) {
+ // TODO assignments for indexed bitstrings
+ testCaseString.append("rownum="
+ + specValTemplate.getLocation().getLine() + ";\r\n");
- }
- }
+ testCaseString.append(tcAssignIdentifiers.get(assignCounter)
+ + tcAssignValues.get(assignCounter) + ";\r\n");
-
+
+
+ // TODO: add logging here
+ }
- testCaseString.append("}" + "\r\n");
+ }
return testCaseString.toString();
}
-
- public String getJavaSource(){
- createCounter=-1;
- connectCounter=-1;
- startCounter=-1;
- this.writeTestCaseFunction();
-
- String returnString=testCaseString.toString();
- testCaseString.setLength(0);
- return returnString;
- }
+ public void writeConnectStatement(Connect_Statement tc_connectStatement) {
+ testCaseString.append("rownum="
+ + tc_connectStatement.getLocation().getLine() + ";\r\n");
- public void setTcRunsOn(String testCaseRunsOn) {
- this.testCaseRunsOn=testCaseRunsOn;
-
- }
+ testCaseString.append("hc.connect(" + "\""
+ + tcConnectValues.get(connectCounter * 4) + "\"," + "\""
+ + tcConnectValues.get(connectCounter * 4 + 1) + "\"," + "\""
+ + tcConnectValues.get(connectCounter * 4 + 2) + "\"," + "\""
+ + tcConnectValues.get(connectCounter * 4 + 3) + "\"); "
+ + "\r\n");
+
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""
+ + nodeName
+ + "\", \"Connecting port "
+ + tcConnectValues.get(connectCounter * 4 + 1)
+ + " of "
+ + tcConnectValues.get(connectCounter * 4)
+ + " to port "
+ + tcConnectValues.get(connectCounter * 4 + 3)
+ + " of "
+ + tcConnectValues.get(connectCounter * 4 + 2)
+ + "\", false);" + "\r\n");
- public void setStatementBlock(StatementBlock tcStatementBlock) {
- this.tcStatementBlock=tcStatementBlock;
-
}
- public void addVars(String string) {
- tcVars.add(string);
-
+ public void writeUnknownStartStatement(
+ Unknown_Start_Statement tc_startStatement) {
+ startStatementCounter++;
+ testCaseString.append("rownum="
+ + tc_startStatement.getLocation().getLine() + ";\r\n");
+
+ if (testCaseStartValueParameters.get(startStatementCounter) != null) {
+ testCaseString.append("hc.start(" + "\""
+ + tcStartIdentifiers.get(startStatementCounter) + "\",\""
+ + testCaseStartValueParameters.get(startStatementCounter)
+ + "\"); " + "\r\n");
+ } else {
+ testCaseString.append(tcStartIdentifiers.get(startStatementCounter)
+ + ".start()" + ";\r\n");
+ }
+ if (testCaseStartValueParameters.get(startStatementCounter) != null) {
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""
+ + nodeName
+ + "\", \"Starting function "
+ + testCaseStartValueParameters
+ .get(startStatementCounter)
+ + " on component "
+ + tcStartIdentifiers.get(startStatementCounter)
+ + "\", false);" + "\r\n");
+ } else {// timer
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"TIMEROP\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"Timer "
+ + tcStartIdentifiers.get(startStatementCounter)
+ + " started.\", false);" + "\r\n");
+ isThereAStartedTimer = true;
+ currentTimerName = tcStartIdentifiers.get(startStatementCounter);
+
+ }
+
}
- public void addVarTypes(String string) {
- tcVarTypes.add(string);
-
+ public void writeUnknownStopStatement(
+ Unknown_Stop_Statement tc_stopStatement) {
+ stopStatementCounter++;
+ testCaseString.append("rownum="
+ + tc_stopStatement.getLocation().getLine() + ";\r\n");
+
+ if (testCaseStopValueParameters.get(stopStatementCounter) != null) {
+ testCaseString.append("hc.stop(" + "\""
+ + tcStopIdentifiers.get(stopStatementCounter) + "\",\""
+ + testCaseStopValueParameters.get(stopStatementCounter)
+ + "\"); " + "\r\n");
+ } else {
+ testCaseString.append(tcStopIdentifiers.get(stopStatementCounter)
+ + ".stop()" + ";\r\n");
+ }
+ if (testCaseStopValueParameters.get(stopStatementCounter) != null) {
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""
+ + nodeName
+ + "\", \"Stopping function "
+ + testCaseStopValueParameters
+ .get(stopStatementCounter)
+ + " on component "
+ + tcStopIdentifiers.get(stopStatementCounter)
+ + "\", false);" + "\r\n");
+ } else {// timer
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"TIMEROP\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"Timer "
+ + tcStopIdentifiers.get(stopStatementCounter)
+ + " stopped.\", false);" + "\r\n");
+ isThereAStartedTimer = true;
+ currentTimerName = tcStopIdentifiers.get(stopStatementCounter);
+
+ }
+
}
- public void addAssignValues(String string) {
- tcAssignValues.add(string);
-
+ public void writeMapStatement(Map_Statement tc_mapStatement) {
+ StringBuilder mapValueString = new StringBuilder();
+
+ while (Integer.toString(mapCounter).equals(
+ tcMapCounter.get(currentMapValueIndex))) {
+
+ mapValueString.append(tcMapValues.get(currentMapValueIndex) + " ");
+
+ currentMapValueIndex++;
+ if (currentMapValueIndex == tcMapCounter.size()) {
+ break;
+ }
+
+ }
+
+ String[] mapValues = mapValueString.toString().split(" ");
+
+ testCaseString.append("rownum="
+ + tc_mapStatement.getLocation().getLine() + ";\r\n");
+ testCaseString.append("hc.map(" + "\"" + mapValues[0] + "\",\""
+ + mapValues[1] + "\",\"" + mapValues[2] + "\",\""
+ + mapValues[3] + "\"" + ");\r\n");
+
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""
+ + nodeName
+ + "\", \"Mapping port "
+ + mapValues[1]
+ + " of "
+ + mapValues[0]
+ + " to port "
+ + mapValues[3]
+ + " of " + mapValues[2] + "\", false);" + "\r\n");
}
- public void addCreateValues(String string) {
- tcCreateValues.add(string);
-
+ public void writeIfStatement(If_Statement tc_ifStatement) {
+ testCaseString.append("rownum="
+ + tc_ifStatement.getLocation().getLine() + ";\r\n");
+
+ testCaseString.append("if(" + tcIfConditions.get(tcIfConditionCounter)
+ + ".getValue()){\r\n");
+
+ // TODO check if several IfClauses are possible
+ writeTestCaseFunction(tc_ifStatement.getIfClauses().getClauses().get(0)
+ .getStatementBlock());
+ if (blockWriter) {
+ testCaseString.append("}" + "\r\n");
+ }
+
+ if (tc_ifStatement.getStatementBlock() != null) {
+ testCaseString.append("else{\r\n");
+ writeTestCaseFunction(tc_ifStatement.getStatementBlock());
+ if (blockWriter) {
+ testCaseString.append("}" + "\r\n");
+ }
+
+ }
}
-
- public void addCreateCounter(String string) {
- tcCreateCounter.add(string);
-
+
+ public void writeSetVerdictStatement(
+ Setverdict_Statement tc_setVerdictStatement) {
+ Verdict_Value tc_VerdictValue = (Verdict_Value) tc_setVerdictStatement
+ .getVerdictValue();
+
+ testCaseString.append("rownum="
+ + tc_setVerdictStatement.getLocation().getLine() + ";\r\n");
+
+ if (tc_VerdictValue.getValue().toString().equals("PASS")) {
+ testCaseString.append("setVerdict(\"pass\")" + ";\r\n");
+ } else if (tc_VerdictValue.getValue().toString().equals("FAIL")) {
+ testCaseString.append("setVerdict(\"fail\")" + ";\r\n");
+ }
+
}
- public void addConnectValues(String string) {
- tcConnectValues.add(string);
-
+ public String writeSendStatement(Send_Statement tc_SendStatement) {
+
+ StringBuilder testCaseString = new StringBuilder("");
+
+ if (sendParameterType.get(sendCounter).equals("INTEGER")) {
+ String parameterValue =sendParameter.get(sendCounter);
+ testCaseString.append("rownum="
+ + tc_SendStatement.getLocation().getLine() + ";\r\n");
+ testCaseString.append(sendPortReference.get(sendCounter) + ".send("
+ + parameterValue + ");" + "\r\n");
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"SEND event on port "
+ + sendPortReference.get(sendCounter)
+ + ":INTEGER \""
+ + " + "
+ + parameterValue
+ + ".toString(), false);" + "\r\n");
+
+ }
+ if (sendParameterType.get(sendCounter).equals("IDENTIFIER")) {
+ String parameterValue = sendParameter.get(sendCounter);
+ testCaseString.append("rownum="
+ + tc_SendStatement.getLocation().getLine() + ";\r\n");
+ testCaseString.append(sendPortReference.get(sendCounter) + ".send("
+ + parameterValue + ");" + "\r\n");
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"SEND event on port "
+ + sendPortReference.get(sendCounter)
+ + ": \""
+ + " + "
+ + parameterValue
+ + ".toString(), false);"
+ + "\r\n");
+
+ }
+
+ return testCaseString.toString();
}
- public void addConnectCounter(String string) {
- tcConnectCounter.add(string);
-
+ public String writeReceiveStatement(Receive_Port_Statement currentStatement) {
+ StringBuilder testCaseString = new StringBuilder("");
+ String receiveStatement = "";
+
+ // no alt guard && any port recieve
+ if (receivePortReference.get(receiveCounter).equals("any port")) {
+ receiveStatement = "anyPortReceive(true)";
+
+ } else {
+ // no alt guard && typed port recieve
+ if (receiveType.get(receiveCounter).equals("_TYPED_PARAM_")) {
+
+ if (receiveAnyValValue.get(receiveCounter) != null) {
+ receiveStatement = "("
+ + receiveAnyValValue.get(receiveCounter) + "="
+ + receivePortReference.get(receiveCounter)
+ + ".receive_" + receiveValue.get(receiveCounter)
+ + "(true))!=null";
+
+ } else {
+
+ }
+
+ } else { // no alt guard && normal port recieve
+ receiveStatement = receivePortReference.get(receiveCounter)
+ + ".receive(" + receiveValue.get(receiveCounter)
+ + ",true)!=null";
+ }
+ if (receiveValue.get(receiveCounter).startsWith("Templates")) {
+ receiveType.set(receiveCounter, "Templates");
+ }
+ }
+
+ testCaseString.append("if(" + receiveStatement + "){\r\n");
+ testCaseString.append("rownum="
+ + currentStatement.getLocation().getLine() + ";\r\n");
+
+ if (receiveType.get(receiveCounter).equals("Templates")) {
+ String methodName = receiveValue.get(receiveCounter);
+ if (methodName.endsWith("()")
+ && methodName.startsWith("Templates.")) {
+
+ methodName = (String) methodName.subSequence(10,
+ methodName.length() - 2);
+ }
+
+ testCaseString
+ .append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"RECEIVE event on port "
+ + receivePortReference.get(receiveCounter)
+ + ":\\n "
+ + methodName
+ + ":=\" + "
+ + receiveValue.get(receiveCounter)
+ + ".toString(), true);" + "\r\n");
+ } else if (receiveType.get(receiveCounter).equals("any port")) {
+ testCaseString
+ .append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"RECEIVE event on port any port\", true);"
+ + "\r\n");
+ } else if (receiveType.get(receiveCounter).equals("_TYPED_PARAM_")) {
+ testCaseString
+ .append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"RECEIVE event on port "
+ + receivePortReference.get(receiveCounter)
+ + ": type "
+ + receiveValue.get(receiveCounter)
+ + "\", true);" + "\r\n");
+
+ } else {
+ testCaseString
+ .append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"RECEIVE event on port "
+ + receivePortReference.get(receiveCounter)
+ + ":\" + "
+ + receiveValue.get(receiveCounter)
+ + ".toString(), true);" + "\r\n");
+ }
+
+ for (int i = 0; i < receiveStatements.get(receiveCounter).getSize(); i++) {
+ if (receiveStatements.get(receiveCounter).getStatementByIndex(i) instanceof Setverdict_Statement) {
+
+ Setverdict_Statement setVerdictStatement = (Setverdict_Statement) receiveStatements
+ .get(receiveCounter).getStatementByIndex(i);
+ String verdict = "";
+
+ if (setVerdictStatement.getVerdictValue() instanceof Verdict_Value) {
+ Verdict_Value verdictValue = (Verdict_Value) setVerdictStatement
+ .getVerdictValue();
+ if (verdictValue.getValue().toString().equals("PASS")) {
+ verdict = "pass";
+ } else if (verdictValue.getValue().toString()
+ .equals("INCONC")) {
+ verdict = "inconc";
+ } else {
+ verdict = "fail";
+ }
+ }
+ testCaseString
+ .append("rownum="
+ + setVerdictStatement.getLocation().getLine()
+ + ";\r\n");
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"VERDICTOP\", sourcefilename, rownum, \"function\", \""
+ + nodeName
+ + "\", \"setverdict("
+ + verdict
+ + "): \" + getVerdict() + \" -> "
+ + verdict
+ + "\", true);" + "\r\n");
+ testCaseString.append("setVerdict(\"" + verdict + "\");"
+ + "\r\n");
+
+ }
+ }
+
+ testCaseString.append("}\r\n");
+
+ return testCaseString.toString();
}
- public void addStartValues(String string) {
- tcStartValues.add(string);
-
+ public void writeDisconnectStatement(
+ Disconnect_Statement tc_disconnectStatement) {
+
+ testCaseString.append("rownum="
+ + tc_disconnectStatement.getLocation().getLine() + ";\r\n");
+
+ testCaseString.append("hc.disconnect(" + "\""
+ + tcDisconnectValues.get(disconnectCounter * 4) + "\"," + "\""
+ + tcDisconnectValues.get(disconnectCounter * 4 + 1) + "\","
+ + "\"" + tcDisconnectValues.get(disconnectCounter * 4 + 2)
+ + "\"," + "\""
+ + tcDisconnectValues.get(disconnectCounter * 4 + 3) + "\"); "
+ + "\r\n");
+
+ testCaseString
+ .append("TTCN3Logger.writeLog(\"mtc\", \"PARALLEL\", sourcefilename, rownum, \"testcase\", \""
+ + nodeName
+ + "\", \"Disconnecting port "
+ + tcDisconnectValues.get(disconnectCounter * 4 + 1)
+ + " of "
+ + tcDisconnectValues.get(disconnectCounter * 4)
+ + " to port "
+ + tcDisconnectValues.get(disconnectCounter * 4 + 3)
+ + " of "
+ + tcDisconnectValues.get(disconnectCounter * 4 + 2)
+ + "\", false);" + "\r\n");
}
- public void addStartCounter(String string) {
- tcStartCounter.add(string);
-
+ public void clearLists() {
+
+ logCreateCounter = 0;
+ createCounter = -1;
+ connectCounter = -1;
+ disconnectCounter = -1;
+ currentCounterValue = 0;
+ defCounter = -1;
+ defValueCounter = -1;
+ assignCounter = -1;
+ mapCounter = 0;
+ tcIfConditionCounter = -1;
+ sendCounter = -1;
+ startStatementCounter = -1;
+ stopStatementCounter = -1;
+ currentMapValueIndex = 0;
+ receiveCounter = -1;
+
+ tcConnectValues.clear();
+ tcStartIdentifiers.clear();
+ tcStartCounter.clear();
+ tcMapValues.clear();
+ tcMapCounter.clear();
+ tcIfConditions.clear();
+ tcVars.clear();
+ tcVarTypes.clear();
+ tcVarValues.clear();
+ tcAssignIdentifiers.clear();
+ tcAssignValues.clear();
+ tcValueIsAValueReference.clear();
+ tcCreateValues.clear();
+ tcCreateCounter.clear();
+ sendPortReference.clear();
+ sendParameter.clear();
+ sendParameterType.clear();
+
+ tcVarIsConstant.clear();
+ tcVarIsTemplate.clear();
+ tcDisconnectValues.clear();
+ testCaseStartValueParameters.clear();
+ tcValueTypeIsAReference.clear();
+ tcStopIdentifiers.clear();
+ tcStopCounter.clear();
+ testCaseStopValueParameters.clear();
+
+ receivePortReference.clear();
+ receiveValue.clear();
+ receiveAnyValValue.clear();
+ receiveType.clear();
+ nodeVarIsRecord.clear();
+ receiveStatements.clear();
}
+ public void clearAltLists() {
+ altStatementCounter = -1;
+
+ altStatements.clear();
+ }
}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Charstring.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Bitstring_Writer.java
similarity index 79%
rename from org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Charstring.java
rename to org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Bitstring_Writer.java
index 861482b3002b22a4ee0ea920d41ef3ef52226e37..16949eba0cbda90d3578c8d365052a208647e3ab 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Charstring.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Bitstring_Writer.java
@@ -15,38 +15,34 @@
package org.eclipse.titan.codegenerator;
-import java.util.ArrayList;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
-import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
-
-public class Def_Type_Charstring {
+//TODO: duplicate of charstring, ONLY A PLACEHOLDER YET
+public class Def_Type_Bitstring_Writer {
private Def_Type typeNode;
private StringBuilder charStringString = new StringBuilder("");
- private CompilationTimeStamp compilationCounter = CompilationTimeStamp
- .getNewCompilationCounter();
+
private String charStringValue = null;
private String nodeName = null;
private static Map charStringHashes = new LinkedHashMap();
- private Def_Type_Charstring(Def_Type typeNode) {
+ private Def_Type_Bitstring_Writer(Def_Type typeNode) {
super();
this.typeNode = typeNode;
- nodeName = typeNode.getIdentifier().toString();
+ nodeName = this.typeNode.getIdentifier().toString();
}
- public static Def_Type_Charstring getInstance(Def_Type typeNode) {
+ public static Def_Type_Bitstring_Writer getInstance(Def_Type typeNode) {
if (!charStringHashes.containsKey(typeNode.getIdentifier().toString())) {
charStringHashes.put(typeNode.getIdentifier().toString(),
- new Def_Type_Charstring(typeNode));
+ new Def_Type_Bitstring_Writer(typeNode));
}
- return (Def_Type_Charstring) charStringHashes.get(typeNode
+ return (Def_Type_Bitstring_Writer) charStringHashes.get(typeNode
.getIdentifier().toString());
}
@@ -86,7 +82,14 @@ public class Def_Type_Charstring {
}
+ public void clearLists(){
+ //TODO put lists and fields here which should be initialized
+ }
+
public String getJavaSource() {
+
+ AstWalkerJava.logToConsole(" Starting processing: Bitstring " + nodeName );
+
charStringString.append("class " + nodeName
+ " extends SubTypeDef{" + "\r\n");
this.writeConstructor();
@@ -96,6 +99,9 @@ public class Def_Type_Charstring {
String returnString = charStringString.toString();
charStringString.setLength(0);
charStringValue = null;
+
+ AstWalkerJava.logToConsole(" Finished processing: Bitstring " + nodeName );
+
return returnString;
}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Charstring_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Charstring_Writer.java
new file mode 100644
index 0000000000000000000000000000000000000000..ad65eed5f51a0dc99f48c0611aa5f87a3e427706
--- /dev/null
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Charstring_Writer.java
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Keremi, Andras
+ * Eros, Levente
+ * Kovacs, Gabor
+ *
+ ******************************************************************************/
+
+package org.eclipse.titan.codegenerator;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
+
+public class Def_Type_Charstring_Writer {
+ private Def_Type typeNode;
+ private StringBuilder charStringString = new StringBuilder("");
+
+ private String charStringValue = null;
+ private String nodeName = null;
+
+ private static Map charStringHashes = new LinkedHashMap();
+
+ private Def_Type_Charstring_Writer(Def_Type typeNode) {
+ super();
+ this.typeNode = typeNode;
+ nodeName = this.typeNode.getIdentifier().toString();
+
+ }
+
+ public static Def_Type_Charstring_Writer getInstance(Def_Type typeNode) {
+ if (!charStringHashes.containsKey(typeNode.getIdentifier().toString())) {
+ charStringHashes.put(typeNode.getIdentifier().toString(),
+ new Def_Type_Charstring_Writer(typeNode));
+
+ }
+ return (Def_Type_Charstring_Writer) charStringHashes.get(typeNode
+ .getIdentifier().toString());
+ }
+
+ public void addCharStringValue(String value) {
+ charStringValue = value;
+ }
+
+ private void writeConstructor() {
+ charStringString.append(nodeName + "(" + "CHARSTRING" + " val){");
+ charStringString.append("\r\n" + "super(val);");
+
+ if (charStringValue != null) {
+
+ charStringString.append("\r\n" + "allowedValues.add"
+ + "(new CHARSTRING(\"" + charStringValue + "\"));");
+
+ }
+
+ charStringString.append("\r\n }\r\n");
+
+ }
+
+ private void writeMatcher() {
+ charStringString.append("public static boolean match(" + nodeName
+ + " pattern, " + "Object " + " message){" + "\r\n");
+ charStringString.append("if(!(message instanceof " + nodeName
+ + ")) return false;" + "\r\n");
+ charStringString.append(" return CHARSTRING.match(pattern.value, (("
+ + nodeName + ")message).value);" + "\r\n");
+ charStringString.append("}" + "\r\n");
+ }
+
+ private void writeEquals() {
+ charStringString.append("public BOOLEAN equals(" + nodeName
+ + " v){\r\n");
+ charStringString.append(" return value.equals(v.value);\r\n");
+ charStringString.append("}\r\n");
+
+ }
+
+ public void clearLists(){
+ //TODO put lists and fields here which should be initialized
+ }
+
+ public String getJavaSource() {
+
+ AstWalkerJava.logToConsole(" Starting processing: Charstring " + nodeName );
+
+ charStringString.append("class " + nodeName
+ + " extends SubTypeDef{" + "\r\n");
+ this.writeConstructor();
+ this.writeMatcher();
+ this.writeEquals();
+ charStringString.append("\r\n}");
+ String returnString = charStringString.toString();
+ charStringString.setLength(0);
+ charStringValue = null;
+
+ AstWalkerJava.logToConsole(" Finished processing: Charstring " + nodeName );
+
+ return returnString;
+ }
+
+}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Component.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Component_Writer.java
similarity index 71%
rename from org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Component.java
rename to org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Component_Writer.java
index 15c64ebbe94c17ed42875ac2a4fe459ba5f988e7..04f2a21246c58160f7335718c648078487ee2acc 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Component.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Component_Writer.java
@@ -20,39 +20,31 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Port;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
-import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
-public class Def_Type_Component {
+public class Def_Type_Component_Writer {
private Def_Type typeNode;
private StringBuilder compString = new StringBuilder("");
- private CompilationTimeStamp compilationCounter = CompilationTimeStamp
- .getNewCompilationCounter();
- private List compFieldTypes = new ArrayList();
- private List compFieldNames = new ArrayList();
- private String nodeName=null;
-
+
+ public List compFieldTypes = new ArrayList();
+ public List compFieldNames = new ArrayList();
+ private String nodeName = null;
+
private static Map compHashes = new LinkedHashMap();
- private Def_Type_Component(Def_Type typeNode) {
+ private Def_Type_Component_Writer(Def_Type typeNode) {
super();
this.typeNode = typeNode;
- nodeName = typeNode.getIdentifier().toString();
+ nodeName = this.typeNode.getIdentifier().toString();
}
- public static Def_Type_Component getInstance(Def_Type typeNode) {
+ public static Def_Type_Component_Writer getInstance(Def_Type typeNode) {
if (!compHashes.containsKey(typeNode.getIdentifier().toString())) {
compHashes.put(typeNode.getIdentifier().toString(),
- new Def_Type_Component(typeNode));
+ new Def_Type_Component_Writer(typeNode));
}
- return (Def_Type_Component) compHashes.get(typeNode.getIdentifier()
- .toString());
- }
-
- public void addCompFields(String type, String name) {
- compFieldTypes.add(type);
- compFieldNames.add(name);
+ return (Def_Type_Component_Writer) compHashes.get(typeNode
+ .getIdentifier().toString());
}
public void writeCompFields() {
@@ -69,12 +61,15 @@ public class Def_Type_Component {
compString.append("super(name);" + "\r\n");
compString.append("hc=hcont;" + "\r\n");
- compString.append("if(hc.debugmode)TTCN3Logger.writeLog(name, \"PARALLEL\", \"Test component \" + name + \" created.\", false);" + "\r\n");
-
+ compString
+ .append("if(hc.debugmode)TTCN3Logger.writeLog(name, \"PARALLEL\", \"Test component \" + name + \" created.\", false);"
+ + "\r\n");
+
for (int i = 0; i < compFieldNames.size(); i++) {
compString.append(compFieldNames.get(i) + " =new "
- + compFieldTypes.get(i) + "(this,\"+compFieldNames.get(i)+\");" + "\r\n");
+ + compFieldTypes.get(i) + "(this,\""
+ + compFieldNames.get(i) + "\");" + "\r\n");
}
compString.append("created = true;" + "\r\n");
@@ -130,7 +125,7 @@ public class Def_Type_Component {
compString.append(" " + "\r\n");
compString.append("}" + "\r\n");
}
-
+
public void writeDomap() {
compString.append("" + "\r\n");
compString.append("@Override" + "\r\n");
@@ -138,15 +133,36 @@ public class Def_Type_Component {
.append("public void domap(String thisport, String remotecomp, String remoteport) {"
+ "\r\n");
- //TODO
+ // TODO
+ for (int i = 0; i < compFieldTypes.size(); i++) {
+ if (myASTVisitor.nodeNameNodeTypeHashMap.get(compFieldTypes.get(i))
+ .equals("port")) {
+ if (!(myASTVisitor.portNamePortTypeHashMap.get(compFieldTypes
+ .get(i)).equals("TP_INTERNAL"))) {
+ compString.append("if(thisport.equals(\""
+ + compFieldNames.get(i) + "\")) "
+ + compFieldNames.get(i)
+ + ".map(remotecomp, remoteport);" + "\r\n");
+ }
+ }
+ }
compString.append(" " + "\r\n");
compString.append("}" + "\r\n");
}
+ public void clearLists() {
+ compFieldTypes.clear();
+ compFieldNames.clear();
+ }
+
public String getJavaSource() {
- compString.append("class " + nodeName
- + " extends ComponentDef{" + "\r\n");
+
+ AstWalkerJava.logToConsole(" Starting processing: Component "
+ + nodeName);
+
+ compString.append("class " + nodeName + " extends ComponentDef{"
+ + "\r\n");
this.writeCompFields();
this.writeConstructor();
this.writeAnyPortReceive();
@@ -154,12 +170,13 @@ public class Def_Type_Component {
this.writeConnect();
this.writeDomap();
compString.append("\r\n}");
-
+
String returnString = compString.toString();
compString.setLength(0);
- compFieldTypes.clear();
- compFieldNames.clear();
-
+
+ AstWalkerJava.logToConsole(" Finished processing: Component "
+ + nodeName);
+
return returnString;
}
}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Enum.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Enum.java
deleted file mode 100644
index 17057efdabdad878f9bee230b6294894531a78d8..0000000000000000000000000000000000000000
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Enum.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2000-2016 Ericsson Telecom AB
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *
- * Keremi, Andras
- * Eros, Levente
- * Kovacs, Gabor
- *
- ******************************************************************************/
-
-package org.eclipse.titan.codegenerator;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.titan.designer.AST.IVisitableNode;
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
-import org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type;
-import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
-
-public class Def_Type_Enum {
- private Def_Type enumNode;
- private StringBuilder enumString = new StringBuilder("");
- private CompilationTimeStamp compilationCounter = CompilationTimeStamp
- .getNewCompilationCounter();
- private List enumItems = new ArrayList();
- private String nodeName=null;
-
- private static Map enumStringHashes = new LinkedHashMap();
-
- private Def_Type_Enum(Def_Type typeNode) {
- super();
- this.enumNode = typeNode;
- nodeName = typeNode.getIdentifier().toString();
- }
-
- public static Def_Type_Enum getInstance(Def_Type typeNode) {
- if (!enumStringHashes.containsKey(typeNode.getIdentifier().toString())) {
- enumStringHashes.put(typeNode.getIdentifier().toString(),
- new Def_Type_Enum(typeNode));
- }
- return (Def_Type_Enum) enumStringHashes.get(typeNode
- .getIdentifier().toString());
- }
-
- public void addEnumItem(String value) {
- enumItems.add(value);
- }
-
- private void writeConstructors() {
- enumString.append("public Method(){"+ "\r\n");
- for(int i=0;i enumItems = new ArrayList();
+ public List enumItemValues = new ArrayList();
+ private String nodeName = null;
+
+ private static Map enumStringHashes = new LinkedHashMap();
+
+ private Def_Type_Enum_Writer(Def_Type typeNode) {
+ super();
+ this.typeNode = typeNode;
+ nodeName = this.typeNode.getIdentifier().toString();
+ }
+
+ public static Def_Type_Enum_Writer getInstance(Def_Type typeNode) {
+ if (!enumStringHashes.containsKey(typeNode.getIdentifier().toString())) {
+ enumStringHashes.put(typeNode.getIdentifier().toString(),
+ new Def_Type_Enum_Writer(typeNode));
+ }
+ return (Def_Type_Enum_Writer) enumStringHashes.get(typeNode
+ .getIdentifier().toString());
+ }
+
+ private void writeConstructors() {
+ enumString.append("public " + nodeName + "(){" + "\r\n");
+ int enumValueCounter = 0;
+ for (int i = 0; i < enumItems.size(); i++) {
+ enumString.append("values.put(\"" + enumItems.get(i) + "\",");
+ if (enumItemValues.get(i) != null) {
+ enumString.append(enumItemValues.get(i) + ");" + "\r\n");
+ } else {
+ while (enumItemValues.contains(Integer
+ .toString(enumValueCounter))) {
+ enumValueCounter++;
+ }
+ enumString.append(+enumValueCounter + ");" + "\r\n");
+ enumValueCounter++;
+ }
+
+ }
+ enumString.append("}" + "\r\n");
+
+ enumString.append("public " + nodeName + "(String v){" + "\r\n");
+ enumString.append("this();" + "\r\n");
+ enumString.append("setValue(v);}");
+ }
+
+ public void clearLists() {
+ enumItems.clear();
+ enumItemValues.clear();
+ }
+
+ public String getJavaSource() {
+
+ AstWalkerJava.logToConsole(" Starting processing: Enum " + nodeName);
+
+ enumString
+ .append("class " + nodeName + " extends ENUMERATED{" + "\r\n");
+ this.writeConstructors();
+ enumString.append("\r\n}");
+ String returnString = enumString.toString();
+ enumString.setLength(0);
+
+ AstWalkerJava.logToConsole(" Finished processing: Enum " + nodeName);
+
+ return returnString;
+ }
+
+}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Integer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Integer.java
deleted file mode 100644
index f58a2ee68296e5ad45e2e2ef3a3fc009ea724b30..0000000000000000000000000000000000000000
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Integer.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2000-2016 Ericsson Telecom AB
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *
- * Keremi, Andras
- * Eros, Levente
- * Kovacs, Gabor
- *
- ******************************************************************************/
-
-package org.eclipse.titan.codegenerator;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
-import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
-
-public class Def_Type_Integer {
- private Def_Type typeNode;
- private StringBuilder integerString = new StringBuilder("");
- private CompilationTimeStamp compilationCounter = CompilationTimeStamp
- .getNewCompilationCounter();
- private boolean isValueRangeSet=false;
- private int minValue;
- private int maxValue;
- private String nodeName=null;
-
- private static Map integerHashes = new LinkedHashMap();
-
-
- private Def_Type_Integer(Def_Type typeNode) {
- super();
- this.typeNode = typeNode;
- nodeName = typeNode.getIdentifier().toString();
- }
-
- public static Def_Type_Integer getInstance(Def_Type typeNode) {
- if (!integerHashes.containsKey(typeNode.getIdentifier().toString())) {
- integerHashes.put(typeNode.getIdentifier().toString(), new Def_Type_Integer(typeNode));
- }
- return (Def_Type_Integer) integerHashes.get(typeNode.getIdentifier().toString());
- }
-
- public void addMinMaxFields(int min, int max){
- isValueRangeSet=true;
- minValue=min;
- maxValue=max;
- }
-
- private void writeConstructor() {
- integerString.append(nodeName + "("
- + "INTEGER" + " val){");
- integerString.append("\r\n" +"super(val);");
-
- integerString.append("\r\n" + "allowedIntervals.add(new SubTypeInterval(new INTEGER("+minValue+"),new INTEGER("+maxValue+")));\r\n");
- integerString.append("\r\n" + " " + " " + "checkValue();");
- integerString.append("\r\n }\r\n");
- }
- private void writeMatcher() {
- integerString.append("public static boolean match("
- + nodeName + " pattern, " + "Object "
- + " message){" + "\r\n");
- integerString.append("if(!(message instanceof "
- + nodeName + ")) return false;"
- + "\r\n");
- integerString.append(" return INTEGER.match(pattern.value, (("
- + nodeName + ")message).value);"
- + "\r\n");
- integerString.append("}" + "\r\n");
-
- }
-
- private void writeEquals() {
- integerString.append("public boolean equals("
- + nodeName + " v){\r\n");
- integerString.append(" return value.equals(v.value);\r\n");
- integerString.append("}\r\n");
-
- }
-
- public String getJavaSource(){
- integerString.append("class " + nodeName
- + " extends SubTypeDef{"
- + "\r\n");
- this.writeConstructor();
- this.writeMatcher();
- this.writeEquals();
- integerString.append("\r\n}");
- String returnString=integerString.toString();
- integerString.setLength(0);
- minValue=0;
- maxValue=0;
- isValueRangeSet=false;
- return returnString;
- }
-
-
-
-}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Integer_Writer.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Integer_Writer.java
new file mode 100644
index 0000000000000000000000000000000000000000..d54a3914360e023cb423eef1f307d2abb7e6aded
--- /dev/null
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Integer_Writer.java
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Keremi, Andras
+ * Eros, Levente
+ * Kovacs, Gabor
+ *
+ ******************************************************************************/
+
+package org.eclipse.titan.codegenerator;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
+
+public class Def_Type_Integer_Writer {
+ private Def_Type typeNode;
+ private StringBuilder integerString = new StringBuilder("");
+
+ private String nodeName = null;
+ public static List allowedValues = new ArrayList();
+
+ private static Map integerHashes = new LinkedHashMap();
+
+ private Def_Type_Integer_Writer(Def_Type typeNode) {
+ super();
+ this.typeNode = typeNode;
+ nodeName = this.typeNode.getIdentifier().toString();
+ }
+
+ public static Def_Type_Integer_Writer getInstance(Def_Type typeNode) {
+ if (!integerHashes.containsKey(typeNode.getIdentifier().toString())) {
+ integerHashes.put(typeNode.getIdentifier().toString(), new Def_Type_Integer_Writer(typeNode));
+ }
+ return (Def_Type_Integer_Writer) integerHashes.get(typeNode.getIdentifier().toString());
+ }
+
+ private void writeConstructor() {
+ integerString.append(nodeName + "(" + "INTEGER" + " val){" + "\r\n");
+ integerString.append("super(val);\r\n");
+
+ for (int i = 0; i < allowedValues.size(); i++) {
+
+ if (allowedValues.get(i).startsWith("new SubTypeInterval")) {
+ integerString.append("allowedIntervals.add(" + allowedValues.get(i) + ");\r\n");
+ } else {
+ integerString.append("allowedValues.add(" + allowedValues.get(i) + ");\r\n");
+ }
+ }
+
+ integerString.append("\r\n" + " " + " " + "checkValue();");
+ integerString.append("\r\n }\r\n");
+ }
+
+ private void writeMatcher() {
+ integerString
+ .append("public static boolean match(" + nodeName + " pattern, " + "Object " + " message){" + "\r\n");
+ integerString.append("if(!(message instanceof " + nodeName + ")) return false;" + "\r\n");
+ integerString.append(" return INTEGER.match(pattern.value, ((" + nodeName + ")message).value);" + "\r\n");
+ integerString.append("}" + "\r\n");
+
+ }
+
+ private void writeEquals() {
+ integerString.append("public BOOLEAN equals(" + nodeName + " v){\r\n");
+ integerString.append(" return value.equals(v.value);\r\n");
+ integerString.append("}\r\n");
+
+ }
+
+ public void clearLists() {
+ // TODO put lists and fields here which should be initialized
+ }
+
+ public String getJavaSource() {
+
+ AstWalkerJava.logToConsole(" Starting processing: Integer " + nodeName);
+
+ integerString.append("class " + nodeName + " extends SubTypeDef{" + "\r\n");
+ this.writeConstructor();
+ this.writeMatcher();
+ this.writeEquals();
+ integerString.append("\r\n}");
+ String returnString = integerString.toString();
+ integerString.setLength(0);
+ allowedValues.clear();
+ AstWalkerJava.logToConsole(" Finished processing: Integer " + nodeName);
+
+ return returnString;
+ }
+
+}
diff --git a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Port.java b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Port_Writer.java
similarity index 88%
rename from org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Port.java
rename to org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Port_Writer.java
index a3c811e62c608e7d059b739db70a69bcb8f4c43c..206b773a39e2c698a292ea22f0ecb556672ca933 100644
--- a/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Port.java
+++ b/org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Port_Writer.java
@@ -21,58 +21,50 @@ import java.util.List;
import java.util.Map;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
-import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
//only supports inout messages
-public class Def_Type_Port {
+public class Def_Type_Port_Writer {
private Def_Type typeNode;
private StringBuilder portString = new StringBuilder("");
- private CompilationTimeStamp compilationCounter = CompilationTimeStamp
- .getNewCompilationCounter();
- private List inMessageName = new ArrayList();
- private List outMessageName = new ArrayList();
- private List inOutMessageName = new ArrayList();
+ public List inMessageName = new ArrayList();
+ public List outMessageName = new ArrayList();
+ public List