Skip to content

Commit

Permalink
- Update some RML syntax to MetaModelica
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6994 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 12, 2010
1 parent 36b290a commit 841b8ec
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 44 deletions.
12 changes: 6 additions & 6 deletions Compiler/BackendDAETransform.mo
Expand Up @@ -280,7 +280,7 @@ algorithm
equation
newarr = arrayCreate(size, 0);
newarr_1 = Util.arrayNCopy(arr, newarr, size);
vec = array_copy(newarr_1);
vec = arrayCopy(newarr_1);
then
vec;
case (_)
Expand Down Expand Up @@ -1217,7 +1217,7 @@ algorithm
(dummy_der,dae) = newDummyVar(state, dae) ;
// print("Chosen dummy: ");print(ComponentReference.printComponentRefStr(dummy_der));print("\n");
reqns = BackendDAEUtil.eqnsForVarWithStates(mt, stateno);
changedeqns = Util.listUnionOnTrue(deqns, reqns, int_eq);
changedeqns = Util.listUnionOnTrue(deqns, reqns, intEq);
(dae,m,mt) = replaceDummyDer(state, dummy_der, dae, m, mt, changedeqns)
"We need to change variables in the differentiated equations and in the equations having the dummy derivative" ;
dae = makeAlgebraic(dae, state);
Expand Down Expand Up @@ -1353,7 +1353,7 @@ algorithm
/* eqns dummy state */
case ((dae as BackendDAE.DAE(vars,kv,ev,av,e,se,ie,ae,al,ei,eoc)),eqns,dummy,dummy_no)
equation
eqns_1 = Util.listMap1(eqns, int_sub, 1);
eqns_1 = Util.listMap1(eqns, intSub, 1);
eqns_lst = Util.listMap1r(eqns_1, BackendDAEUtil.equationNth, e);
crefs = BackendEquation.equationsCrefs(eqns_lst);
crefs = Util.listDeleteMemberOnTrue(crefs, dummy, ComponentReference.crefEqualNoStringCompare);
Expand All @@ -1369,7 +1369,7 @@ algorithm
// Never propagate fixed=true
case ((dae as BackendDAE.DAE(vars,kv,ev,av,e,se,ie,ae,al,ei,eoc)),eqns,dummy,dummy_no)
equation
eqns_1 = Util.listMap1(eqns, int_sub, 1);
eqns_1 = Util.listMap1(eqns, intSub, 1);
eqns_lst = Util.listMap1r(eqns_1, BackendDAEUtil.equationNth, e);
crefs = BackendEquation.equationsCrefs(eqns_lst);
crefs = Util.listDeleteMemberOnTrue(crefs, dummy, ComponentReference.crefEqualNoStringCompare);
Expand Down Expand Up @@ -1969,7 +1969,7 @@ protected function varStateSelectHeuristicPrio3
output Real prio;
algorithm
prio := matchcontinue(cr,vars)
local Integer i; Real c,prio;
local Integer i; Real c;
case(cr,vars)
equation
((_,i)) = BackendVariable.traverseBackendDAEVars(vars,varHasSameLastIdent,(cr,0));
Expand Down Expand Up @@ -2268,7 +2268,7 @@ protected function statesAsAlgebraicVars "function: statesAsAlgebraicVars
input BackendDAE.Variables vars;
output BackendDAE.Variables v1_1;
list<BackendDAE.Var> varlst,varlst_1;
BackendDAE.Variables v1,v1_1;
BackendDAE.Variables v1;
algorithm
varlst := BackendDAEUtil.varList(vars) "Creates a new set of BackendDAE.Variables from a BackendDAE.Var list" ;
varlst_1 := statesAsAlgebraicVars2(varlst);
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackendDAEUtil.mo
Expand Up @@ -1876,7 +1876,7 @@ algorithm
case (BackendDAE.VAR(varName = cr),((dae as BackendDAE.DAE(orderedVars = vars)),arr,m,mt,a1,a2))
equation
(_,v_indxs) = BackendVariable.getVar(cr, vars);
v_indxs_1 = Util.listMap1(v_indxs, int_sub, 1);
v_indxs_1 = Util.listMap1(v_indxs, intSub, 1);
eqns = Util.listMap1r(v_indxs_1, arrayNth, a1);
((arr_1,m,mt,a1,a2)) = markStateEquation2(eqns, (arr,m,mt,a1,a2));
then
Expand Down Expand Up @@ -3571,7 +3571,7 @@ algorithm
case (BackendDAE.RESIDUAL_EQUATION(exp = e),vars,ae,m,mt,eqn_indx,differentiateIfExp,inEntrylst)
equation
var_indxs = varsInEqn(m, eqn_indx);
var_indxs_1 = Util.listUnionOnTrue(var_indxs, {}, int_eq) "Remove duplicates and get in correct order: ascending index" ;
var_indxs_1 = Util.listUnionOnTrue(var_indxs, {}, intEq) "Remove duplicates and get in correct order: ascending index" ;
SOME(eqns) = calculateJacobianRow2(e, vars, eqn_indx, var_indxs_1,differentiateIfExp);
then
(SOME(eqns),inEntrylst);
Expand All @@ -3587,7 +3587,7 @@ algorithm
(subs,entrylst1) = getArrayEquationSub(indx,ad,inEntrylst);
new_exp = Expression.applyExpSubscripts(new_exp,subs);
var_indxs = varsInEqn(m, eqn_indx);
var_indxs_1 = Util.listUnionOnTrue(var_indxs, {}, int_eq) "Remove duplicates and get in correct order: acsending index";
var_indxs_1 = Util.listUnionOnTrue(var_indxs, {}, intEq) "Remove duplicates and get in correct order: acsending index";
SOME(eqns) = calculateJacobianRow2(new_exp, vars, eqn_indx, var_indxs_1,differentiateIfExp);
then
(SOME(eqns),entrylst1);
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackendDump.mo
Expand Up @@ -1121,7 +1121,7 @@ public function dumpMatching
algorithm
print("Matching\n");
print("========\n");
len := array_length(v);
len := arrayLength(v);
len_str := intString(len);
print(len_str);
print(" variables and equations\n");
Expand All @@ -1142,7 +1142,7 @@ algorithm
array<BackendDAE.Value> v;
case (v,i)
equation
len = array_length(v);
len = arrayLength(v);
i_1 = i + 1;
(len == i_1) = true;
s = intString(i_1);
Expand All @@ -1157,7 +1157,7 @@ algorithm
();
case (v,i)
equation
len = array_length(v);
len = arrayLength(v);
i_1 = i + 1;
(len == i_1) = false;
s = intString(i_1);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackendVariable.mo
Expand Up @@ -1663,7 +1663,7 @@ algorithm
matchcontinue (inindex,dimlist)
local
list<Integer> index_lst,dim_lst;
Integer value,value1,index,dim;
Integer value1,index,dim;
case ({},{}) then 0;
case (index::{},_) then index;
case (index::index_lst,dim::dim_lst)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/DAEQuery.mo
Expand Up @@ -735,7 +735,7 @@ algorithm
BackendVariable.getVar(cr, vars) "If variable x is a state, der(x) is a variable in incidence matrix,
x is inserted as negative value, since it is needed by debugging and index
reduction using dummy derivatives" ;
p_1 = Util.listMap1r(p, int_sub, 0);
p_1 = Util.listMap1r(p, intSub, 0);
pStr = Util.listMap(p_1, intString);
then
pStr;
Expand Down
22 changes: 11 additions & 11 deletions Compiler/DFA.mo
Expand Up @@ -254,7 +254,7 @@ algorithm
case ({},Absyn.TUPLE({}) :: _,_,_) then {};

