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

Commit

Permalink
[NF] handle discrete variability better
Browse files Browse the repository at this point in the history
- if the type of component is discrete return discrete if
  is lower variability than the explicit component variability
- handle discrete builtin calls (String, Integer, pre, edge, change)

Belonging to [master]:
  - #2063
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Dec 2, 2017
1 parent e8f130f commit 0e14e98
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
26 changes: 25 additions & 1 deletion Compiler/NFFrontEnd/NFCall.mo
Expand Up @@ -497,8 +497,32 @@ uniontype Call
algorithm
argtycall := typeNormalCall(call, info);
(call , ty, variability) := matchTypedNormalCall(argtycall, info);
variability := match call
case TYPED_CALL()
then getBuiltinVariability(
variability,
Absyn.pathLastIdent(Function.nameConsiderBuiltin(call.fn)));
else variability;
end match;
end typeMatchNormalCall;

function getBuiltinVariability
"@author: adrpo
some builtin function have specific variability,
handle that here, TODO FIXME: see if we need more"
input output Variability variability;
input String name;
algorithm
variability := match name
case "pre" then Variability.DISCRETE;
case "edge" then Variability.DISCRETE;
case "change" then Variability.DISCRETE;
case "String" then Variability.DISCRETE;
case "Integer" then Variability.DISCRETE;
else variability;
end match;
end getBuiltinVariability;

function typeNormalCall
input output Call call;
input SourceInfo info;
Expand Down Expand Up @@ -546,7 +570,7 @@ uniontype Call
CallAttributes ca;
list<TypedArg> tyArgs;
algorithm
(argtycall , ty, variability) := match argtycall
(argtycall, ty, variability) := match argtycall
case ARG_TYPED_CALL() algorithm

// Match the arguments with the expected ones.
Expand Down
7 changes: 6 additions & 1 deletion Compiler/NFFrontEnd/NFComponent.mo
Expand Up @@ -409,7 +409,12 @@ uniontype Component
output Variability variability;
algorithm
variability := match component
case TYPED_COMPONENT(attributes = Attributes.ATTRIBUTES(variability = variability)) then variability;
// adrpo: select discrete if the type is discrete and explicit component variability > discrete
case TYPED_COMPONENT(attributes = Attributes.ATTRIBUTES(variability = variability))
then
if Type.isDiscrete(component.ty) and variability > Variability.DISCRETE
then Variability.DISCRETE
else variability;
case TYPED_COMPONENT() guard Type.isDiscrete(component.ty) then Variability.DISCRETE;
case UNTYPED_COMPONENT(attributes = Attributes.ATTRIBUTES(variability = variability)) then variability;
case ITERATOR() then Variability.CONSTANT;
Expand Down

0 comments on commit 0e14e98

Please sign in to comment.