Skip to content

Commit 6d2a317

Browse files
committed
- Fix RML oddities
git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/sjoelund-functiontree@6954 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent a0e71ef commit 6d2a317

File tree

4 files changed

+46
-54
lines changed

4 files changed

+46
-54
lines changed

Compiler/CevalFunction.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ algorithm
616616
env = updateVariableBinding(inIter, env, inIterType, inStartValue);
617617
(cache, env, loop_ctrl) = evaluateStatements(inStatements, cache, env);
618618
next_val = ValuesUtil.safeIntRealOp(inStartValue, inStepValue,
619-
Values.ADDOP);
619+
Values.ADDOP());
620620
(cache, env, loop_ctrl) = evaluateForLoopRange(cache, env, inIter,
621621
inIterType, next_val, inStepValue, inStopValue, inStatements, loop_ctrl);
622622
then
@@ -708,7 +708,7 @@ protected function setupFunctionEnvironment
708708
output Env.Cache outCache;
709709
output Env.Env outEnv;
710710
algorithm
711-
outEnv := Env.openScope(inEnv, false, SOME(inFuncName), SOME(Env.FUNCTION_SCOPE));
711+
outEnv := Env.openScope(inEnv, false, SOME(inFuncName), SOME(Env.FUNCTION_SCOPE()));
712712
(outCache, outEnv) :=
713713
extendEnvWithFunctionVars(inCache, outEnv, inFuncVars, inFuncArgs);
714714
end setupFunctionEnvironment;

Compiler/DAEUtil.mo

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,6 @@ public function getOutputVars "function getOutputVars
12051205
"
12061206
input list<DAE.Element> vl;
12071207
output list<DAE.Element> vl_1;
1208-
list<DAE.Element> vl_1;
12091208
algorithm
12101209
vl_1 := getMatchingElements(vl, isOutputVar);
12111210
end getOutputVars;
@@ -1217,7 +1216,6 @@ public function getProtectedVars "
12171216
"
12181217
input list<DAE.Element> vl;
12191218
output list<DAE.Element> vl_1;
1220-
list<DAE.Element> vl_1;
12211219
algorithm
12221220
vl_1 := getMatchingElements(vl, isProtectedVar);
12231221
end getProtectedVars;
@@ -1229,7 +1227,6 @@ public function getBidirVars "function get_output_vars
12291227
"
12301228
input list<DAE.Element> vl;
12311229
output list<DAE.Element> vl_1;
1232-
list<DAE.Element> vl_1;
12331230
algorithm
12341231
vl_1 := getMatchingElements(vl, isBidirVar);
12351232
end getBidirVars;
@@ -1239,7 +1236,6 @@ public function getInputVars "
12391236
"
12401237
input list<DAE.Element> vl;
12411238
output list<DAE.Element> vl_1;
1242-
list<DAE.Element> vl_1;
12431239
algorithm
12441240
vl_1 := getMatchingElements(vl, isInput);
12451241
end getInputVars;
@@ -2479,8 +2475,7 @@ algorithm
24792475
absynCommentOption = comment) /* VAR */
24802476
equation
24812477
e1 = Util.optionToList(bndexp);
2482-
e3 = Util.listMap(instdims, getAllExpsSubscript);
2483-
e3 = Util.listFlatten(e3);
2478+
e3 = Util.listFlatten(Util.listMap(instdims, getAllExpsSubscript));
24842479
crefexp = crefToExp(cref);
24852480
exps = Util.listFlatten({e1,e3,{crefexp}});
24862481
then

