Changeset 6eb1528 in OpenModelica


Ignore:
Timestamp:
2021-11-25T13:35:50+01:00 (2 years ago)
Author:
Per Östlund <perost86@…>
Parents:
dc7de090
git-author:
Per Östlund <perost86@…> (11/25/21 13:33:17)
git-committer:
Per Östlund <perost86@…> (11/25/21 13:35:50)
Message:

Make subscripting functions for -f optional

  • Use the -m flag to enable the output of subscripting functions when -f is used, and otherwise output subscripted expressions.
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • OMCompiler/Compiler/NFFrontEnd/NFExpression.mo

    rbbbca3c8 r6eb1528  
    17801780    list<Subscript> subs;
    17811781  algorithm
    1782     subs := list(s for s guard not Subscript.isSplitIndex(s) in subscripts);
    1783 
    1784     if listEmpty(subs) then
    1785       str := toFlatString(exp);
     1782    if Flags.getConfigBool(Flags.MODELICA_OUTPUT) then
     1783      subs := list(s for s guard not Subscript.isSplitIndex(s) in subscripts);
     1784
     1785      if listEmpty(subs) then
     1786        str := toFlatString(exp);
     1787      else
     1788        exp_ty := typeOf(exp);
     1789        dims := List.firstN(Type.arrayDims(exp_ty), listLength(subs));
     1790        sub_tyl := list(Dimension.subscriptType(d) for d in dims);
     1791        name := Type.subscriptedTypeName(exp_ty, sub_tyl);
     1792
     1793        strl := {")"};
     1794
     1795        for s in subs loop
     1796          strl := Subscript.toFlatString(s) :: strl;
     1797          strl := "," :: strl;
     1798        end for;
     1799
     1800        strl := toFlatString(exp) :: strl;
     1801        strl := "'(" :: strl;
     1802        strl := name :: strl;
     1803        strl := "'" :: strl;
     1804        str := stringAppendList(strl);
     1805      end if;
    17861806    else
    1787       exp_ty := typeOf(exp);
    1788       dims := List.firstN(Type.arrayDims(exp_ty), listLength(subs));
    1789       sub_tyl := list(Dimension.subscriptType(d) for d in dims);
    1790       name := Type.subscriptedTypeName(exp_ty, sub_tyl);
    1791 
    1792       strl := {")"};
    1793 
    1794       for s in subs loop
    1795         strl := Subscript.toFlatString(s) :: strl;
    1796         strl := "," :: strl;
    1797       end for;
    1798 
    1799       strl := toFlatString(exp) :: strl;
    1800       strl := "'(" :: strl;
    1801       strl := name :: strl;
    1802       strl := "'" :: strl;
    1803       str := stringAppendList(strl);
     1807      str := toFlatString(exp) + Subscript.toFlatStringList(subscripts);
    18041808    end if;
    18051809  end toFlatSubscriptedString;
  • OMCompiler/Compiler/NFFrontEnd/NFFlatModel.mo

    r7c3ddb9c r6eb1528  
    512512    types := match exp
    513513      case Expression.SUBSCRIPTED_EXP()
     514        guard Flags.getConfigBool(Flags.MODELICA_OUTPUT)
    514515        algorithm
    515516          types := collectSubscriptedFlatType(exp.exp, exp.subscripts, exp.ty, types);
  • testsuite/openmodelica/flatmodelica/DoublePendulum.mos

    rea1a004 r6eb1528  
    33
    44loadModel(Modelica, {"3.2.3"});getErrorString();
    5 setCommandLineOptions("-d=newInst -f");
     5setCommandLineOptions("-d=newInst -f -m");
    66writeFile("DoublePendulum.mo", OpenModelica.Scripting.instantiateModel(Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum));getErrorString();
    77clear();
  • testsuite/openmodelica/flatmodelica/Makefile

    r74e94c8 r6eb1528  
    1010
    1111TESTFILES = DoublePendulum.mos \
    12   Tables.mos
     12  Tables.mos \
     13  SD.mo
    1314
    1415
  • testsuite/openmodelica/flatmodelica/Tables.mos

    r221b299 r6eb1528  
    44loadModel(ModelicaServices, {"3.2.3+maint.om"});getErrorString();
    55loadModel(ModelicaTest, {"3.2.3"});getErrorString();
    6 setCommandLineOptions("-d=newInst -f");
     6setCommandLineOptions("-d=newInst -f -m");
    77writeFile("Tables.mo", OpenModelica.Scripting.instantiateModel(ModelicaTest.Tables.CombiTable1D.Test33));getErrorString();
    88clear();
Note: See TracChangeset for help on using the changeset viewer.