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
42a56cc5
Commit
42a56cc5
authored
Oct 23, 2017
by
Sascha Niklas Schneiders
Browse files
fixed ComponentSymbolReference argument bug
parent
fe6b5640
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/ComponentSymbol.java
View file @
42a56cc5
...
...
@@ -691,6 +691,7 @@ public class ComponentSymbol extends TaggingScopeSpanningSymbol {
this
.
arguments
=
arguments
;
}
public
void
addIncomingPort
(
PortSymbol
symbol
)
{
//TODO implement me
}
...
...
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/ComponentSymbolReference.java
View file @
42a56cc5
...
...
@@ -24,6 +24,7 @@
package
de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable
;
import
com.google.common.collect.ImmutableList
;
import
de.monticore.lang.monticar.mcexpressions._ast.ASTExpression
;
import
de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol
;
import
de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution
;
import
de.monticore.symboltable.MutableScope
;
...
...
@@ -49,6 +50,7 @@ public class ComponentSymbolReference extends ComponentSymbol implements
private
List
<
ActualTypeArgument
>
actualTypeArguments
=
new
ArrayList
<>();
private
List
<
ResolutionDeclarationSymbol
>
resSymbols
=
new
ArrayList
<>();
private
List
<
ASTExpression
>
arguments
=
new
ArrayList
<>();
public
ComponentSymbolReference
(
final
String
name
,
final
Scope
definingScopeOfReference
)
{
super
(
name
);
...
...
@@ -85,6 +87,7 @@ public class ComponentSymbolReference extends ComponentSymbol implements
public
List
<
ResolutionDeclarationSymbol
>
getResolutionDeclarationSymbols
()
{
return
resSymbols
;
}
@Override
public
Optional
<
ResolutionDeclarationSymbol
>
getResolutionDeclarationSymbol
(
String
name
)
{
for
(
ResolutionDeclarationSymbol
symbol
:
getResolutionDeclarationSymbols
())
{
...
...
@@ -93,6 +96,7 @@ public class ComponentSymbolReference extends ComponentSymbol implements
}
return
Optional
.
empty
();
}
@Override
public
boolean
hasResolutionDeclaration
(
String
name
)
{
for
(
ResolutionDeclarationSymbol
resDeclSym
:
resSymbols
)
...
...
@@ -101,6 +105,7 @@ public class ComponentSymbolReference extends ComponentSymbol implements
}
return
false
;
}
@Override
public
int
howManyResolutionDeclarationSymbol
()
{
return
resSymbols
.
size
();
...
...
@@ -160,7 +165,22 @@ public class ComponentSymbolReference extends ComponentSymbol implements
public
boolean
isReferencedSymbolLoaded
()
{
return
reference
.
isReferencedSymbolLoaded
();
}
@Override
public
List
<
ASTExpression
>
getArguments
()
{
return
arguments
;
}
@Override
public
void
addArgument
(
ASTExpression
astExpression
)
{
arguments
.
add
(
astExpression
);
}
@Override
public
void
setArguments
(
List
<
ASTExpression
>
arguments
)
{
this
.
arguments
=
arguments
;
}
/* Methods of Symbol interface */
@Override
...
...
@@ -192,5 +212,4 @@ public class ComponentSymbolReference extends ComponentSymbol implements
public
void
setAccessModifier
(
AccessModifier
accessModifier
)
{
getReferencedSymbol
().
setAccessModifier
(
accessModifier
);
}
}
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/EmbeddedMontiArcSymbolTableCreator.java
View file @
42a56cc5
...
...
@@ -36,6 +36,7 @@ import de.monticore.lang.monticar.common2._ast.ASTStereoValue;
import
de.monticore.lang.monticar.mcexpressions._ast.ASTExpression
;
import
de.monticore.lang.monticar.ranges._ast.ASTRange
;
import
de.monticore.lang.monticar.ranges._ast.ASTRanges
;
import
de.monticore.lang.monticar.ranges._ast.ASTUnitNumberExpression
;
import
de.monticore.lang.monticar.resolution._ast.ASTResolutionDeclaration
;
import
de.monticore.lang.monticar.resolution._ast.ASTTypeArgument
;
import
de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol
;
...
...
@@ -282,6 +283,13 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
}
@Override
public
void
visit
(
ASTUnitNumberExpression
node
)
{
UnitNumberExpressionSymbol
symbol
=
new
UnitNumberExpressionSymbol
(
node
);
addToScopeAndLinkWithNode
(
symbol
,
node
);
}
@Override
public
void
visit
(
ASTPort
node
)
{
...
...
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/ExpandedComponentInstanceSymbol.java
View file @
42a56cc5
...
...
@@ -359,4 +359,8 @@ public class ExpandedComponentInstanceSymbol
public
void
setArguments
(
List
<
ASTExpression
>
arguments
)
{
this
.
arguments
=
arguments
;
}
public
Optional
<
ExpandedComponentInstanceSymbol
>
getEnclosingComponent
()
{
return
(
Optional
<
ExpandedComponentInstanceSymbol
>)
getEnclosingScope
().
getSpanningSymbol
();
}
}
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/UnitNumberExpressionSymbol.java
0 → 100644
View file @
42a56cc5
/**
*
* ******************************************************************************
* 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.monticar.interfaces.TextualExpression
;
import
de.monticore.lang.monticar.ranges._ast.ASTUnitNumberExpression
;
import
de.monticore.symboltable.CommonSymbol
;
import
de.monticore.symboltable.SymbolKind
;
/**
* Only used for getting expression value
*
* @author Sascha Schneiders
*/
public
class
UnitNumberExpressionSymbol
extends
CommonSymbol
implements
TextualExpression
{
protected
ASTUnitNumberExpression
unitNumberExpression
;
public
UnitNumberExpressionSymbol
()
{
super
(
""
,
SymbolKind
.
KIND
);
}
public
UnitNumberExpressionSymbol
(
ASTUnitNumberExpression
astUnitNumberExpression
)
{
super
(
""
,
SymbolKind
.
KIND
);
this
.
unitNumberExpression
=
astUnitNumberExpression
;
}
@Override
public
String
getTextualRepresentation
()
{
String
result
=
""
;
if
(
unitNumberExpression
.
getTUnitNumber
().
isPresent
())
{
result
+=
unitNumberExpression
.
getTUnitNumber
().
get
();
}
else
{
result
+=
unitNumberExpression
.
getTUnitInf
().
get
();
}
return
result
;
}
}
src/main/java/de/monticore/lang/embeddedmontiarc/helper/ASTExpressionPrinter.java
0 → 100644
View file @
42a56cc5
/**
*
* ******************************************************************************
* 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.helper
;
import
de.monticore.lang.monticar.mcexpressions._ast.ASTArrayExpression
;
import
de.monticore.lang.monticar.mcexpressions._ast.ASTExpression
;
import
de.monticore.lang.monticar.ranges._ast.ASTUnitNumberExpression
;
/**
* @author Sascha Schneiders
*/
public
class
ASTExpressionPrinter
{
}
src/test/java/de/monticore/lang/embeddedmontiarc/AbstractSymtabTest.java
View file @
42a56cc5
...
...
@@ -48,7 +48,7 @@ public class AbstractSymtabTest {
}
GlobalScope
scope
=
new
GlobalScope
(
mp
,
fam
);
LogConfig
.
init
();
LogConfig
.
init
();
//TODO comment for logger output
return
scope
;
}
}
src/test/java/de/monticore/lang/embeddedmontiarc/ExpandedComponentInstanceTest.java
View file @
42a56cc5
...
...
@@ -27,6 +27,8 @@ import de.se_rwth.commons.logging.Log;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
java.util.Iterator
;
import
static
org
.
junit
.
Assert
.*;
/**
...
...
@@ -166,11 +168,16 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
assertNotNull
(
inst
);
System
.
out
.
println
(
inst
);
assertEquals
(
2
,
inst
.
getSubComponents
().
size
());
assertEquals
(
1
,
inst
.
getSubComponents
().
iterator
().
next
().
getParameters
().
size
());
for
(
ASTExpression
astExpression
:
inst
.
getSubComponents
().
iterator
().
next
().
getArguments
())
{
Log
.
info
(
astExpression
.
toString
(),
"info:"
);
}
assertEquals
(
1
,
inst
.
getSubComponents
().
iterator
().
next
().
getArguments
().
size
());
Iterator
<
ExpandedComponentInstanceSymbol
>
iterator
=
inst
.
getSubComponents
().
iterator
();
UnitNumberExpressionSymbol
symbol1
=
(
UnitNumberExpressionSymbol
)
iterator
.
next
().
getArguments
().
get
(
0
).
getSymbol
().
get
();
UnitNumberExpressionSymbol
symbol2
=
(
UnitNumberExpressionSymbol
)
iterator
.
next
().
getArguments
().
get
(
0
).
getSymbol
().
get
();
assertEquals
(
"5"
,
symbol1
.
getTextualRepresentation
());
assertEquals
(
"1"
,
symbol2
.
getTextualRepresentation
());
}
@Test
...
...
src/test/java/de/monticore/lang/embeddedmontiarc/SymtabTest.java
View file @
42a56cc5
...
...
@@ -22,6 +22,7 @@ package de.monticore.lang.embeddedmontiarc;
import
de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*
;
import
de.monticore.lang.embeddedmontiarc.embeddedmontiarc.unit.constant.EMAConstantSIUnit
;
import
de.monticore.lang.monticar.mcexpressions._ast.ASTExpression
;
import
de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol
;
import
de.monticore.lang.monticar.si._symboltable.SIUnitRangesSymbol
;
import
de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution
;
...
...
@@ -322,8 +323,8 @@ public class SymtabTest extends AbstractSymtabTest {
//check for all names
assertEquals
(
5
,
cs
.
getAllIncomingPorts
().
size
());
assertEquals
(
5
,
cs
.
getAllOutgoingPorts
().
size
());
for
(
ConnectorSymbol
con
:
cs
.
getConnectors
()){
Log
.
debug
(
con
.
toString
(),
"testPortArray"
);
for
(
ConnectorSymbol
con
:
cs
.
getConnectors
())
{
Log
.
debug
(
con
.
toString
(),
"testPortArray"
);
}
}
...
...
@@ -595,11 +596,10 @@ public class SymtabTest extends AbstractSymtabTest {
//ComponentInstanceSymbol csInner = symTab.<ComponentInstanceSymbol>resolve("testing.BasicResolutionInstance.br1", ComponentInstanceSymbol.KIND).orElse(null);
//assertNotNull(csInner);
Log
.
debug
(
cs
.
getSubComponents
().
iterator
().
next
().
getComponentType
().
getReferencedSymbol
().
howManyResolutionDeclarationSymbol
()
+
""
,
"Expanded:"
);
Log
.
debug
(
cs
.
getSubComponents
().
iterator
().
next
().
getComponentType
().
getReferencedSymbol
().
howManyResolutionDeclarationSymbol
()
+
""
,
"Expanded:"
);
Log
.
debug
(
cs
.
getSubComponents
().
iterator
().
next
().
getComponentType
().
getReferencedSymbol
().
getResolutionDeclarationSymbols
().
get
(
0
).
getNameToResolve
(),
"Name to Resolve:"
);
ResolutionDeclarationSymbol
jt
=
cs
.
getSubComponents
().
iterator
().
next
().
getComponentType
().
getReferencedSymbol
().
getResolutionDeclarationSymbol
(
"n"
).
get
();
assertNotNull
(
jt
);
assertEquals
(
6
,
((
ASTUnitNumberResolution
)
jt
.
getASTResolution
()).
getNumber
().
get
().
intValue
());
...
...
@@ -647,6 +647,23 @@ public class SymtabTest extends AbstractSymtabTest {
}
@Test
public
void
testComponentGenericsSameComponent
()
{
Scope
symTab
=
createSymTab
(
"src/test/resources"
);
ComponentSymbol
inst
=
symTab
.<
ComponentSymbol
>
resolve
(
"testing.BasicParameterInstance"
,
ComponentSymbol
.
KIND
).
orElse
(
null
);
assertNotNull
(
inst
);
System
.
out
.
println
(
inst
.
getSubComponents
().
iterator
().
next
().
getComponentType
());
for
(
ASTExpression
astExpression
:
inst
.
getSubComponents
().
iterator
().
next
().
getComponentType
().
getArguments
())
{
Log
.
info
(
astExpression
.
toString
(),
"info:"
);
}
assertEquals
(
2
,
inst
.
getSubComponents
().
size
());
Iterator
<
ComponentInstanceSymbol
>
iterator
=
inst
.
getSubComponents
().
iterator
();
UnitNumberExpressionSymbol
symbol1
=
(
UnitNumberExpressionSymbol
)
iterator
.
next
().
getComponentType
().
getArguments
().
get
(
0
).
getSymbol
().
get
();
UnitNumberExpressionSymbol
symbol2
=
(
UnitNumberExpressionSymbol
)
iterator
.
next
().
getComponentType
().
getArguments
().
get
(
0
).
getSymbol
().
get
();
assertEquals
(
"5"
,
symbol1
.
getTextualRepresentation
());
assertEquals
(
"1"
,
symbol2
.
getTextualRepresentation
());
}
}
src/test/resources/testing/BasicParameterInstance.ema
View file @
42a56cc5
...
...
@@ -3,4 +3,6 @@ package testing;
component
BasicParameterInstance
{
instance
BasicParameter
(
5
)
basicParameter
;
instance
BasicParameter
(
1
)
basicParameter2
;
}
\ No newline at end of file
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