Commit 5add0f34 authored by Svetlana Pavlitskaya's avatar Svetlana Pavlitskaya Committed by Evgeny Kusmenko
Browse files

Migration to monticore 5.0.1 and a newer Math

parent cbc47c05
......@@ -28,21 +28,24 @@ masterJobLinux:
image: maven:3-jdk-8
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean deploy --settings settings.xml
- cat target/site/jacoco/index.html
- mvn package sonar:sonar -s settings.xml
only:
- master
masterJobWindows:
stage: windows
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
tags:
- Windows10
#masterJobWindows:
# stage: windows
# script:
# - mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
# tags:
# - Windows10
BranchJobLinux:
stage: linux
image: maven:3-jdk-8
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
- cat target/site/jacoco/index.html
except:
- master
![pipeline](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/languages/EmbeddedMontiArcDL/badges/master/build.svg)
![coverage](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/languages/EmbeddedMontiArcDL/badges/master/coverage.svg)
# EmbeddedMontiArcDL
Embeds [CNNArch](https://github.com/EmbeddedMontiArc/CNNArchLang), [CNNTrain](https://github.com/EmbeddedMontiArc/CNNTrainLang) and MontiMath into EmbeddedMontiArc.
......
......@@ -30,23 +30,22 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-deeplearning</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.2.2-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<properties>
<!-- .. SE-Libraries .................................................. -->
<monticore.version>4.5.4.08.11.2017</monticore.version>
<se-commons.version>1.7.7</se-commons.version>
<mc.grammars.assembly.version>0.0.6-SNAPSHOT</mc.grammars.assembly.version>
<SIUnit.version>0.0.10-SNAPSHOT</SIUnit.version>
<Common-MontiCar.version>0.0.12</Common-MontiCar.version>
<Embedded-MontiArc.version>0.0.17-SNAPSHOT</Embedded-MontiArc.version>
<Embedded-MontiArc-Behaviour.version>0.0.11</Embedded-MontiArc-Behaviour.version>
<CNNArch.version>0.2.2-SNAPSHOT</CNNArch.version>
<Math.version>0.0.11</Math.version>
<Embedded-MontiArc-Math.version>0.0.12</Embedded-MontiArc-Math.version>
<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>
<Common-MontiCar.version>0.0.14-SNAPSHOT</Common-MontiCar.version>
<Embedded-MontiArc.version>0.0.18-SNAPSHOT</Embedded-MontiArc.version>
<Embedded-MontiArc-Math.version>0.0.19-SNAPSHOT</Embedded-MontiArc-Math.version>
<Embedded-MontiArc-Behaviour.version>0.0.14-SNAPSHOT</Embedded-MontiArc-Behaviour.version>
<CNNArch.version>0.2.4-SNAPSHOT</CNNArch.version>
<Math.version>0.0.19-SNAPSHOT</Math.version>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
......@@ -55,11 +54,12 @@
<jscience.version>4.3.1</jscience.version>
<!-- .. Plugins ....................................................... -->
<monticore.plugin>4.5.3.1</monticore.plugin>
<monticore.plugin>5.0.1</monticore.plugin>
<assembly.plugin>2.5.4</assembly.plugin>
<compiler.plugin>3.3</compiler.plugin>
<source.plugin>2.4</source.plugin>
<shade.plugin>2.4.3</shade.plugin>
<jacoco.plugin>0.8.1</jacoco.plugin>
<!-- Classifiers -->
<grammars.classifier>grammars</grammars.classifier>
......@@ -119,21 +119,6 @@
<version>${se-commons.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang</groupId>
<artifactId>NumberUnit</artifactId>
<version>${SIUnit.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang</groupId>
<artifactId>NumberUnit</artifactId>
<version>${SIUnit.version}</version>
<classifier>${grammars.classifier}</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>common-monticar</artifactId>
......@@ -251,6 +236,29 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<!-- Test coverage -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- MontiCore Generation -->
<plugin>
<groupId>de.monticore.mojo</groupId>
......
......@@ -3,14 +3,11 @@ package de.monticore.lang.monticar;
grammar EMADL extends de.monticore.lang.embeddedmontiarc.EmbeddedMontiArcBehavior,
de.monticore.lang.monticar.CNNArch{
EMADLCompilationUnit = EMACompilationUnit;
start EMACompilationUnit;
BehaviorEmbedding = Architecture | MathStatements;
BehaviorName = name:"CNN" | name:"Math";
MathStatements = Statement+;
token NEWLINETOKEN =
('\r' '\n' |
'\r' |
'\n' ):;
BehaviorName = name:"CNN" | name:"Math";
}
\ No newline at end of file
......@@ -46,14 +46,14 @@ public class CheckBehaviorName implements EMADLASTBehaviorNameCoCo, EMADLASTBeha
}
private void checkBehavior() {
if (behaviorName.getName().get().equals("Math")){
if (!behaviorEmbedding.getMathStatements().isPresent()){
if (behaviorName.getNameOpt().get().equals("Math")){
if (!behaviorEmbedding.isPresentMathStatements()){
Log.error("Implementation Name 'Math' is incorrect."
, behaviorName.get_SourcePositionStart());
}
}
else {
if (!behaviorEmbedding.getArchitecture().isPresent()){
if (!behaviorEmbedding.isPresentArchitecture()){
Log.error("Implementation Name 'Math' is incorrect."
, behaviorName.get_SourcePositionStart());
}
......
......@@ -23,7 +23,7 @@ package de.monticore.lang.monticar.emadl._cocos;
import de.monticore.lang.embeddedmontiarc.cocos.*;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath.cocos.AtomicComponentCoCo;
import de.monticore.lang.math.math._cocos.MatrixAssignmentDeclarationCheck;
import de.monticore.lang.math._cocos.MatrixAssignmentDeclarationCheck;
import de.monticore.lang.monticar.cnnarch._cocos.CNNArchCocos;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
......
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.monticar.emadl._symboltable;
import de.monticore.symboltable.SymbolKind;
public class EMADLCompilationUnitKind implements SymbolKind {
private static final String NAME = "de.monticore.lang.monticar.emadl._symboltable.EMADLCompilationUnitKind";
@Override
public String getName() {
return NAME;
}
@Override
public boolean isKindOf(SymbolKind kind) {
return NAME.equals(kind.getName()) || SymbolKind.super.isKindOf(kind);
}
}
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.monticar.emadl._symboltable;
public class EMADLCompilationUnitSymbol extends de.monticore.symboltable.CommonSymbol {
public static final EMADLCompilationUnitKind KIND = new EMADLCompilationUnitKind();
public EMADLCompilationUnitSymbol(String name) {
super(name, KIND);
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ import de.monticore.antlr4.MCConcreteParser;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EmbeddedMontiArcLanguage;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath.adapter.PortArraySymbol2MathVariableDeclarationSymbolTypeFilter;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath.adapter.ResolutionDeclarationSymbol2MathVariableDeclarationTypeFilter;
import de.monticore.lang.math.math._symboltable.MathLanguage;
import de.monticore.lang.math._symboltable.MathLanguage;
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage;
import de.monticore.lang.monticar.emadl._parser.EMADLParser;
import de.monticore.lang.monticar.emadl.adapter.PortArraySymbol2IODeclarationSymbolTypeFilter;
......
......@@ -20,28 +20,31 @@
*/
package de.monticore.lang.monticar.emadl._symboltable;
import de.monticore.symboltable.SymbolKind;
import de.monticore.lang.math._ast.ASTStatement;
import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.math._symboltable.MathStatementsSymbolKind;
import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.monticar.emadl._ast.ASTMathStatements;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.ArrayList;
import java.util.List;
public class EMADLModelNameCalculator extends de.monticore.CommonModelNameCalculator {
@Override
public Set<String> calculateModelNames(final String name, final SymbolKind kind) {
final Set<String> calculatedModelNames = new LinkedHashSet<>();
public class EMADLMathStatementsSymbol extends MathStatementsSymbol {
protected List<MathExpressionSymbol> emadlMathExpressionSymbols = null;
if (EMADLCompilationUnitSymbol.KIND.isKindOf(kind)) {
calculatedModelNames.addAll(calculateModelNamesForEMADLCompilationUnit(name));
public EMADLMathStatementsSymbol(String name, ASTMathStatements ast) {
super(name, null);
this.emadlMathExpressionSymbols = new ArrayList<>();
for (ASTStatement astStatement : ast.getStatementList()) {
emadlMathExpressionSymbols.add((MathExpressionSymbol) astStatement.getSymbolOpt().get());
}
return calculatedModelNames;
}
protected Set<String> calculateModelNamesForEMADLCompilationUnit(String name) {
final Set<String> modelNames = new LinkedHashSet<>();
modelNames.add(name);
return modelNames;
@Override
public List<MathExpressionSymbol> getMathExpressionSymbols() {
return this.emadlMathExpressionSymbols;
}
}
}
......@@ -20,6 +20,7 @@
*/
package de.monticore.lang.monticar.emadl._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTEMACompilationUnit;
import de.monticore.symboltable.ArtifactScope;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.ResolvingConfiguration;
......@@ -27,14 +28,14 @@ import de.monticore.symboltable.Scope;
import de.se_rwth.commons.logging.Log;
public class EMADLModelLoader extends de.monticore.modelloader.ModelingLanguageModelLoader<de.monticore.lang.monticar.emadl._ast.ASTEMADLCompilationUnit> {
public class EMADLModelLoader extends de.monticore.modelloader.ModelingLanguageModelLoader<ASTEMACompilationUnit> {
public EMADLModelLoader(EMADLLanguage language) {
super(language);
}
@Override
protected void createSymbolTableFromAST(final de.monticore.lang.monticar.emadl._ast.ASTEMADLCompilationUnit ast, final String modelName,
protected void createSymbolTableFromAST(final ASTEMACompilationUnit ast, final String modelName,
final MutableScope enclosingScope, final ResolvingConfiguration resolvingConfiguration) {
final EMADLSymbolTableCreator symbolTableCreator =
getModelingLanguage().getSymbolTableCreator(resolvingConfiguration, enclosingScope).orElse(null);
......
......@@ -20,10 +20,15 @@
*/
package de.monticore.lang.monticar.emadl._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTEMACompilationUnit;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EmbeddedMontiArcSymbolTableCreator;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcbehavior._symboltable.EmbeddedMontiArcBehaviorSymbolTableCreator;
import de.monticore.lang.math._ast.ASTStatement;
import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchSymbolTableCreator;
import de.monticore.lang.monticar.emadl._visitor.CommonEMADLDelegatorVisitor;
import de.monticore.lang.monticar.emadl._ast.ASTMathStatements;
import de.monticore.lang.monticar.emadl._visitor.EMADLDelegatorVisitor;
import de.monticore.lang.monticar.emadl._visitor.EMADLVisitor;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.ResolvingConfiguration;
......@@ -35,7 +40,7 @@ import java.util.Deque;
public class EMADLSymbolTableCreator extends de.monticore.symboltable.CommonSymbolTableCreator
implements EMADLVisitor {
private final CommonEMADLDelegatorVisitor visitor = new CommonEMADLDelegatorVisitor();
private final EMADLDelegatorVisitor visitor = new EMADLDelegatorVisitor();
private EmbeddedMontiArcSymbolTableCreator emaSTC;
private CNNArchSymbolTableCreator cnnArchSTC;
......@@ -56,12 +61,21 @@ public class EMADLSymbolTableCreator extends de.monticore.symboltable.CommonSymb
this.emaSTC = new ModifiedEMASymbolTableCreator(resolvingConfig, scopeStack);//new ModifiedEMASymbolTableCreator(resolvingConfig, scopeStack);
this.cnnArchSTC = new CNNArchSymbolTableCreator(resolvingConfig, scopeStack);
visitor.set_de_monticore_lang_embeddedmontiarc_embeddedmontiarc__visitor_EmbeddedMontiArcVisitor(emaSTC);
visitor.set_de_monticore_lang_embeddedmontiarc_embeddedmontiarcbehavior__visitor_EmbeddedMontiArcBehaviorVisitor(
visitor.setEmbeddedMontiArcVisitor(emaSTC);
visitor.setEmbeddedMontiArcBehaviorVisitor(
new EmbeddedMontiArcBehaviorSymbolTableCreator(resolvingConfig, scopeStack));
visitor.set_de_monticore_lang_monticar_emadl__visitor_EMADLVisitor(this);
visitor.set_de_monticore_lang_monticar_cnnarch__visitor_CNNArchVisitor(cnnArchSTC);
visitor.set_de_monticore_lang_math_math__visitor_MathVisitor(cnnArchSTC.getMathSTC());
visitor.setEMADLVisitor(this);
visitor.setCNNArchVisitor(cnnArchSTC);
visitor.setMathVisitor(cnnArchSTC.getMathSTC());
visitor.setMatrixVisitor(cnnArchSTC.getMathSTC());
visitor.setMatrixExpressionsVisitor(cnnArchSTC.getMathSTC());
visitor.setExpressionsBasisVisitor(cnnArchSTC.getMathSTC());
visitor.setCommonExpressionsVisitor(cnnArchSTC.getMathSTC());
visitor.setTypes2Visitor(cnnArchSTC.getMathSTC());
visitor.setAssignmentExpressionsVisitor(cnnArchSTC.getMathSTC());
}
/**
......@@ -73,7 +87,7 @@ public class EMADLSymbolTableCreator extends de.monticore.symboltable.CommonSymb
*/
public Scope createFromAST(de.monticore.lang.monticar.emadl._ast.ASTEMADLCompilationUnit rootNode) {
public Scope createFromAST(ASTEMACompilationUnit rootNode) {
Log.errorIfNull(rootNode, "0xA7004_184 Error by creating of the EMADLSymbolTableCreator symbol table: top ast node is null");
rootNode.accept(visitor);
return getFirstCreatedScope();
......@@ -98,11 +112,7 @@ public class EMADLSymbolTableCreator extends de.monticore.symboltable.CommonSymb
}
}
/*@Override
public void visit(ASTEMADLCompilationUnit ast) {
EMADLCompilationUnitSymbol compilationUnit = new EMADLCompilationUnitSymbol("");
addToScopeAndLinkWithNode(compilationUnit, ast);
}*/
}
public void endVisit(ASTMathStatements ast) {
addToScopeAndLinkWithNode(new EMADLMathStatementsSymbol("MathStatements", ast), ast);
}
}
\ No newline at end of file
......@@ -49,8 +49,8 @@ public class ModifiedEMASymbolTableCreator extends EmbeddedMontiArcSymbolTableCr
public void endVisit(ASTEMACompilationUnit node) {
this.removeCurrentScope();
if (!this.aboartVisitComponent) {
Log.debug("endVisit of " + node.getComponent().getSymbol().get().getFullName(), "SymbolTableCreator:");
getInstanceSymbolCreator().createInstances((ComponentSymbol)(Log.errorIfNull(node.getComponent().getSymbol().orElse(null))));
Log.debug("endVisit of " + node.getComponent().getSymbolOpt().get().getFullName(), "SymbolTableCreator:");
getInstanceSymbolCreator().createInstances((ComponentSymbol)(Log.errorIfNull(node.getComponent().getSymbolOpt().orElse(null))));
}
}
......
......@@ -21,14 +21,14 @@
package de.monticore.lang.monticar.emadl._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*;
import de.monticore.lang.math.math._ast.ASTMathNumberExpression;
import de.monticore.lang.math._ast.ASTNumberExpression;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.VariableSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.VariableType;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.ts.MCFieldSymbol;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution;
import de.monticore.lang.monticar.resolution._ast.ASTUnitNumberResolution;
import de.se_rwth.commons.logging.Log;
import java.util.*;
......@@ -75,8 +75,8 @@ public class ModifiedExpandedComponentInstanceBuilder extends ExpandedComponentI
//add configuration parameters
for (int i = 0; i < instance.getArguments().size(); i++){
if (instance.getArguments().get(i) instanceof ASTMathNumberExpression){
ASTMathNumberExpression exp = (ASTMathNumberExpression) instance.getArguments().get(i);
if (instance.getArguments().get(i) instanceof ASTNumberExpression){
ASTNumberExpression exp = (ASTNumberExpression) instance.getArguments().get(i);
MCFieldSymbol emaParam = instance.getComponentType().getConfigParameters().get(i);
VariableSymbol archParam = new VariableSymbol.Builder()
......@@ -84,7 +84,7 @@ public class ModifiedExpandedComponentInstanceBuilder extends ExpandedComponentI
.type(VariableType.ARCHITECTURE_PARAMETER)
.build();
archParam.setExpression(ArchSimpleExpressionSymbol.of(
exp.getNumber().getUnitNumber().get().getNumber().get()));
exp.getNumberWithUnit().getNumber().get()));
instance.getSpannedScope().getAsMutableScope().add(archParam);
}
......@@ -98,7 +98,7 @@ public class ModifiedExpandedComponentInstanceBuilder extends ExpandedComponentI
public void addPortArraySymbolsToInstance(ExpandedComponentInstanceSymbol instance){
Map<String, List<PortSymbol>> nameToPortList = new HashMap<>();
for (PortSymbol port : instance.getPorts()){
for (PortSymbol port : instance.getPortsList()){
List<PortSymbol> list = nameToPortList
.computeIfAbsent(port.getNameWithoutArrayBracketPart(), k -> new ArrayList<>());
list.add(port);
......
......@@ -37,7 +37,7 @@ public class ModifiedExpandedInstanceSymbolCreator extends EmbeddedMontiArcExpan
//everything below is copied from super class
builder.setSymbolReference(new ComponentSymbolReference(cmp.getName(), cmp.getEnclosingScope()))
.addPorts(cmp.getPorts())
.addPorts(cmp.getPortsList())
.addConnectors(cmp.getConnectors()).addResolutionDeclarationSymbols(cmp.getResolutionDeclarationSymbols()).addParameters(cmp.getParameters()).addArguments(cmp.getArguments());
for (ConnectorSymbol connectorSymbol : cmp.getConnectors())
......@@ -72,7 +72,7 @@ public class ModifiedExpandedInstanceSymbolCreator extends EmbeddedMontiArcExpan
}
builder.addPortsIfNameDoesNotExists(
superCmp.getSuperComponent().get().getPorts(),
superCmp.getSuperComponent().get().getPortsList(),
superCmp.getSuperComponent().get().getFormalTypeParameters(),
superCmp.getSuperComponent().get().getActualTypeArguments());
builder.addConnectorsIfNameDoesNotExists(superCmp.getSuperComponent().get().getConnectors());
......
......@@ -21,18 +21,19 @@
package de.monticore.lang.monticar.emadl.adapter;
import de.monticore.ast.ASTNode;
import de.monticore.expressionsbasis._ast.ASTExpression;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortArraySymbol;
import de.monticore.lang.math.math._symboltable.expression.MathNameExpressionSymbol;
import de.monticore.lang.math._ast.ASTNameExpression;
import de.monticore.lang.math._ast.ASTNumberExpression;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.IODeclarationSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.VariableSymbol;
import de.monticore.lang.monticar.common2._ast.ASTCommonDimensionElement;
import de.monticore.lang.monticar.common2._ast.ASTCommonMatrixType;
import de.monticore.lang.monticar.ts.MCASTTypeSymbol;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.monticar.types2._ast.ASTElementType;
import de.monticore.lang.monticar.types2._ast.ASTType;
import de.monticore.types.types._ast.ASTType;
import de.monticore.symboltable.resolving.SymbolAdapter;
import de.se_rwth.commons.SourcePosition;
......@@ -91,16 +92,15 @@ public class PortArraySymbol2IODeclarationSymbol extends IODeclarationSymbol
if (astType instanceof ASTCommonMatrixType){
ASTCommonMatrixType matrixType = (ASTCommonMatrixType) astType;
for (ASTCommonDimensionElement element : matrixType.getCommonDimension().getCommonDimensionElements()){
if (element.getUnitNumber().isPresent()){
int dimension = element.getUnitNumber().get().getNumber().get().getDividend().intValue();
for (ASTExpression element : matrixType.getDimension().getDimensionList()){
if (element instanceof ASTNumberExpression){
int dimension = ((ASTNumberExpression) element).getNumberWithUnit().getNumber().get().intValue();
dimensionList.add(ArchSimpleExpressionSymbol.of(dimension));
}
else {
ArchSimpleExpressionSymbol dimension = ArchSimpleExpressionSymbol.of(
new MathNameExpressionSymbol(element.getName().get()));
String instName = element instanceof ASTNameExpression ? ((ASTNameExpression) element).getName() : element.getSymbolOpt().get().getName();
VariableSymbol variable= port.getEnclosingScope()
.<VariableSymbol>resolve(element.getName().get(), VariableSymbol.KIND).get();
.<VariableSymbol>resolve(instName, VariableSymbol.KIND).get();
dimensionList.add(variable.getExpression());
}
}
......
......@@ -25,7 +25,7 @@ import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbo
import de.monticore.lang.monticar.cnnarch._symboltable.VariableSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.VariableType;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution;
import de.monticore.lang.monticar.resolution._ast.ASTUnitNumberResolution;
import de.monticore.symboltable.resolving.SymbolAdapter;
import de.se_rwth.commons.SourcePosition;
import org.jscience.mathematics.number.Rational;
......@@ -40,10 +40,10 @@ public class ResolutionDeclarationSymbol2VariableSymbol extends VariableSymbol
public ResolutionDeclarationSymbol2VariableSymbol(ResolutionDeclarationSymbol ps, ASTUnitNumberResolution unitNumberResolution) {
super(ps.getName());
setType(VariableType.ARCHITECTURE_PARAMETER);
Rational rational = unitNumberResolution.getNumber().get();
setExpression(ArchSimpleExpressionSymbol.of(rational.getDivisor().equals(1)
? rational.getDividend().intValue()
: rational.doubleValue()));
Double doubleValue = unitNumberResolution.getNumberWithUnit().getNumber().get();
setExpression(ArchSimpleExpressionSymbol.of((doubleValue % 1)!= 0
? doubleValue.intValue()
: doubleValue));
this.adaptee = ps;
}
......
......@@ -22,7 +22,7 @@ package de.monticore.lang.monticar.emadl.adapter;
import de.monticore.lang.monticar.cnnarch._symboltable.VariableSymbol;