Skip to content

Commit

Permalink
- Added missing 'each' prefixes to more models
Browse files Browse the repository at this point in the history
- Made DAE.TYPED and DAE.UNTYPED modifications contain Absyn.Info and started using that whenever possible
  - This makes error-messages appear at the source of the modification instead of at the component being modified, which is better since it is easier to look up the component than to figure where the #!#&@ the modification came from


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12988 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Sep 20, 2012
1 parent 6b80f77 commit 2781393
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 130 deletions.
2 changes: 2 additions & 0 deletions Compiler/FrontEnd/DAE.mo
Expand Up @@ -1093,10 +1093,12 @@ uniontype EqMod "To generate the correct set of equations, the translator has to
Option<Values.Value> modifierAsValue "modifierAsValue ; modifier as Value option" ;
Properties properties "properties" ;
Option<Absyn.Exp> modifierAsAbsynExp "keep the untyped modifier as an absyn expression for modification comparison";
Absyn.Info info;
end TYPED;

record UNTYPED
Absyn.Exp exp;
Absyn.Info info;
end UNTYPED;

end EqMod;
Expand Down
116 changes: 59 additions & 57 deletions Compiler/FrontEnd/Inst.mo

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Compiler/FrontEnd/Lookup.mo
Expand Up @@ -2027,7 +2027,7 @@ algorithm
case (cache,env,cl as SCode.CLASS(name=id,info=info))
equation
(cache,env,funcelts,elts) = buildRecordConstructorClass2(cache,env,cl,DAE.NOMOD());
reselt = buildRecordConstructorResultElt(funcelts,id,env);
reselt = buildRecordConstructorResultElt(funcelts,id,env,info);
cl = SCode.CLASS(id,SCode.defaultPrefixes,SCode.NOT_ENCAPSULATED(),SCode.NOT_PARTIAL(),SCode.R_FUNCTION(SCode.FR_RECORD_CONSTRUCTOR()),SCode.PARTS((reselt :: funcelts),{},{},{},{},{},{},NONE(),{},NONE()),info);
then
(cache,env,cl);
Expand Down Expand Up @@ -2233,6 +2233,7 @@ protected function buildRecordConstructorResultElt
input list<SCode.Element> elts;
input SCode.Ident id;
input Env.Env env;
input Absyn.Info info;
output SCode.Element outElement;
annotation(__OpenModelica_EarlyInline = true);
algorithm
Expand All @@ -2243,7 +2244,7 @@ algorithm
outElement := SCode.COMPONENT("result",SCode.defaultPrefixes,
SCode.ATTR({},SCode.POTENTIAL(),SCode.NON_PARALLEL(),SCode.VAR(),Absyn.OUTPUT()),
Absyn.TPATH(Absyn.IDENT(id),NONE()),
SCode.NOMOD(),NONE(),NONE(),Absyn.dummyInfo);
SCode.NOMOD(),NONE(),NONE(),info);
end buildRecordConstructorResultElt;

public function isInBuiltinEnv
Expand Down
120 changes: 62 additions & 58 deletions Compiler/FrontEnd/Mod.mo

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions Compiler/FrontEnd/SCodeUtil.mo
Expand Up @@ -1444,7 +1444,7 @@ algorithm
setHasStreamConnectorsHandler(st); // signal the external flag that we have stream connectors
xs_1 = translateElementspec(cc, finalPrefix, io, repl, vis,
Absyn.COMPONENTS(attr,t,xs), info);
mod = translateMod(m, SCode.NOT_FINAL(), SCode.NOT_EACH(), Absyn.dummyInfo);
mod = translateMod(m, SCode.NOT_FINAL(), SCode.NOT_EACH(), info);
prl1 = translateParallelism(parallelism);
var1 = translateVariability(variability);
// PR. This adds the arraydimension that may be specified together with the type of the component.
Expand Down Expand Up @@ -1957,7 +1957,7 @@ algorithm
componentRef = cref, modification = mod, info = info) :: rest_args, _)
equation
smod = translateMod(mod, SCode.boolFinal(fp), translateEach(ep), info);
sub = translateSub(cref, smod);
sub = translateSub(cref, smod, info);
then
translateArgs_tail(rest_args, sub :: inAccumSubs);