// _ := ... then ..., not fail()
case ({Absyn.CREF(Absyn.WILD)},_,_,_) then {};
case ({Absyn.CREF(Absyn.WILD())},_,_,_) then {};

case (firstLhs :: restLhs,firstRhs :: restRhs,localAccList,info)
equation
Expand Down Expand Up @@ -828,7 +828,7 @@ algorithm
localDfaEnv = listReverse(localDfaEnv);
then (SOME(localDfaEnv),localCache);

case (Absyn.CREF(Absyn.WILD) :: restExps,localDfaEnv,localCache,localEnv,info)
case (Absyn.CREF(Absyn.WILD()) :: restExps,localDfaEnv,localCache,localEnv,info)
equation
(res,localCache) = addVarsToDfaEnv2(restExps,localDfaEnv,localCache,localEnv,info);
then (res,localCache);
Expand Down Expand Up @@ -1504,9 +1504,9 @@ protected function matchContinueToSwitch2
input list<tuple<Absyn.Ident,Absyn.TypeSpec>> initialDfaEnv;
input Absyn.Info info;
output Env.Cache outCache;
output list<Absyn.Exp> expr;
output list<Absyn.Exp> exprs;
algorithm
(outCache, expr) := matchcontinue (patMat, caseLocalDecls, inputVarList, resVarList, rhlist, elseRhSide, cache, localEnv, invalidDecls, initialDfaEnv, info)
(outCache, exprs) := matchcontinue (patMat, caseLocalDecls, inputVarList, resVarList, rhlist, elseRhSide, cache, localEnv, invalidDecls, initialDfaEnv, info)
local
RenamedPatList firstCase;
RenamedPatMatrix2 restCase;
Expand Down Expand Up @@ -1699,8 +1699,8 @@ function generatePathVarDeclarationsList
algorithm
(outCache,outDfaEnv,outEls,outAlgs) := matchcontinue(pats, inputVarList, cache, env, dfaEnv,info)
local
list<Absyn.ElementItem> outEls, outEls1, outEls2, matchDecls;
list<Absyn.AlgorithmItem> outAlgs, outAlgs1, outAlgs2, matchAlgs;
list<Absyn.ElementItem> outEls1, outEls2, matchDecls;
list<Absyn.AlgorithmItem> outAlgs1, outAlgs2, matchAlgs;
list<RenamedPat> rest;
RenamedPat pat;
list<Absyn.Exp> varList;
Expand Down Expand Up @@ -1768,25 +1768,25 @@ algorithm

