﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3510	inline function	Vitalij Ruge	Willi Braun	"OM generate for the following example:

{{{#!modelica
model foo
  function f
    input Real x;
    output Real y;
  protected
    Real tmp1;
    Real tmp2;
  algorithm
    tmp1 := sin(x) + 1 + 2 + 3 + 4 + 5;
    tmp2 := cos(tmp1) * tmp1 - tmp1;
    y := exp(tmp1 * tmp2) + abs(tmp1);
    annotation(Inline = true);
  end f;

  Real y = f(time ^ 2);
end foo;
}}}
the following code:

{{{#!modelica
y = exp((15.0 + sin(time ^ 2.0)) * (cos(15.0 + sin(time ^ 2.0)) * (15.0 + sin(time ^ 2.0)) - (15.0 + sin(time ^ 2.0)))) + abs(15.0 + sin(time ^ 2.0))
}}}

The tmp-vars are removed. (probaly losing a lot of speed)

 In the spec. p. 214 we find:
''If “Inline = true”, the model developer proposes to inline the function. This
means, that the body of the function is included at all places where the function is
called.''

expectation code with function body:
{{{ #!modelica
model foo
  Real f_x_1 = time ^ 2;
  Real f_tmp1_1 = sin(f_x_1) + 1 + 2 + 3 + 4 + 5;
  Real f_tmp2_1 = cos(f_tmp1_1) * f_tmp1_1- f_tmp1_1;
  Real f_y_1 = exp(f_tmp1_1* f_tmp2_1) + abs(f_tmp1_1);
  Real y = f_y_1;
end foo;
}}}



"	defect	assigned	critical	Future	*unknown*			inline function	