Expand All @@ -1984,9 +1984,10 @@ protected function translateSub
of modifications into a number of nested SCode.SUBMOD."
input Absyn.ComponentRef inComponentRef;
input SCode.Mod inMod;
input Absyn.Info info;
output SCode.SubMod outSubMod;
algorithm
outSubMod := match (inComponentRef,inMod)
outSubMod := match (inComponentRef,inMod,info)
local
String c_str,mod_str,i;
Absyn.ComponentRef c,path;
Expand All @@ -1995,30 +1996,30 @@ algorithm
SCode.SubMod sub;

// First some rules to prevent bad modifications
case ((c as Absyn.CREF_IDENT(subscripts = (_ :: _))),(mod as SCode.MOD(subModLst = (_ :: _))))
case ((c as Absyn.CREF_IDENT(subscripts = (_ :: _))),(mod as SCode.MOD(subModLst = (_ :: _))),info)
equation
c_str = Dump.printComponentRefStr(c);
mod_str = SCodeDump.printModStr(mod);
Error.addMessage(Error.ILLEGAL_MODIFICATION, {mod_str,c_str});
Error.addSourceMessage(Error.ILLEGAL_MODIFICATION, {mod_str,c_str}, info);
then
fail();
case ((c as Absyn.CREF_QUAL(subscripts = (_ :: _))),(mod as SCode.MOD(subModLst = (_ :: _))))
case ((c as Absyn.CREF_QUAL(subscripts = (_ :: _))),(mod as SCode.MOD(subModLst = (_ :: _))),info)
equation
c_str = Dump.printComponentRefStr(c);
mod_str = SCodeDump.printModStr(mod);
Error.addMessage(Error.ILLEGAL_MODIFICATION, {mod_str,c_str});
Error.addSourceMessage(Error.ILLEGAL_MODIFICATION, {mod_str,c_str}, info);
then
fail();
// Then the normal rules
case (Absyn.CREF_IDENT(name = i,subscripts = ss),mod)
case (Absyn.CREF_IDENT(name = i,subscripts = ss),mod,_)
equation
mod_1 = translateSubSub(ss, mod);
then
SCode.NAMEMOD(i,mod_1);
case (Absyn.CREF_QUAL(name = i,subscripts = ss,componentRef = path),mod)
case (Absyn.CREF_QUAL(name = i,subscripts = ss,componentRef = path),mod,info)
equation
sub = translateSub(path, mod);
mod = SCode.MOD(SCode.NOT_FINAL(),SCode.NOT_EACH(),{sub},NONE(),Absyn.dummyInfo);
sub = translateSub(path, mod, info);
mod = SCode.MOD(SCode.NOT_FINAL(),SCode.NOT_EACH(),{sub},NONE(),info);
mod_1 = translateSubSub(ss, mod);
then
SCode.NAMEMOD(i,mod_1);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Types.mo
Expand Up @@ -1883,7 +1883,7 @@ algorithm
then
str;

case(DAE.UNTYPED(e2))
case(DAE.UNTYPED(exp=e2))
equation
str = Dump.printExpStr(e2);
then str;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Util/Debug.mo
Expand Up @@ -559,7 +559,7 @@ public function bcallret3_2
replaceable type Type_c subtypeof Any;
replaceable type Type_d subtypeof Any;
replaceable type Type_e subtypeof Any;
annotation(__OpenModelica_EarlyInline = true);
// Apparently cannot inline stuff with function pointers... annotation(__OpenModelica_EarlyInline = true);
algorithm
(res1,res2) := match (flag,func,arg1,arg2,arg3,default1,default2)
case (true,_,_,_,_,_,_)
Expand Down

0 comments on commit 2781393

Please sign in to comment.