Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
fix ticket:5336, set non connector instead of potential
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo committed Feb 13, 2019
1 parent 19e82ea commit 9ae5692
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Compiler/NFFrontEnd/NFComponent.mo
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ constant Component.Attributes DEFAULT_ATTR =
);
constant Component.Attributes INPUT_ATTR =
Component.Attributes.ATTRIBUTES(
ConnectorType.POTENTIAL,
ConnectorType.NON_CONNECTOR,
Parallelism.NON_PARALLEL,
Variability.CONTINUOUS,
Direction.INPUT,
Expand All @@ -74,7 +74,7 @@ constant Component.Attributes INPUT_ATTR =

constant Component.Attributes OUTPUT_ATTR =
Component.Attributes.ATTRIBUTES(
ConnectorType.POTENTIAL,
ConnectorType.NON_CONNECTOR,
Parallelism.NON_PARALLEL,
Variability.CONTINUOUS,
Direction.OUTPUT,
Expand All @@ -86,7 +86,7 @@ constant Component.Attributes OUTPUT_ATTR =

constant Component.Attributes CONSTANT_ATTR =
Component.Attributes.ATTRIBUTES(
ConnectorType.POTENTIAL,
ConnectorType.NON_CONNECTOR,
Parallelism.NON_PARALLEL,
Variability.CONSTANT,
Direction.NONE,
Expand All @@ -98,7 +98,7 @@ constant Component.Attributes CONSTANT_ATTR =

constant Component.Attributes IMPL_DISCRETE_ATTR =
Component.Attributes.ATTRIBUTES(
ConnectorType.POTENTIAL,
ConnectorType.NON_CONNECTOR,
Parallelism.NON_PARALLEL,
Variability.IMPLICITLY_DISCRETE,
Direction.NONE,
Expand Down Expand Up @@ -653,7 +653,7 @@ uniontype Component
case UNTYPED_COMPONENT(attributes = Attributes.ATTRIBUTES(connectorType = cty)) then cty;
case TYPED_COMPONENT(attributes = Attributes.ATTRIBUTES(connectorType = cty)) then cty;
case DELETED_COMPONENT() then connectorType(component.component);
else ConnectorType.POTENTIAL;
else ConnectorType.NON_CONNECTOR;
end match;
end connectorType;

Expand Down
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFFunction.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ protected
var := Component.variability(InstNode.component(component));

// Function components may not be connectors.
if cty <> ConnectorType.POTENTIAL then
if cty == ConnectorType.FLOW or cty == ConnectorType.STREAM then
Error.addSourceMessage(Error.INNER_OUTER_FORMAL_PARAMETER,
{Prefixes.connectorTypeString(cty), InstNode.name(component)},
InstNode.info(component));
Expand Down
4 changes: 3 additions & 1 deletion Compiler/NFFrontEnd/NFPrefixes.mo
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import Type = NFType;
type ConnectorType = enumeration(
POTENTIAL,
FLOW,
STREAM
STREAM,
NON_CONNECTOR
);

type Parallelism = enumeration(
Expand Down Expand Up @@ -101,6 +102,7 @@ algorithm
case ConnectorType.POTENTIAL then DAE.ConnectorType.POTENTIAL();
case ConnectorType.FLOW then DAE.ConnectorType.FLOW();
case ConnectorType.STREAM then DAE.ConnectorType.STREAM(NONE());
case ConnectorType.NON_CONNECTOR then DAE.ConnectorType.NON_CONNECTOR();
end match;
end connectorTypeToDAE;

Expand Down
18 changes: 11 additions & 7 deletions Compiler/NFFrontEnd/NFTyping.mo
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ algorithm
flows := c :: flows;
elseif cty == ConnectorType.STREAM then
streams := c :: streams;
else
elseif cty == ConnectorType.POTENTIAL then
pots := c :: pots;
end if;
end for;
Expand Down Expand Up @@ -432,13 +432,17 @@ algorithm
// The Modelica specification forbids using stream outside connector
// declarations, but has no such restriction for flow. To compromise we
// print a warning for both flow and stream.
if cty <> ConnectorType.POTENTIAL and not checkConnectorType(component) then
Error.addSourceMessage(Error.CONNECTOR_PREFIX_OUTSIDE_CONNECTOR,
{Prefixes.connectorTypeString(cty)}, InstNode.info(component));
if not checkConnectorType(component) then
if (cty == ConnectorType.STREAM or cty == ConnectorType.FLOW) then
Error.addSourceMessage(Error.CONNECTOR_PREFIX_OUTSIDE_CONNECTOR,
{Prefixes.connectorTypeString(cty)}, InstNode.info(component));
end if;
// Remove the prefix from the component, to avoid issues like a flow
// equation being generated for it.
attr.connectorType := ConnectorType.POTENTIAL;
InstNode.componentApply(component, Component.setAttributes, attr);
if not (InstNode.isEmpty(component) or InstNode.isInnerOuterNode(component)) then
attr.connectorType := ConnectorType.NON_CONNECTOR;
InstNode.componentApply(component, Component.setAttributes, attr);
end if;
end if;
then
();
Expand All @@ -451,7 +455,7 @@ function checkConnectorType
input InstNode node;
output Boolean isConnector;
algorithm
if InstNode.isEmpty(node) then
if InstNode.isEmpty(node) or InstNode.isInnerOuterNode(node) then
isConnector := false;
else
isConnector := Class.isConnectorClass(InstNode.getClass(node)) or
Expand Down

0 comments on commit 9ae5692

Please sign in to comment.