Skip to content

Commit 8d349db

Browse files
committed
- latest modifications from MathCoreOSMC branch
Revision: 4303 Author: bjozac Date: 11:57:25, den 5 oktober 2009 Message: Fixed bug with type instantiation of arrays/matrices. ---- Modified : /branches/MathCoreOSMC/Compiler/Inst.mo git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/OpenModelica1.5.0@4304 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 41f29df commit 8d349db

File tree

1 file changed

+25
-58
lines changed

1 file changed

+25
-58
lines changed

Compiler/Inst.mo

Lines changed: 25 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,46 +1000,6 @@ algorithm
10001000
then
10011001
fail();
10021002

1003-
1004-
/* TEMP DUMMY **/
1005-
/*
1006-
case (cache,env,store,mod,pre,csets,
1007-
(c as SCode.CLASS(name = n,encapsulatedPrefix = encflag,restriction = r, partialPrefix = false)),
1008-
inst_dims,impl,callscope,graph)
1009-
local
1010-
Types.EqualityConstraint equalityConstraint;
1011-
equation
1012-
//print("---- CLASS: "); print(n);print(" ----\n"); print(SCode.printClassStr(c)); //Print out the input SCode class
1013-
//str = SCode.printClassStr(c); print("------------------- CLASS instClass-----------------\n");print(str);print("\n===============================================\n");
1014-
env_1 = Env.openScope(env, encflag, SOME(n));
1015-
ci_state = ClassInf.start(r, n);
1016-
(cache,dae1,env_3,store,(csets_1 as Connect.SETS(_,crs,dc,oc)),ci_state_1,tys,bc_ty,oDA,equalityConstraint, graph)
1017-
= instClassIn(cache,env_1, store, mod, pre, csets, ci_state, c, false, inst_dims, impl, graph,NONE) ;
1018-
(cache,fq_class) = makeFullyQualified(cache,env, Absyn.IDENT(n));
1019-
//str = Absyn.pathString(fq_class); print("------------------- CLASS makeFullyQualified instClass-----------------\n");print(n); print(" ");print(str);print("\n===============================================\n");
1020-
dae1_1 = DAE.setComponentType(dae1, fq_class);
1021-
true = isTopCall(callscope);
1022-
callscope_1 = true;
1023-
//print(" Top scope?: " +& Util.boolString(callscope_1) +& " \n");
1024-
//print("in class ");print(n);print(" generate equations for sets:");print(Connect.printSetsStr(csets_1));print("\n");
1025-
checkMissingInnerDecl(dae1_1,callscope_1);
1026-
(csets_1,_) = retrieveOuterConnections(cache,env_3,pre,csets_1,callscope_1);
1027-
//print(" sets: \n" +& Connect.printSetsStr(csets_1) +& "\n");
1028-
//print("updated sets: ");print(Connect.printSetsStr(csets_1));print("\n");
1029-
dae2 = Connect.equations(csets_1,pre);
1030-
//print("connected: " +& DAE.dumpElementsStr(dae2));
1031-
1032-
(cache,dae3) = Connect.unconnectedFlowEquations(cache,csets_1, dae1, env_3, pre,callscope_1,{});
1033-
dae1_1 = updateTypesInUnconnectedConnectors(dae3,dae1_1);
1034-
//print("Unconnected: " +& DAE.dumpElementsStr(dae3));
1035-
dae = Util.listFlatten({dae1_1,dae2,dae3});
1036-
//dae = updateTypesInUnconnectedConnectors(dae3,dae);
1037-
ty = mktype(fq_class, ci_state_1, tys, bc_ty, equalityConstraint) ;
1038-
//print("\n---- DAE ----\n"); DAE.printDAE(DAE.DAE(dae)); //Print out flat modelica
1039-
dae = renameUniqueVarsInTopScope(callscope_1,dae);
1040-
then
1041-
(cache,dae,env_3,store,Connect.SETS({},crs,dc,oc),ty,ci_state_1,oDA,graph);
1042-
*/
10431003
/* Instantiation of a class. Create new scope and call instClassIn.
10441004
* Then generate equations from connects.
10451005
*/
@@ -1133,7 +1093,10 @@ algorithm
11331093
end matchcontinue;
11341094
end reportUnitConsistency;
11351095

1136-
protected function extractConnectorPrefix ""
1096+
protected function extractConnectorPrefix "
1097+
Author: BZ, 2009-09
1098+
Extract the part before the conector ex: a.b.c.connector_d.e would return a.b.c
1099+
"
11371100
input Exp.ComponentRef connectorRef;
11381101
output Exp.ComponentRef prefixCon;
11391102
algorithm prefixCon := matchcontinue(connectorRef)
@@ -1159,7 +1122,12 @@ algorithm prefixCon := matchcontinue(connectorRef)
11591122
end matchcontinue;
11601123
end extractConnectorPrefix;
11611124

