Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
languages
EmbeddedMontiArc
Commits
7c5fa253
Commit
7c5fa253
authored
Nov 02, 2020
by
Malte Heithoff
Browse files
Fix Ports and Parameters
parent
2a40a6cb
Pipeline
#352052
passed with stage
in 3 minutes and 19 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/EmbeddedMontiArcSymbolTableCreator.java
View file @
7c5fa253
/* (c) https://github.com/MontiCore/monticore */
/* (c) https://github.com/MontiCore/monticore */
package
de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable
;
import
de.monticore.expressionsbasis._ast.ASTExpression
;
...
...
@@ -255,8 +255,7 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
/* for (ASTExpression arg : node.getArguments()) { String value = new JavaDSLPrettyPrinter(new
* IndentPrinter()).prettyprint(arg); value = value.replace("\"", "\\\"").replace("\n", "");
* configArgs.add(new ValueSymbol<>(value, Kind.Expression)); } */
for
(
ASTExpression
astExpression
:
node
.
getArgumentsList
())
componentTypeReference
.
addArgument
(
astExpression
);
componentTypeReference
.
setArguments
(
node
.
getArgumentsList
());
componentTypeReference
.
fixResolutions
(
this
);
// instances
...
...
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/cncModel/EMAPortBuilder.java
View file @
7c5fa253
...
...
@@ -86,8 +86,8 @@ public class EMAPortBuilder {
throw
new
Error
(
"not all parameters have been set before to build the port symbol"
);
}
public
static
EMAPortInstanceSymbol
instantiate
(
EMAPortSymbol
port
,
String
packageName
)
{
EMAPortInstanceSymbol
portInstance
=
new
EMAPortInstanceSymbol
(
port
.
getN
ame
()
);
public
static
EMAPortInstanceSymbol
instantiate
(
EMAPortSymbol
port
,
String
packageName
,
String
name
)
{
EMAPortInstanceSymbol
portInstance
=
new
EMAPortInstanceSymbol
(
n
ame
);
portInstance
.
setDirection
(
port
.
isIncoming
());
portInstance
.
setTypeReference
(
port
.
getTypeReference
());
if
(
port
.
getAstNode
().
isPresent
())
...
...
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/instanceStructure/EMAComponentInstanceBuilder.java
View file @
7c5fa253
...
...
@@ -27,6 +27,7 @@ import de.monticore.symboltable.MutableScope;
import
de.monticore.symboltable.Symbol
;
import
de.monticore.symboltable.resolving.ResolvingFilter
;
import
de.monticore.symboltable.types.references.ActualTypeArgument
;
import
de.se_rwth.commons.Names
;
import
de.se_rwth.commons.logging.Log
;
import
java.util.*
;
...
...
@@ -359,12 +360,13 @@ public class EMAComponentInstanceBuilder {
final
MutableScope
scope
=
(
MutableScope
)
sym
.
getSpannedScope
();
resolvingFilters
.
stream
().
forEachOrdered
(
f
->
scope
.
addResolver
(
f
));
String
componentFullName
=
Names
.
getQualifiedName
(
sym
.
getPackageName
(),
sym
.
getName
());
ports
.
stream
().
forEachOrdered
(
p
->
instantiatePortSymbol
(
p
,
sym
.
ge
tFullName
()
,
scope
));
// must be cloned since we change it if it has
handlePort
(
p
,
componen
tFullName
,
scope
));
// must be cloned since we change it if it has
addPortArraySymbolsToInstance
(
sym
);
// generics
connectors
.
stream
().
forEachOrdered
(
c
->
instantiateConnectorSymbol
(
c
,
sym
.
ge
tFullName
()
,
scope
));
connectors
.
stream
().
forEachOrdered
(
c
->
instantiateConnectorSymbol
(
c
,
componen
tFullName
,
scope
));
subComponents
.
stream
().
forEachOrdered
(
s
->
scope
.
add
(
s
));
sym
.
setActualTypeArguments
(
actualTypeArguments
.
values
().
stream
().
collect
(
Collectors
.
toList
()));
...
...
@@ -375,7 +377,7 @@ public class EMAComponentInstanceBuilder {
// set arguments
// there are either no arguments or the equal number to parameters
if
(!
arguments
.
isEmpty
()
&&
arguments
.
size
()
!=
parameters
.
size
())
{
Log
.
error
(
"TODO Wrong number of arguments: "
+
sym
.
ge
tFullName
()
);
Log
.
error
(
"TODO Wrong number of arguments: "
+
componen
tFullName
);
}
setDefaultValuesToArguments
(
sym
);
sym
.
setArguments
(
arguments
);
...
...
@@ -420,9 +422,24 @@ public class EMAComponentInstanceBuilder {
scope
.
add
(
EMAConnectorBuilder
.
instantiate
(
c
,
fullName
));
}
protected
void
instantiatePortSymbol
(
EMAPortSymbol
port
,
String
packageName
,
MutableScope
scope
)
{
EMAPortInstanceSymbol
symbol
=
EMAPortBuilder
.
instantiate
(
port
,
packageName
);
protected
void
handlePort
(
EMAPortSymbol
port
,
String
packageName
,
MutableScope
scope
)
{
if
(
port
instanceof
EMAPortArraySymbol
)
instantiatePortArraySymbol
((
EMAPortArraySymbol
)
port
,
packageName
,
scope
);
else
instantiatePortSymbol
(
port
,
packageName
,
port
.
getName
(),
scope
);
}
protected
EMAPortInstanceSymbol
instantiatePortSymbol
(
EMAPortSymbol
port
,
String
packageName
,
String
name
,
MutableScope
scope
)
{
EMAPortInstanceSymbol
symbol
=
EMAPortBuilder
.
instantiate
(
port
,
packageName
,
name
);
scope
.
add
(
symbol
);
return
symbol
;
}
protected
void
instantiatePortArraySymbol
(
EMAPortArraySymbol
port
,
String
packageName
,
MutableScope
scope
)
{
for
(
int
i
=
0
;
i
<
port
.
getDimension
();
++
i
)
{
String
portName
=
port
.
getName
()
+
"["
+
(
i
+
1
)
+
"]"
;
instantiatePortSymbol
(
port
,
packageName
,
portName
,
scope
);
}
}
protected
void
addOtherToComponentInstance
(
EMAComponentInstanceSymbol
sym
)
{
...
...
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/instanceStructure/EMAComponentInstanceSymbolCreator.java
View file @
7c5fa253
...
...
@@ -79,7 +79,10 @@ public class EMAComponentInstanceSymbolCreator {
.
setSymbolReference
(
new
EMAComponentSymbolReference
(
cmp
.
getName
(),
cmp
.
getEnclosingScope
()))
.
addPorts
(
cmp
.
getPortsList
())
.
addConnectors
(
cmp
.
getConnectors
()).
addResolutionDeclarationSymbols
(
cmp
.
getResolutionDeclarationSymbols
()).
addParameters
(
cmp
.
getParameters
()).
addArguments
(
cmp
.
getArguments
());
.
addConnectors
(
cmp
.
getConnectors
())
.
addResolutionDeclarationSymbols
(
cmp
.
getResolutionDeclarationSymbols
())
.
addParameters
(
cmp
.
getParameters
())
.
addArguments
(
cmp
.
getArguments
());
for
(
EMAConnectorSymbol
emaConnectorSymbol
:
cmp
.
getConnectors
())
Log
.
info
(
emaConnectorSymbol
.
toString
(),
"Building Connector:"
);
// add sub components
...
...
@@ -95,7 +98,8 @@ public class EMAComponentInstanceSymbolCreator {
.
addResolvingFilters
(
filters
)
.
addResolutionDeclarationSymbols
(
inst
.
getComponentType
().
getResolutionDeclarationSymbols
())
.
addParameters
(
inst
.
getComponentType
().
getReferencedSymbol
().
getParameters
())
.
addArguments
(
inst
.
getComponentType
().
getReferencedSymbol
().
getArguments
()).
build
());
.
addArguments
(
inst
.
getComponentType
().
getReferencedSymbol
().
getArguments
())
.
build
());
Log
.
debug
(
inst
.
getInstanceInformation
().
get
().
getInstanceNumberForArgumentIndex
(
0
)
+
""
,
"InstanceInformation:"
);
Log
.
debug
(
inst
.
toString
(),
"ComponentInstance CreateInstance PostSub"
);
...
...
src/test/java/de/monticore/lang/embeddedmontiarc/ExpandedComponentInstanceTest.java
View file @
7c5fa253
...
...
@@ -228,10 +228,10 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
(
UnitNumberExpressionSymbol
)
sub21
.
getArguments
().
get
(
0
).
getSymbolOpt
().
get
();
UnitNumberExpressionSymbol
symbol22
=
(
UnitNumberExpressionSymbol
)
sub22
.
getArguments
().
get
(
0
).
getSymbolOpt
().
get
();
assertEquals
(
"
2
"
,
symbol1
.
getTextualRepresentation
());
assertEquals
(
"
3
"
,
symbol1
.
getTextualRepresentation
());
assertEquals
(
"9"
,
symbol2
.
getTextualRepresentation
());
assertEquals
(
"
2
"
,
symbol11
.
getTextualRepresentation
());
assertEquals
(
"
2
"
,
symbol12
.
getTextualRepresentation
());
assertEquals
(
"
3
"
,
symbol11
.
getTextualRepresentation
());
assertEquals
(
"
3
"
,
symbol12
.
getTextualRepresentation
());
assertEquals
(
"9"
,
symbol21
.
getTextualRepresentation
());
assertEquals
(
"9"
,
symbol22
.
getTextualRepresentation
());
}
...
...
src/test/resources/testing/ExpandedParameterInstance.ema
View file @
7c5fa253
/*
(
c
)
https
://
github
.
com
/
MontiCore
/
monticore
*/
package
testing
;
component
ExpandedParameterInstance
(
N1
val
=
2
){
component
ExpandedParameterInstance
(
N1
val
=
3
){
instance
ExpandedParameter
(
val
)
basicParameter
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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