Skip to content

Commit

Permalink
- Fixed spelling error in ZEROCROSSING generation
Browse files Browse the repository at this point in the history
- Updated template scalarLhsCref
- Fixed type bug in range-for generation
- Added template daeExpCrefRhs
- Added support for binary operations: ADD_ARR, SUB_ARR, and DIV_ARRAY_SCALAR
- Changed ASUB template case to match how Codegen works
- Changed the way relations are generated: non-simulation specific relations
  are now generated in simulation context


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4719 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Rickard Lindberg committed Dec 18, 2009
1 parent 451b84e commit e1748f5
Show file tree
Hide file tree
Showing 5 changed files with 3,536 additions and 1,520 deletions.
89 changes: 89 additions & 0 deletions Compiler/SimCode.mo
Expand Up @@ -106,6 +106,95 @@ algorithm
len := listLength(lst);
end listLengthMatrix2;

public
function listLengthSubscript
input list<DAE.Subscript> lst;
output Integer len;
algorithm
len := listLength(lst);
end listLengthSubscript;

// Assume that cref is CREF_IDENT
public
function crefSubIsScalar
input DAE.ComponentRef cref;
output Boolean isScalar;
algorithm
isScalar :=
matchcontinue (cref)
local
list<DAE.Subscript> subs;
case (DAE.CREF_IDENT(subscriptLst=subs)) then subsToScalar(subs);
case _ then false;
end matchcontinue;
end crefSubIsScalar;

// Assume that cref is CREF_IDENT
public
function crefNoSub
input DAE.ComponentRef cref;
output Boolean noSub;
algorithm
noSub :=
matchcontinue (cref)
local
list<DAE.Subscript> subs;
case (DAE.CREF_IDENT(subscriptLst={})) then true;
case (DAE.CREF_IDENT(subscriptLst=subs)) then false;
case _
equation
Error.addMessage(Error.INTERNAL_ERROR, {""});
then
fail();
end matchcontinue;
end crefNoSub;

protected
function subsToScalar "function: subsToScalar

Returns true if subscript results applied to variable or expression
results in scalar expression.
"
input list<DAE.Subscript> inExpSubscriptLst;
output Boolean outBoolean;
algorithm
outBoolean:=
matchcontinue (inExpSubscriptLst)
local
Boolean b;
list<DAE.Subscript> r;
case {} then true;
case (DAE.SLICE(exp = _) :: _) then false;
case (DAE.WHOLEDIM() :: _) then false;
case (DAE.INDEX(exp = _) :: r)
equation
b = subsToScalar(r);
then
b;
end matchcontinue;
end subsToScalar;

public function buildCrefExpFromAsub
input DAE.Exp cref;
input list<DAE.Exp> subs;
output DAE.Exp cRefOut;
algorithm
cRefOut := matchcontinue(cref, subs)
local
DAE.Exp sub;
DAE.ExpType ty;
list<DAE.Exp> rest;
DAE.ComponentRef crNew;
list<DAE.Subscript> indexes;
case (cref, {}) then cref;
case (DAE.CREF(componentRef=crNew, ty=ty), subs)
equation
indexes = Util.listMap(subs, Exp.makeIndexSubscript);
crNew = Exp.subscriptCref(crNew, indexes);
then
DAE.CREF(crNew, ty);
end matchcontinue;
end buildCrefExpFromAsub;

/************** FUNCTIONS ***********/
/* a type to use for function return, parameters and variable declarations is based on Exp.Type */
Expand Down

0 comments on commit e1748f5

Please sign in to comment.