@@ -672,7 +672,7 @@ protected
672672 subscript_exp := Expression . fromCref(iterator_name);
673673
674674 for arg in rest loop
675- _ := match arg
675+ failed := match arg
676676 case Expression . CREF (cref = rhs) guard(not failed) algorithm
677677 ty := Expression . typeOf(arg);
678678 sz := Type . sizeOf(ty);
@@ -728,34 +728,14 @@ protected
728728 if Flags . isSet(Flags . DUMPBACKENDINLINE ) then
729729 print("-- Result: " + Equation . pointerToString(new_eqn) + " \n " );
730730 end if ;
731- then () ;
731+ then false ;
732732
733+ // inline for literals down to element, nested arrays possible
733734 case Expression . ARRAY () guard(not failed and Expression . isLiteral(arg)) algorithm
734- // a literal expression, does not need subscripting
735- for elem in arg. elements loop
736- ty := Expression . typeOf(elem);
737- sz := Type . sizeOf(ty);
738- // properly subscript LHS with shift
739- lhs_sub := Expression . INTEGER (shift+ 1 );
740- lhs := ComponentRef . mergeSubscripts(Subscript . fillWithWholeLeft({Subscript . INDEX (lhs_sub)}, n), cref);
741- lhs_exp := Expression . fromCref(lhs);
735+ (eqns, shift) := inlineCatCallLiterals(arg, cref, iter, attr, n, index, failed, eqns, shift);
736+ then false ;
742737
743- // create the new equation
744- new_eqn := Equation . makeAssignment(lhs_exp, elem, index, NBEquation . SIMULATION_STR , iter, attr);
745-
746- // bump the shift adding the size of this last equation
747- shift := shift + sz;
748-
749- eqns := new_eqn :: eqns;
750- if Flags . isSet(Flags . DUMPBACKENDINLINE ) then
751- print("-- Result: " + Equation . pointerToString(new_eqn) + " \n " );
752- end if ;
753- end for ;
754- then ();
755-
756- else algorithm
757- failed := true ;
758- then ();
738+ else true ;
759739 end match;
760740 end for ;
761741
@@ -765,6 +745,53 @@ protected
765745 end if ;
766746 end inlineCatCall;
767747
748+ function inlineCatCallLiterals
749+ "recursively inlines arrays of literal expressions that were an argument to a cat() call"
750+ input Expression exp;
751+ input ComponentRef cref;
752+ input Iterator iter;
753+ input EquationAttributes attr;
754+ input Integer n;
755+ input Pointer < Integer > index;
756+ input Boolean failed;
757+ input output list< Pointer < Equation >> eqns;
758+ input output Integer shift;
759+ algorithm
760+ _ := match exp
761+ local
762+ Integer sz;
763+ ComponentRef lhs;
764+ Expression lhs_sub, lhs_exp;
765+ Pointer < Equation > new_eqn;
766+
767+ case Expression . ARRAY () guard(not failed and Expression . isLiteral(exp)) algorithm
768+ // a literal expression, does not need subscripting
769+ for elem in exp. elements loop
770+ (eqns, shift) := inlineCatCallLiterals(elem, cref, iter, attr, n, index, failed, eqns, shift);
771+ end for ;
772+ then ();
773+
774+ else algorithm
775+ sz := Type . sizeOf(Expression . typeOf(exp));
776+ // properly subscript LHS with shift
777+ lhs_sub := Expression . INTEGER (shift+ 1 );
778+ lhs := ComponentRef . mergeSubscripts(Subscript . fillWithWholeLeft({Subscript . INDEX (lhs_sub)}, n), cref);
779+ lhs_exp := Expression . fromCref(lhs);
780+
781+ // create the new equation
782+ new_eqn := Equation . makeAssignment(lhs_exp, exp, index, NBEquation . SIMULATION_STR , iter, attr);
783+
784+ // bump the shift adding the size of this last equation
785+ shift := shift + sz;
786+
787+ eqns := new_eqn :: eqns;
788+ if Flags . isSet(Flags . DUMPBACKENDINLINE ) then
789+ print("-- Result: " + Equation . pointerToString(new_eqn) + " \n " );
790+ end if ;
791+ then ();
792+ end match;
793+ end inlineCatCallLiterals;
794+
768795 function createInlinedEquation
769796 "used for inlining record, tuple and array equations.
770797 tries to create new equation from lhs and rhs and applying
0 commit comments