This repository was archived by the owner on May 18, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +55
-1
lines changed
Expand file tree Collapse file tree 4 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -13380,6 +13380,45 @@ algorithm
1338013380 end matchcontinue;
1338113381end cref2simvar;
1338213382
13383+ public function codegenExpSanityCheck "Handle some things that Susan cannot handle:
13384+ * Expand simulation context arrays that contain variables stored in different locations...
13385+ * We could move collapsing arrays here since it should be safer to do so when we can lookup which index a variable corresponds to...
13386+ "
13387+ input output DAE.Exp e;
13388+ input SimCodeFunction.Context context;
13389+ protected
13390+ list<SimCodeVar.SimVar> vars;
13391+ SimCode.SimCode simCode;
13392+ Integer index;
13393+ algorithm
13394+ if match context
13395+ case SimCodeFunction.FUNCTION_CONTEXT() then true;
13396+ case SimCodeFunction.PARALLEL_FUNCTION_CONTEXT() then true;
13397+ else false; end match
13398+ then
13399+ return;
13400+ end if;
13401+ e := match e
13402+ case DAE.CREF(ty=DAE.T_ARRAY())
13403+ algorithm
13404+ simCode := getSimCode();
13405+ vars := list(cref2simvar(cr, simCode) for cr in ComponentReference.expandCref(e.componentRef, true));
13406+ if not listEmpty(vars) then
13407+ SimCodeVar.SIMVAR(index=index)::vars := vars;
13408+ for v in vars loop
13409+ // The array needs to be expanded because it's not stored in contiguous memory
13410+ if v.index <> index+1 then
13411+ e := Expression.expandCrefs(e);
13412+ break;
13413+ end if;
13414+ index := v.index;
13415+ end for;
13416+ end if;
13417+ then e;
13418+ else e;
13419+ end match;
13420+ end codegenExpSanityCheck;
13421+
1338313422public function isModelTooBigForCSharpInOneFile
1338413423"Used by C# template to determine if the generated code should be split into several files
1338513424 to make Visual Studio responsive when the file is opened (C# compiler is OK,
Original file line number Diff line number Diff line change 11encapsulated package SimCodeUtil
22
33import SimCode;
4+ import SimCodeFunction;
45import SimCodeVar;
56
67function sortEqSystems< T>
@@ -31,5 +32,13 @@ algorithm
3132 assert (false , getInstanceName ());
3233end cref2simvar;
3334
35+ function codegenExpSanityCheck
36+ input output DAE.Exp e;
37+ input SimCodeFunction.Context context;
38+ algorithm
39+ /* Do nothing */
40+ end codegenExpSanityCheck;
41+
42+
3443annotation(__OpenModelica_Interface="backend" );
3544end SimCodeUtil;
Original file line number Diff line number Diff line change @@ -4303,7 +4303,7 @@ end getTempDeclMatchOutputName;
43034303 "Generates code for an expression.
43044304 used in Compiler/Template/CodegenQSS.tpl"
43054305::=
4306- match exp
4306+ match codegenExpSanityCheck( exp, context)
43074307 case e as ICONST(__) then '((modelica_integer) <%integer%>)' /* Yes, we need to cast int to long on 64-bit arch... */
43084308 case e as RCONST(__) then real
43094309 case e as SCONST(__) then daeExpSconst(string, &preExp, &varDecls)
Original file line number Diff line number Diff line change @@ -985,6 +985,12 @@ package SimCodeUtil
985985 input SimCode.SimCode simCode;
986986 output Boolean outIsTooBig;
987987 end isModelTooBigForCSharpInOneFile;
988+
989+ function codegenExpSanityCheck
990+ input DAE.Exp inExp;
991+ input SimCodeFunction.Context context;
992+ output DAE.Exp outExp;
993+ end codegenExpSanityCheck;
988994end SimCodeUtil;
989995
990996package SimCodeFunctionUtil
You can’t perform that action at this time.
0 commit comments