1162-
protected function updateTypesInUnconnectedConnectors ""
1125+
protected function updateTypesInUnconnectedConnectors "
1126+
Author: BZ, 2009-09
1127+
Given a set of zeroequations (unconnected flow variables) and the subset dae containing flow-variable declaration:
1128+
Set same type to variable as the equations have.
1129+
Note: This is a hack to readd the typing of the variables.
1130+
"
11631131
input list<DAE.Element> zeroEqns;
11641132
input list<DAE.Element> fullDae;
11651133
output list<DAE.Element> outdae;
@@ -1206,7 +1174,10 @@ algorithm outdae := matchcontinue(zeroEqns,fullDae)
12061174
end matchcontinue;
12071175
end updateTypesInUnconnectedConnectors;
12081176

1209-
protected function updateTypesInUnconnectedConnectors2 ""
1177+
protected function updateTypesInUnconnectedConnectors2 "
1178+
Author: BZ, 2009-09
1179+
Helper function for updateTypesInUnconnectedConnectors
1180+
"
12101181
input Exp.ComponentRef inCr;
12111182
input list<DAE.Element> elems;
12121183
output list<DAE.Element> outelems;
@@ -1216,24 +1187,18 @@ algorithm outelems := matchcontinue(inCr, elems)
12161187
DAE.Element elem,elem2;
12171188
case(cr1,{})
12181189
equation
1219-
//print("error updateTypesInUnconnectedConnectors2 updateTypesInUnconnectedConnectors2\n");
1190+
//print("error updateTypesInUnconnectedConnectors2\n");
12201191
//print(" no match for: " +& Exp.printComponentRefStr(cr1) +& "\n");
12211192
then
12221193
{};
12231194
case(inCr,(elem2 as DAE.VAR(componentRef = cr2))::elems)
12241195
equation
1225-
//true = Exp.crefEqual(cr1,cr2);
12261196
true = Exp.crefPrefixOf(inCr,cr2);
1227-
1228-
//print(" Found: " +& Exp.printComponentRefStr(cr2) +& "\n");
1229-
cr1 = updateCrefTypesWithConnectorPrefix(inCr,cr2);
1197+
//print(" Found: " +& Exp.printComponentRefStr(cr2) +& "\n");
1198+
cr1 = updateCrefTypesWithConnectorPrefix(inCr,cr2);
12301199
elem = DAE.replaceCrefInVar(cr1,elem2);
1231-
//print(" to repl\n");
1232-
//print(" replaced to: " );
1233-
//print(DAE.dump2str(DAE.DAE({elem})));
1234-
//print("\n");
1235-
1236-
elems = updateTypesInUnconnectedConnectors2(inCr, elems);
1200+
//print(" replaced to: " ); print(DAE.dump2str(DAE.DAE({elem}))); print("\n");
1201+
elems = updateTypesInUnconnectedConnectors2(inCr, elems);
12371202
then
12381203
elem::elems;
12391204
case(cr1,elem2::elems)
@@ -1245,7 +1210,10 @@ algorithm outelems := matchcontinue(inCr, elems)
12451210
end matchcontinue;
12461211
end updateTypesInUnconnectedConnectors2;
12471212

1248-
protected function updateCrefTypesWithConnectorPrefix ""
1213+
protected function updateCrefTypesWithConnectorPrefix "
1214+
Author: BZ, 2009-09
1215+
Helper function for updateTypesInUnconnectedConnectors2
1216+
"
12491217
input Exp.ComponentRef cr1,cr2;
12501218
output Exp.ComponentRef outCref;
12511219
algorithm outCref := matchcontinue(cr1,cr2)
@@ -5004,8 +4972,7 @@ algorithm
50044972
end matchcontinue;
50054973
end memberCrefs;
50064974

5007-
public function instElement
5008-
"function: instElement
4975+
public function instElement "
50094976
This monster function instantiates an element of a class
50104977
definition. An element is either a class definition, a variable,
50114978
or an extends clause.
@@ -14546,7 +14513,7 @@ algorithm
1454614513
cl2 = removeCrefFromCrefs(cl1, c1);
1454714514
(cache,c,cenv) = Lookup.lookupClass(cache,env, sty, true);
1454814515
(cache,dims) = elabArraydim(cache,cenv, c1, sty, ad, NONE, impl, NONE,true) ;
14549-
(cache,compenv,ih,store,_,_,ty,_) = instVar(cache,cenv,ih, store,state, Types.NOMOD(), pre, csets, n, c, attr, prot, dims, {}, inst_dims, impl, NONE ,io,finalPrefix,info,ConnectionGraph.EMPTY);
14516+
(cache,compenv,ih,store,_,_,ty,_) = instVar(cache,cenv,ih, store,state, Types.NOMOD(), pre, csets, n, c, attr, prot, dims, {}, inst_dims, true, NONE ,io,finalPrefix,info,ConnectionGraph.EMPTY);
1455014517
new_var = Types.VAR(n,Types.ATTR(flowPrefix,streamPrefix,acc,param,dir,io),prot,ty,Types.UNBOUND());
1455114518
env = Env.updateFrameV(env, new_var, Env.VAR_TYPED(), compenv) ;
1455214519
then

0 commit comments

Comments
 (0)