Skip to content

Commit

Permalink
Don't print inline type in the flat model (#8188)
Browse files Browse the repository at this point in the history
- Remove the printing of the inline type in the flat model, since it's
  using a syntax that's not compatible with Modelica and doesn't seem to
  be used for anything.

Fixes #8178
  • Loading branch information
perost committed Nov 22, 2021
1 parent 39c1ea1 commit 4a0fcc7
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 132 deletions.
16 changes: 4 additions & 12 deletions OMCompiler/Compiler/FrontEnd/DAEDump.mo
Expand Up @@ -1200,12 +1200,11 @@ algorithm
Absyn.Path fpath;
list<DAE.Element> daeElts;
DAE.Type t;
DAE.InlineType inlineType;
Option<SCode.Comment> c;
DAE.ExternalDecl ext_decl;
Boolean isImpure;

case DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_DEF(body = daeElts)::_),
case DAE.FUNCTION(path = fpath, functions = (DAE.FUNCTION_DEF(body = daeElts)::_),
type_ = t,isImpure = isImpure,comment = c)
equation
typeStr = Types.printTypeStr(t);
Expand All @@ -1217,8 +1216,6 @@ algorithm
Print.printBuf("function ");
fstr = AbsynUtil.pathStringNoQual(fpath);
Print.printBuf(fstr);
inlineTypeStr = dumpInlineTypeStr(inlineType);
Print.printBuf(inlineTypeStr);
Print.printBuf(dumpCommentStr(c));
Print.printBuf("\n");
dumpFunctionElements(daeElts);
Expand All @@ -1233,16 +1230,14 @@ algorithm
then
();

case DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_EXT(body = daeElts, externalDecl = ext_decl)::_),
case DAE.FUNCTION(path = fpath, functions = (DAE.FUNCTION_EXT(body = daeElts, externalDecl = ext_decl)::_),
isImpure = isImpure, comment = c)
equation
impureStr = if isImpure then "impure " else "";
Print.printBuf(impureStr);
Print.printBuf("function ");
fstr = AbsynUtil.pathStringNoQual(fpath);
Print.printBuf(fstr);
inlineTypeStr = dumpInlineTypeStr(inlineType);
Print.printBuf(inlineTypeStr);
Print.printBuf(dumpCommentStr(c));
Print.printBuf("\n");
dumpFunctionElements(daeElts);
Expand Down Expand Up @@ -3588,13 +3583,12 @@ algorithm
list<DAE.Element> daeElts;
DAE.Type t;
DAE.Type tp;
DAE.InlineType inlineType;
IOStream.IOStream str;
Option<SCode.Comment> c;
DAE.ExternalDecl ext_decl;
Boolean isImpure;

case (DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_DEF(body = daeElts)::_),
case (DAE.FUNCTION(path = fpath, functions = (DAE.FUNCTION_DEF(body = daeElts)::_),
type_ = t, isImpure = isImpure, comment = c), str)
equation
str = IOStream.append(str, dumpParallelismStr(t));
Expand All @@ -3603,7 +3597,6 @@ algorithm
str = IOStream.append(str, impureStr);
str = IOStream.append(str, "function ");
str = IOStream.append(str, fstr);
str = IOStream.append(str, dumpInlineTypeStr(inlineType));
str = IOStream.append(str, dumpCommentStr(c));
str = IOStream.append(str, "\n");
str = dumpFunctionElementsStream(daeElts, str);
Expand All @@ -3618,15 +3611,14 @@ algorithm
then
str;