case (RP_EMPTYLIST(_), var, nequal,info) // Optimizes comparison with emptylist by not creating an empty list to compare with
equation
alg = Absyn.ALGORITHMITEM(Absyn.ALG_BREAK, NONE(), info);
alg = Absyn.ALGORITHMITEM(Absyn.ALG_BREAK(), NONE(), info);
exp = Absyn.CALL(Absyn.CREF_FULLYQUALIFIED(Absyn.CREF_IDENT("listEmpty",{})), Absyn.FUNCTIONARGS({var}, {}));
exp = Util.if_(nequal, Absyn.LUNARY(Absyn.NOT(), exp), exp);
alg = Absyn.ALGORITHMITEM(Absyn.ALG_IF(exp, {alg}, {}, {}), NONE(), info);
then {alg};

case (RP_NONE(_), var, nequal,info) // Optimizes comparison with NONE() by not creating an empty option to compare with
equation
alg = Absyn.ALGORITHMITEM(Absyn.ALG_BREAK, NONE(), info);
alg = Absyn.ALGORITHMITEM(Absyn.ALG_BREAK(), NONE(), info);
exp = Absyn.CALL(Absyn.CREF_FULLYQUALIFIED(Absyn.CREF_IDENT("optionNone",{})), Absyn.FUNCTIONARGS({var}, {}));
exp = Util.if_(nequal, Absyn.LUNARY(Absyn.NOT(), exp), exp);
alg = Absyn.ALGORITHMITEM(Absyn.ALG_IF(exp, {alg}, {}, {}), NONE(), info);
then {alg};

case (pat, var, nequal,info)
equation
op = Util.if_(nequal, Absyn.NEQUAL, Absyn.EQUAL);
op = Util.if_(nequal, Absyn.NEQUAL(), Absyn.EQUAL());
exp = getPatternExp(pat);
alg = Absyn.ALGORITHMITEM(Absyn.ALG_BREAK, NONE(), info);
alg = Absyn.ALGORITHMITEM(Absyn.ALG_BREAK(), NONE(), info);
alg = Absyn.ALGORITHMITEM(Absyn.ALG_IF(Absyn.RELATION(var,op,exp), {alg}, {}, {}), NONE(), info);
then {alg};

