Skip to content

Commit

Permalink
Enable tracing the flattening operation (from SCode to DAE)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18772 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 24, 2014
1 parent 7f4f0b1 commit 90ea88b
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 95 deletions.
6 changes: 6 additions & 0 deletions Compiler/FrontEnd/ComponentReference.mo
Expand Up @@ -377,6 +377,12 @@ algorithm
e_1 = Expression.unelabExp(e);
then
(Absyn.SUBSCRIPT(e_1) :: xs_1);
case (DAE.WHOLE_NONEXP(exp = e) :: xs)
equation
xs_1 = unelabSubscripts(xs);
e_1 = Expression.unelabExp(e);
then
(Absyn.SUBSCRIPT(e_1) :: xs_1);
end match;
end unelabSubscripts;

Expand Down
6 changes: 5 additions & 1 deletion Compiler/FrontEnd/DAE.mo
Expand Up @@ -105,6 +105,10 @@ end ElementSource;
public constant ElementSource emptyElementSource = SOURCE(Absyn.dummyInfo,{},{},{},{},{},{});

public uniontype SymbolicOperation
record FLATTEN "From one equation/statement to a list of DAE elements (in case it is expanded)"
SCode.EEquation scode;
Option<Element> dae;
end FLATTEN;
record SIMPLIFY
EquationExp before;
EquationExp after;
Expand Down Expand Up @@ -1126,7 +1130,7 @@ uniontype EqMod "To generate the correct set of equations, the translator has to
Exp modifierAsExp "modifier as expression" ;
Option<Values.Value> modifierAsValue "modifier as Value option" ;
Properties properties "properties" ;
Option<Absyn.Exp> modifierAsAbsynExp "keep the untyped modifier as an absyn expression for modification comparison";
Absyn.Exp modifierAsAbsynExp "keep the untyped modifier as an absyn expression for modification comparison";
Absyn.Info info;
end TYPED;

Expand Down
26 changes: 26 additions & 0 deletions Compiler/FrontEnd/DAEUtil.mo
Expand Up @@ -6074,6 +6074,32 @@ algorithm
end match;
end addSymbolicTransformationDeriveLst;

public function addSymbolicTransformationFlattenedEqs
input DAE.ElementSource source;
input DAE.Element elt;
output DAE.ElementSource outSource;
algorithm
outSource := match (source,elt)
local
Absyn.Info info "the line and column numbers of the equations and algorithms this element came from";
list<Absyn.Path> typeLst "the absyn type of the element" ;
list<Absyn.Within> partOfLst "the models this element came from" ;
list<Option<DAE.ComponentRef>> instanceOptLst "the instance this element is part of" ;
list<Option<tuple<DAE.ComponentRef, DAE.ComponentRef>>> connectEquationOptLst "this element came from this connect" ;
list<DAE.SymbolicOperation> operations;
DAE.Exp h1,t1,t2;
list<SCode.Comment> comment;
SCode.EEquation scode;
list<DAE.Element> elts;
case (DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, typeLst, DAE.FLATTEN(scode,NONE())::operations,comment),_)
then DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, typeLst, DAE.FLATTEN(scode,SOME(elt))::operations,comment);
case (DAE.SOURCE(info=info),_)
equation
Error.addSourceMessage(Error.INTERNAL_ERROR, {"Tried to add the flattened elements to the list of operations, but did not find the SCode equation"}, info);
then fail();
end match;
end addSymbolicTransformationFlattenedEqs;

public function addSymbolicTransformationSubstitutionLst
input list<Boolean> add;
input DAE.ElementSource isource;
Expand Down
15 changes: 12 additions & 3 deletions Compiler/FrontEnd/InstBinding.mo
Expand Up @@ -535,11 +535,11 @@ public function instModEquation
input DAE.ComponentRef inComponentRef;
input DAE.Type inType;
input DAE.Mod inMod;
input DAE.ElementSource source "the origin of the element";
input DAE.ElementSource inSource "the origin of the element";
input Boolean inBoolean;
output DAE.DAElist outDae;
algorithm
outDae:= matchcontinue (inComponentRef,inType,inMod,source,inBoolean)
outDae:= matchcontinue (inComponentRef,inType,inMod,inSource,inBoolean)
local
DAE.Type t;
DAE.DAElist dae;
Expand All @@ -549,6 +549,11 @@ algorithm
DAE.Exp e,lhs;
DAE.Properties prop2;
Boolean impl;
Absyn.Exp aexp1,aexp2;
SCode.EEquation scode;
Absyn.ComponentRef acr;
Absyn.Info info;
DAE.ElementSource source;

// Record constructors are different
// If it's a constant binding, all fields will already be bound correctly. Don't return a DAE.
Expand All @@ -565,10 +570,14 @@ algorithm
DAE.emptyDae;

// Regular cases
case (cr,ty1,(mod as DAE.MOD(eqModOption = SOME(DAE.TYPED(e,_,prop2,_,_)))),_,impl)
case (cr,ty1,(mod as DAE.MOD(eqModOption = SOME(DAE.TYPED(e,_,prop2,aexp2,info)))),source,impl)
equation
t = Types.simplifyType(ty1);
lhs = Expression.makeCrefExp(cr, t);
acr = ComponentReference.unelabCref(cr);
aexp1 = Absyn.CREF(acr);
scode = SCode.EQ_EQUALS(aexp1,aexp2,SCode.noComment,info);
source = DAEUtil.addSymbolicTransformation(source,DAE.FLATTEN(scode,NONE()));
dae = InstSection.instEqEquation(lhs, DAE.PROP(ty1,DAE.C_VAR()), e, prop2, source, SCode.NON_INITIAL(), impl);
then
dae;
Expand Down

0 comments on commit 90ea88b

Please sign in to comment.