@@ -1000,46 +1000,6 @@ algorithm
1000
1000
then
1001
1001
fail();
1002
1002
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
- */
1043
1003
/* Instantiation of a class. Create new scope and call instClassIn.
1044
1004
* Then generate equations from connects.
1045
1005
*/
@@ -1133,7 +1093,10 @@ algorithm
1133
1093
end matchcontinue;
1134
1094
end reportUnitConsistency;
1135
1095
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
+ "
1137
1100
input Exp.ComponentRef connectorRef;
1138
1101
output Exp.ComponentRef prefixCon;
1139
1102
algorithm prefixCon := matchcontinue(connectorRef)
@@ -1159,7 +1122,12 @@ algorithm prefixCon := matchcontinue(connectorRef)
1159
1122
end matchcontinue;
1160
1123
end extractConnectorPrefix;
1161
1124
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
+ "
1163
1131
input list<DAE.Element> zeroEqns;
1164
1132
input list<DAE.Element> fullDae;
1165
1133
output list<DAE.Element> outdae;
@@ -1206,7 +1174,10 @@ algorithm outdae := matchcontinue(zeroEqns,fullDae)
1206
1174
end matchcontinue;
1207
1175
end updateTypesInUnconnectedConnectors;
1208
1176
1209
- protected function updateTypesInUnconnectedConnectors2 ""
1177
+ protected function updateTypesInUnconnectedConnectors2 "
1178
+ Author: BZ, 2009-09
1179
+ Helper function for updateTypesInUnconnectedConnectors
1180
+ "
1210
1181
input Exp.ComponentRef inCr;
1211
1182
input list<DAE.Element> elems;
1212
1183
output list<DAE.Element> outelems;
@@ -1216,24 +1187,18 @@ algorithm outelems := matchcontinue(inCr, elems)
1216
1187
DAE.Element elem,elem2;
1217
1188
case(cr1,{})
1218
1189
equation
1219
- //print("error updateTypesInUnconnectedConnectors2 updateTypesInUnconnectedConnectors2 \n");
1190
+ //print("error updateTypesInUnconnectedConnectors2\n");
1220
1191
//print(" no match for: " +& Exp.printComponentRefStr(cr1) +& "\n");
1221
1192
then
1222
1193
{};
1223
1194
case(inCr,(elem2 as DAE.VAR(componentRef = cr2))::elems)
1224
1195
equation
1225
- //true = Exp.crefEqual(cr1,cr2);
1226
1196
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);
1230
1199
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);
1237
1202
then
1238
1203
elem::elems;
1239
1204
case(cr1,elem2::elems)
@@ -1245,7 +1210,10 @@ algorithm outelems := matchcontinue(inCr, elems)
1245
1210
end matchcontinue;
1246
1211
end updateTypesInUnconnectedConnectors2;
1247
1212
1248
- protected function updateCrefTypesWithConnectorPrefix ""
1213
+ protected function updateCrefTypesWithConnectorPrefix "
1214
+ Author: BZ, 2009-09
1215
+ Helper function for updateTypesInUnconnectedConnectors2
1216
+ "
1249
1217
input Exp.ComponentRef cr1,cr2;
1250
1218
output Exp.ComponentRef outCref;
1251
1219
algorithm outCref := matchcontinue(cr1,cr2)
@@ -5004,8 +4972,7 @@ algorithm
5004
4972
end matchcontinue;
5005
4973
end memberCrefs;
5006
4974
5007
- public function instElement
5008
- "function: instElement
4975
+ public function instElement "
5009
4976
This monster function instantiates an element of a class
5010
4977
definition. An element is either a class definition, a variable,
5011
4978
or an extends clause.
@@ -14546,7 +14513,7 @@ algorithm
14546
14513
cl2 = removeCrefFromCrefs(cl1, c1);
14547
14514
(cache,c,cenv) = Lookup.lookupClass(cache,env, sty, true);
14548
14515
(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);
14550
14517
new_var = Types.VAR(n,Types.ATTR(flowPrefix,streamPrefix,acc,param,dir,io),prot,ty,Types.UNBOUND());
14551
14518
env = Env.updateFrameV(env, new_var, Env.VAR_TYPED(), compenv) ;
14552
14519
then
0 commit comments