Changeset 13389


Ignore:
Timestamp:
2012-10-15T14:56:06+02:00 (12 years ago)
Author:
jfrenkel
Message:
  • check for cyclic bindings in start values while merging alias variables
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/BackEnd/BackendVariable.mo

    r13323 r13389  
    4646protected import Absyn;
    4747protected import BackendDAEUtil;
     48protected import BaseHashSet;
    4849protected import ComponentReference;
    4950protected import DAEUtil;
     
    5556protected import Flags;
    5657protected import HashTable2;
     58protected import HashSet;
    5759protected import List;
    5860protected import SCode;
     
    34233425  sv := varStartValueOption(inVar);
    34243426  sva := varStartValueOption(inAVar);
    3425   (v1) := mergeStartFixed(inVar,fixed,sv,inAVar,fixeda,sva,negate,knVars);
     3427  v1 := mergeStartFixed(inVar,fixed,sv,inAVar,fixeda,sva,negate,knVars);
    34263428  // nominal
    34273429  v2 := mergeNominalAttribute(inAVar,v1,negate);
     
    35893591end mergeStartFixed1;
    35903592
    3591 public function replaceCrefWithBindExp
    3592   input tuple<DAE.Exp, tuple<BackendDAE.Variables,Boolean>> inTuple;
    3593   output tuple<DAE.Exp, tuple<BackendDAE.Variables,Boolean>> outTuple;
     3593protected function replaceCrefWithBindExp
     3594  input tuple<DAE.Exp, tuple<BackendDAE.Variables,Boolean,HashSet.HashSet>> inTuple;
     3595  output tuple<DAE.Exp, tuple<BackendDAE.Variables,Boolean,HashSet.HashSet>> outTuple;
    35943596algorithm
    35953597  outTuple := matchcontinue(inTuple)
     
    35993601      DAE.ComponentRef cr;
    36003602      Boolean b;
     3603      HashSet.HashSet hs;
    36013604    // true if crefs replaced in expression
    3602     case ((DAE.CREF(componentRef=cr), (vars,_)))
    3603       equation
    3604          ({BackendDAE.VAR(bindExp = SOME(e))}, _) = getVar(cr, vars);
    3605          ((e, _)) = Expression.traverseExp(e, replaceCrefWithBindExp, (vars,false));
    3606       then
    3607         ((e, (vars,true)));
     3605    case ((DAE.CREF(componentRef=cr), (vars,_,hs)))
     3606      equation
     3607        // check for cyclic bindings in start value
     3608        false = BaseHashSet.has(cr, hs);
     3609        ({BackendDAE.VAR(bindExp = SOME(e))}, _) = getVar(cr, vars);
     3610        hs = BaseHashSet.add(cr,hs);
     3611        ((e, (_,_,hs))) = Expression.traverseExp(e, replaceCrefWithBindExp, (vars,false,hs));
     3612      then
     3613        ((e, (vars,true,hs)));
    36083614    // true if crefs in expression
    3609     case ((e as DAE.CREF(componentRef=cr), (vars,_)))
    3610       then
    3611         ((e, (vars,true)));       
     3615    case ((e as DAE.CREF(componentRef=cr), (vars,_,hs)))
     3616      then
     3617        ((e, (vars,true,hs)));       
    36123618    else then inTuple;
    36133619  end matchcontinue;
     
    36413647      equation
    36423648        // simple evaluation, by replace crefs with bind expressions recursivly
    3643         ((exp1_1, (_,b))) = Expression.traverseExp(exp1, replaceCrefWithBindExp, (knVars,false));
    3644         ((exp2_1, _)) = Expression.traverseExp(exp2, replaceCrefWithBindExp, (knVars,false));
     3649        ((exp1_1, (_,b,_))) = Expression.traverseExp(exp1, replaceCrefWithBindExp, (knVars,false,HashSet.emptyHashSet()));
     3650        ((exp2_1, _)) = Expression.traverseExp(exp2, replaceCrefWithBindExp, (knVars,false,HashSet.emptyHashSet()));
    36453651        true = Expression.expEqual(exp1_1, exp2_1);
    36463652        exp1_1 = Util.if_(b,exp1,exp2);
Note: See TracChangeset for help on using the changeset viewer.