@@ -361,16 +361,28 @@ algorithm
361361end instGetStore;
362362
363363public function emptyInstStore "returns an empty InstStore"
364- output UnitAbsyn . InstStore st;
365- protected
366- UnitAbsyn . Store s;
367- HashTable . HashTable ht;
364+ output UnitAbsyn . InstStore st;
368365algorithm
369- s := emptyStore();
370- ht := HashTable . emptyHashTable();
371- st := UnitAbsyn . INSTSTORE (s,ht,NONE ());
366+ st := emptyInstStore2(Flags . getConfigBool(Flags . UNIT_CHECKING ));
372367end emptyInstStore;
373368
369+ protected function emptyInstStore2 "returns an empty InstStore"
370+ input Boolean wantInstStore;
371+ output UnitAbsyn . InstStore st;
372+ algorithm
373+ st := match wantInstStore
374+ local
375+ UnitAbsyn . Store s;
376+ HashTable . HashTable ht;
377+ case true
378+ equation
379+ s = emptyStore();
380+ ht = HashTable . emptyHashTable();
381+ then UnitAbsyn . INSTSTORE (s,ht,NONE ());
382+ else UnitAbsyn . noStore;
383+ end match;
384+ end emptyInstStore2;
385+
374386public function emptyStore "Returns an empty store with 10 empty array elements"
375387output UnitAbsyn . Store st;
376388protected
@@ -689,10 +701,6 @@ algorithm
689701 HashTable . HashTable ht;
690702 UnitAbsyn . UnitTerms terms2;
691703 Option < UnitAbsyn . UnitCheckResult > res;
692- case (_,_,_,_)
693- equation
694- false = Flags . getConfigBool(Flags . UNIT_CHECKING );
695- then(UnitAbsyn . noStore,{});
696704 case (_,_,_,UnitAbsyn . NOSTORE ()) then (UnitAbsyn . NOSTORE (),{});
697705 case (_,_,_,UnitAbsyn . INSTSTORE (st,ht,res))
698706 equation
@@ -743,29 +751,29 @@ algorithm
743751 UnitAbsyn . InstStore store;
744752 DAE . Type tp;
745753
746- case (store,_,_) equation
747- false = Flags . getConfigBool(Flags . UNIT_CHECKING );
748- then UnitAbsyn . noStore;
754+ case (UnitAbsyn . NOSTORE (),_,_)
755+ then istore;
749756
750- case (UnitAbsyn . INSTSTORE (st,ht,res),DAE . T_REAL (varLst = DAE . TYPES_VAR (name= "unit" ,binding = DAE . EQBOUND (exp= DAE . SCONST (unitStr)))::_),_) equation
751- unit = str2unit(unitStr,NONE ());
752- unit = Util . if_(0 == stringCompare(unitStr,"" ),UnitAbsyn . UNSPECIFIED (),unit);
753- (st,indx) = add(unit,st);
754- ht = BaseHashTable . add((cr,indx),ht);
755- then UnitAbsyn . INSTSTORE (st,ht,res);
756- case (store,DAE . T_REAL (_::vs,ts),_) equation
757+ case (UnitAbsyn . INSTSTORE (st,ht,res),DAE . T_REAL (varLst = DAE . TYPES_VAR (name= "unit" ,binding = DAE . EQBOUND (exp= DAE . SCONST (unitStr)))::_),_)
758+ equation
759+ unit = str2unit(unitStr,NONE ());
760+ unit = Util . if_(0 == stringCompare(unitStr,"" ),UnitAbsyn . UNSPECIFIED (),unit);
761+ (st,indx) = add(unit,st);
762+ ht = BaseHashTable . add((cr,indx),ht);
763+ then UnitAbsyn . INSTSTORE (st,ht,res);
764+ case (store,DAE . T_REAL (_::vs,ts),_)
757765 then instAddStore(store,DAE . T_REAL (vs,ts),cr);
758766
759767 /* No unit available. */
760- case (UnitAbsyn . INSTSTORE (st,ht,res),DAE . T_REAL (varLst = {}),_) equation
761- (st,indx) = add(UnitAbsyn . UNSPECIFIED (),st);
762- ht = BaseHashTable . add((cr,indx),ht);
763- then UnitAbsyn . INSTSTORE (st,ht,res);
768+ case (UnitAbsyn . INSTSTORE (st,ht,res),DAE . T_REAL (varLst = {}),_)
769+ equation
770+ (st,indx) = add(UnitAbsyn . UNSPECIFIED (),st);
771+ ht = BaseHashTable . add((cr,indx),ht);
772+ then UnitAbsyn . INSTSTORE (st,ht,res);
764773
765- case (store,DAE . T_SUBTYPE_BASIC (complexType= tp),_) equation
766- store = instAddStore(store,tp,cr);
767- then store;
768- case (store,_,_) then store;
774+ case (store,DAE . T_SUBTYPE_BASIC (complexType= tp),_)
775+ then instAddStore(store,tp,cr);
776+ else istore;
769777 end matchcontinue;
770778end instAddStore;
771779
0 commit comments