Skip to content

Commit f82316e

Browse files
committed
- not working yet, reverting.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14256 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 228d02f commit f82316e

File tree

2 files changed

+35
-116
lines changed

2 files changed

+35
-116
lines changed

Compiler/FrontEnd/Inst.mo

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8220,27 +8220,22 @@ algorithm
82208220
// e.g. Point p => Real p[3]; These must be handled separately since even if they do not
82218221
// appear to be an array, they can. Therefore we need to collect
82228222
// the full dimensionality and call instVar2
8223-
case (cache,env,ih,store,ci_state,mod,pre,n,(cl as SCode.CLASS(name = id)),attr as SCode.ATTR(variability = vt),pf,_,idxs,inst_dims,impl,comment,_,graph,csets)
8223+
case (cache,env,ih,store,ci_state,mod,pre,n,(cl as SCode.CLASS(name = id)),attr as SCode.ATTR(variability = vt),pf,dims,idxs,inst_dims,impl,comment,_,graph,csets)
82248224
equation
82258225
// Collect dimensions
82268226
p1 = Absyn.IDENT(n);
82278227
p1 = PrefixUtil.prefixPath(p1,pre);
82288228
str = Absyn.pathString(p1);
82298229
Error.updateCurrentComponent(str,info);
82308230
(cache, dims as (_ :: _),cl,type_mods) = getUsertypeDimensions(cache, env, ih, mod, pre, cl, inst_dims, impl);
8231-
8232-
type_mods = Mod.addEachIfNeeded(type_mods, dims);
8233-
mod = Mod.addEachIfNeeded(mod, inDimensionLst);
8234-
8235-
dims = listAppend(inDimensionLst, dims);
82368231
mod = Mod.merge(mod, type_mods, env, pre);
82378232

82388233
attr = propagateClassPrefix(attr,pre);
82398234
(cache,compenv,ih,store,dae,csets,ty,graph) =
82408235
instVar2(cache,env,ih,store, ci_state, mod, pre, n, cl, attr,
82418236
pf, dims, idxs, inst_dims, impl, comment, info, graph, csets);
82428237
source = DAEUtil.createElementSource(info, Env.getEnvPath(env), PrefixUtil.prefixToCrefOpt(pre), NONE(), NONE());
8243-
(cache,dae) = addArrayVarEquation(cache, env, ih, ci_state, dae, ty, mod, NFInstUtil.toConst(vt), pre, n, source);
8238+
(cache,dae) = addArrayVarEquation(cache,env,ih,ci_state, dae, ty, mod, NFInstUtil.toConst(vt), pre, n, source);
82448239
cache = addRecordConstructorFunction(cache,Types.arrayElementType(ty));
82458240
Error.updateCurrentComponent("",Absyn.dummyInfo);
82468241
then
@@ -9192,52 +9187,54 @@ algorithm
91929187
list<SCode.Element> els;
91939188
SCode.Path path;
91949189

9195-
case (cache,_,_,_,_,cl as SCode.CLASS(name = "Real"),_,_) then (cache,{},cl,DAE.NOMOD());
9190+
case (cache,_,_,_,_,cl as SCode.CLASS(name = "Real"),_,_) then (cache,{},cl,DAE.NOMOD()); /* impl */
91969191
case (cache,_,_,_,_,cl as SCode.CLASS(name = "Integer"),_,_) then (cache,{},cl,DAE.NOMOD());
91979192
case (cache,_,_,_,_,cl as SCode.CLASS(name = "String"),_,_) then (cache,{},cl,DAE.NOMOD());
91989193
case (cache,_,_,_,_,cl as SCode.CLASS(name = "Boolean"),_,_) then (cache,{},cl,DAE.NOMOD());
91999194

92009195
case (cache,_,_,_,_,cl as SCode.CLASS(restriction = SCode.R_RECORD(),
92019196
classDef = SCode.PARTS(elementLst = _)),_,_) then (cache,{},cl,DAE.NOMOD());
92029197

