Opened 14 years ago

Last modified 9 years ago

#1441 new defect

Removing STMT_TUPLE_ASSIGN

Reported by: Martin Sjölund Owned by: Martin Sjölund
Priority: high Milestone: Future
Component: Backend Version:
Keywords: Cc: Martin Sjölund, Adrian Pop, Peter Aronsson

Description (last modified by Martin Sjölund)

Tuple assignments have a problem today:

class B
  function fn
    output Integer o1 := 1;
    output Integer o2 := 2;
    annotation(__OpenModelica_Impure = true);
  end fn;
  Integer i1,i2;
  Real r1,r2;
algorithm
  (i1,i2) := fn();
  (r1,r2) := fn();
end B;

Class B would accept (r1,r2) := fn(), which works in this particular case (because in the C-code, a double can be assigned an integer at the loss of precision (>48-bit long ints; not a big issue)).
The big problem here is that converting an integer array to real array or unboxing returned data is not performed. We could either remove STMT_TUPLE_ASSIGN altogether (replace it with pattern assignments - my favorite) or extend the type to include a list of types so that the code generation can perform necessary casts but this does not always work.

We could also make the STMT_TUPLE_ASSIGN statement return a temporary variable plus a list of (non-tuple) assignments performed on this temp.var.

For now, I'll change the implementation to only check for subtype instead of type conversions, see if the testsuite runs, and commit.

Change History (3)

comment:1 by Martin Sjölund, 14 years ago

Any comments?

comment:2 by Martin Sjölund, 12 years ago

Cc: sjoelund.se, adrpo, petar, sjoelund.se → sjoelund.se, adrpo, petar
Component: Backend
Description: modified (diff)

comment:3 by Dietmar Winkler, 9 years ago

Milestone: Future
Note: See TracTickets for help on using tickets.