Compiler/Interactive.mo

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3794,7 +3794,6 @@ protected function renameComponentInExternalDecl
37943794
input Absyn.ComponentRef old_comp;
37953795
input Absyn.ComponentRef new_comp;
37963796
output Absyn.ExternalDecl external_1;
3797-
Absyn.ExternalDecl external_1;
37983797
algorithm
37993798
print("-rename_component_in_external_decl not implemented yet\n");
38003799
external_1 := external_;
@@ -4396,14 +4395,14 @@ protected function extractAllComponents
43964395
extracts all the components and \"extends\""
43974396
input Absyn.Program p;
43984397
output Components comps;
4399-
Absyn.Program p_1;
4398+
SCode.Program p_1;
44004399
list<Env.Frame> env;
44014400
protected
44024401
Real t1,t2,t3;
44034402
algorithm
44044403
p_1 := SCodeUtil.translateAbsyn2SCode(p);
44054404
(_,env) := Inst.makeEnvFromProgram(Env.emptyCache(),p_1, Absyn.IDENT(""));
4406-
((p_1,_,(comps,p,env))) := traverseClasses(p,NONE(), extractAllComponentsVisitor,
4405+
((_,_,(comps,_,_))) := traverseClasses(p,NONE(), extractAllComponentsVisitor,
44074406
(COMPONENTS({},0),p,env), true) "traverse protected" ;
44084407
end extractAllComponents;
44094408

@@ -5740,7 +5739,7 @@ algorithm
57405739
String visibility_str,s1,element_str,res,s2;
57415740
Absyn.ElementItem current;
57425741
list<Absyn.ElementItem> rest;
5743-
case (visibility_str,{}) /* Util.string_append_list({\"{ elementvisibility=\", visibility_str,\" }\"}) => res */ then "";
5742+
case (visibility_str,{}) then "";
57445743
case (visibility_str,(current :: {})) /* deal with the last element */
57455744
equation
57465745
s1 = getElementInfo(current);
@@ -5804,16 +5803,17 @@ algorithm
58045803
local
58055804
Absyn.Path modelpath;
58065805
String i,public_str,protected_str,elements_str,str;
5807-
Boolean p,f,e;
5806+
Boolean f,e;
58085807
Absyn.Restriction r;
58095808
list<Absyn.ClassPart> parts;
58105809
list<Absyn.ElementItem> public_elementitem_list,protected_elementitem_list;
58115810
Absyn.ComponentRef model_;
5811+
Absyn.Program p;
58125812
/* a class with parts */
58135813
case (model_,p)
58145814
equation
58155815
modelpath = Absyn.crefToPath(model_);
5816-
Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(parts,_),_) = getPathedClassInProgram(modelpath, p);
5816+
Absyn.CLASS(i,_,f,e,r,Absyn.PARTS(parts,_),_) = getPathedClassInProgram(modelpath, p);
58175817
public_elementitem_list = getPublicList(parts);
58185818
protected_elementitem_list = getProtectedList(parts);
58195819
public_str = constructElementsInfo("public", public_elementitem_list);
@@ -5826,7 +5826,7 @@ algorithm
58265826
case (model_,p)
58275827
equation
58285828
modelpath = Absyn.crefToPath(model_);
5829-
Absyn.CLASS(i,p,f,e,r,Absyn.CLASS_EXTENDS(parts=parts),_) = getPathedClassInProgram(modelpath, p);
5829+
Absyn.CLASS(i,_,f,e,r,Absyn.CLASS_EXTENDS(parts=parts),_) = getPathedClassInProgram(modelpath, p);
58305830
public_elementitem_list = getPublicList(parts);
58315831
protected_elementitem_list = getProtectedList(parts);
58325832
public_str = constructElementsInfo("public", public_elementitem_list);
@@ -5839,7 +5839,7 @@ algorithm
58395839
case (model_,p)
58405840
equation
58415841
modelpath = Absyn.crefToPath(model_);
5842-
Absyn.CLASS(i,p,f,e,r,_,_) = getPathedClassInProgram(modelpath, p) "there are no elements in DERIVED, ENUMERATION, OVERLOAD, CLASS_EXTENDS and PDER
5842+
Absyn.CLASS(i,_,f,e,r,_,_) = getPathedClassInProgram(modelpath, p) "there are no elements in DERIVED, ENUMERATION, OVERLOAD, CLASS_EXTENDS and PDER
58435843
maybe later we can give info about that also" ;
58445844
then
58455845
"{ }";
@@ -6389,13 +6389,14 @@ algorithm
63896389
outAbsynElementSpecLst:=
63906390
matchcontinue (inAbsynElementItemLst)
63916391
local
6392+
Absyn.Element el;
63926393
Absyn.ElementSpec elt;
63936394
list<Absyn.ElementSpec> res;
63946395
list<Absyn.ElementItem> rest;
63956396
case ({}) then {};
6396-
case ((Absyn.ELEMENTITEM(element = elt) :: rest))
6397+
case ((Absyn.ELEMENTITEM(element = el) :: rest))
63976398
equation
6398-
elt = getExtendsElementspecInElement(elt) "Bug in MetaModelica Compiler (MMC). If the two premisses below are in swapped order
6399+
elt = getExtendsElementspecInElement(el) "Bug in MetaModelica Compiler (MMC). If the two premisses below are in swapped order
63996400
the compiler enters infinite loop (but no stack overflow)" ;
64006401
res = getExtendsElementspecInElementitems(rest);
64016402
then
@@ -7035,8 +7036,8 @@ algorithm
70357036
equation
70367037
name = Dump.printComponentRefStr(cr);
70377038
names2 = getModificationNames(args);
7038-
names2_1 = Util.listMap1r(names2, string_append, ".");
7039-
names2_2 = Util.listMap1r(names2_1, string_append, name);
7039+
names2_1 = Util.listMap1r(names2, stringAppend, ".");
7040+
names2_2 = Util.listMap1r(names2_1, stringAppend, name);
70407041
names = getModificationNames(rest);
70417042
res = listAppend(names2_2, names);
70427043
then
@@ -7046,8 +7047,8 @@ algorithm
70467047
equation
70477048
name = Dump.printComponentRefStr(cr);
70487049
names2 = getModificationNames(args);
7049-
names2_1 = Util.listMap1r(names2, string_append, ".");
7050-
names2_2 = Util.listMap1r(names2_1, string_append, name);
7050+
names2_1 = Util.listMap1r(names2, stringAppend, ".");
7051+
names2_2 = Util.listMap1r(names2_1, stringAppend, name);
70517052
names = getModificationNames(rest);
70527053
res = listAppend(names2_2, names);
70537054
then
@@ -7647,7 +7648,7 @@ algorithm
76477648
list<Absyn.ElementItem> elements_1,elements;
76487649
Absyn.Path old_comp,new_comp;
76497650
Absyn.ClassPart a;
7650-
case ({},_,_,env) then ({},false); /* the old name for the component signal if something in class have been changed rule Absyn.path_string(old_comp) => old_str & Absyn.path_string(new_comp) => new_str & Util.string_append_list({old_str,\" => \", new_str,\"\\n\"}) => print_str & print print_str & int_eq(1,2) => true --------- rename_class_in_parts(_,old_comp,new_comp,env) => ({},false) */
7651+
case ({},_,_,env) then ({},false); /* the old name for the component signal if something in class have been changed rule */
76517652
case ((Absyn.PUBLIC(contents = elements) :: res),old_comp,new_comp,env)
76527653
equation
76537654
(res_1,changed1) = renameClassInParts(res, old_comp, new_comp, env);
@@ -7741,13 +7742,13 @@ algorithm
77417742
Option<Absyn.Comment> cmt;
77427743
list<Absyn.ElementArg> elargs;
77437744

