Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
3992fd04
Commit
3992fd04
authored
Dec 23, 2018
by
Alexander David Hellwig
Browse files
Fix: EMADL2CPP/issues/1 + testcase
parent
31032678
Pipeline
#94036
failed with stage
in 15 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/ComponentConverterMethodGeneration.java
View file @
3992fd04
...
...
@@ -41,6 +41,7 @@ import de.monticore.lang.monticar.ts.references.MCTypeReference;
import
de.se_rwth.commons.logging.Log
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
/**
...
...
@@ -106,7 +107,7 @@ public class ComponentConverterMethodGeneration {
for
(
currentGenerationIndex
=
0
;
currentGenerationIndex
<
mathStatementsSymbol
.
getMathExpressionSymbols
().
size
();
++
currentGenerationIndex
)
{
int
beginIndex
=
currentGenerationIndex
;
MathExpressionSymbol
mathExpressionSymbol
=
mathStatementsSymbol
.
getMathExpressionSymbols
().
get
(
currentGenerationIndex
);
if
(!
visitedMathExpressionSymbols
.
contains
(
mathExpressionSymbol
))
{
if
(!
containsExactObject
(
visitedMathExpressionSymbols
,
mathExpressionSymbol
))
{
if
(
generatorCPP
.
useAlgebraicOptimizations
())
{
List
<
MathExpressionSymbol
>
precedingExpressions
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
counter
;
++
i
)
...
...
@@ -124,6 +125,16 @@ public class ComponentConverterMethodGeneration {
removeUselessVariableDefinitions
(
method
);
}
private
static
boolean
containsExactObject
(
Collection
collection
,
Object
obj
){
for
(
Object
other
:
collection
){
//equals is not used on purpose!
//the jvm object id must be the same!
if
(
other
==
obj
)
return
true
;
}
return
false
;
}
private
static
void
removeUselessVariableDefinitions
(
Method
method
)
{
List
<
Instruction
>
instructionsToRemove
=
new
ArrayList
<>();
for
(
Instruction
instruction1
:
method
.
getInstructions
())
{
...
...
src/test/java/de/monticore/lang/monticar/generator/cpp/AutomaticStreamTestGenerationTest.java
View file @
3992fd04
...
...
@@ -327,4 +327,18 @@ public class AutomaticStreamTestGenerationTest extends AbstractSymtabTest {
}
//Maybe add test that executes all stream tests in the resource dir(will take longer than an hour to execute) later
@Test
public
void
testMultipleAssignments
()
throws
Exception
{
AutomaticStreamTestGenerator
generator
=
new
AutomaticStreamTestGenerator
();
String
fullComponentInstanceName
=
"test.multipleAssignments"
;
String
modelDir
=
"src/test/resources/streamtests/multipleAssignmentsBase"
;
generator
.
generateTests
(
fullComponentInstanceName
,
modelDir
,
"N:/target/generated-sources-cpp/streamtest/multipleAssignments/"
,
"1"
,
1
);
testGenCPPFilesAndExec
(
"./target/generated-sources-cpp/streamtest"
,
"/multipleAssignments"
,
modelDir
,
"./target/generated-sources-cpp/streamtest/multipleAssignments"
,
fullComponentInstanceName
,
"test.MultipleAssignmentsTest"
);
}
}
Write
Preview
Supports
Markdown
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