9203-
//------------------------
9204-
// MetaModelica extension
9205-
case (cache, env, ih, _, pre, cl as SCode.CLASS(name = id, info=info,
9198+
/*------------------------*/
9199+
/* MetaModelica extension */
9200+
case (cache,env,ih,_,pre,cl as SCode.CLASS(name = id, info=info,
92069201
classDef = SCode.DERIVED(Absyn.TCOMPLEX(Absyn.IDENT(_),_,arrayDim = ad),
92079202
modifications = mod)),
9208-
dims, impl)
9203+
dims,impl)
92099204
equation
9210-
true = Config.acceptMetaModelicaGrammar();
9205+
true=Config.acceptMetaModelicaGrammar();
92119206
owncref = Absyn.CREF_IDENT(id,{});
92129207
ad_1 = getOptionArraydim(ad);
9213-
(cache,dim1) = elabArraydim(cache, env, owncref, Absyn.IDENT("Integer"), ad_1, NONE(), impl, NONE(), true, false, pre, info, dims);
9208+
// Absyn.IDENT("Integer") used as a dummie
9209+
(cache,dim1) = elabArraydim(cache,env, owncref, Absyn.IDENT("Integer"), ad_1,NONE(), impl,NONE(),true, false,pre,info,dims);
92149210
then
9215-
(cache, dim1, cl, DAE.NOMOD());
9211+
(cache,dim1,cl,DAE.NOMOD());
92169212

92179213
// Partial function definitions with no output - stefan
9218-
case (cache, env, ih, _, _,
9214+
case (cache,env,ih,_,_,
92199215
cl as SCode.CLASS(name = id,restriction = SCode.R_FUNCTION(SCode.FR_NORMAL_FUNCTION()),
92209216
partialPrefix = SCode.PARTIAL()),_,_)
92219217
then
92229218
(cache,{},cl,DAE.NOMOD());
92239219

9224-
case (cache, env, ih, _, _,
9220+
case (cache,env,ih,_,_,
92259221
SCode.CLASS(name = id,info=info,restriction = SCode.R_FUNCTION(SCode.FR_NORMAL_FUNCTION()),
92269222
partialPrefix = SCode.NOT_PARTIAL()),_,_)
92279223
equation
92289224
Error.addSourceMessage(Error.META_FUNCTION_TYPE_NO_PARTIAL_PREFIX, {id}, info);
92299225
then fail();
92309226

9231-
// MetaModelica Uniontype. Added 2009-05-11 sjoelund
9232-
case (cache, env, ih, _, _,
9227+
// MetaModelica Uniontype. Added 2009-05-11 sjoelund
9228+
case (cache,env,ih,_,_,
92339229
cl as SCode.CLASS(name = id,restriction = SCode.R_UNIONTYPE()),_,_)
9234-
then (cache, {}, cl, DAE.NOMOD());
9230+
then (cache,{},cl,DAE.NOMOD());
9231+
/*----------------------*/
92359232

9236-
// Derived classes with restriction type, e.g. type Point = Real[3];
9237-
case (cache, env, ih, mods, pre,
9233+
/* Derived classes with restriction type, e.g. type Point = Real[3]; */
9234+
case (cache,env,ih,mods,pre,
92389235
SCode.CLASS(name = id,restriction = SCode.R_TYPE(),info=info,
92399236
classDef = SCode.DERIVED(Absyn.TPATH(path = cn, arrayDim = ad),modifications = mod)),
9240-
dims, impl)
9237+
dims,impl)
92419238
equation
92429239
(cache,cl,cenv) = Lookup.lookupClass(cache,env, cn, true);
92439240
owncref = Absyn.CREF_IDENT(id,{});
@@ -9250,37 +9247,29 @@ algorithm
92509247
mods_2 = Mod.merge(mods, mod_1, env, pre);
92519248
eq = Mod.modEquation(mods_2);
92529249
mods_3 = Mod.lookupCompModification(mods_2, id);
9253-
(cache,dim1,cl,type_mods) = getUsertypeDimensions(cache, cenv, ih, mods_3, pre, cl, dims, impl);
9254-
(cache,dim2) = elabArraydim(cache, env, owncref, cn, ad_1, eq, impl, NONE(), true, false, pre, info, dims);
9255-
9256-
type_mods = Mod.addEachIfNeeded(type_mods, dim1);
9257-
// do not add each to mod_1, it should have it already!
9258-
// mod_1 = Mod.addEachIfNeeded(mod_1, dim2);
9259-
9260-
res = listAppend(dim2, dim1);
9250+
(cache,dim1,cl,type_mods) = getUsertypeDimensions(cache,cenv,ih, mods_3, pre, cl, dims, impl);
92619251
type_mods = Mod.merge(mod_1, type_mods, env, pre);
9252+
(cache,dim2) = elabArraydim(cache,env, owncref, cn, ad_1, eq, impl,NONE(),true, false,pre,info,dims);
9253+
res = listAppend(dim2, dim1);
92629254
then
92639255
(cache,res,cl,type_mods);
92649256

9265-
// extended classes type Y = Real[3]; class X extends Y;
9266-
case (cache, env, ih, mods, pre,
9267-
SCode.CLASS(name = id, restriction = _,
9257+
/* extended classes type Y = Real[3]; class X extends Y; */
9258+
case (cache,env,ih,mods,pre,
9259+
SCode.CLASS(name = id,restriction = _,
92689260
classDef = SCode.PARTS(elementLst=els,
9269-
normalEquationLst = {},
9270-
initialEquationLst = {},
9271-
normalAlgorithmLst = {},
9272-
initialAlgorithmLst = {},
9273-
externalDecl = _)),
9274-
dims, impl)
9261+
normalEquationLst={},
9262+
initialEquationLst={},
9263+
normalAlgorithmLst={},
9264+
initialAlgorithmLst={},
9265+
externalDecl=_)),
9266+
dims,impl)
92759267
equation
92769268
(_,_,{SCode.EXTENDS(path, _, mod,_, info)},{}) = splitElts(els); // ONLY ONE extends!
92779269
(cache,mod_1) = Mod.elabModForBasicType(cache, env, ih, pre, mod, impl, info);
92789270
mods_2 = Mod.merge(mods, mod_1, env, pre);
92799271
(cache,cl,cenv) = Lookup.lookupClass(cache,env, path, false);
92809272
(cache,res,cl,type_mods) = getUsertypeDimensions(cache,env,ih,mods_2,pre,cl,{},impl);
9281-
9282-
type_mods = Mod.addEachIfNeeded(type_mods, res);
9283-
92849273
type_mods = Mod.merge(mods_2, type_mods, env, pre);
92859274
then
92869275
(cache,res,cl,type_mods);

Compiler/FrontEnd/Mod.mo

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ algorithm
591591
end updateMod;
592592

593593
protected function updateSubmods ""
594-
input Env.Cache inCache;
594+
input Env.Cache inCache;
595595
input Env.Env inEnv;
596596
input InstanceHierarchy inIH;
597597
input Prefix.Prefix inPrefix;
@@ -715,7 +715,7 @@ end elabUntypedMod;
715715
protected function elabSubmods
716716
"function: elabSubmods
717717
This function helps elabMod by recusively elaborating on a list of submodifications."
718-
input Env.Cache inCache;
718+
input Env.Cache inCache;
719719
input Env.Env inEnv;
720720
input InstanceHierarchy inIH;
721721
input Prefix.Prefix inPrefix;
@@ -752,7 +752,7 @@ protected function elabSubmod
752752
"function: elabSubmod
753753
This function elaborates on a submodification, turning an
754754
SCode.SubMod into one or more DAE.SubMod."
755-
input Env.Cache inCache;
755+
input Env.Cache inCache;
756756
input Env.Env inEnv;
757757
input InstanceHierarchy inIH;
758758
input Prefix.Prefix inPrefix;
@@ -3538,75 +3538,5 @@ algorithm outsubs := match(inSubs,componentName)
35383538
end match;
35393539
end removeModInSubs;
35403540

3541-
public function addEachIfNeeded
3542-
"This function adds each to the mods
3543-
if the dimensions are not empty."
3544-
input DAE.Mod inMod;
3545-
input DAE.Dimensions inDimensions;
3546-
output DAE.Mod outMod;
3547-
algorithm
3548-
outMod := matchcontinue (inMod, inDimensions)
3549-
local
3550-
SCode.Final finalPrefix;
3551-
list<tuple<SCode.Element, DAE.Mod>> elist;
3552-
SCode.Each eachPrefix;
3553-
list<DAE.SubMod> subs;
3554-
Option<DAE.EqMod> eq;
3555-
3556-
case (_, {}) then inMod;
3557-
3558-
case (DAE.NOMOD(), _)
3559-
then DAE.NOMOD();
3560-
3561-
case (DAE.REDECL(finalPrefix,eachPrefix,elist), _)
3562-
then
3563-
DAE.REDECL(finalPrefix,SCode.EACH(),elist);
3564-
3565-
case (DAE.MOD(finalPrefix,eachPrefix,subs,eq), _)
3566-
equation
3567-
subs = addEachToSubsIfNeeded(subs, inDimensions);
3568-
then
3569-
DAE.MOD(finalPrefix,SCode.EACH(),subs,eq);
3570-
3571-
case(_, _)
3572-
equation
3573-
print("Mod.addEachIfNeeded failed on: " +& printModStr(inMod) +& "\n");
3574-
then
3575-
fail();
3576-
3577-
end matchcontinue;
3578-
end addEachIfNeeded;
3579-
3580-
public function addEachToSubsIfNeeded
3581-
input list<DAE.SubMod> inSubMods;
3582-
input DAE.Dimensions inDimensions;
3583-
output list<DAE.SubMod> outSubMods;
3584-
algorithm
3585-
outSubMods := matchcontinue(inSubMods, inDimensions)
3586-
local
3587-
list<DAE.SubMod> rest;
3588-
DAE.Mod m;
3589-
String id;
3590-
list<Integer> idxs;
3591-
3592-
case ({}, _) then {};
3593-
3594-
case (DAE.NAMEMOD(id, m)::rest, _)
3595-
equation
3596-
m = addEachIfNeeded(m, inDimensions);
3597-
rest = addEachToSubsIfNeeded(rest, inDimensions);
3598-
then
3599-
DAE.NAMEMOD(id, m)::rest;
3600-
3601-
case (DAE.IDXMOD(idxs, m)::rest, _)
3602-
equation
3603-
m = addEachIfNeeded(m, inDimensions);
3604-
rest = addEachToSubsIfNeeded(rest, inDimensions);
3605-
then
3606-
DAE.IDXMOD(idxs, m)::rest;
3607-
3608-
end matchcontinue;
3609-
end addEachToSubsIfNeeded;
3610-
36113541
end Mod;
36123542

0 commit comments

Comments
 (0)