Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Some fixes for unknown end-expressions by removing DAE.END(), replacing it with calls to size(cr,dim)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9406 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jul 4, 2011
1 parent bfa10f8 commit eb8bcb5
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 51 deletions.
5 changes: 0 additions & 5 deletions Compiler/BackEnd/TaskGraph.mo
Expand Up @@ -968,11 +968,6 @@ algorithm
print("TaskGraph.buildExpression(REDUCTION) not impl. yet\n");
then
fail();
case (DAE.END())
equation
print("TaskGraph.buildExpression(END) not impl. yet\n");
then
fail();
case (e)
equation
print("-TaskGraph.buildExpression failed\n Exp = ");
Expand Down
7 changes: 0 additions & 7 deletions Compiler/BackEnd/XMLDump.mo
Expand Up @@ -1589,13 +1589,6 @@ algorithm
Absyn.Path fcn;
list<DAE.Exp> args,es;
list<list<tuple<DAE.Exp, Boolean>>> ebs;
case (DAE.END())
////////////////////////////////////////////////
////// TO DO: ADD SUPPORT TO END ////////
////////////////////////////////////////////////
equation
Print.printBuf("end");
then ();
case (DAE.ICONST(integer = x))
equation
dumpStrMathMLNumberAttr(intString(x),MathMLType,MathMLInteger);
Expand Down
10 changes: 10 additions & 0 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -5167,5 +5167,15 @@ algorithm
CREF_INVALID(cref2);
end matchcontinue;
end crefInsertSubscriptLstLst2;

public function isCref
input Exp exp;
output Boolean b;
algorithm
b := match exp
case CREF(_) then true;
else false;
end match;
end isCref;

end Absyn;
10 changes: 0 additions & 10 deletions Compiler/FrontEnd/Ceval.mo
Expand Up @@ -180,16 +180,6 @@ algorithm
case (cache,_,DAE.ENUM_LITERAL(name = name, index = i),_,stOpt,_,_)
then (cache, Values.ENUM_LITERAL(name, i), stOpt);

case (cache,_,DAE.END(),_,stOpt,SOME(dim),_) then (cache,Values.INTEGER(dim),stOpt);

case (cache,_,DAE.END(),_,stOpt,NONE(), MSG())
equation
Error.addMessage(Error.END_ILLEGAL_USE_ERROR, {});
then
fail();

case (cache,_,DAE.END(),_,stOpt,NONE(), NO_MSG()) then fail();

case (cache,env,DAE.CODE(code = Absyn.C_EXPRESSION(exp = exp)),impl,stOpt,_,msg)
equation
(cache,exp_1) = CevalScript.cevalAstExp(cache,env, exp, impl, stOpt, msg, Absyn.dummyInfo);
Expand Down
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/DAE.mo
Expand Up @@ -1181,8 +1181,6 @@ uniontype Exp "Expressions
ReductionIterators iterators;
end REDUCTION;

record END "array index to last element, e.g. a{end}:=1;" end END;

/* Part of MetaModelica extension. KS */
record LIST "MetaModelica list"
list<Exp> valList;
Expand Down
12 changes: 0 additions & 12 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -283,7 +283,6 @@ algorithm
then
Absyn.CALL(acref, Absyn.FOR_ITER_FARG(ae1, aiters));

case(DAE.END()) then Absyn.END();
end matchcontinue;
end unelabExp;

Expand Down Expand Up @@ -1619,7 +1618,6 @@ algorithm
then liftArrayR(Types.elabType(ty),DAE.DIM_UNKNOWN());
case (DAE.REDUCTION(reductionInfo=DAE.REDUCTIONINFO(exprType=ty)))
then Types.elabType(ty);
case (DAE.END()) then DAE.ET_OTHER(); /* Can be any type. */
case (DAE.SIZE(_,NONE())) then DAE.ET_ARRAY(DAE.ET_INT(),{DAE.DIM_UNKNOWN()});
case (DAE.SIZE(_,SOME(_))) then DAE.ET_INT();

Expand Down Expand Up @@ -3595,8 +3593,6 @@ algorithm
// Why don't we call rel() for these expressions?
case (e as DAE.CODE(code = _),rel,ext_arg) then ((e,ext_arg));

case (DAE.END(),_,ext_arg) then ((DAE.END(),ext_arg));

case (e,rel,ext_arg)
equation
str = ExpressionDump.printExpStr(e);
Expand Down Expand Up @@ -3980,9 +3976,6 @@ algorithm
then
((DAE.BOX(e1_1),ext_arg_1));

// ---------------------
case (DAE.END(),_,ext_arg) then ((DAE.END(),ext_arg));

case (e,rel,ext_arg)
equation
str = ExpressionDump.printExpStr(e);
Expand Down Expand Up @@ -4594,8 +4587,6 @@ algorithm
then
(DAE.REDUCTION(reductionInfo, e1, riters), tup);

case (DAE.END(), _) then (inExp, inTuple);

case (DAE.LIST(valList = expl), tup)
equation
(expl, tup) = traverseExpListBidir(expl, tup);
Expand Down Expand Up @@ -5147,8 +5138,6 @@ algorithm

case (DAE.SIZE(exp=e1,sz=SOME(e2)),_) then isConstWork(e1,isConstWork(e2,true));

case (DAE.END(),_) then true;

/*TODO:Make this work for multiple iters, guard exps*/
case (DAE.REDUCTION(expr=e1,iterators={DAE.REDUCTIONITER(exp=e2)}),_)
then isConstWork(e1,isConstWork(e2,true));
Expand Down Expand Up @@ -6257,7 +6246,6 @@ algorithm
res;

// end id
case (DAE.END(),DAE.END(),_,_) then true;
/*// everything else failed, try structural equality
case (e1,e2)
equation
Expand Down
12 changes: 0 additions & 12 deletions Compiler/FrontEnd/ExpressionDump.mo
Expand Up @@ -590,8 +590,6 @@ algorithm
case (DAE.EMPTY(scope = scope, name = name, tyStr = tyStr), _, _, _)
then "<EMPTY(scope: " +& scope +& ", name: " +& ComponentReference.printComponentRefStr(name) +& ", ty: " +& tyStr +& ")>";

case (DAE.END(), _, _, _) then "end";

case (DAE.ICONST(integer = i), _, _, _)
equation
s = intString(i);
Expand Down Expand Up @@ -1006,7 +1004,6 @@ algorithm
case (DAE.ENUM_LITERAL(name = _)) then 0;
case (DAE.CREF(_,_)) then 0;
case (DAE.ASUB(_,_)) then 0;
case (DAE.END()) then 0;
case (DAE.CAST(_,_)) then 0;
case (DAE.CALL(path=_)) then 0;
case (DAE.PARTEVALFUNCTION(path=_)) then 0;
Expand Down Expand Up @@ -1129,8 +1126,6 @@ algorithm
Boolean b;
list<list<tuple<DAE.Exp, Boolean>>> lstes;

case (DAE.END()) then Graphviz.NODE("END",{},{});

case (DAE.ICONST(integer = i))
equation
s = intString(i);
Expand Down Expand Up @@ -1319,13 +1314,6 @@ algorithm
list<list<tuple<DAE.Exp,Boolean>>> lstes;
Boolean b;

case (DAE.END(),level)
equation
gen_str = genStringNTime(" |", level);
res_str = stringAppendList({gen_str,"END","\n"});
then
res_str;

case (DAE.ICONST(integer = x),level) /* Graphviz.LNODE(\"ICONST\",{s},{},{}) */
equation
gen_str = genStringNTime(" |", level);
Expand Down
84 changes: 83 additions & 1 deletion Compiler/FrontEnd/Static.mo
Expand Up @@ -373,7 +373,9 @@ algorithm
(cache,DAE.BCONST(b),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),st);

case (cache,_,Absyn.END(),impl,st,doVect,_,info,_)
then (cache,DAE.END(),DAE.PROP(DAE.T_INTEGER_DEFAULT,DAE.C_CONST()),st);
equation
Error.addSourceMessage(Error.END_ILLEGAL_USE_ERROR, {}, info);
then fail();

case (cache,env,Absyn.CREF(componentRef = cr),impl,st,doVect,pre,info,_) // BoschRexroth specifics
equation
Expand Down Expand Up @@ -9577,6 +9579,7 @@ algorithm
// a normal cref
case (cache,env,c,impl,doVect,pre,info) /* impl */
equation
c = replaceEnd(c);
(cache,c_1,const) = elabCrefSubs(cache, env, c, Prefix.NOPRE(), impl, info);
(cache,attr,t,binding,forIteratorConstOpt,splicedExpData,_,_,_) = Lookup.lookupVar(cache, env, c_1);
variability = applySubscriptsVariability(DAEUtil.getAttrVariability(attr), const);
Expand All @@ -9590,6 +9593,7 @@ algorithm
// An enumeration type => array of enumeration literals.
case (cache, env, c, impl, doVect, pre, info)
equation
c = replaceEnd(c);
path = Absyn.crefToPath(c);
(cache, cl as SCode.CLASS(restriction = SCode.R_ENUMERATION()), env) =
Lookup.lookupClass(cache, env, path, false);
Expand Down Expand Up @@ -13303,4 +13307,82 @@ algorithm
end matchcontinue;
end elabArrayDim2;