7744-
case (Absyn.COMPONENTS(attributes = a,typeSpec = Absyn.TPATH(path_1,x),components = comp_items),old_comp,new_comp,env) /* the old name for the component signal if something in class have been changed rule Absyn.path_string(old_comp) => old_str & Absyn.path_string(new_comp) => new_str & Util.string_append_list({old_str,\" ==> \", new_str,\"\\n\"}) => print_str & print print_str & int_eq(1,2) => true --------- rename_class_in_element_spec(A,old_comp,new_comp,env) => (A,false) */
7745+
case (Absyn.COMPONENTS(attributes = a,typeSpec = Absyn.TPATH(path_1,x),components = comp_items),old_comp,new_comp,env) /* the old name for the component signal if something in class have been changed rule */
77457746
equation
77467747
(cache,SCode.CLASS(name=id),cenv) = Lookup.lookupClass(Env.emptyCache(),env, path_1, false);
77477748
path_1 = Absyn.IDENT(id);
77487749
(_,path) = Inst.makeFullyQualified(cache, cenv, path_1);
77497750
true = ModUtil.pathEqual(path, old_comp);
7750-
new_path = changeLastIdent(path, new_comp) "& Absyn.path_string(path) => old_str & Absyn.path_string(new_comp) => new_str & Absyn.path_string(new_path) => new2_str & Util.string_append_list({old_str,\" =E=> \", new_str,\" \",new2_str ,\"\\n\"}) => print_str & print print_str &" ;
7751+
new_path = changeLastIdent(path, new_comp);
77517752
then
77527753
(Absyn.COMPONENTS(a,Absyn.TPATH(new_path,x),comp_items),true);
77537754
case (Absyn.EXTENDS(path = path_1,elementArg = elargs, annotationOpt=annOpt),old_comp,new_comp,env)
@@ -8554,7 +8555,7 @@ protected function getClassAttributes
85548555
input Absyn.Program p;
85558556
output String res_1;
85568557
Absyn.Path path;
8557-
String name,file,strPartial,strFinal,strEncapsulated,res,cmt,str_readonly,str_sline,str_scol,str_eline,str_ecol,res_1;
8558+
String name,file,strPartial,strFinal,strEncapsulated,res,cmt,str_readonly,str_sline,str_scol,str_eline,str_ecol;
85588559
Boolean partialPrefix,finalPrefix,encapsulatedPrefix,isReadOnly;
85598560
Absyn.Restriction restr;
85608561
Absyn.ClassDef cdef;
@@ -18101,7 +18102,7 @@ algorithm
1810118102
(topNamesStr, newLF, pAst); // loading
1810218103
case (f, lf, pAst, _)
1810318104
equation
18104-
failure(p1 = Parser.parse(f)); // failed to parse!
18105+
failure(_ = Parser.parse(f)); // failed to parse!
1810518106
then
1810618107
("error",lf,pAst); // return error
1810718108
end matchcontinue;
@@ -18158,7 +18159,7 @@ algorithm
1815818159
res := matchcontinue (ast,addFunctions)
1815918160
local
1816018161
list<Absyn.Class> classes;
18161-
String old, res;
18162+
String old;
1816218163
list<String> toPrint;
1816318164
case (ast,addFunctions)
1816418165
equation
@@ -18193,7 +18194,6 @@ algorithm
1819318194
list<Absyn.Class> rest;
1819418195
Absyn.Class class_;
1819518196
String str;
18196-
list<String> res;
1819718197
case ({},_) then {};
1819818198
case (class_::rest,addFunctions) equation
1819918199
str = getDefinitionsClass(class_, addFunctions);
@@ -18212,7 +18212,7 @@ algorithm
1821218212
list<Absyn.Class> rest;
1821318213
list<Absyn.ClassPart> parts;
1821418214
String ident, baseIdent, tyStr;
18215-
list<String> enumList, res;
18215+
list<String> enumList,strs;
1821618216
Absyn.TypeSpec ts;
1821718217
Absyn.ElementAttributes attr;
1821818218
list<Absyn.EnumLiteral> el;
@@ -18223,40 +18223,40 @@ algorithm
1822318223
case (Absyn.CLASS(name = ident, body = Absyn.PARTS(classParts = parts), restriction = Absyn.R_PACKAGE()),addFunctions)
1822418224
equation
1822518225
ident = "(package " +& ident;
18226-
res = getDefinitionParts(parts, addFunctions);
18227-
res = ident :: res;
18228-
then Util.stringDelimitList(res, "\n");
18226+
strs = getDefinitionParts(parts, addFunctions);
18227+
strs = ident :: strs;
18228+
then Util.stringDelimitList(strs, "\n");
1822918229
case (Absyn.CLASS(partialPrefix = true, name = ident, body = Absyn.PARTS(classParts = parts), restriction = Absyn.R_FUNCTION()),_)
1823018230
equation
18231-
res = {"(partial function", ident, ")"};
18232-
then Util.stringDelimitList(res, " ");
18231+
strs = {"(partial function", ident, ")"};
18232+
then Util.stringDelimitList(strs, " ");
1823318233
case (Absyn.CLASS(partialPrefix = false, name = ident, body = Absyn.PARTS(classParts = parts), restriction = Absyn.R_FUNCTION()),true)
1823418234
equation
18235-
res = getDefinitionParts(parts, true);
18236-
res = "(function" :: ident :: res;
18237-
then Util.stringDelimitList(res, " ");
18235+
strs = getDefinitionParts(parts, true);
18236+
strs = "(function" :: ident :: strs;
18237+
then Util.stringDelimitList(strs, " ");
1823818238
case (Absyn.CLASS(name = ident, body = Absyn.PARTS(classParts = parts), restriction = Absyn.R_UNIONTYPE()),_)
1823918239
equation
18240-
res = {"(uniontype", ident, ")"};
18241-
then Util.stringDelimitList(res, " ");
18240+
strs = {"(uniontype", ident, ")"};
18241+
then Util.stringDelimitList(strs, " ");
1824218242
case (Absyn.CLASS(name = ident, body = Absyn.PARTS(classParts = parts), restriction = Absyn.R_RECORD()),_)
1824318243
equation
18244-
res = getDefinitionParts(parts, false);
18245-
res = "(record" :: ident :: res;
18246-
then Util.stringDelimitList(res, " ");
18244+
strs = getDefinitionParts(parts, false);
18245+
strs = "(record" :: ident :: strs;
18246+
then Util.stringDelimitList(strs, " ");
1824718247
case (Absyn.CLASS(name = ident, body = Absyn.PARTS(classParts = parts), restriction = Absyn.R_METARECORD(name = path, index = index)),_)
1824818248
equation
1824918249
indexArg = intString(index);
1825018250
pathArg = Absyn.pathLastIdent(path);
18251-
res = getDefinitionParts(parts, false);
18252-
res = "(metarecord" :: ident :: indexArg :: pathArg :: res;
18253-
then Util.stringDelimitList(res, " ");
18251+
strs = getDefinitionParts(parts, false);
18252+
strs = "(metarecord" :: ident :: indexArg :: pathArg :: strs;
18253+
then Util.stringDelimitList(strs, " ");
1825418254
case (Absyn.CLASS(name = ident, body = Absyn.DERIVED(typeSpec = ts, attributes = attr)),_)
1825518255
equation
1825618256
numDim = getDefinitionDimensions(ts,attr);
1825718257
tyStr = Util.if_(numDim == 0, "", "[" +& intString(numDim)) +& getDefinitionTypeSpecPathString(ts);
18258-
res = {"(type", ident, tyStr, ")"};
18259-
then Util.stringDelimitList(res, " ");
18258+
strs = {"(type", ident, tyStr, ")"};
18259+
then Util.stringDelimitList(strs, " ");
1826018260
// Do enumerations really work properly in OMC?
1826118261
//case Absyn.CLASS(name = ident, body = Absyn.ENUMERATION(enumLiterals = Absyn.ENUMLITERALS(el))) equation
1826218262
// enumList = Util.listMap(el, getEnumerationLiterals);
@@ -18294,8 +18294,6 @@ protected function getDefinitionPathString
1829418294
output String out;
1829518295
algorithm
1829618296
out := matchcontinue (path)
18297-
local
18298-
Absyn.Path path;
1829918297
// Doesn't work because we only know the AST after parsing... case (Absyn.FULLYQUALIFIED(path)) then "#" +& Absyn.pathString(path);
1830018298
// Thus, scope/lookup is done by the application recieving this information
1830118299
case path then Absyn.pathString(path);
@@ -18370,7 +18368,7 @@ algorithm
1837018368
Absyn.TypeSpec ts;
1837118369
Absyn.Variability variability;
1837218370
Absyn.ElementAttributes attr;
18373-
list<String> res,res2;
18371+
list<String> res2;
1837418372

