Opened 14 years ago

Closed 12 years ago

#1406 closed defect (invalid)

Better support for records in functions

Reported by: Per Östlund Owned by: Per Östlund
Priority: high Milestone:
Component: Simulation Code Generation Version: trunk
Keywords: Cc: Per Östlund

Description

The following model contains several issues that may or may not need to be fixed:

model BETest
  model BTNode
    constant Integer parentEdge;
    constant Integer childEdge;
  end BTNode;

  model BTEdge
    constant Integer parent;
    constant Integer child;
  end BTEdge;

  model BT
    BTNode node[3](parentEdge={0,1,2}, childEdge={1,2,0});
    BTEdge edge[2](parent={1,2}, child={2,3});
  end BT;

  function getChild
    input Integer p;
    output Integer c;
    BT bt;
  algorithm
    c := bt.edge[bt.node[p].childEdge].child;
  end getChild;

  Integer value;
equation
  value = getChild(2); // 3
end BETest;

The local variable bt in the getChild function is currently removed in Inst.daeDeclare4. The specification is a bit unclear about whether it's allowed to use variables of model type in functions or not. If BTNode, BTEdge and BT are declared as records the model will pass through OMC, but the generated code will contain errors, because arrays of records inside records are not handled correctly. There might also be other problems related to records inside records.

Change History (1)

comment:1 by Per Östlund, 12 years ago

Cc: perost, → perost
Resolution: invalid
Status: newclosed

The specification is now clear that functions may not contain components of specialized class model.

Note: See TracTickets for help on using tickets.