Opened 6 years ago

Last modified 6 years ago

#5064 new defect

Inline doesn't work properly

Reported by: Adrian Pop Owned by: Lennart Ochel
Priority: high Milestone: Future
Component: Backend Version:
Keywords: Cc:

Description

The NF can flatten attached model: AdvancedNoise.Examples.VaryingDistribution
but the inline doesn't work properly, the nBuffer is not inlined or evaluated when inlined and ends up as an undefined in the code generation.

function AdvancedNoise.Sources.TimeBasedNoise.interpolation.interpolate "Inline before index reduction" "Constant interpolation in a buffer of random values"
  input Real[:] buffer "Buffer of random numbers";
  input Real offset "Offset from buffer start (0..size(buffer)-1";
  input Real samplePeriod = 1.0 "The sample period of the noise buffer";
  output Real y "Interpolated value at position offset";
  protected Integer nBuffer = size(buffer, 1) "Size of the buffer";
algorithm
  y := buffer[if nBuffer == 1 then 1 else integer(offset) + 1];
end AdvancedNoise.Sources.TimeBasedNoise.interpolation.interpolate;

Attachments (1)

vd.mo (25.3 KB ) - added by Adrian Pop 6 years ago.

Download all attachments as: .zip

Change History (2)

by Adrian Pop, 6 years ago

Attachment: vd.mo added

comment:1 by Vitalij Ruge, 6 years ago

replaceExp (inCompiler/Util/VarTransform.mo) has an issue
because the type of

buffer[if nBuffer == 1 then 1 else integer(offset) + 1];

is

CREF arr[CREF idx [Integer] CREFTYPE:Integer] [Real[:]] CREFTYPE:Real

which is unsoporrted. but DAE.ASUB is supported.

Note: See TracTickets for help on using tickets.