Commit 763044ea authored by Evgeny Kusmenko's avatar Evgeny Kusmenko
Browse files

Merge branch 'ExecutionSemantics' into 'master'

Execution semantics

See merge request !24
parents d3fc1772 63dcdedb
Pipeline #420948 passed with stage
in 1 minute and 32 seconds
<!--
(c) https://github.com/MontiCore/monticore
The license generally applicable for this project
can be found under https://github.com/MontiCore/monticore.
-->
<!-- (c) https://github.com/MontiCore/monticore -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
......@@ -10,26 +18,26 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-deeplearning</artifactId>
<version>0.2.12-SNAPSHOT</version>
<version>0.4.4-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<properties>
<!-- .. EMA-Libraries ................................................. -->
<Common-MontiCar.version>0.2.12-SNAPSHOT</Common-MontiCar.version>
<Embedded-MontiArc.version>0.2.12-SNAPSHOT</Embedded-MontiArc.version>
<Embedded-MontiArc-Math.version>0.2.12-SNAPSHOT</Embedded-MontiArc-Math.version>
<Embedded-MontiArc-Dynamics.version>0.2.12-SNAPSHOT</Embedded-MontiArc-Dynamics.version>
<Embedded-MontiArc-Behaviour.version>0.2.12-SNAPSHOT</Embedded-MontiArc-Behaviour.version>
<Math.version>0.2.12-SNAPSHOT</Math.version>
<MathOpt.version>0.2.12-SNAPSHOT</MathOpt.version>
<Common-MontiCar.version>0.4.4-SNAPSHOT</Common-MontiCar.version>
<Embedded-MontiArc.version>0.4.4-SNAPSHOT</Embedded-MontiArc.version>
<Embedded-MontiArc-Math.version>0.4.4-SNAPSHOT</Embedded-MontiArc-Math.version>
<Embedded-MontiArc-Dynamics.version>0.4.4-SNAPSHOT</Embedded-MontiArc-Dynamics.version>
<Embedded-MontiArc-Behaviour.version>0.4.4-SNAPSHOT</Embedded-MontiArc-Behaviour.version>
<Math.version>0.4.4-SNAPSHOT</Math.version>
<MathOpt.version>0.4.4-SNAPSHOT</MathOpt.version>
<CNNArch.version>0.4.4-SNAPSHOT</CNNArch.version>
<!-- .. SE-Libraries .................................................. -->
<monticore.version>5.0.1</monticore.version>
<se-commons.version>1.7.8</se-commons.version>
<mc.grammars.assembly.version>0.0.6</mc.grammars.assembly.version>
<CNNArch.version>0.4.0-SNAPSHOT</CNNArch.version>
<!-- .. Libraries .................................................. -->
<guava.version>25.1-jre</guava.version>
......@@ -117,11 +125,11 @@
<version>${se-commons.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>common-monticar</artifactId>
<version>${Common-MontiCar.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>de.monticore.lang.monticar</groupId>-->
<!-- <artifactId>common-monticar</artifactId>-->
<!-- <version>${Common-MontiCar.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
......@@ -131,11 +139,11 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc</artifactId>
<version>${Embedded-MontiArc.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>de.monticore.lang.monticar</groupId>-->
<!-- <artifactId>embedded-montiarc</artifactId>-->
<!-- <version>${Embedded-MontiArc.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
......@@ -146,11 +154,11 @@
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-behaviour</artifactId>
<version>${Embedded-MontiArc-Behaviour.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>de.monticore.lang.monticar</groupId>-->
<!-- <artifactId>embedded-montiarc-behaviour</artifactId>-->
<!-- <version>${Embedded-MontiArc-Behaviour.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
......@@ -160,11 +168,11 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.monticore.lang</groupId>
<artifactId>math</artifactId>
<version>${Math.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>de.monticore.lang</groupId>-->
<!-- <artifactId>math</artifactId>-->
<!-- <version>${Math.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>de.monticore.lang</groupId>
......@@ -174,11 +182,11 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.monticore.lang</groupId>
<artifactId>math-opt</artifactId>
<version>${MathOpt.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>de.monticore.lang</groupId>-->
<!-- <artifactId>math-opt</artifactId>-->
<!-- <version>${MathOpt.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>de.monticore.lang</groupId>
......@@ -216,11 +224,11 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-dynamics</artifactId>
<version>${Embedded-MontiArc-Dynamics.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>de.monticore.lang.monticar</groupId>-->
<!-- <artifactId>embedded-montiarc-dynamics</artifactId>-->
<!-- <version>${Embedded-MontiArc-Dynamics.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
......
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.emadl.math.visitor;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath._symboltable.math.symbols.*;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath._symboltable.math.visitor.CopyEMAMMathExpressionSymbol;
import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.visitor.MathStatementsSymbolCopy;
import de.monticore.lang.monticar.cnnarch._symboltable.TupleExpressionSymbol;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class CopyEMADLMathExpressionSymbol extends CopyEMAMMathExpressionSymbol
implements EMADLMathExpressionSymbolVisitor {
public static MathStatementsSymbol copy(MathStatementsSymbol symbol) {
MathStatementsSymbolCopy res = new MathStatementsSymbolCopy(symbol.getName(), symbol.astMathStatements);
if (symbol.getAstNode().isPresent()) res.setAstNode(symbol.getAstNode().get());
res.setAccessModifier(symbol.getAccessModifier());
res.setPackageName(symbol.getPackageName());
res.setFullName(symbol.getFullName());
List<MathExpressionSymbol> mathExpressionSymbolsCopy = new LinkedList<>();
for (MathExpressionSymbol mathExpressionSymbol : symbol.getMathExpressionSymbols()) {
mathExpressionSymbolsCopy.add(copy(mathExpressionSymbol));
}
res.setMathExpressionSymbols(mathExpressionSymbolsCopy);
return res;
}
public static <T extends MathExpressionSymbol> T copy(T symbol) {
CopyEMADLMathExpressionSymbol copy = new CopyEMADLMathExpressionSymbol();
copy.handle(symbol);
T res = copy.get(symbol);
return res;
}
@Override
protected <T extends MathExpressionSymbol> T get(T symbol) {
MathExpressionSymbol copy = copyMap.get(symbol);
if (copy != null) return (T) copy;
if (symbol instanceof TupleExpressionSymbol)
copy = new TupleExpressionSymbol();
else
return super.get(symbol);
copyMap.put(symbol, copy);
return (T) copy;
}
@Override
public void endVisit(TupleExpressionSymbol node) {
TupleExpressionSymbol res = get(node);
copyMathExpressionSymbol(res, node);
for (MathExpressionSymbol expression : node.getExpressions())
res.add(get(expression));
}
}
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.emadl.math.visitor;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath._symboltable.math.visitor.EMAMMathExpressionSymbolParentAwareVisitor;
import de.monticore.lang.monticar.cnnarch._symboltable.TupleExpressionSymbol;
public interface EMADLMathExpressionSymbolParentAwareVisitor extends EMAMMathExpressionSymbolParentAwareVisitor,
EMADLMathExpressionSymbolVisitor {
@Override
default void handle(TupleExpressionSymbol node) {
if (shouldContinue(node)) {
visit(node);
pushParent(node);
traverse(node);
popParent();
endVisit(node);
}
}
}
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.emadl.math.visitor;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath._symboltable.math.visitor.EMAMMathExpressionSymbolReplacementVisitor;
import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.TupleExpressionSymbol;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
public class EMADLMathExpressionSymbolReplacementVisitor extends EMAMMathExpressionSymbolReplacementVisitor
implements EMADLMathExpressionSymbolVisitor {
public EMADLMathExpressionSymbolReplacementVisitor(Map<MathExpressionSymbol, MathExpressionSymbol> replacementMap) {
super(replacementMap);
}
public EMADLMathExpressionSymbolReplacementVisitor(Function<MathExpressionSymbol, MathExpressionSymbol> replacementFunction) {
super(replacementFunction);
}
public static void replace(MathExpressionSymbol mathExpressionSymbol,
Map<MathExpressionSymbol, MathExpressionSymbol> replacementMap) {
EMADLMathExpressionSymbolReplacementVisitor replacementVisitor =
new EMADLMathExpressionSymbolReplacementVisitor(replacementMap);
replacementVisitor.handle(mathExpressionSymbol);
}
public static void replace(MathExpressionSymbol mathExpressionSymbol,
Function<MathExpressionSymbol, MathExpressionSymbol> replacementFunction) {
EMADLMathExpressionSymbolReplacementVisitor replacementVisitor =
new EMADLMathExpressionSymbolReplacementVisitor(replacementFunction);
replacementVisitor.handle(mathExpressionSymbol);
}
public static void replace(MathStatementsSymbol mathStatementsSymbol,
Map<MathExpressionSymbol, MathExpressionSymbol> replacementMap) {
EMADLMathExpressionSymbolReplacementVisitor replacementVisitor =
new EMADLMathExpressionSymbolReplacementVisitor(replacementMap);
replacementVisitor.handle(mathStatementsSymbol);
}
public static void replace(MathStatementsSymbol mathStatementsSymbol,
Function<MathExpressionSymbol, MathExpressionSymbol> replacementFunction) {
EMADLMathExpressionSymbolReplacementVisitor replacementVisitor =
new EMADLMathExpressionSymbolReplacementVisitor(replacementFunction);
replacementVisitor.handle(mathStatementsSymbol);
}
@Override
public void visit(TupleExpressionSymbol node) {
List<MathExpressionSymbol> expressions = new LinkedList();
for (MathExpressionSymbol expression : node.getExpressions())
expressions.add(get(expression));
node.setExpressions(expressions);
}
}
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.emadl.math.visitor;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath._symboltable.math.visitor.EMAMMathExpressionSymbolVisitor;
import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.TupleExpressionSymbol;
public interface EMADLMathExpressionSymbolVisitor extends EMAMMathExpressionSymbolVisitor {
@Override
default void handle(MathExpressionSymbol node) {
if (node == null) return;
else if (node instanceof TupleExpressionSymbol)
handle((TupleExpressionSymbol) node);
else
EMAMMathExpressionSymbolVisitor.super.handle(node);
}
public default void handle(TupleExpressionSymbol node) {
if (shouldContinue(node)) {
visit(node);
traverse(node);
endVisit(node);
}
}
public default void traverse(TupleExpressionSymbol node) {
for (MathExpressionSymbol expression : node.getExpressions()) {
handle(expression);
}
}
public default void visit(TupleExpressionSymbol node) {
}
public default void endVisit(TupleExpressionSymbol node) {
}
}
Markdown is supported
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