Expand All @@ -1811,7 +1811,7 @@ algorithm

case (pathVar,(DAE.T_METARECORD(index=i),_),numFields,info)
equation
alg = Absyn.ALGORITHMITEM(Absyn.ALG_BREAK, NONE(), info);
alg = Absyn.ALGORITHMITEM(Absyn.ALG_BREAK(), NONE(), info);
fargs = Absyn.FUNCTIONARGS({Absyn.CREF(Absyn.CREF_IDENT(pathVar,{})),Absyn.INTEGER(i),Absyn.INTEGER(numFields)}, {});
exp = Absyn.CALL(Absyn.CREF_FULLYQUALIFIED(Absyn.CREF_QUAL("OpenModelicaInternal",{},Absyn.CREF_IDENT("uniontypeMetarecordTypedefEqual",{}))), fargs);
exp = Absyn.LUNARY(Absyn.NOT(), exp);
Expand Down
12 changes: 6 additions & 6 deletions Compiler/Inline.mo
Expand Up @@ -80,9 +80,9 @@ algorithm
BackendDAE.EquationArray orderedEqs;
BackendDAE.EquationArray removedEqs;
BackendDAE.EquationArray initialEqs;
BackendDAE.MultiDimEquation[:] arrayEqs;
array<BackendDAE.MultiDimEquation> arrayEqs;
list<BackendDAE.MultiDimEquation> mdelst;
Algorithm.Algorithm[:] algorithms;
array<Algorithm.Algorithm> algorithms;
list<Algorithm.Algorithm> alglst;
BackendDAE.EventInfo eventInfo;
BackendDAE.ExternalObjectClasses extObjClasses;
Expand Down Expand Up @@ -121,7 +121,7 @@ algorithm
local
Functiontuple fns;
Integer i1,i2;
Option<BackendDAE.Equation>[:] eqarr,eqarr_1;
array<Option<BackendDAE.Equation>> eqarr,eqarr_1;
list<Option<BackendDAE.Equation>> eqlst,eqlst_1;
case(BackendDAE.EQUATION_ARRAY(i1,i2,eqarr),fns)
equation
Expand Down Expand Up @@ -251,10 +251,10 @@ algorithm
outVariables := matchcontinue(inVariables,inElementList)
local
Functiontuple fns;
list<BackendDAE.CrefIndex>[:] crefind;
list<BackendDAE.StringIndex>[:] strind;
array<list<BackendDAE.CrefIndex>> crefind;
array<list<BackendDAE.StringIndex>> strind;
Integer i1,i2,i3,i4;
Option<BackendDAE.Var>[:] vararr,vararr_1;
array<Option<BackendDAE.Var>> vararr,vararr_1;
list<Option<BackendDAE.Var>> varlst,varlst_1;
case(BackendDAE.VARIABLES(crefind,strind,BackendDAE.VARIABLE_ARRAY(i3,i4,vararr),i1,i2),fns)
equation
Expand Down
1 change: 0 additions & 1 deletion Compiler/MetaUtil.mo
Expand Up @@ -828,7 +828,6 @@ algorithm
Absyn.TypeSpec tSpec;
list<Absyn.TypeSpec> tSpecList;
String id,str;
DAE.Type t;
list<DAE.Type> tList;
Absyn.Path p;
case ((DAE.T_INTEGER(_),_)) then Absyn.TPATH(Absyn.IDENT("Integer"),NONE());
Expand Down
2 changes: 1 addition & 1 deletion Compiler/PartFn.mo
Expand Up @@ -737,7 +737,7 @@ algorithm
DAE.Element el,el_1,el1,el1_1,el2,el2_1;
list<DAE.Element> elts,elts_1;
DAE.Function fn;
list<DAE.Function> cdr,cdr_1,dae;
list<DAE.Function> cdr,cdr_1;
list<list<DAE.Element>> elm,elm_1;
DAE.ComponentRef cref;
DAE.VarKind kind;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Patternm.mo
Expand Up @@ -119,8 +119,8 @@ algorithm
// Create pattern matrix. The as-bindings ( ... case (var1 as 3) ...)
// are first collected in the fillMatrix function and then
// assignments of these variables are added to the RightHandSide list
patMat = fill({},varListLength);
asBindings = fill({},listLength(rhsList));
patMat = arrayCreate(varListLength,{});
asBindings = arrayCreate(listLength(rhsList),{});
(localCache,patMat,asBindings,_) =
fillMatrix(1,asBindings,varList,patList,patMat,localCache,localEnv,(1,{}),infoList);
rhsList = addAsBindings(rhsList,arrayList(asBindings)); // Add the as-bindings (assignments)
Expand Down
3 changes: 0 additions & 3 deletions Compiler/SimCode.mo
Expand Up @@ -764,7 +764,6 @@ public function generateModelCodeFMU
DAE.DAElist dae2;
String filename, funcfilename;
SimCode simCode;
Real timeSimCode, timeTemplates;
algorithm
System.realtimeTick(CevalScript.RT_CLOCK_BUILD_MODEL);
(libs, includes, functions, outIndexedBackendDAE, dae2) :=
Expand Down Expand Up @@ -892,7 +891,6 @@ public function generateModelCode
// DAE.DAElist dae2;
String filename, funcfilename;
SimCode simCode;
Real timeSimCode, timeTemplates;
algorithm
System.realtimeTick(CevalScript.RT_CLOCK_BUILD_MODEL);
(libs, includes, functions, outIndexedBackendDAE, _) :=
Expand Down Expand Up @@ -1580,7 +1578,6 @@ algorithm
array<list<Integer>> m,mt;
Absyn.Path class_;
// new variables
SimCode simCode;
ModelInfo modelInfo;
list<SimEqSystem> allEquations;
list<SimEqSystem> allEquationsPlusWhen;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/TaskGraph.mo
Expand Up @@ -367,10 +367,10 @@ algorithm
Expression.print_exp_str expr => s2 & print s2 & print \"\\n\" &" ;
then
();
case (BackendDAE.DAE(orderedVars = vars,orderedEqs = eqns),ass1,ass2,e) /* rule int_sub(e,1) => e\' &
case (BackendDAE.DAE(orderedVars = vars,orderedEqs = eqns),ass1,ass2,e) /* rule intSub(e,1) => e\' &
BackendDAE.equation_nth(eqns,e\') => BackendDAE.EQUATION(e1,e2,_) &
vector_nth(ass2,e\') => v & ( v==variable no solved in this equation ))
int_sub(v,1) => v\' &
intSub(v,1) => v\' &
BackendDAE.vararray_nth(vararr,v\') => BackendDAE.VAR(cr,_,_,_,_,_,_,_,_,origname,_,dae_var_attr,comment,flow) &
let varexp = DAE.CREF(cr,DAE.ET_REAL) &
not ExpressionSolve.solve(e1,e2,varexp) => _ &
Expand Down
3 changes: 1 addition & 2 deletions Compiler/Util.mo
Expand Up @@ -4605,7 +4605,7 @@ algorithm
case (x,pos,arr,fillv)
equation
//Replacing element out of range of array, create new array, and copy elts.
newarr = fill(fillv, pos);
newarr = arrayCreate(pos, fillv);
res = arrayCopy(arr, newarr);
res_1 = arrayUpdate(res, pos , x);
then
Expand Down Expand Up @@ -4644,7 +4644,6 @@ public function arrayNCopy "function arrayNCopy
output array<Type_a> dst_1;
replaceable type Type_a subtypeof Any;
Integer n_1;
array<Type_a> dst_1;
algorithm
n_1 := n - 1;
dst_1 := arrayCopy2(src, dst, n_1);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/XMLDump.mo
Expand Up @@ -2515,7 +2515,7 @@ algorithm
BackendDAE.Value[:] v;
case (v,i)
equation
len = array_length(v);
len = arrayLength(v);
i_1 = i + 1;
(len == i_1) = true;
s = intString(i_1);
Expand All @@ -2529,7 +2529,7 @@ algorithm
();
case (v,i)
equation
len = array_length(v);
len = arrayLength(v);
i_1 = i + 1;
(len == i_1) = false;
s = intString(i_1);
Expand Down

0 comments on commit 841b8ec

Please sign in to comment.