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
ab9a5588
Commit
ab9a5588
authored
Jun 21, 2018
by
Alexander David Hellwig
Browse files
Relaxed getInitLine error handling: some types dont need init lines
parent
63ae391f
Pipeline
#57102
passed with stage
in 2 minutes and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/ComponentConverter.java
View file @
ab9a5588
...
...
@@ -15,6 +15,7 @@ import de.monticore.lang.monticar.generator.optimization.MathInformationRegister
import
de.se_rwth.commons.logging.Log
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
...
...
@@ -174,7 +175,8 @@ public class ComponentConverter {
method
.
addInstruction
(
new
TargetCodeInstruction
(
"this->"
+
MathInformationRegister
.
getVariableInitName
(
v
,
bluePrint
)
+
"="
+
MathInformationRegister
.
getVariableInitName
(
v
,
bluePrint
)
+
";\n"
));
method
.
addParameter
(
v
);
}
else
{
method
.
addInstruction
(
new
TargetCodeInstruction
(
MathConverter
.
getInitLine
(
v
,
bluePrint
)));
Optional
<
String
>
initLine
=
MathConverter
.
getInitLine
(
v
,
bluePrint
);
initLine
.
ifPresent
(
s
->
method
.
addInstruction
(
new
TargetCodeInstruction
(
s
)));
}
}
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/MathConverter.java
View file @
ab9a5588
...
...
@@ -12,6 +12,8 @@ import de.monticore.lang.monticar.generator.optimization.MathInformationRegister
import
de.monticore.numberunit._ast.ASTNumberWithUnit
;
import
de.se_rwth.commons.logging.Log
;
import
java.util.Optional
;
/**
* @author Sascha Schneiders
*/
...
...
@@ -145,7 +147,7 @@ public class MathConverter {
return
String
.
format
(
"%s = %s(%s, %s, %s);\n"
,
MathInformationRegister
.
getVariableInitName
(
v
,
bluePrint
),
curBackend
.
getWholeNumberCubeTypeName
(),
v
.
getDimensionalInformation
().
get
(
0
),
v
.
getDimensionalInformation
().
get
(
1
),
v
.
getDimensionalInformation
().
get
(
2
));
}
public
static
String
getInitLine
(
Variable
v
,
BluePrintCPP
bluePrint
)
{
public
static
Optional
<
String
>
getInitLine
(
Variable
v
,
BluePrintCPP
bluePrint
)
{
String
initLine
=
null
;
if
(
v
.
getVariableType
().
getTypeNameTargetLanguage
().
equals
(
MathConverter
.
curBackend
.
getMatrixTypeName
()))
{
initLine
=
MathConverter
.
getMatrixInitLine
(
v
,
bluePrint
);
...
...
@@ -171,10 +173,6 @@ public class MathConverter {
initLine
=
""
;
}
if
(
initLine
==
null
)
{
Log
.
error
(
"0x3b097: Type not supported"
);
}
return
initLine
;
return
Optional
.
ofNullable
(
initLine
);
}
}
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