Skip to content

Commit

Permalink
fix for #3503, prefix clocks
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo committed Oct 12, 2015
1 parent 0610df2 commit c5ce437
Showing 1 changed file with 68 additions and 4 deletions.
72 changes: 68 additions & 4 deletions Compiler/FrontEnd/PrefixUtil.mo
Expand Up @@ -684,6 +684,7 @@ algorithm
DAE.ReductionIterators riters;
DAE.CallAttributes attr;
list<String> fieldNames;
DAE.ClockKind clk;

// no prefix, return the input expression
case (cache,_,_,e,Prefix.NOPRE())
Expand Down Expand Up @@ -713,15 +714,22 @@ algorithm
equation
(cache, crefExp) = prefixExpCref(cache, env, ih, inExp, pre);
then
(cache,crefExp);
(cache, crefExp);

// clocks
case (cache, env, ih, DAE.CLKCONST(clk), pre)
equation
(cache, clk) = prefixClockKind(cache, env, ih, clk, pre);
then
(cache, DAE.CLKCONST(clk));

case (cache,env,ih,(DAE.ASUB(exp = e1, sub = expl)),pre)
equation
(cache,es_1) = prefixExpList(cache, env, ih, expl, pre);
(cache,e1) = prefixExp(cache, env, ih, e1,pre);
(cache, es_1) = prefixExpList(cache, env, ih, expl, pre);
(cache, e1) = prefixExp(cache, env, ih, e1, pre);
e2 = Expression.makeASUB(e1,es_1);
then
(cache,e2);
(cache, e2);

case (cache,env,ih,(DAE.TSUB(e1, index_, t)),pre)
equation
Expand Down Expand Up @@ -1354,5 +1362,61 @@ algorithm
end match;
end isNoPrefix;

public function prefixClockKind "Add the supplied prefix to the clock kind"
input FCore.Cache inCache;
input FCore.Graph inEnv;
input InnerOuter.InstHierarchy inIH;
input DAE.ClockKind inClkKind;
input Prefix.Prefix inPrefix;
output FCore.Cache outCache;
output DAE.ClockKind outClkKind;
algorithm
(outCache, outClkKind) := match (inCache, inEnv, inIH, inClkKind, inPrefix)
local
DAE.Exp e;
DAE.ClockKind clkKind;
FCore.Cache cache;
FCore.Graph env;
InstanceHierarchy ih;
Prefix.Prefix p;
Integer resolution;
Real interval;
String method;

// clock kinds
case (cache, env, ih, DAE.INFERRED_CLOCK(), p)
then (cache, inClkKind);

case (cache, env, ih, DAE.INTEGER_CLOCK(e, resolution), p)
equation
(cache, e) = prefixExp(cache, env, ih, e, p);
clkKind = DAE.INTEGER_CLOCK(e, resolution);
then
(cache, clkKind);

case (cache, env, ih, DAE.REAL_CLOCK(e), p)
equation
(cache, e) = prefixExp(cache, env, ih, e, p);
clkKind = DAE.REAL_CLOCK(e);
then
(cache, clkKind);

case (cache, env, ih, DAE.BOOLEAN_CLOCK(e, interval), p)
equation
(cache, e) = prefixExp(cache, env, ih, e, p);
clkKind = DAE.BOOLEAN_CLOCK(e, interval);
then
(cache, clkKind);

case (cache, env, ih, DAE.SOLVER_CLOCK(e, method), p)
equation
(cache, e) = prefixExp(cache, env, ih, e, p);
clkKind = DAE.SOLVER_CLOCK(e, method);
then
(cache, clkKind);

end match;
end prefixClockKind;

annotation(__OpenModelica_Interface="frontend");
end PrefixUtil;

0 comments on commit c5ce437

Please sign in to comment.