Commit 6702976c authored by Mészáros Máté Róbert's avatar Mészáros Máté Róbert
Browse files

codegenerator bugfixes: snapshot semantics, matching, etc. (by Andras Keremi)


Signed-off-by: default avatarMészáros Máté Róbert <mateusz.meszaros@gmail.com>
parent 2f9d6467
......@@ -19,6 +19,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
......@@ -77,7 +79,7 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
// ttcn3-bl msolt
// copied from ttcn-3
static {
try {
......@@ -151,7 +153,6 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
// get files in the folder
File folder = new File(folderPath.toString());
File[] listOfFiles = folder.listFiles();
String leadingPath = "";
for (int i = 0; i < path.segmentCount(); i++) {
......@@ -191,23 +192,26 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
}
}
//initialize common files
myASTVisitor.currentFileName = "Constants";
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings); // erre
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
myASTVisitor.visualizeNodeToJava("class Constants{\r\n}\r\n");
myASTVisitor.currentFileName = "Templates";
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings); // erre
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
myASTVisitor.visualizeNodeToJava("class Templates{\r\n}\r\n");
myASTVisitor.currentFileName = "TTCN_functions";
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings); // erre
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
myASTVisitor.visualizeNodeToJava("class TTCN_functions{\r\n}\r\n");
if (fileNames.size() > 0) {
for (int i = 0, num = files.size(); i < num; i++) {
//process files
currentTTCN3module = (TTCN3Module) doAnalysis(files.get(i),
null);
modules.put(fileNames.get(i), currentTTCN3module);
......@@ -230,6 +234,8 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
Object[] modulestart = modules.get(fileNames.get(i))
.getOutlineChildren();
//start AST processing
walkChildren(modulestart);
}
......@@ -247,18 +253,18 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
//write additional classes
Additional_Class_Writer additional_class=new Additional_Class_Writer();
myASTVisitor.currentFileName = "HC";
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings); //erre
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
myASTVisitor.visualizeNodeToJava(additional_class.writeHCClass());
myASTVisitor.currentFileName = "HCType";
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings); //erre
myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
myASTVisitor.visualizeNodeToJava(additional_class.writeHCTypeClass());
//clear lists
myASTVisitor.componentList.clear();
myASTVisitor.testCaseList.clear();
myASTVisitor.testCaseRunsOnList.clear();
......
......@@ -575,11 +575,13 @@ public class Def_Function_Writer {
functionString
.append("if(timeout>0) try{queue.poll(timeout,TimeUnit.MILLISECONDS);}catch(InterruptedException e){} "
+ "\r\n");
functionString.append("this.lock();" + "\r\n");
} else {
functionString
.append("try{queue.take();}catch(InterruptedException e){}"
+ "\r\n");
functionString.append("this.lock();" + "\r\n");
}
// endoftimer
......@@ -654,7 +656,7 @@ public class Def_Function_Writer {
functionString.append("}" + "\r\n");
}
functionString.append("this.unlock();" + "\r\n");
functionString.append("}" + "\r\n");
}
......
......@@ -115,7 +115,7 @@ public class Def_Testcase_Writer {
+ testCaseNode.getLocation().getFile().getFullPath()
.lastSegment() + "\";" + "\r\n");
testCaseString.append("int rownum=" +tcStatementBlock.getLocation().getLine()+ ";\r\n");
testCaseString.append("if(!created) return;" + "\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;
......@@ -205,7 +205,7 @@ public class Def_Testcase_Writer {
testCaseString.append("rownum="+tc_connectStatement.getLocation().getLine()+";\r\n");
testCaseString.append("hc.connect("+"\"" +tcConnectValues.get(currentConnectValue)+"\"");
logValues[logWriteCounter]=tcConnectValues.get(currentCounterValue);
logValues[logWriteCounter]=tcConnectValues.get(currentConnectValue);
currentConnectValue++;
logWriteCounter++;
......
......@@ -65,9 +65,9 @@ public class Def_Type_Component {
public void writeConstructor() {
compString.append("public " + nodeName
+ "(HCType hcomp, String name, String ID){" + "\r\n");
+ "(HCType hcont, String name, String ID){" + "\r\n");
compString.append("super(name);" + "\r\n");
compString.append("hc=hcomp;" + "\r\n");
compString.append("hc=hcont;" + "\r\n");
compString.append("if(hc.debugmode)TTCN3Logger.writeLog(name, \"PARALLEL\", \"Test component \" + name + \" created.\", false);" + "\r\n");
......@@ -130,6 +130,19 @@ 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");
compString
.append("public void domap(String thisport, String remotecomp, String remoteport) {"
+ "\r\n");
//TODO
compString.append(" " + "\r\n");
compString.append("}" + "\r\n");
}
public String getJavaSource() {
compString.append("class " + nodeName
......@@ -139,6 +152,7 @@ public class Def_Type_Component {
this.writeAnyPortReceive();
this.writePrepareForConnection();
this.writeConnect();
this.writeDomap();
compString.append("\r\n}");
String returnString = compString.toString();
......
......@@ -59,12 +59,10 @@ public class Def_Type_Enum {
for(int i=0;i<enumItems.size();i++){
enumString.append("values.put(\""+enumItems.get(i)+"\","+i+");" + "\r\n");
}
enumString.append("}");
enumString.append("}"+ "\r\n");
enumString.append("public Method(String v){"+ "\r\n");
for(int i=0;i<enumItems.size();i++){
enumString.append("values.put(\""+enumItems.get(i)+"\","+i+");" + "\r\n");
}
enumString.append("this();"+ "\r\n");
enumString.append("setValue(v);}");
}
......
......@@ -80,7 +80,7 @@ public class Def_Type_Record {
recordString.append("if(pattern.omitField&&!((" + nodeName
+ ")message).omitField) return false;" + "\r\n");
recordString.append("if(pattern.anyField&&((" + nodeName
+ ")message).anyField) return false;" + "\r\n");
+ ")message).omitField) return false;" + "\r\n");
recordString.append(" return "); //
......
......@@ -85,7 +85,7 @@ public class Def_Type_Set {
+ ")message).omitField) return false;" + "\r\n");
setString.append("if(pattern.anyField&&(("
+ nodeName
+ ")message).anyField) return false;" + "\r\n");
+ ")message).omitField) return false;" + "\r\n");
......
......@@ -74,15 +74,15 @@ public class Def_Type_Set_Of {
+ nodeName
+ ")message).omitField) return true;" + "\r\n");
setOfString.append("if(pattern.anyOrOmitField) return true;" + "\r\n");
setOfString.append("if(pattern.anyField&&(("
setOfString.append("if(pattern.anyField&&!(("
+ nodeName
+ ")message).omitField) return true;" + "\r\n");
setOfString.append("if(pattern.omitField&&(("
setOfString.append("if(pattern.omitField&&!(("
+ nodeName
+ ")message).omitField) return false;" + "\r\n");
setOfString.append("if(pattern.anyField&&(("
+ nodeName
+ ")message).anyField) return false;" + "\r\n");
+ ")message).omitField) return false;" + "\r\n");
setOfString.append("return pattern.equals(("
......
......@@ -68,20 +68,17 @@ public class Def_Type_Union {
unionString.append("if(!(message instanceof " + nodeName
+ "))return false;" + "\r\n");
/*if (AstWalkerJava.areCommentsAllowed) {
unionString.append("System.out.println(\"" + nodeName
+ " tipusegyezes2\");" + "\r\n");
}*/
unionString.append("if(pattern.omitField&&((" + nodeName
+ ")message).omitField) return true;" + "\r\n");
unionString.append("if(pattern.anyOrOmitField) return true;" + "\r\n");
unionString.append("if(pattern.anyField&&((" + nodeName
unionString.append("if(pattern.anyField&&!((" + nodeName
+ ")message).omitField) return true;" + "\r\n");
unionString.append("if(pattern.omitField&&((" + nodeName
unionString.append("if(pattern.omitField&&!((" + nodeName
+ ")message).omitField) return false;" + "\r\n");
unionString.append("if(pattern.anyField&&((" + nodeName
+ ")message).anyField) return false;" + "\r\n");
+ ")message).omitField) return false;" + "\r\n");
for (int l = 0; l < compFieldTypes.size(); l++) {
unionString.append("if(pattern instanceof " + "SC_" + (l + 1) + "_"
......@@ -150,14 +147,14 @@ public class Def_Type_Union {
+ ")message).omitField) return true;" + "\r\n");
unionChildString.append("if(pattern.anyOrOmitField) return true;"
+ "\r\n");
unionChildString.append("if(pattern.anyField&&((" + "SC_" + (i + 1)
unionChildString.append("if(pattern.anyField&&!((" + "SC_" + (i + 1)
+ "_" + nodeName + ")message).omitField) return true;"
+ "\r\n");
unionChildString.append("if(pattern.omitField&&((" + "SC_"
unionChildString.append("if(pattern.omitField&&!((" + "SC_"
+ (i + 1) + "_" + nodeName
+ ")message).omitField) return false;" + "\r\n");
unionChildString.append("if(pattern.anyField&&((" + "SC_" + (i + 1)
+ "_" + nodeName + ")message).anyField) return false;"
+ "_" + nodeName + ")message).omitField) return false;"
+ "\r\n");
unionChildString.append(" return " + compFieldTypes.get(i)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment