Commit a0f5d8b3 authored by Evgeny Kusmenko's avatar Evgeny Kusmenko
Browse files

Merge branch 'richter-dev' into 'master'

Richter dev

See merge request !12
parents 5ade1c2c bd99fed5
Pipeline #63699 passed with stage
in 2 minutes and 47 seconds
......@@ -8,7 +8,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-generator</artifactId>
<version>0.0.19-SNAPSHOT</version>
<version>0.0.20-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -21,9 +21,9 @@
<Common-MontiCar.version>0.0.14-SNAPSHOT</Common-MontiCar.version>
<Embedded-MontiArc.version>0.0.18-SNAPSHOT</Embedded-MontiArc.version>
<Embedded-MontiArc-Behaviour.version>0.0.14-SNAPSHOT</Embedded-MontiArc-Behaviour.version>
<Math.version>0.0.17-SNAPSHOT</Math.version>
<Embedded-MontiArc-Math.version>0.0.18-SNAPSHOT</Embedded-MontiArc-Math.version>
<tagging.version>0.0.3-SNAPSHOT</tagging.version>
<Math.version>0.0.18-SNAPSHOT</Math.version>
<Embedded-MontiArc-Math.version>0.0.19-SNAPSHOT</Embedded-MontiArc-Math.version>
<tagging.version>0.0.4</tagging.version>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
<junit.version>4.12</junit.version>
......
......@@ -11,15 +11,19 @@ public abstract class BaseMathFunctionFixerHandler extends BaseChainOfResponsibi
protected abstract void doFixMathFunction(MathExpressionSymbol symbol, BluePrintCPP bluePrintCPP);
public void handleFixMathFunction(MathExpressionSymbol symbol, BluePrintCPP bluePrintCPP) {
private 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);
}
}
......@@ -112,7 +112,7 @@ public class MathFunctionFixer extends BaseMathFunctionFixerHandler {
}
public static void fixMathFunctions(MathExpressionSymbol mathExpressionSymbol, BluePrintCPP bluePrintCPP) {
getInstance().doFixMathFunction(mathExpressionSymbol, bluePrintCPP);
getInstance().chainHandleFixMathFunction(mathExpressionSymbol, bluePrintCPP);
}
public static void fixMathFunctions(MathPreOperatorExpressionSymbol mathExpressionSymbol, BluePrintCPP bluePrintCPP) {
......
......@@ -17,12 +17,12 @@ public abstract class BaseExecuteMethodGeneratorHandler extends BaseChainOfRespo
protected abstract String doGenerateExecuteCode(MathExpressionSymbol symbol, List<String> includeStrings);
public String handleGenerateExecuteCode(MathExpressionSymbol symbol, List<String> includeStrings) {
private 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);
}
}
......@@ -101,7 +101,7 @@ public class ExecuteMethodGenerator extends BaseExecuteMethodGeneratorHandler {
}
public static String generateExecuteCode(MathExpressionSymbol mathExpressionSymbol, List<String> includeStrings) {
return getInstance().handleGenerateExecuteCode(mathExpressionSymbol, includeStrings);
return getInstance().chainHandleGenerateExecuteCode(mathExpressionSymbol, includeStrings);
}
/**
......
......@@ -7,14 +7,28 @@ package de.monticore.lang.monticar.pattern;
*/
public abstract class BaseChainOfResponsibility<T> {
private T successor = null;
private BaseChainOfResponsibility<T> predecessor = 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();
......
......@@ -158,4 +158,18 @@ public class BasicMathGenerationArmadilloTest extends AbstractSymtabTest {
String restPath = "armadillo/testMath/l0/";
testFilesAreEqual(files, restPath);
}
@Test
public void matScalarAddTest() throws IOException {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources");
ExpandedComponentInstanceSymbol componentSymbol = symtab.<ExpandedComponentInstanceSymbol>resolve("test.math.matScalarAddTest", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath("./target/generated-sources-cpp/armadillo/testMath/l0");
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
String restPath = "armadillo/testMath/l0/";
testFilesAreEqual(files, restPath);
}
}
#ifndef TEST_MATH_MATSCALARADDTEST
#define TEST_MATH_MATSCALARADDTEST
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include "armadillo.h"
using namespace arma;
class test_math_matScalarAddTest{
public:
void init()
{
}
void execute()
{
mat A = (ones<mat>(2, 2));
double b = 1;
A = A+1;
}
};
#endif
package test.math;
component MatScalarAddTest{
implementation Math{
Q^{2,2} A = ones(2,2);
Q b = 1;
A = A + 1;
}
}
\ No newline at end of file
Supports Markdown
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