Opened 12 years ago

Closed 12 years ago

#1826 closed defect (fixed)

Passing built in functions as funargs generates invalid C code

Reported by: adabe588@… Owned by: sjoelund.se
Priority: high Milestone: 1.9.0
Component: Backend Version: trunk
Keywords: Cc:

Description

I tried this with with intString and stringInt and they both fail, I'm guessing other built in functions as well. A workaround is to wrap the built in functions in a regular function, but either way should work I think.

Script:

setCommandLineOptions({"+g=MetaModelica"});
loadFile("stringInt.mo"); getErrorString();
Test.test(); getErrorString();

stringInt.mos:

package Test

protected function app
  input  F f;
  input  String x;
protected
  partial function F
    input String inElement;
    output Integer outElement;
  end F;
algorithm
  f(x);
end app;

// Passing this as a funarg instead of stringInt works.
function si
  input String s;
  output Integer i;
algorithm
  i := stringInt(s);
end si;

function test
algorithm
  app(stringInt, "123");
end test;

end Test;

Change History (2)

comment:1 Changed 12 years ago by sjoelund.se

  • Owner changed from somebody to sjoelund.se
  • Status changed from new to accepted

comment:2 Changed 12 years ago by sjoelund.se

  • Resolution set to fixed
  • Status changed from accepted to closed

I don't think you tested this for intString, since that actually works. Look into trunk/SimulationRuntime/c/meta/meta_modelica_builtin_boxptr.h; it's quite easy to add the built-ins you need.

Fixed in r13003.

Note: See TracTickets for help on using tickets.