Skip to content

Commit

Permalink
-Added function DAE.getProtectedAttr.
Browse files Browse the repository at this point in the history
-Added function Util.listMap4

git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/MathCoreOSMC@3967 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Mar 24, 2009
1 parent 7015599 commit a20f1e2
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
19 changes: 18 additions & 1 deletion Compiler/DAE.mo
Expand Up @@ -1805,6 +1805,23 @@ algorithm
end matchcontinue;
end setProtectedAttr;

public function getProtectedAttr "
retrieves the protected attribute form VariableAttributes.
"
input Option<VariableAttributes> attr;
output Boolean isProtected;
algorithm
isProtected:=
matchcontinue (attr)
case (SOME(VAR_ATTR_REAL(isProtected=SOME(isProtected)))) then isProtected;
case (SOME(VAR_ATTR_INT(isProtected=SOME(isProtected)))) then isProtected;
case (SOME(VAR_ATTR_BOOL(isProtected=SOME(isProtected)))) then isProtected;
case (SOME(VAR_ATTR_STRING(isProtected=SOME(isProtected)))) then isProtected;
case (SOME(VAR_ATTR_ENUMERATION(isProtected=SOME(isProtected)))) then isProtected;
case(_) then false;
end matchcontinue;
end getProtectedAttr;

public function setFixedAttr "Function: setFixedAttr
Sets the start attribute:fixed to inputarg
"
Expand Down Expand Up @@ -1962,7 +1979,7 @@ algorithm
Option<Exp.Exp> quant,unit,displayUnit;
Option<Exp.Exp> min,max,Initial,nominal;
Option<Exp.Exp> fixed;
Option<StateSelect> stateSel;
Option<StateSelect> stateSel;
case (SOME(VAR_ATTR_REAL(quant,unit,displayUnit,(min,max),Initial,fixed,nominal,stateSel,_,_,_)))
equation
quantity = Dump.getOptionWithConcatStr(quant, Exp.printExpStr, "quantity = ");
Expand Down
49 changes: 48 additions & 1 deletion Compiler/Util.mo
Expand Up @@ -1340,7 +1340,54 @@ algorithm
end matchcontinue;
end listMap3;

/* TODO: listMap4, listMap5, listMap6, can be created upon requests ;) */
public function listMap4 "function listMap4
Takes a list and a function and four extra arguments passed to the function.
The function produces one new value which is used for creating a new list."
input list<Type_a> inTypeALst;
input mapFunc f;
input Type_b inTypeB;
input Type_c inTypeC;
input Type_d inTypeD;
input Type_e inTypeE;
output list<Type_f> outTypeELst;
replaceable type Type_a subtypeof Any;
partial function mapFunc
input Type_a inTypeA;
input Type_b inTypeB;
input Type_c inTypeC;
input Type_d inTypeD;
input Type_e inTypeE;
output Type_f outTypeF;
end mapFunc;
replaceable type Type_b subtypeof Any;
replaceable type Type_c subtypeof Any;
replaceable type Type_d subtypeof Any;
replaceable type Type_e subtypeof Any;
replaceable type Type_f subtypeof Any;
algorithm
outTypeELst:=
matchcontinue (inTypeALst,f,inTypeB,inTypeC,inTypeD,inTypeE)
local
Type_e f_1;
list<Type_e> r_1;
Type_a f;
list<Type_a> r;
mapFunc fn;
Type_b extraarg1;
Type_c extraarg2;
Type_d extraarg3;
Type_e extraarg4;
case ({},_,_,_,_,_) then {};
case ((f :: r),fn,extraarg1,extraarg2,extraarg3,extraarg4)
equation
f_1 = fn(f, extraarg1, extraarg2, extraarg3,extraarg4);
r_1 = listMap4(r, fn, extraarg1, extraarg2, extraarg3,extraarg4);
then
(f_1 :: r_1);
end matchcontinue;
end listMap4;

/* TODO: listMap5, listMap6, can be created upon requests ;) */

public function listMap7 "function listMap7
Takes a list and a function and seven extra arguments passed to the function.
Expand Down

0 comments on commit a20f1e2

Please sign in to comment.