1837518373
case ({},_,_) then {};
1837618374
case (Absyn.ELEMENTITEM(Absyn.ELEMENT(specification = Absyn.CLASSDEF(replaceable_ = false, class_ = class_)))::rest,addFunctions,isPublic)
@@ -18427,7 +18425,6 @@ algorithm
1842718425
local
1842818426
list<Absyn.ComponentItem> rest;
1842918427
String ident;
18430-
list<String> res;
1843118428
list<Absyn.Subscript> l;
1843218429
Integer sumDim;
1843318430

@@ -18695,7 +18692,7 @@ algorithm
1869518692
Absyn.ElementItem current, tmp;
1869618693
list<Absyn.ElementItem> rest;//, res_list, list2;
1869718694
Absyn.Program p;
18698-
case ({}, p) /* Util.string_append_list({\"{ elementvisibility=\", visibility_str,\" }\"}) => res */
18695+
case ({}, p)
1869918696
equation
1870018697
s1 = "";
1870118698
res_list = Util.listCreate(s1);

Compiler/SimCode.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6774,7 +6774,7 @@ protected function getCalledFunctionsInFunctions
67746774
algorithm
67756775
res := matchcontinue(paths,accumulated,funcs)
67766776
local
6777-
list<Absyn.Path> res,acc,rest;
6777+
list<Absyn.Path> acc,rest;
67786778
Absyn.Path path;
67796779
case ({},accumulated,funcs) then accumulated;
67806780
case (path::rest,accumulated,funcs)

0 commit comments

Comments
 (0)