Skip to content

Commit

Permalink
Added some functions used by MC back end
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4929 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Björn Zachrisson committed Feb 5, 2010
1 parent 8634e48 commit fb7ef48
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Compiler/Exp.mo
Expand Up @@ -329,6 +329,48 @@ algorithm outSubscriptLst:= matchcontinue (inComponentRef)
end matchcontinue;
end crefIdent;

public function stripCrefIdentSliceSubs "
Author BZ
"
input ComponentRef inCref;
output ComponentRef outCref;
algorithm
outCref := matchcontinue(inCref)
local
Ident id;
ComponentRef cr;
Type ty;
list<Subscript> subs;
case (DAE.CREF_IDENT(ident = id,subscriptLst=subs, identType = ty))
equation
subs = removeSliceSubs(subs);
then DAE.CREF_IDENT(id,ty,subs);
case (DAE.CREF_QUAL(componentRef = cr, identType=ty, subscriptLst=subs, ident=id))
equation
outCref = crefStripSubs(cr);
then
DAE.CREF_QUAL(id,ty,subs,outCref);
end matchcontinue;
end stripCrefIdentSliceSubs;

protected function removeSliceSubs "
helper function for stripCrefIdentSliceSubs
"
input list<Subscript> subs;
output list<Subscript> osubs;
algorithm
osubs := matchcontinue(subs)
local Subscript s;
case({}) then {};
case(DAE.SLICE(exp=_)::subs) then removeSliceSubs(subs);
case(s::subs)
equation
osubs = removeSliceSubs(subs);
then
s::osubs;
end matchcontinue;
end removeSliceSubs;

public function crefStripSubs "
Removes all subscript of a componentref
"
Expand Down
20 changes: 20 additions & 0 deletions Compiler/Util.mo
Expand Up @@ -5560,6 +5560,26 @@ algorithm
out := (a,b);
end makeTuple2;

public function makeTupleList
input list<Type_a> al;
input list<Type_b> bl;
output list<tuple<Type_a,Type_b>> out;
replaceable type Type_a subtypeof Any;
replaceable type Type_b subtypeof Any;
algorithm
out := matchcontinue(al,bl)
local
Type_a a;
Type_b b;
case({},_) then {};
case(a::al,b::bl)
equation
out = makeTupleList(al,bl);
then
(a,b)::out;
end matchcontinue;
end makeTupleList;

public function listAppendNoCopy
"author: adrpo
this function handles special cases
Expand Down

0 comments on commit fb7ef48

Please sign in to comment.