Commit 5ca9b2f1 authored by Nina Pichler's avatar Nina Pichler
Browse files

Removing Stereotypes and MontiArcTiming

parent 3b097514
......@@ -41,9 +41,6 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
/* ===== Modified but based on old ARCD Grammar =========*/
/* ======================================================*/
Stereotype =
Name ;
/**
* A component may contain arbitrary many Elements.
* This interface may be used as an extension point to
......@@ -58,7 +55,6 @@ Stereotype =
* procedure to a whole application. A component may be
* either decomposed to subcomponents or is atomic.
*
* @attribute stereotype an optional stereotype
* @attribute name type name of this component
* @attribute head is used to set generic types, a
* configuration and a parent component
......@@ -68,8 +64,6 @@ Stereotype =
* allowed for inner component definitions.
* @attribute body contains the architectural elements
* inherited by this component
*/
/**
* A components head is used to define generic type
* parameters that may be used as port types in the
* component, to define configuration parameters that may
......@@ -88,7 +82,6 @@ Stereotype =
*/
symbol scope Component implements Element =
Stereotype?
"component" Name
genericTypeParameters:TypeParameters // TypeParameters is optional itself
("(" (Parameter || ",")+ ")")?
......@@ -110,13 +103,10 @@ Stereotype =
/**
* An Interface defines an interface of a component
* containing in- and outgoing ports.
*
* @attribute stereotype an optional stereotype
* @attribute ports a list of ports that are contained in
* this interface
*/
Interface implements Element =
Stereotype?
("port"|"ports")
ports:(Port || ",")+ ";";
......@@ -125,7 +115,6 @@ Stereotype =
* outgoing port is used to send messages of a specific
* type. Ports can now also be specified as an array.
*
* @attribute stereotype an optional stereotype
* @attribute incoming true, if this is an incoming port
* @attribute outgoing true, if this is an outgoing port
* @attribute type the message type of this port
......@@ -135,32 +124,14 @@ Stereotype =
* declaration later on
*/
Port =
Stereotype?
(incoming:["in"] | outgoing:["out"])
Type (Name? | Name ( "[" UnitNumberResolution "]" )?);
/**
* Sets the timing of a component.
*
* @attribute stereotype optional stereotype
* @attribute instant a timed component
* @attribute delayed a timed component with delay
* @attribute causalsync a causal synchronous component
* @attribute sync a synchronous component
* TODO move to sub language?!
*/
MontiArcTiming implements MontiArcConfig =
"timing" Stereotype?
(["instant"] | ["delayed"] | ["untimed"] | ["causalsync"] | ["sync"]) ";";
/**
* A subcomponent is used to create one or more instances
* of another component. This way the hierarchical
* structure of a component is defined.
*
* @attribute stereotype an optional stereotype
* @attribute type the type of the instantiated component
* @attribute arguments list of configuration parameters
* that are to be set, if the instantiated component is
......@@ -169,7 +140,6 @@ Stereotype =
* created
*/
SubComponent implements Element =
Stereotype?
"instance"
type:ReferenceType
("(" arguments:(Expression || ",")+ ")" )?
......@@ -202,7 +172,6 @@ Stereotype =
* instance names
*/
Connector implements Element=
Stereotype?
"connect" (source:QualifiedNameWithArray | (boolLiteral:BooleanLiteral) | (stringLiteral:StringLiteral)| UnitNumberResolution) "->"
targets:(QualifiedNameWithArray || ",")+ ";";
......@@ -218,22 +187,9 @@ Stereotype =
*/
interface MontiArcConfig extends Element;
/**
* An invariant constrains the behavior of a component.
*
* @attribute kind the optional kind of this invariant.
* @attribute name name of the invariant
* @attribute invariantExpression the invariant defined
* in the language 'kind'
*/
/*MontiArcInvariant implements Element =
(kind:Name)? "inv" Name ":"
invariantExpression:InvariantContent ";";
*/
/**
* AutoConnect is used to connect ports automatically.
*
* @attribute stereotype optional stereotype
* @attribute type autoconnect unambigous ports with the
* same type
* @attribute port autoconnect unambigous ports with the
......@@ -241,19 +197,18 @@ Stereotype =
* @attribute off do not use autoconnection (default)
*/
MontiArcAutoConnect implements MontiArcConfig =
"autoconnect" Stereotype?
"autoconnect"
(["type"] | ["port"] | ["off"]) ";";
/**
* AutoInstantiate is used to automatically instantiate inner components.
*
* @attribute stereotype optional stereotype
* @attribute type autoinstantiate for inner components
* @attribute on to enable automatically instantiating inner components
* @attribute off do not use autoinstantiate (default)
*/
MontiArcAutoInstantiate implements MontiArcConfig =
"autoinstantiate" Stereotype?
"autoinstantiate"
(["on"] | ["off"]) ";";
......
/**
*
* ******************************************************************************
* 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.embeddedmontiarc;
import de.monticore.lang.embeddedmontiarc.helper.AutoconnectMode;
import de.monticore.lang.embeddedmontiarc.helper.Timing;
import java.io.File;
/**
* Constants for the MontiArc language. <br>
* <br>
* Copyright (c) 2017, MontiCore. All rights reserved.
*
* @author (last commit) $Author: ahaber $
* $Revision: 3080 $
*/
public final class EmbeddedMontiArcConstants {
/**
* Default auto connect mode = OFF.
*/
public static final AutoconnectMode DEFAULT_AUTO_CONNECT = AutoconnectMode.OFF;
/**
* Default time paradigm = timed.
*
* @since 2.3.0
*/
public static final Timing DEFAULT_TIME_PARADIGM = Timing.INSTANT;
/**
* Default documentation directory.
*/
public static final String DEFAULT_DOC_DIR = "target" + File.separator + "madoc";
/**
* Default output directory.
*/
public static final String DEFAULT_GEN_DIR = "target" + File.separator +
"generated-sources" + File.separator +
"montiarc" + File.separator +
"sourcecode";
/**
* Default model directory.
*/
public static final String DEFAULT_MODEL_DIR = "src" + File.separator + "main" + File.separator
+ "models";
}
/**
*
* ******************************************************************************
* 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.embeddedmontiarc;
import de.monticore.lang.embeddedmontiarc.helper.AutoconnectMode;
import java.io.File;
/**
* Constants for the MontiArc language. <br>
* <br>
* Copyright (c) 2017, MontiCore. All rights reserved.
*
* @author (last commit) $Author: ahaber $
* $Revision: 3080 $
*/
public final class EmbeddedMontiArcConstants {
/**
* Default auto connect mode = OFF.
*/
public static final AutoconnectMode DEFAULT_AUTO_CONNECT = AutoconnectMode.OFF;
/**
* Default documentation directory.
*/
public static final String DEFAULT_DOC_DIR = "target" + File.separator + "madoc";
/**
* Default output directory.
*/
public static final String DEFAULT_GEN_DIR = "target" + File.separator +
"generated-sources" + File.separator +
"montiarc" + File.separator +
"sourcecode";
/**
* Default model directory.
*/
public static final String DEFAULT_MODEL_DIR = "src" + File.separator + "main" + File.separator
+ "models";
}
......@@ -20,9 +20,6 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast;
//import de.monticore.common.common._ast.ASTStereotype;
//import de.monticore.types.types._ast.ASTTypeArguments;
import de.monticore.lang.monticar.common2._ast.ASTParameter;
import de.monticore.lang.monticar.types2._ast.ASTReferenceType;
import de.monticore.lang.monticar.types2._ast.ASTTypeParameters;
......@@ -45,8 +42,6 @@ public class ASTComponent extends ASTComponentTOP {
}
protected ASTComponent(
ASTStereotype stereotype
,
String name
,
ASTTypeParameters genericTypeParameters
......@@ -58,7 +53,7 @@ public class ASTComponent extends ASTComponentTOP {
ASTComponentBody body
) {
super(stereotype, name, genericTypeParameters, parameters, superComponent, body);
super(name, genericTypeParameters, parameters, superComponent, body);
}
// do not use symbol table, since symbol table must not be created
......
/**
*
* ******************************************************************************
* 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.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTPort;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution;
import de.monticore.symboltable.*;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.monticar.ts.references.MCTypeReference;
import de.se_rwth.commons.logging.Log;
import org.jscience.mathematics.number.Rational;
import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Collectors;
/**
* Symboltable entry for port arrays
*/
public class PortArraySymbol extends PortSymbol {
public static final PortArraySymbolKind KIND = PortArraySymbolKind.INSTANCE;
protected Optional<String> nameSizeDependsOn;
public PortArraySymbol(String name, String nameSizeDependsOn) {
super(name, KIND);
this.nameSizeDependsOn = Optional.ofNullable(nameSizeDependsOn);
Log.debug(getFullName(), "PortArraySymbol ");
Log.debug(this.nameSizeDependsOn.orElse(null), "set NameSizeDependsOn to:");
}
private int dimension = 1;
public Optional<String> getNameSizeDependsOn() {
return nameSizeDependsOn;
}
public int getDimension() {
return dimension;
}
public void setDimension(int dimension) {
this.dimension = dimension;
}
public List<? extends PortSymbol> getConcretePortSymbols() {
//TODO fix wrong port return
return getEnclosingScope().<PortSymbol>resolveLocally(PortSymbol.KIND)
.stream().filter(s -> s.getName().startsWith(this.getName()/*+"["*/))
.collect(Collectors.toList());
}
/**
* starts with 1
*
* @param index
* @return
*/
public Optional<PortSymbol> getPortSymbolWithIndex(int index) {
for (PortSymbol portSymbol : getConcretePortSymbols()) {
if (portSymbol.getName().contains("[" + index + "]")) {
return Optional.of(portSymbol);
}
}
return Optional.ofNullable(null);
}
public void recreatePortArray(ResolutionDeclarationSymbol resDeclSym, EmbeddedMontiArcSymbolTableCreator emastc, ComponentSymbolReference componentSymbolReference) {
Log.debug(componentSymbolReference.toString(), "recreate");
Log.debug(getNameSizeDependsOn().toString(), "String info:");
if (getNameSizeDependsOn().isPresent() && getNameSizeDependsOn().get().equals(resDeclSym.getNameToResolve())) {
int size = -1;
if (resDeclSym.getASTResolution() instanceof ASTUnitNumberResolution) {
size = ((ASTUnitNumberResolution) resDeclSym.getASTResolution()).getNumber().get().intValue();
}
List<? extends PortSymbol> portSymbols = getConcretePortSymbols();
PortSymbol firstPort = getPortSymbolWithIndex(1).get();
int oldSize = portSymbols.size();
if (size == 0) {
size = oldSize;
((ASTUnitNumberResolution) resDeclSym.getASTResolution()).setNumber(Rational.valueOf("" + oldSize));
}
Log.debug(componentSymbolReference.toString(), "FullName:");
Log.debug(oldSize + "", "old Port Size:");
Log.debug(size + "", "new Port Size:");
for (int i = 0; i <= size; ++i) {
if (oldSize < i) {
//Log.debug();
createPortSymbolForArrayIndex(componentSymbolReference, (ASTPort) firstPort.getAstNode().get(), this.getName() + "[" + i + "]", firstPort.getStereotype(), firstPort.getTypeReference());
}
}
//just add missing ports here and fix actual size after expandedcomponentinstance creation
/*for (int i = size + 1; i <= oldSize; ++i) {
if (getPortSymbolWithIndex(i).isPresent())
getEnclosingScope().getAsMutableScope().remove(getPortSymbolWithIndex(i).get());
}
*/
} else {
Log.debug("Is not Present", "NameSizeDependsOn:");
}
}
private void createPortSymbolForArrayIndex(ComponentSymbolReference componentSymbolReference, ASTPort node, String name, Map<String, Optional<String>> stereoType, MCTypeReference<? extends MCTypeSymbol> typeRef) {
PortSymbol ps;
if (name.startsWith("CONSTANTPORT")) {
ps = new ConstantPortSymbol(name);
} else {
ps = new PortSymbol(name);
}
ps.setNameDependsOn(nameSizeDependsOn);
ps.setTypeReference(typeRef);
ps.setDirection(node.isIncoming());
stereoType
.forEach(ps::addStereotype);
getEnclosingScope().getAsMutableScope().add(ps);
//emastc.addToScopeAndLinkWithNode(ps, node);
Log.debug(name + " " + componentSymbolReference.getAllIncomingPorts().size(), "Added PortSymbol From PortArray:");
}
public static class PortArraySymbolKind implements SymbolKind {
public static final PortArraySymbolKind INSTANCE = new PortArraySymbolKind();
protected PortArraySymbolKind() {
}
}
}
/**
*
* ******************************************************************************
* 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.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTPort;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution;
import de.monticore.symboltable.*;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.monticar.ts.references.MCTypeReference;
import de.se_rwth.commons.logging.Log;
import org.jscience.mathematics.number.Rational;
import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Collectors;
/**
* Symboltable entry for port arrays
*/
public class PortArraySymbol extends PortSymbol {
public static final PortArraySymbolKind KIND = PortArraySymbolKind.INSTANCE;
protected Optional<String> nameSizeDependsOn;
public PortArraySymbol(String name, String nameSizeDependsOn) {
super(name, KIND);
this.nameSizeDependsOn = Optional.ofNullable(nameSizeDependsOn);
Log.debug(getFullName(), "PortArraySymbol ");
Log.debug(this.nameSizeDependsOn.orElse(null), "set NameSizeDependsOn to:");
}
private int dimension = 1;
public Optional<String> getNameSizeDependsOn() {
return nameSizeDependsOn;
}
public int getDimension() {
return dimension;
}
public void setDimension(int dimension) {
this.dimension = dimension;
}
public List<? extends PortSymbol> getConcretePortSymbols() {
//TODO fix wrong port return
return getEnclosingScope().<PortSymbol>resolveLocally(PortSymbol.KIND)
.stream().filter(s -> s.getName().startsWith(this.getName()/*+"["*/))
.collect(Collectors.toList());
}
/**
* starts with 1
*
* @param index
* @return
*/
public Optional<PortSymbol> getPortSymbolWithIndex(int index) {
for (PortSymbol portSymbol : getConcretePortSymbols()) {
if (portSymbol.getName().contains("[" + index + "]")) {
return Optional.of(portSymbol);
}
}
return Optional.ofNullable(null);
}
public void recreatePortArray(ResolutionDeclarationSymbol resDeclSym, EmbeddedMontiArcSymbolTableCreator emastc, ComponentSymbolReference componentSymbolReference) {
Log.debug(componentSymbolReference.toString(), "recreate");
Log.debug(getNameSizeDependsOn().toString(), "String info:");
if (getNameSizeDependsOn().isPresent() && getNameSizeDependsOn().get().equals(resDeclSym.getNameToResolve())) {
int size = -1;
if (resDeclSym.getASTResolution() instanceof ASTUnitNumberResolution) {
size = ((ASTUnitNumberResolution) resDeclSym.getASTResolution()).getNumber().get().intValue();
}
List<? extends PortSymbol> portSymbols = getConcretePortSymbols();
PortSymbol firstPort = getPortSymbolWithIndex(1).get();
int oldSize = portSymbols.size();
if (size == 0) {
size = oldSize;
((ASTUnitNumberResolution) resDeclSym.getASTResolution()).setNumber(Rational.valueOf("" + oldSize));
}
Log.debug(componentSymbolReference