Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse Titan
titan.EclipsePlug-ins
Commits
d8fa1ac0
Commit
d8fa1ac0
authored
Jun 28, 2016
by
Elemer Lelik
Committed by
GitHub
Jun 28, 2016
Browse files
Merge pull request #94 from matemeszaros/master
codegenerator bugfixes
parents
2f9d6467
8531ced1
Changes
9
Hide whitespace changes
Inline
Side-by-side
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/AstWalkerJava.java
View file @
d8fa1ac0
...
...
@@ -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,8 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
// get files in the folder
File
folder
=
new
File
(
folderPath
.
toString
());
File
[]
listOfFiles
=
folder
.
listFiles
();
// Sort them in ascending order (temporary fix for linux)
Arrays
.
sort
(
listOfFiles
);
String
leadingPath
=
""
;
for
(
int
i
=
0
;
i
<
path
.
segmentCount
();
i
++)
{
...
...
@@ -191,23 +194,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 +236,8 @@ public class AstWalkerJava implements IWorkbenchWindowActionDelegate {
Object
[]
modulestart
=
modules
.
get
(
fileNames
.
get
(
i
))
.
getOutlineChildren
();
//start AST processing
walkChildren
(
modulestart
);
}
...
...
@@ -247,18 +255,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
();
...
...
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Function_Writer.java
View file @
d8fa1ac0
...
...
@@ -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"
);
}
...
...
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Testcase_Writer.java
View file @
d8fa1ac0
...
...
@@ -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
(
currentCo
unter
Value
);
logValues
[
logWriteCounter
]=
tcConnectValues
.
get
(
currentCo
nnect
Value
);
currentConnectValue
++;
logWriteCounter
++;
...
...
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Component.java
View file @
d8fa1ac0
...
...
@@ -65,9 +65,9 @@ public class Def_Type_Component {
public
void
writeConstructor
()
{
compString
.
append
(
"public "
+
nodeName
+
"(HCType hco
mp
, String name, String ID){"
+
"\r\n"
);
+
"(HCType hco
nt
, String name, String ID){"
+
"\r\n"
);
compString
.
append
(
"super(name);"
+
"\r\n"
);
compString
.
append
(
"hc=hco
mp
;"
+
"\r\n"
);
compString
.
append
(
"hc=hco
nt
;"
+
"\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
();
...
...
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Enum.java
View file @
d8fa1ac0
...
...
@@ -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);}"
);
}
...
...
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Record.java
View file @
d8fa1ac0
...
...
@@ -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).
any
Field) return false;"
+
"\r\n"
);
+
")message).
omit
Field) return false;"
+
"\r\n"
);
recordString
.
append
(
" return "
);
//
...
...
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Set.java
View file @
d8fa1ac0
...
...
@@ -85,7 +85,7 @@ public class Def_Type_Set {
+
")message).omitField) return false;"
+
"\r\n"
);
setString
.
append
(
"if(pattern.anyField&&(("
+
nodeName
+
")message).
any
Field) return false;"
+
"\r\n"
);
+
")message).
omit
Field) return false;"
+
"\r\n"
);
...
...
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Set_Of.java
View file @
d8fa1ac0
...
...
@@ -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).
any
Field) return false;"
+
"\r\n"
);
+
")message).
omit
Field) return false;"
+
"\r\n"
);
setOfString
.
append
(
"return pattern.equals(("
...
...
org.eclipse.titan.codegenerator/src/org/eclipse/titan/codegenerator/Def_Type_Union.java
View file @
d8fa1ac0
...
...
@@ -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).
any
Field) return false;"
+
"\r\n"
);
+
")message).
omit
Field) 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).
any
Field) return false;"
+
"_"
+
nodeName
+
")message).
omit
Field) return false;"
+
"\r\n"
);
unionChildString
.
append
(
" return "
+
compFieldTypes
.
get
(
i
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment