Skip to content

Commit

Permalink
- Fixed record component assignment in CevalFunction.
Browse files Browse the repository at this point in the history
- Removed nogen and noevalfunc flags from fluid tests that don't need them.
- Removed some unused code.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10086 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Oct 11, 2011
1 parent cd7b1fa commit 692c5cc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
9 changes: 1 addition & 8 deletions Compiler/FrontEnd/Ceval.mo
Expand Up @@ -5081,7 +5081,7 @@ public function cevalCrefBinding "function: cevalCrefBinding
algorithm
(outCache,outValue) := matchcontinue (inCache,inEnv,inComponentRef,inBinding,inBoolean,inMsg)
local
DAE.ComponentRef cr_1,cr,e1;
DAE.ComponentRef cr,e1;
list<DAE.Subscript> subsc;
DAE.Type tp;
list<Integer> sizelst;
Expand All @@ -5096,7 +5096,6 @@ algorithm
case (cache,env,cr,DAE.VALBOUND(valBound = v),impl,msg)
equation
Debug.fprint("tcvt", "+++++++ Ceval.cevalCrefBinding DAE.VALBOUND\n");
cr_1 = ComponentReference.crefStripLastSubs(cr) "lookup without subscripts, so dimension sizes can be determined." ;
subsc = ComponentReference.crefLastSubs(cr);
(cache,res) = cevalSubscriptValue(cache, env, subsc, v, impl, msg);
then
Expand All @@ -5114,7 +5113,6 @@ algorithm
case (cache,env,cr,DAE.EQBOUND(exp = exp,constant_ = DAE.C_CONST()),impl,msg)
equation
DAE.REDUCTION(reductionInfo=DAE.REDUCTIONINFO(path = Absyn.IDENT(name = rfn)),expr = elexp, iterators = {DAE.REDUCTIONITER(id=iter,exp=iterexp)}) = exp;
cr_1 = ComponentReference.crefStripLastSubs(cr) "lookup without subscripts, so dimension sizes can be determined." ;
(cache,v,_) = ceval(cache, env, exp, impl,NONE(), msg);
subsc = ComponentReference.crefLastSubs(cr);
(cache,res) = cevalSubscriptValue(cache, env, subsc, v, impl, msg);
Expand All @@ -5124,7 +5122,6 @@ algorithm
// arbitrary expressions, C_VAR, value exists.
case (cache,env,cr,DAE.EQBOUND(exp = exp,evaluatedExp = SOME(e_val),constant_ = DAE.C_VAR()),impl,msg)
equation
cr_1 = ComponentReference.crefStripLastSubs(cr) "lookup without subscripts, so dimension sizes can be determined." ;
subsc = ComponentReference.crefLastSubs(cr);
(cache,res) = cevalSubscriptValue(cache,env, subsc, e_val, impl, msg);
then
Expand All @@ -5133,7 +5130,6 @@ algorithm
// arbitrary expressions, C_PARAM, value exists.
case (cache,env,cr,DAE.EQBOUND(exp = exp,evaluatedExp = SOME(e_val),constant_ = DAE.C_PARAM()),impl,msg)
equation
cr_1 = ComponentReference.crefStripLastSubs(cr) "lookup without subscripts, so dimension sizes can be determined." ;
subsc = ComponentReference.crefLastSubs(cr);
(cache,res)= cevalSubscriptValue(cache,env, subsc, e_val, impl, msg);
then
Expand All @@ -5142,7 +5138,6 @@ algorithm
// arbitrary expressions. When binding has optional value.
case (cache,env,cr,DAE.EQBOUND(exp = exp,constant_ = DAE.C_CONST()),impl,msg)
equation
cr_1 = ComponentReference.crefStripLastSubs(cr) "lookup without subscripts, so dimension sizes can be determined." ;
(cache,v,_) = ceval(cache, env, exp, impl, NONE(), msg);
subsc = ComponentReference.crefLastSubs(cr);
(cache,res) = cevalSubscriptValue(cache,env, subsc, v, impl, msg);
Expand All @@ -5152,8 +5147,6 @@ algorithm
// arbitrary expressions. When binding has optional value.
case (cache,env,cr,DAE.EQBOUND(exp = exp,constant_ = DAE.C_PARAM()),impl,msg)
equation
cr_1 = ComponentReference.crefStripLastSubs(cr) "lookup without subscripts, so dimension sizes can be determined." ;

