1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-09-30 15:09:47 +03:00
fped/gui_meas.c

471 lines
9.4 KiB
C
Raw Normal View History

/*
* gui_meas.c - GUI, measurements
*
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
* Written 2009, 2010 by Werner Almesberger
* Copyright 2009, 2010 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "util.h"
#include "coord.h"
#include "meas.h"
#include "inst.h"
#include "gui_canvas.h"
#include "gui_tool.h"
#include "gui_meas.h"
static struct inst *meas_inst; /* point from which we're dragging */
static enum {
min_to_next_or_max,
max_to_min,
next_to_min,
} mode;
/* ----- measurement type characteristics ---------------------------------- */
static struct meas_dsc {
lt_op_type lt;
enum meas_type type;
} *meas_dsc;
static struct meas_dsc meas_dsc_xy = {
.lt = lt_xy,
.type = mt_xy_next,
};
static struct meas_dsc meas_dsc_x = {
.lt = lt_x,
.type = mt_x_next,
};
static struct meas_dsc meas_dsc_y = {
.lt = lt_y,
.type = mt_y_next,
};
/* ----- min/next/max tester ----------------------------------------------- */
static int is_min(lt_op_type lt, const struct inst *inst)
{
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
const struct sample *min;
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
min = meas_find_min(lt, active_pkg->samples[inst->vec->n], NULL);
return coord_eq(inst->u.vec.end, min->pos);
}
static int is_next(lt_op_type lt,
const struct inst *inst, const struct inst *ref)
{
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
const struct sample *next;
next = meas_find_next(lt, active_pkg->samples[inst->vec->n],
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
ref->u.vec.end, NULL);
return coord_eq(inst->u.vec.end, next->pos);
}
static int is_max(lt_op_type lt, const struct inst *inst)
{
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
const struct sample *max;
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
max = meas_find_max(lt, active_pkg->samples[inst->vec->n], NULL);
return coord_eq(inst->u.vec.end, max->pos);
}
static int is_a_next(lt_op_type lt, struct inst *inst)
{
struct inst *a;
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
const struct sample *min, *next;
for (a = insts_ip_vec(); a; a = a->next) {
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
min = meas_find_min(lt, active_pkg->samples[a->vec->n], NULL);
next = meas_find_next(lt, active_pkg->samples[inst->vec->n],
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
min->pos, NULL);
if (coord_eq(next->pos, inst->u.vec.end))
return 1;
}
return 0;
}
#if 0
static int is_min_of_next(lt_op_type lt,
const struct inst *inst, const struct inst *ref)
{
struct coord min, next;
min = meas_find_min(lt, inst->vec->samples);
next = meas_find_next(lt, ref->vec->samples, min);
return coord_eq(next, ref->u.vec.end);
}
#endif
/* ----- picker functions -------------------------------------------------- */
static int meas_pick_vec_a(struct inst *inst, void *ctx)
{
struct vec *vec = inst->vec;
if (!active_pkg->samples[vec->n])
return 0;
if (is_min(meas_dsc->lt, inst)) {
mode = min_to_next_or_max;
return 1;
}
if (is_max(meas_dsc->lt, inst)) {
mode = max_to_min;
return 1;
}
if (is_a_next(meas_dsc->lt, inst)) {
mode = next_to_min;
return 1;
}
return 0;
}
static int meas_pick_vec_b(struct inst *inst, void *ctx)
{
struct vec *vec = inst->vec;
struct inst *a = ctx;
if (!active_pkg->samples[vec->n])
return 0;
switch (mode) {
case min_to_next_or_max:
if (is_max(meas_dsc->lt, inst))
return 1;
if (is_next(meas_dsc->lt, inst, a))
return 1;
return 0;
case max_to_min:
return is_min(meas_dsc->lt, inst);
case next_to_min:
if (!is_min(meas_dsc->lt, inst))
return 0;
return is_next(meas_dsc->lt, a, inst);
// return is_min_of_next(meas_dsc->lt, inst, a);
default:
abort();
}
}
/* ----- highlighting ------------------------------------------------------ */
static void meas_highlight_a(void)
{
inst_highlight_vecs(meas_pick_vec_a, NULL);
}
static void meas_highlight_b(void)
{
inst_highlight_vecs(meas_pick_vec_b, meas_inst);
}
/* ----- meas -------------------------------------------------------------- */
struct pix_buf *draw_move_meas(struct inst *inst, struct coord pos, int i)
{
return draw_move_line_common(inst, inst->u.meas.end, pos,
inst->obj->u.meas.inverted ? 1-i : i);
}
/* ----- tool selection ---------------------------------------------------- */
static void tool_selected_meas(void)
{
highlight = meas_highlight_a;
redraw();
}
static void tool_selected_meas_xy(void)
{
meas_dsc = &meas_dsc_xy;
tool_selected_meas();
}
static void tool_selected_meas_x(void)
{
meas_dsc = &meas_dsc_x;
tool_selected_meas();
}
static void tool_selected_meas_y(void)
{
meas_dsc = &meas_dsc_y;
tool_selected_meas();
}
static void tool_deselected_meas(void)
{
highlight = NULL;
redraw();
}
/* ----- find start point (new measurement) -------------------------------- */
static int is_highlighted(struct inst *inst, void *user)
{
return inst->u.vec.highlighted;
}
static struct inst *find_point_meas_new(struct coord pos)
{
return inst_find_vec(pos, is_highlighted, NULL);
}
/* ----- begin dragging new measurement ------------------------------------ */
static void begin_drag_new_meas(struct inst *inst)
{
highlight = meas_highlight_b;
meas_inst = inst;
if (is_min(meas_dsc->lt, inst))
mode = min_to_next_or_max;
else if (is_max(meas_dsc->lt, inst))
mode = max_to_min;
else
mode = next_to_min;
redraw();
}
/* ----- end dragging new measurement -------------------------------------- */
static int end_new_meas(struct inst *from, struct inst *to)
{
struct obj *obj;
struct meas *meas;
meas_inst = NULL;
highlight = NULL;
if (from == to)
return 0;
/* it's safe to pass "from" here, but we may change it later */
obj = new_obj_unconnected(ot_meas, from);
connect_obj(frames, obj);
meas = &obj->u.meas;
meas->label = NULL;
switch (mode) {
case min_to_next_or_max:
if (!is_max(meas_dsc->lt, to)) {
meas->type = meas_dsc->type;
} else {
meas->type = meas_dsc->type+3;
}
obj->base = from->vec;
meas->high = to->vec;
break;
case next_to_min:
meas->type = meas_dsc->type;
obj->base = to->vec;
meas->high = from->vec;
break;
case max_to_min:
meas->type = meas_dsc->type+3;
obj->base = to->vec;
meas->high = from->vec;
break;
default:
abort();
}
meas->inverted =
mode == min_to_next_or_max && is_min(meas_dsc->lt, to) ? 0 :
meas_dsc->lt(from->u.vec.end, to->u.vec.end) !=
(mode == min_to_next_or_max);
meas->offset = NULL;
meas_dsc = NULL;
The mechanism for selecting points for measurements reaches its limits when using frames to encapsulate building blocks, e.g., like macros or functions in a programming language. Since measurements only know about the frame containing a vector but not the frames containing that frame, invocations of this frame from different places can only be distinguished within the min/next/max scheme. (See the example in README.) To eliminate this limitation, one needs a way to tell fped to consider a point only if it has been instantiated through a certain path, e.g., by requiring some other frames to be visited in its instantiation. This increases the number of distinct points available for measurements. The mechanism chosen is to qualify a measurement point with frames that lead to it. This list of outer frames does not have to include all frames. Without qualifying, the old behaviour results. Note that this doesn't cover all possible ways in which a point can appear in different roles. Multiple frame references can also result from repeating the same frame reference in the same parent frame. The current qualification mechanism does not allow such paths to be distinguished. However, one can always introduce intermediate frames for this purpose. Furthermore, repetitions create multiple instances of a point, although in what should be considered the same role. - fpd.l: make scanner support free-format a little better by switching back to keyword mode after frame braces. This way, one can write a simple frame in a single line, which is useful for regression tests. - fpd.l, fpd.y, README, test/dbg_meas: added %meas directive to print the result of a measurement - fpd.y, README: measurements can now be labeled. Note that, due to limitations of the grammar, the first measurement cannot be labeled. - error.h, error.c (yywarn): new function for non-fatal diagnostics that always get reported to standard error - bitset.h, bitset.c: functions to manipulate variable-size bit sets - meas.h, fpd.y, README, test/meas_qual: added the means to specify qualifiers for points used in measurements - dump.c (print_meas_base, print_meas): dump qualifiers - delete.c (delete_references, test/del_frame): delete measurements that reference a frame being deleted in their qualifiers - obj.h, obj.c (enumerate_frames, instantiate): enumerate all frames so that we have an index into the bit vector of visited frames - meas.h, meas.c (reset_samples, meas_post), obj.c (generate_vecs, generate_frame, instantiate): record the set of frames visited for each sample - meas.c (meas_post): only treat two instances of a point as equivalent if the set of frames visited of one of them is a superset of set of the other. In this case, keep the union of the two sets. - meas.h, meas.c (meas_find_min, meas_find_next, meas_find_max), test/meas_qual: instantiate_meas_pkg only select points for which all frames in the qualification have been visited - gui_meas.c (is_min, is_next, is_max, is_a_next): updated for above change - inst.h, inst.c (curr_frame, propagate_bbox, add_inst, inst_begin_frame, inst_end_frame, inst_start): renamed curr_frame to frame_instantiating to avoid clash with curr_frame in fpd.y - inst.h, inst.c (find_meas_hint): make global - test/structure, test/del_vec, test/del_frame: fped now warns if a measurement is in an unlinked frame. Changed regressions tests to avoid this warning. - test/Common: new function expect_grep to compare only part of the output git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5967 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-05-30 00:13:48 +03:00
/* we don't support qualifiers through the GUI yet */
meas->low_qual = NULL;
meas->high_qual = NULL;
return 1;
}
static void cancel_drag_new_meas(void)
{
meas_inst = NULL;
highlight = NULL;
redraw();
}
/* ----- begin dragging existing measurement ------------------------------- */
/*
* We didn't record which instance provided the vector we're using here, so we
* have to search for it now.
*/
static struct inst *vec_at(const struct vec *vec, struct coord pos)
{
struct inst *inst;
const struct sample *s;
for (inst = insts_ip_vec(); inst; inst = inst->next)
if (inst->vec == vec)
for (s = active_pkg->samples[vec->n]; s; s = s->next)
if (coord_eq(s->pos, pos))
return inst;
abort();
}
void begin_drag_move_meas(struct inst *inst, int i)
{
const struct meas *meas = &inst->obj->u.meas;
struct coord a, b;
switch (meas->type) {
case mt_xy_next:
case mt_xy_max:
meas_dsc = &meas_dsc_xy;
break;
case mt_x_next:
case mt_x_max:
meas_dsc = &meas_dsc_x;
break;
case mt_y_next:
case mt_y_max:
meas_dsc = &meas_dsc_y;
break;
default:
abort();
}
highlight = meas_highlight_b;
/*
* We're setting up the same conditions as after picking the first
* point when making a new measurement. Thus, we set meas_inst to the
* vector to the endpoint we're not moving.
*/
a = inst->base;
b = inst->u.meas.end;
if (inst->obj->u.meas.inverted)
SWAP(a, b);
switch (i) {
case 0:
mode = meas->type < 3 ? next_to_min : max_to_min;
meas_inst = vec_at(inst->obj->u.meas.high, b);
break;
case 1:
mode = min_to_next_or_max;
meas_inst = vec_at(inst->obj->base, a);
break;
default:
abort();
}
// redraw();
}
/* ----- find end point (existing measurement) ----------------------------- */
struct inst *find_point_meas_move(struct inst *inst, struct coord pos)
{
return inst_find_vec(pos, is_highlighted, NULL);
}
/* ----- end dragging existing measurements -------------------------------- */
void end_drag_move_meas(void)
{
highlight = NULL;
redraw();
}
void do_move_to_meas(struct inst *inst, struct inst *to, int i)
{
struct meas *meas = &inst->obj->u.meas;
switch (i) {
case 0:
inst->obj->base = inst_get_vec(to);
break;
case 1:
meas->high = inst_get_vec(to);
if (is_max(meas_dsc->lt, to))
meas->type = (meas->type % 3)+3;
else
meas->type = (meas->type % 3);
break;
default:
abort();
}
}
/* ----- operations -------------------------------------------------------- */
struct tool_ops tool_meas_ops = {
.tool_selected = tool_selected_meas_xy,
.tool_deselected= tool_deselected_meas,
.find_point = find_point_meas_new,
.begin_drag_new = begin_drag_new_meas,
.drag_new = drag_new_line,
.end_new = end_new_meas,
.cancel_drag_new= cancel_drag_new_meas,
};
struct tool_ops tool_meas_ops_x = {
.tool_selected = tool_selected_meas_x,
.tool_deselected= tool_deselected_meas,
.find_point = find_point_meas_new,
.begin_drag_new = begin_drag_new_meas,
.drag_new = drag_new_line,
.end_new = end_new_meas,
.cancel_drag_new= cancel_drag_new_meas,
};
struct tool_ops tool_meas_ops_y = {
.tool_selected = tool_selected_meas_y,
.tool_deselected= tool_deselected_meas,
.find_point = find_point_meas_new,
.begin_drag_new = begin_drag_new_meas,
.drag_new = drag_new_line,
.end_new = end_new_meas,
.cancel_drag_new= cancel_drag_new_meas,
};