@@ -2827,17 +2827,19 @@ void Data::synthStructMacro ()
2827
2827
void UserDef::_apply_ref_overrides (ActBody *b, ActBody *srch)
2828
2828
{
2829
2829
list_t *ol = NULL ;
2830
+
2830
2831
while (srch) {
2831
2832
ActBody_Lang *l = dynamic_cast <ActBody_Lang *> (srch);
2832
2833
if (l) {
2833
2834
if (l->gettype () == ActBody_Lang::LANG_REFINE) {
2834
2835
act_refine *r = (act_refine *) l->getlang ();
2835
- if (acceptRefine (ActNamespace::Act ()->getRefSteps (), r->nsteps ) &&
2836
- r->overrides ) {
2836
+ if (acceptRefine (ActNamespace::Act ()->getRefSteps (), r->nsteps )) {
2837
2837
listitem_t *oi, *oprev;
2838
2838
if (!ol) {
2839
2839
ol = list_new ();
2840
2840
}
2841
+
2842
+ /* insert the override into a sorted list of refinement levels */
2841
2843
oi = list_first (ol);
2842
2844
oprev = NULL ;
2843
2845
while (oi) {
@@ -2870,14 +2872,33 @@ void UserDef::_apply_ref_overrides (ActBody *b, ActBody *srch)
2870
2872
}
2871
2873
/* apply overrides in refinement order */
2872
2874
if (ol) {
2873
- for (listitem_t *oi = list_first (ol); oi; oi = list_next (oi)) {
2874
- act_refine *ri = (act_refine *) list_value (oi);
2875
- refine_override *rl = ri->overrides ;
2875
+ for (listitem_t *oi = list_first (ol); oi; oi = list_next (oi)) {
2876
+ act_refine *ri = (act_refine *) list_value (oi);
2877
+ refine_override *rl = ri->overrides ;
2878
+
2876
2879
while (rl) {
2877
- b->updateInstType (rl->ids , rl->it );
2878
- rl = rl->next ;
2879
- }
2880
- }
2880
+ b->updateInstType (rl->ids , rl->it , false );
2881
+ rl = rl->next ;
2882
+ }
2883
+
2884
+ /* also propagate the refinement to the bodies of the earlier
2885
+ refinement bodies! */
2886
+
2887
+ /* * XXX: this doesn't correctly handle nested refinement blocks **/
2888
+ if (ri->overrides ) {
2889
+ for (listitem_t *op = list_first (ol); op != oi; op = list_next (op)) {
2890
+ act_refine *rp = (act_refine *) list_value (op);
2891
+ rl = ri->overrides ;
2892
+ Assert (rp->nsteps <= ActNamespace::Act ()->getRefSteps (), " What?" );
2893
+ ActNamespace::Act ()->decRefSteps (rp->nsteps );
2894
+ while (rl) {
2895
+ rp->b ->updateInstType (rl->ids , rl->it , true );
2896
+ rl = rl->next ;
2897
+ }
2898
+ ActNamespace::Act ()->incRefSteps (rp->nsteps );
2899
+ }
2900
+ }
2901
+ }
2881
2902
}
2882
2903
}
2883
2904
0 commit comments