From 59335b63b0bfc2e874d64fdd661d501124b9c2bd Mon Sep 17 00:00:00 2001 From: werner Date: Tue, 20 Apr 2010 21:01:16 +0000 Subject: [PATCH] The partial order algorithm in dump.c sometimes dumped objects before a vector they referenced. As a band-aid, we now explicitly keep track of which vectors have been dumped, and defer objects accordingly. A more correct solution would be to properly abstract the partial order algorithms (along with the heuristics for maximizing the number of ".") and to implement it properly. - fpd.y (debug_item): new rule for %dump and %exit, which can appear also among measurements - fpd.y (frame_items, measurements): rearranged grammar to allow debug_item also in measurements. To avoid ambiguities, the "measurements" section can no longer be empty, but it can be omitted as a whole. - obj.h, dump.c (later, recurse_vec, order_frame): vectors now also have a "dumped" flag which is used in "later" to defer dumping an object until all the vectors it depends on have been dumped. git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5928 99fdad57-331a-0410-800a-d7fa5415bdb3 --- dump.c | 8 +++++++- fpd.y | 14 ++++++++++++-- obj.h | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/dump.c b/dump.c index de9f1f5..8e4f738 100644 --- a/dump.c +++ b/dump.c @@ -75,6 +75,8 @@ static int need(const struct vec *base, const struct vec *prev) static int later(const struct vec *base, const struct vec *prev) { + return base && !base->dumped; +#if 0 while (1) { prev = prev->next; if (!prev) @@ -83,6 +85,7 @@ static int later(const struct vec *base, const struct vec *prev) return 1; } return 0; +#endif } @@ -134,7 +137,7 @@ static void put_obj(struct order **curr, struct obj *obj, } /* - * Tricky logic ahead: when dumping a vector, we search for a vectors that + * Tricky logic ahead: when dumping a vector, we search for a vector that * depends on that vector for ".". If we find one, we dump it immediately after * this vector. */ @@ -144,6 +147,7 @@ static void recurse_vec(struct order **curr, struct vec *vec) struct vec *next; struct obj *obj; + vec->dumped = 1; add_item(curr, vec, NULL); for (obj = vec->frame->objs; obj; obj = obj->next) if (may_put_obj_now(obj, vec)) @@ -178,6 +182,8 @@ struct order *order_frame(const struct frame *frame) if (obj->type != ot_meas) n++; + for (vec = frame->vecs; vec; vec = vec->next) + vec->dumped = 0; for (obj = frame->objs; obj; obj = obj->next) obj->dumped = 0; diff --git a/fpd.y b/fpd.y index cddfedb..0f23e7d 100644 --- a/fpd.y +++ b/fpd.y @@ -404,7 +404,7 @@ frame_def: ; frame_items: - measurements + | measurements | frame_item frame_items ; @@ -459,7 +459,11 @@ frame_item: if (!dbg_print($2)) YYABORT; } - | TOK_DBG_DUMP + | debug_item + ; + +debug_item: + TOK_DBG_DUMP { /* * It's okay to do append the root frame multiple @@ -718,11 +722,17 @@ pad_type: ; measurements: + meas + { + *next_obj = $1; + next_obj = &$1->next; + } | measurements meas { *next_obj = $2; next_obj = &$2->next; } + | measurements debug_item ; meas: diff --git a/obj.h b/obj.h index 7b54e73..e70f5e0 100644 --- a/obj.h +++ b/obj.h @@ -142,6 +142,9 @@ struct vec { /* for re-ordering after a move */ int mark; + /* for dumping */ + int dumped; + /* for the GUI */ GtkWidget *list_widget; /* NULL if items aren't shown */ };