// TODO: Ugly hack to prevent infinite recursion. If we have a binding r = r that
// can for instance come from a modifier, this can cause an infinite loop here if r has no value.
false = isRecursiveBinding(cr,exp);
Expand Down
41 changes: 41 additions & 0 deletions Compiler/FrontEnd/CevalFunction.mo
Expand Up @@ -1996,6 +1996,9 @@ algorithm
Env.Cache cache;
Env.Env env;
SymbolTable st;

case ({}, {}, _, _, _) then (inCache, inEnv, inST);

case (DAE.COMPLEX_VAR(name = name, tp = ety) :: rest_vars,
val :: rest_vals, _ , _, st)
equation
Expand Down Expand Up @@ -2236,6 +2239,10 @@ algorithm
DAE.Type ty;
list<Values.Value> values;
Values.Value value;
Absyn.Path path;
list<DAE.Var> vars;
list<String> var_names;

case ((DAE.T_INTEGER(varLstInt = _), _)) then Values.INTEGER(0);
case ((DAE.T_REAL(varLstReal = _), _)) then Values.REAL(0.0);
case ((DAE.T_STRING(varLstString = _), _)) then Values.STRING("");
Expand All @@ -2250,6 +2257,12 @@ algorithm
dims = ValuesUtil.valueDimensions(value);
then
Values.ARRAY(values, int_dim :: dims);
case ((DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(path = path),
complexVarLst = vars), _))
equation
(values, var_names) = List.map_2(vars, getRecordVarBindingAndName);
then
Values.RECORD(path, values, var_names, -1);
case (_)
equation
Debug.fprintln("evalfunc", "- CevalFunction.generateDefaultBinding failed\n");
Expand All @@ -2258,6 +2271,34 @@ algorithm
end matchcontinue;
end generateDefaultBinding;

protected function getRecordVarBindingAndName
input DAE.Var inVar;
output Values.Value outBinding;
output String outName;
algorithm
(outBinding, outName) := matchcontinue(inVar)
local
String name;
DAE.Type ty;
DAE.Binding binding;
Values.Value val;

case (DAE.TYPES_VAR(name = name, ty = ty, binding = binding))
equation
val = getBindingOrDefault(binding, ty);
then
(val, name);

case (DAE.TYPES_VAR(name = name))
equation
true = RTOpts.debugFlag("evalfunc");
Debug.traceln("- CevalFunction.getRecordVarBindingAndName failed on variable "
+& name +& "\n");
then
fail();
end matchcontinue;
end getRecordVarBindingAndName;

protected function getFunctionReturnValue
"This function fetches one return value for the function, given an output
variable and an environment."
Expand Down
3 changes: 1 addition & 2 deletions Compiler/FrontEnd/Lookup.mo
Expand Up @@ -2680,8 +2680,7 @@ algorithm
ty_1 = checkSubscripts(ty, ss);
ss = addArrayDimensions(ty,ss);
tty = Types.elabType(ty);
ty2_2 = Types.elabType(ty);
cref_ = ComponentReference.makeCrefIdent(id,ty2_2, ss);
cref_ = ComponentReference.makeCrefIdent(id,tty, ss);
splicedExp = Expression.makeCrefExp(cref_,tty);
//print("splicedExp ="+&ExpressionDump.dumpExpStr(splicedExp,0)+&"\n");
then
Expand Down

0 comments on commit 692c5cc

Please sign in to comment.