Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…=true

  now the equality constraint function call contains the correct inline annotation.
- added Inline annotations to testsuite/libraries/multibody/loops/_LoopsTotal.mo
  to test the propagation of annotation into the flattened code (as a comment for the function)
- update to the tests due to annotations

- DAE.EqualityConstraint tuple now contains the DAE.InlineType
- DAEUtil.dumpFunction now dumps the inline type as a function comment 
  if there is an inline annotation.
- Inst.equalityConstraint also sets the inline type in the DAE.EqualityConstraint tuple
- Inst.connectComponents will build the call to equalityConstraint with the correct inline type.



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5470 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed May 7, 2010
1 parent a666545 commit ad5bfb2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
4 changes: 3 additions & 1 deletion Compiler/DAE.mo
Expand Up @@ -626,7 +626,9 @@ public type Type = tuple<TType, Option<Absyn.Path>> "
- Type";

public
type EqualityConstraint = Option<tuple<Absyn.Path, Integer>>;
type EqualityConstraint = Option<tuple<Absyn.Path, Integer, InlineType>>
"contains the path to the equalityConstraint function,
the dimension of the output and the inline type of the function";

public constant Type T_REAL_DEFAULT = (T_REAL({}),NONE());
public constant Type T_INTEGER_DEFAULT = (T_INTEGER({}),NONE());
Expand Down
37 changes: 26 additions & 11 deletions Compiler/DAEUtil.mo
Expand Up @@ -2661,16 +2661,15 @@ algorithm
end matchcontinue;
end dumpExtObjectClass;

public function printInlineTypeStr "
Print what kind of inline we have
"
input DAE.InlineType it;
output String str;
public function printInlineTypeStr
"Print what kind of inline we have"
input DAE.InlineType it;
output String str;
algorithm
str := matchcontinue(it)
case(DAE.NO_INLINE) then "No inline";
case(DAE.AFTER_INDEX_RED_INLINE) then "Inline after index reduction";
case(DAE.NORM_INLINE) then "Inline before index reduction";
case(DAE.AFTER_INDEX_RED_INLINE) then "Inline after index reduction";
case(DAE.NORM_INLINE) then "Inline before index reduction";
end matchcontinue;
end printInlineTypeStr;

Expand Down Expand Up @@ -2717,28 +2716,33 @@ protected function dumpFunction
algorithm
_ := matchcontinue (inElement)
local
String fstr;
String fstr, inlineTypeStr;
Absyn.Path fpath;
list<DAE.Element> daeElts;
DAE.Type t;
case DAE.FUNCTION(path = fpath,functions = (DAE.FUNCTION_DEF(body = daeElts)::_),type_ = t)
DAE.InlineType inlineType;

case DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_DEF(body = daeElts)::_),type_ = t)
equation
Print.printBuf("function ");
fstr = Absyn.pathString(fpath);
Print.printBuf(fstr);
inlineTypeStr = dumpInlineTypeStr(inlineType);
Print.printBuf(inlineTypeStr);
Print.printBuf("\n");
dumpFunctionElements(daeElts);
Print.printBuf("end ");
Print.printBuf(fstr);
Print.printBuf(";\n\n");
then
();
case DAE.FUNCTION(path = fpath,functions = (DAE.FUNCTION_EXT(body = daeElts)::_),type_ = t)
case DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_EXT(body = daeElts)::_),type_ = t)
local String fstr,daestr,str;
equation
fstr = Absyn.pathString(fpath);
inlineTypeStr = dumpInlineTypeStr(inlineType);
daestr = dumpElementsStr(daeElts);
str = Util.stringAppendList({"function ",fstr,"\n",daestr,"\nexternal \"C\";\nend ",fstr,";\n\n"});
str = Util.stringAppendList({"function ",fstr,inlineTypeStr,"\n",daestr,"\nexternal \"C\";\nend ",fstr,";\n\n"});
Print.printBuf(str);
then
();
Expand All @@ -2760,6 +2764,17 @@ algorithm
end matchcontinue;
end dumpFunction;

protected function dumpInlineTypeStr
input DAE.InlineType inlineType;
output String str;
algorithm
str := matchcontinue(inlineType)
case(DAE.NO_INLINE) then "";
case(DAE.AFTER_INDEX_RED_INLINE) then " \"Inline after index reduction\"";
case(DAE.NORM_INLINE) then " \"Inline before index reduction\"";
end matchcontinue;
end dumpInlineTypeStr;

protected function printRecordConstructorInputsStr "help function to dumpFunction. Prints the inputs of a record constructor"
input DAE.Type tp;
output String str;
Expand Down
13 changes: 9 additions & 4 deletions Compiler/Inst.mo
Expand Up @@ -2623,6 +2623,8 @@ algorithm
list<DAE.Type> types;
Integer dimension;
DAE.EqualityConstraint result;
DAE.InlineType inlineType;

case(cache, env, {})
then NONE;
case(cache, env, SCode.CLASSDEF(classDef = classDef as SCode.CLASS(name = "equalityConstraint", restriction = SCode.R_FUNCTION,
Expand All @@ -2642,7 +2644,9 @@ algorithm
/*print("dimension: ");
print(intString(dimension));
print("\n");*/
then SOME((path, dimension));
// adrpo: get the inline type of the function
inlineType = isInlineFunc2(classDef);
then SOME((path, dimension, inlineType));
case(cache, env, _ :: tail)
then equalityConstraint(cache, env, tail);
end matchcontinue;
Expand Down Expand Up @@ -13712,6 +13716,7 @@ algorithm
InstanceHierarchy ih;
DAE.ElementSource source "the origin of the element";
DAE.FunctionTree funcs;
DAE.InlineType inlineType1, inlineType2;

/* connections to outer components */
case(cache,env,ih,sets,pre,c1,f1,t1,vt1,c2,f2,t2,vt2,flowPrefix,io1,io2,graph)
Expand Down Expand Up @@ -13883,8 +13888,8 @@ algorithm
(cache,env,ih,sets_1,DAEUtil.emptyDae,graph);

/* Connection of connectors with an equality constraint.*/
case (cache,env,ih,sets,pre,c1,f1,t1 as (DAE.T_COMPLEX(equalityConstraint=SOME((fpath1,dim1))),_),vt1,
c2,f2,t2 as (DAE.T_COMPLEX(equalityConstraint=SOME((fpath2,dim2))),_),vt2,
case (cache,env,ih,sets,pre,c1,f1,t1 as (DAE.T_COMPLEX(equalityConstraint=SOME((fpath1,dim1,inlineType1))),_),vt1,
c2,f2,t2 as (DAE.T_COMPLEX(equalityConstraint=SOME((fpath2,dim2,inlineType2))),_),vt2,
flowPrefix,io1,io2,
(graph as ConnectionGraph.GRAPH(updateGraph = true)))
local
Expand Down Expand Up @@ -13922,7 +13927,7 @@ algorithm
breakDAEElements =
{DAE.EQUATION(zeroVector,
DAE.CALL(fpath1,{DAE.CREF(c1_1, DAE.ET_OTHER()), DAE.CREF(c2_1, DAE.ET_OTHER())},
false, false, DAE.ET_REAL(), DAE.NO_INLINE()),
false, false, DAE.ET_REAL(), inlineType1), // use the inline type
source // set the origin of the element
)};
graph = ConnectionGraph.addConnection(graph, c1_1, c2_1, breakDAEElements);
Expand Down

0 comments on commit ad5bfb2

Please sign in to comment.