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
de8a36a4
Commit
de8a36a4
authored
Jul 17, 2018
by
Christoph Richter
Browse files
ChainOfResponsibility: Ensure to start at top of the chain
parent
9b9d7b81
Pipeline
#63661
failed with stage
in 26 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/BaseMathFunctionFixerHandler.java
View file @
de8a36a4
...
...
@@ -11,15 +11,19 @@ public abstract class BaseMathFunctionFixerHandler extends BaseChainOfResponsibi
protected
abstract
void
doFixMathFunction
(
MathExpressionSymbol
symbol
,
BluePrintCPP
bluePrintCPP
);
p
ublic
void
handleFixMathFunction
(
MathExpressionSymbol
symbol
,
BluePrintCPP
bluePrintCPP
)
{
p
rivate
void
handleFixMathFunction
(
MathExpressionSymbol
symbol
,
BluePrintCPP
bluePrintCPP
)
{
if
(
canFixMathSymbol
(
symbol
))
{
doFixMathFunction
(
symbol
,
bluePrintCPP
);
}
else
if
(
getSuccessor
()
!=
null
)
{
getSuccessor
().
handleFixMathFunction
(
symbol
,
bluePrintCPP
);
((
BaseMathFunctionFixerHandler
)
getSuccessor
()
)
.
handleFixMathFunction
(
symbol
,
bluePrintCPP
);
}
else
{
Log
.
info
(
symbol
.
getTextualRepresentation
(),
"Symbol:"
);
Log
.
debug
(
getRole
(),
"Case not handled!"
);
}
}
public
void
chainHandleFixMathFunction
(
MathExpressionSymbol
symbol
,
BluePrintCPP
bluePrintCPP
)
{
((
BaseMathFunctionFixerHandler
)
getChainStart
()).
handleFixMathFunction
(
symbol
,
bluePrintCPP
);
}
}
src/main/java/de/monticore/lang/monticar/generator/cpp/MathFunctionFixer.java
View file @
de8a36a4
...
...
@@ -112,7 +112,7 @@ public class MathFunctionFixer extends BaseMathFunctionFixerHandler {
}
public
static
void
fixMathFunctions
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrintCPP
bluePrintCPP
)
{
getInstance
().
do
FixMathFunction
(
mathExpressionSymbol
,
bluePrintCPP
);
getInstance
().
chainHandle
FixMathFunction
(
mathExpressionSymbol
,
bluePrintCPP
);
}
public
static
void
fixMathFunctions
(
MathPreOperatorExpressionSymbol
mathExpressionSymbol
,
BluePrintCPP
bluePrintCPP
)
{
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/BaseExecuteMethodGeneratorHandler.java
View file @
de8a36a4
...
...
@@ -17,12 +17,12 @@ public abstract class BaseExecuteMethodGeneratorHandler extends BaseChainOfRespo
protected
abstract
String
doGenerateExecuteCode
(
MathExpressionSymbol
symbol
,
List
<
String
>
includeStrings
);
p
ublic
String
handleGenerateExecuteCode
(
MathExpressionSymbol
symbol
,
List
<
String
>
includeStrings
)
{
p
rivate
String
handleGenerateExecuteCode
(
MathExpressionSymbol
symbol
,
List
<
String
>
includeStrings
)
{
String
result
=
""
;
if
(
canHandleSymbol
(
symbol
))
{
result
=
doGenerateExecuteCode
(
symbol
,
includeStrings
);
}
else
if
(
getSuccessor
()
!=
null
)
{
result
=
getSuccessor
().
handleGenerateExecuteCode
(
symbol
,
includeStrings
);
result
=
((
BaseExecuteMethodGeneratorHandler
)
getSuccessor
()
)
.
handleGenerateExecuteCode
(
symbol
,
includeStrings
);
}
else
{
Log
.
info
(
symbol
.
getTextualRepresentation
(),
"Symbol:"
);
Log
.
debug
(
getRole
(),
"Case not handled!"
);
...
...
@@ -30,4 +30,8 @@ public abstract class BaseExecuteMethodGeneratorHandler extends BaseChainOfRespo
return
result
;
}
public
String
chainHandleGenerateExecuteCode
(
MathExpressionSymbol
symbol
,
List
<
String
>
includeStrings
)
{
return
((
BaseExecuteMethodGeneratorHandler
)
getChainStart
()).
handleGenerateExecuteCode
(
symbol
,
includeStrings
);
}
}
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/ExecuteMethodGenerator.java
View file @
de8a36a4
...
...
@@ -101,7 +101,7 @@ public class ExecuteMethodGenerator extends BaseExecuteMethodGeneratorHandler {
}
public
static
String
generateExecuteCode
(
MathExpressionSymbol
mathExpressionSymbol
,
List
<
String
>
includeStrings
)
{
return
getInstance
().
h
andleGenerateExecuteCode
(
mathExpressionSymbol
,
includeStrings
);
return
getInstance
().
chainH
andleGenerateExecuteCode
(
mathExpressionSymbol
,
includeStrings
);
}
/**
...
...
src/main/java/de/monticore/lang/monticar/pattern/BaseChainOfResponsibility.java
View file @
de8a36a4
...
...
@@ -7,14 +7,28 @@ package de.monticore.lang.monticar.pattern;
*/
public
abstract
class
BaseChainOfResponsibility
<
T
>
{
private
T
suc
cessor
=
null
;
private
BaseChainOfResponsibility
<
T
>
prede
cessor
=
null
;
public
T
getSuccessor
()
{
private
BaseChainOfResponsibility
<
T
>
successor
=
null
;
public
BaseChainOfResponsibility
<
T
>
getSuccessor
()
{
return
successor
;
}
public
void
setSuccessor
(
T
successor
)
{
protected
BaseChainOfResponsibility
<
T
>
getPredecessor
()
{
return
predecessor
;
}
public
void
setSuccessor
(
BaseChainOfResponsibility
<
T
>
successor
)
{
this
.
successor
=
successor
;
successor
.
predecessor
=
this
;
}
protected
BaseChainOfResponsibility
<
T
>
getChainStart
()
{
if
(
predecessor
==
null
)
return
this
;
else
return
predecessor
.
getChainStart
();
}
public
abstract
String
getRole
();
...
...
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