protected function consStrippedCref
input Absyn.Exp e;
input list<Absyn.Exp> es;
output list<Absyn.Exp> oes;
algorithm
oes := match (e,es)
local
Absyn.ComponentRef cr;
case (Absyn.CREF(cr),es)
equation
cr = Absyn.crefStripLastSubs(cr);
then Absyn.CREF(cr)::es;
else es;
end match;
end consStrippedCref;

protected function replaceEndEnter
"Single pass traversal that replaces end-expressions with the correct size-expression.
It uses a couple of stacks and crap to handle all of this :)."
input tuple<Absyn.Exp,tuple<list<Absyn.Exp>,list<Integer>,list<Boolean>>> itpl;
output tuple<Absyn.Exp,tuple<list<Absyn.Exp>,list<Integer>,list<Boolean>>> otpl;
algorithm
otpl := match itpl
local
Absyn.Exp cr,exp;
list<Absyn.Exp> crs;
list<Integer> li;
Integer i,ni;
list<Boolean> bs;
Boolean isCr,inc;
case ((exp,(crs,i::li,bs as (inc::_))))
equation
isCr = Absyn.isCref(exp);
bs = Util.if_(isCr,true::bs,false::bs);
ni = Util.if_(isCr,0,i+1);
li = Util.if_(inc,ni::li,i::li);
li = Util.if_(isCr,0::li,li);
crs = consStrippedCref(exp,crs);
then ((exp,(crs,li,bs)));
end match;
end replaceEndEnter;

protected function replaceEndExit
"Single pass traversal that replaces end-expressions with the correct size-expression.
It uses a couple of stacks and crap to handle all of this :)."
input tuple<Absyn.Exp,tuple<list<Absyn.Exp>,list<Integer>,list<Boolean>>> itpl;
output tuple<Absyn.Exp,tuple<list<Absyn.Exp>,list<Integer>,list<Boolean>>> otpl;
algorithm
otpl := match itpl
local
Absyn.Exp cr,exp;
list<Absyn.Exp> crs;
Integer i;
list<Integer> li;
list<Boolean> bs;
case ((Absyn.END(),(crs as (cr::_),li as (i::_),_::bs)))
then ((Absyn.CALL(Absyn.CREF_IDENT("size",{}),Absyn.FUNCTIONARGS({cr,Absyn.INTEGER(i)},{})),(crs,li,bs)));
case ((cr as Absyn.CREF(_),(_::crs,_::li,_::bs)))
then ((cr,(crs,li,bs)));
case ((exp,(crs,li,_::bs))) then ((exp,(crs,li,bs)));
end match;
end replaceEndExit;

protected function replaceEnd
"Single pass traversal that replaces end-expressions with the correct size-expression.
It uses a couple of stacks and crap to handle all of this :)."
input Absyn.ComponentRef cr;
output Absyn.ComponentRef ocr;
protected
Absyn.ComponentRef stripcr;
algorithm
// print("replaceEnd start " +& Dump.printExpStr(Absyn.CREF(cr)) +& "\n");
stripcr := Absyn.crefStripLastSubs(cr);
// print("stripCref " +& Dump.printExpStr(Absyn.CREF(stripcr)) +& "\n");
(ocr,_) := Absyn.traverseExpBidirCref(cr,(replaceEndEnter,replaceEndExit,({Absyn.CREF(stripcr)},{0},{true})));
// print("replaceEnd end " +& Dump.printExpStr(Absyn.CREF(ocr)) +& "\n");
end replaceEnd;

end Static;
1 change: 0 additions & 1 deletion Compiler/susan_codegen/SimCode/SimCodeCSharp.tpl
Expand Up @@ -1592,7 +1592,6 @@ template daeExp(Exp inExp, Context context, Text &preExp, SimCode simCode) ::=
case SIZE(__) then daeExpSize(inExp, context, &preExp, simCode)
case CODE(__) then "CODE_NOT_IMPLEMENTED"
case REDUCTION(__) then "REDUCTION_NOT_IMPLEMENTED"
case END(__) then "END_NOT_IMPLEMENTED"
//case VALUEBLOCK(__) then "VALUEBLOCK_NOT_IMPLEMENTED"
case LIST(__) then "LIST_NOT_IMPLEMENTED"
case CONS(__) then "CONS_NOT_IMPLEMENTED"
Expand Down
1 change: 0 additions & 1 deletion Compiler/susan_codegen/SimCode/SimCodeTV.mo
Expand Up @@ -839,7 +839,6 @@ package DAE
Exp expr;
ReductionIterators iterators;
end REDUCTION;
record END end END;
record LIST
list<Exp> valList;
end LIST;
Expand Down

0 comments on commit eb8bcb5

Please sign in to comment.