Skip to content

Commit

Permalink
+ Fix #2933. Fix type informations for nested array reductions
Browse files Browse the repository at this point in the history
  • Loading branch information
mahge committed Oct 14, 2015
1 parent db371fa commit 22a42a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -2244,14 +2244,15 @@ algorithm
local
Type tp;
Operator op;
DAE.Exp e1,e2,e3,e;
DAE.Exp e1,e2,e3,e,iterExp,operExp;
list<DAE.Exp> explist,exps;
Absyn.Path p;
String msg;
DAE.Type ty;
DAE.Type ty, iterTp, operTp;
list<DAE.Type> tys;
Integer i,i1,i2;
DAE.Dimension dim;
DAE.Dimensions iterdims;

case (DAE.ICONST()) then DAE.T_INTEGER_DEFAULT;
case (DAE.RCONST()) then DAE.T_REAL_DEFAULT;
Expand Down Expand Up @@ -2290,12 +2291,13 @@ algorithm
case DAE.RSUB() then inExp.ty;
case (DAE.CODE(ty = tp)) then tp;
/* array reduction with known size */
case (DAE.REDUCTION(iterators={DAE.REDUCTIONITER(exp=e,guardExp=NONE())},reductionInfo=DAE.REDUCTIONINFO(exprType=ty as DAE.T_ARRAY(dims=dim::_),path = Absyn.IDENT("array"))))
case (DAE.REDUCTION(iterators={DAE.REDUCTIONITER(exp=iterExp,guardExp=NONE())},expr = operExp, reductionInfo=DAE.REDUCTIONINFO(exprType=ty as DAE.T_ARRAY(dims=dim::_),path = Absyn.IDENT("array"))))
equation
false = dimensionKnown(dim);
DAE.T_ARRAY(dims={dim}) = typeof(e);
true = dimensionKnown(dim);
tp = liftArrayR(Types.unliftArray(Types.simplifyType(ty)),dim);
iterTp = typeof(iterExp);
operTp = typeof(operExp);
DAE.T_ARRAY(dims=iterdims) = iterTp;
tp = Types.liftTypeWithDims(operTp, iterdims);
then tp;
case (DAE.REDUCTION(reductionInfo=DAE.REDUCTIONINFO(exprType=ty)))
then Types.simplifyType(ty);
Expand Down
1 change: 1 addition & 0 deletions Compiler/Template/CodegenCFunctions.tpl
Expand Up @@ -6288,6 +6288,7 @@ template daeExpReduction(Exp exp, Context context, Text &preExp,
case DIM_INTEGER(__) then ', <%integer%>'
case DIM_BOOLEAN(__) then ", 2"
case DIM_ENUM(__) then ', <%size%>'
case DAE.DIM_EXP(exp=e) then ', <%daeExp(e,context,&rangeExpPre,&tmpVarDecls, &auxFunction)%>'
else error(sourceInfo(), 'array reduction unable to generate code for element of unknown dimension sizes; type <%unparseType(typeof(r.expr))%>: <%ExpressionDump.printExpStr(r.expr)%>')
; separator = ", "
'alloc_<%arrayTypeResult%>(&<%res%>, <%intAdd(1,listLength(dims))%>, <%length%><%dimSizes%>);'
Expand Down

0 comments on commit 22a42a4

Please sign in to comment.