case (DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_EXT(body = daeElts, externalDecl = ext_decl)::_),
case (DAE.FUNCTION(path = fpath, functions = (DAE.FUNCTION_EXT(body = daeElts, externalDecl = ext_decl)::_),
isImpure = isImpure, comment = c), str)
equation
fstr = AbsynUtil.pathStringNoQual(fpath);
impureStr = if isImpure then "impure " else "";
str = IOStream.append(str, impureStr);
str = IOStream.append(str, "function ");
str = IOStream.append(str, fstr);
str = IOStream.append(str, dumpInlineTypeStr(inlineType));
str = IOStream.append(str, dumpCommentStr(c));
str = IOStream.append(str, "\n");
str = dumpFunctionElementsStream(daeElts, str);
Expand Down
10 changes: 1 addition & 9 deletions OMCompiler/Compiler/Template/DAEDumpTpl.tpl
Expand Up @@ -68,12 +68,11 @@ template dumpFunction(DAE.Function function)
::=
match function
case FUNCTION(__) then
let inline_str = dumpInlineType(inlineType)
let cmt_str = dumpCommentOpt(comment)
let ann_str = dumpClassAnnotation(comment)
let impure_str = if isImpure then 'impure '
<<
<%impure_str%>function <%AbsynDumpTpl.dumpPathNoQual(path)%><%inline_str%><%cmt_str%>
<%impure_str%>function <%AbsynDumpTpl.dumpPathNoQual(path)%><%cmt_str%>
<%dumpFunctionDefinitions(functions)%>
<%if ann_str then " "%><%ann_str%>
end <%AbsynDumpTpl.dumpPathNoQual(path)%>;
Expand Down Expand Up @@ -225,13 +224,6 @@ match algorithm_
>>
end dumpFunctionAlgorithm;

template dumpInlineType(InlineType it)
::=
match it
case AFTER_INDEX_RED_INLINE() then ' "Inline after index reduction"'
case NORM_INLINE() then ' "Inline before index reduction"'
end dumpInlineType;

