Skip to content

Commit

Permalink
Base of modification processing for non-expanded arrays.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9142 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Alexey Lebedev committed May 27, 2011
1 parent 71a7143 commit 8c486f1
Show file tree
Hide file tree
Showing 3 changed files with 459 additions and 0 deletions.
66 changes: 66 additions & 0 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -5109,4 +5109,70 @@ algorithm
end matchcontinue;
end innerOuterStr;

public function subscriptExpOpt
input Subscript inSub;
output Option<Exp> outExpOpt;
algorithm
outExpOpt := matchcontinue(inSub)
local
Exp e;
case SUBSCRIPT(subScript = e)
then SOME(e);
case NOSUB()
then NONE();
end matchcontinue;
end subscriptExpOpt;

public function crefInsertSubscriptLstLst
input tuple<Exp,list<list<Subscript>>> inTpl;
output tuple<Exp,list<list<Subscript>>> outTpl;
algorithm
outTpl := matchcontinue(inTpl)
local
ComponentRef cref,cref2;
list<list<Subscript>> subs;
Exp e;
case ((CREF(componentRef=cref),subs))
equation
cref2 = crefInsertSubscriptLstLst2(cref,subs);
then
((CREF(cref2),subs));
case ((e,subs)) then ((e,subs));
end matchcontinue;
end crefInsertSubscriptLstLst;

public function crefInsertSubscriptLstLst2
"Helper function to crefInsertSubscriptLstLst"
input ComponentRef inCref;
input list<list<Subscript>> inSubs;
output ComponentRef outCref;
algorithm
outCref := matchcontinue(inCref,inSubs)
local
ComponentRef cref, cref2;
Ident n;
list<list<Subscript>> subs;
list<Subscript> s;
case (cref,{})
then cref;
case (CREF_IDENT(name = n), {s})
then CREF_IDENT(n,s);
case (CREF_QUAL(name = n, componentRef = cref), s::subs)
equation
cref2 = crefInsertSubscriptLstLst2(cref, subs);
then
CREF_QUAL(n,s,cref2);
case (CREF_FULLYQUALIFIED(componentRef = cref), subs)
equation
cref2 = crefInsertSubscriptLstLst2(cref, subs);
then
CREF_FULLYQUALIFIED(cref2);
case (CREF_INVALID(componentRef = cref), subs)
equation
cref2 = crefInsertSubscriptLstLst2(cref, subs);
then
CREF_INVALID(cref2);
end matchcontinue;
end crefInsertSubscriptLstLst2;

end Absyn;
14 changes: 14 additions & 0 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -1299,6 +1299,20 @@ algorithm
end match;
end subscriptExp;

public function subscriptNonExpandedExp
"function: subscriptNonExpandedExp
Returns the expression in a subscript representing non-expanded array.
If the subscript is not WHOLE_NONEXP the function fails."
input Subscript inSubscript;
output DAE.Exp outExp;
algorithm
outExp:=
match (inSubscript)
local DAE.Exp e;
case (DAE.WHOLE_NONEXP(exp = e)) then e;
end match;
end subscriptNonExpandedExp;

public function nthArrayExp
"function: nthArrayExp
author: PA
Expand Down

0 comments on commit 8c486f1

Please sign in to comment.