/*****************************************************************************
* SECTION: VARIABLE SECTION *
*****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion testsuite/flattening/modelica/arrays/TypeTest.mos
Expand Up @@ -30,7 +30,7 @@ instantiateModel(TypeTestArrayBug); getErrorString();
// output Orientation res;
// end Modelica.Mechanics.MultiBody.Frames.Orientation;
//
// function Modelica.Mechanics.MultiBody.Frames.nullRotation \"Inline before index reduction\" \"Return orientation object that does not rotate a frame\"
// function Modelica.Mechanics.MultiBody.Frames.nullRotation \"Return orientation object that does not rotate a frame\"
// output Modelica.Mechanics.MultiBody.Frames.Orientation R \"Orientation object such that frame 1 and frame 2 are identical\";
// algorithm
// R := Modelica.Mechanics.MultiBody.Frames.Orientation({{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}, {0.0, 0.0, 0.0});
Expand Down
22 changes: 11 additions & 11 deletions testsuite/flattening/modelica/connectors/Bug3649.mos
Expand Up @@ -16,15 +16,15 @@ checkModel(Transformer.SC1); getErrorString();
// output Complex res;
// end Complex;
//
// function Complex.'*'.multiply \"Inline before index reduction\" \"Multiply two complex numbers\"
// function Complex.'*'.multiply \"Multiply two complex numbers\"
// input Complex c1 \"Complex number 1\";
// input Complex c2 \"Complex number 2\";
// output Complex c3 \"= c1*c2\";
// algorithm
// c3 := Complex(c1.re * c2.re - c1.im * c2.im, c1.re * c2.im + c1.im * c2.re);
// end Complex.'*'.multiply;
//
// function Complex.'*'.scalarProduct \"Inline before index reduction\" \"Scalar product c1*c2 of two complex vectors\"
// function Complex.'*'.scalarProduct \"Scalar product c1*c2 of two complex vectors\"
// input Complex[:] c1 \"Vector of Complex numbers 1\";
// input Complex[size(c1, 1)] c2 \"Vector of Complex numbers 2\";
// output Complex c3 \"= c1*c2\";
Expand All @@ -35,30 +35,30 @@ checkModel(Transformer.SC1); getErrorString();
// end for;
// end Complex.'*'.scalarProduct;
//
// function Complex.'+' \"Inline before index reduction\" \"Add two complex numbers\"
// function Complex.'+' \"Add two complex numbers\"
// input Complex c1 \"Complex number 1\";
// input Complex c2 \"Complex number 2\";
// output Complex c3 \"= c1 + c2\";
// algorithm
// c3 := Complex(c1.re + c2.re, c1.im + c2.im);
// end Complex.'+';
//
// function Complex.'-'.negate \"Inline before index reduction\" \"Unary minus (multiply complex number by -1)\"
// function Complex.'-'.negate \"Unary minus (multiply complex number by -1)\"
// input Complex c1 \"Complex number\";
// output Complex c2 \"= -c1\";
// algorithm
// c2 := Complex(-c1.re, -c1.im);
// end Complex.'-'.negate;
//
// function Complex.'-'.subtract \"Inline before index reduction\" \"Subtract two complex numbers\"
// function Complex.'-'.subtract \"Subtract two complex numbers\"
// input Complex c1 \"Complex number 1\";
// input Complex c2 \"Complex number 2\";
// output Complex c3 \"= c1 - c2\";
// algorithm
// c3 := Complex(c1.re - c2.re, c1.im - c2.im);
// end Complex.'-'.subtract;
//
// function Complex.'constructor'.fromReal \"Inline before index reduction\" \"Construct Complex from Real\"
// function Complex.'constructor'.fromReal \"Construct Complex from Real\"
// input Real re \"Real part of complex number\";
// input Real im = 0.0 \"Imaginary part of complex number\";
// output Complex result = Complex(re, im) \"Complex number\";
Expand All @@ -70,36 +70,36 @@ checkModel(Transformer.SC1); getErrorString();
// output ComplexOutput res;
// end ComplexOutput;
//
// function Modelica.ComplexMath.'abs' \"Inline before index reduction\" \"Absolute value of complex number\"
// function Modelica.ComplexMath.'abs' \"Absolute value of complex number\"
// input Complex c \"Complex number\";
// output Real result \"= abs(c)\";
// algorithm
// result := (c.re ^ 2.0 + c.im ^ 2.0) ^ 0.5;
// end Modelica.ComplexMath.'abs';
//
// function Modelica.ComplexMath.arg \"Inline before index reduction\" \"Phase angle of complex number\"
// function Modelica.ComplexMath.arg \"Phase angle of complex number\"
// input Complex c \"Complex number\";
// input Real phi0(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") = 0.0 \"Phase angle phi shall be in the range: -pi < phi-phi0 < pi\";
// output Real phi(quantity = \"Angle\", unit = \"rad\", displayUnit = \"deg\") \"= phase angle of c\";
// algorithm
// phi := Modelica.Math.atan3(c.im, c.re, phi0);
// end Modelica.ComplexMath.arg;
//
// function Modelica.ComplexMath.conj \"Inline before index reduction\" \"Conjugate of complex number\"
// function Modelica.ComplexMath.conj \"Conjugate of complex number\"
// input Complex c1 \"Complex number\";
// output Complex c2 \"= c1.re - j*c1.im\";
// algorithm
// c2 := Complex(c1.re, -c1.im);
// end Modelica.ComplexMath.conj;
//
// function Modelica.ComplexMath.imag \"Inline before index reduction\" \"Imaginary part of complex number\"
// function Modelica.ComplexMath.imag \"Imaginary part of complex number\"
// input Complex c \"Complex number\";
// output Real r \"= c.im\";
// algorithm
// r := c.im;
// end Modelica.ComplexMath.imag;
//
// function Modelica.ComplexMath.real \"Inline before index reduction\" \"Real part of complex number\"
// function Modelica.ComplexMath.real \"Real part of complex number\"
// input Complex c \"Complex number\";
// output Real r \"= c.re\";
// algorithm
Expand Down

0 comments on commit 4a0fcc7

Please sign in to comment.