2009-08-05 03:32:38 +03:00
|
|
|
/*
|
|
|
|
* delete.c - Object deletion
|
|
|
|
*
|
2012-05-27 20:09:40 +03:00
|
|
|
* Written 2009, 2010, 2012 by Werner Almesberger
|
|
|
|
* Copyright 2009, 2010, 2012 by Werner Almesberger
|
2009-08-05 03:32:38 +03:00
|
|
|
*
|
|
|
|
* 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 <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "error.h"
|
|
|
|
#include "expr.h"
|
|
|
|
#include "obj.h"
|
|
|
|
#include "delete.h"
|
|
|
|
|
|
|
|
|
|
|
|
static struct deletion {
|
|
|
|
enum del_type {
|
|
|
|
dt_vec,
|
|
|
|
dt_obj,
|
2009-08-05 21:43:00 +03:00
|
|
|
dt_frame,
|
2009-08-07 00:57:18 +03:00
|
|
|
dt_table,
|
|
|
|
dt_row,
|
|
|
|
dt_column,
|
|
|
|
dt_loop,
|
2009-08-05 03:32:38 +03:00
|
|
|
} type;
|
|
|
|
union {
|
2009-08-05 21:43:00 +03:00
|
|
|
struct {
|
|
|
|
struct frame *ref;
|
|
|
|
struct frame *prev;
|
|
|
|
} frame;
|
2009-08-05 03:32:38 +03:00
|
|
|
struct {
|
|
|
|
struct vec *ref;
|
|
|
|
struct vec *prev;
|
|
|
|
} vec;
|
|
|
|
struct {
|
|
|
|
struct obj *ref;
|
|
|
|
struct obj *prev;
|
|
|
|
} obj;
|
2009-08-07 00:57:18 +03:00
|
|
|
struct {
|
|
|
|
struct table *ref;
|
|
|
|
struct table *prev;
|
|
|
|
} table;
|
|
|
|
struct {
|
|
|
|
struct row *ref;
|
|
|
|
struct row *prev;
|
|
|
|
} row;
|
2009-08-07 03:48:06 +03:00
|
|
|
struct column {
|
2009-08-07 00:57:18 +03:00
|
|
|
struct var *var;
|
|
|
|
struct value *values;
|
|
|
|
struct table *table;
|
|
|
|
int n;
|
|
|
|
} col;
|
|
|
|
struct {
|
|
|
|
struct loop *ref;
|
|
|
|
struct loop *prev;
|
|
|
|
} loop;
|
2009-08-05 03:32:38 +03:00
|
|
|
} u;
|
2009-08-06 07:33:49 +03:00
|
|
|
int group;
|
2009-08-05 03:32:38 +03:00
|
|
|
struct deletion *next;
|
|
|
|
} *deletions = NULL;
|
|
|
|
|
2009-08-06 07:33:49 +03:00
|
|
|
static int groups = 0;
|
|
|
|
|
|
|
|
|
|
|
|
static void do_delete_vec(struct vec *vec);
|
|
|
|
static void do_delete_obj(struct obj *obj);
|
|
|
|
|
2009-08-05 03:32:38 +03:00
|
|
|
|
2009-08-21 22:50:45 +03:00
|
|
|
/* ----- helper functions -------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-05 03:32:38 +03:00
|
|
|
static struct deletion *new_deletion(enum del_type type)
|
|
|
|
{
|
|
|
|
struct deletion *del;
|
|
|
|
|
|
|
|
del = alloc_type(struct deletion);
|
|
|
|
del->type = type;
|
2009-08-06 07:33:49 +03:00
|
|
|
del->group = groups;
|
2009-08-05 03:32:38 +03:00
|
|
|
del->next = deletions;
|
|
|
|
deletions = del;
|
|
|
|
return del;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-21 22:50:45 +03:00
|
|
|
static void reset_active_ref(struct frame *ref)
|
|
|
|
{
|
|
|
|
const struct frame *frame;
|
|
|
|
struct obj *obj = NULL;
|
|
|
|
|
|
|
|
for (frame = frames; frame; frame = frame->next)
|
|
|
|
for (obj = frame->objs; obj; obj = obj->next)
|
|
|
|
if (obj->type == ot_frame && obj->u.frame.ref == ref)
|
|
|
|
break;
|
|
|
|
ref->active_ref = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 03:32:38 +03:00
|
|
|
/* ----- vectors ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static void destroy_vec(struct vec *vec)
|
|
|
|
{
|
|
|
|
free_expr(vec->x);
|
|
|
|
free_expr(vec->y);
|
|
|
|
free(vec);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 07:33:49 +03:00
|
|
|
static void delete_vecs_by_ref(struct vec *vecs, const struct vec *ref)
|
2009-08-05 03:32:38 +03:00
|
|
|
{
|
2009-08-06 07:33:49 +03:00
|
|
|
while (vecs) {
|
|
|
|
if (vecs->base == ref)
|
|
|
|
do_delete_vec(vecs);
|
|
|
|
vecs = vecs->next;
|
|
|
|
}
|
2009-08-05 03:32:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 07:33:49 +03:00
|
|
|
static int obj_has_ref(const struct obj *obj, const struct vec *ref)
|
|
|
|
{
|
|
|
|
if (obj->base == ref)
|
|
|
|
return 1;
|
|
|
|
switch (obj->type) {
|
|
|
|
case ot_frame:
|
|
|
|
return 0;
|
|
|
|
case ot_line:
|
|
|
|
return obj->u.line.other == ref;
|
|
|
|
case ot_rect:
|
|
|
|
return obj->u.rect.other == ref;
|
|
|
|
case ot_pad:
|
|
|
|
return obj->u.pad.other == ref;
|
2010-04-25 13:58:07 +03:00
|
|
|
case ot_hole:
|
|
|
|
return obj->u.hole.other == ref;
|
2009-08-06 07:33:49 +03:00
|
|
|
case ot_arc:
|
|
|
|
return obj->u.arc.start == ref || obj->u.arc.end == ref;
|
|
|
|
case ot_meas:
|
2009-08-09 03:06:54 +03:00
|
|
|
return obj->u.meas.high == ref;
|
2012-05-27 20:09:40 +03:00
|
|
|
case ot_iprint:
|
|
|
|
return 0;
|
2009-08-06 07:33:49 +03:00
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void delete_objs_by_ref(struct obj **objs, const struct vec *ref)
|
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
for (obj = *objs; obj; obj = obj->next)
|
|
|
|
if (obj_has_ref(obj, ref))
|
|
|
|
do_delete_obj(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_delete_vec(struct vec *vec)
|
2009-08-05 03:32:38 +03:00
|
|
|
{
|
|
|
|
struct vec *walk, *prev;
|
|
|
|
struct deletion *del;
|
|
|
|
|
|
|
|
prev = NULL;
|
|
|
|
for (walk = vec->frame->vecs; walk != vec; walk = walk->next)
|
|
|
|
prev = walk;
|
|
|
|
if (prev)
|
|
|
|
prev->next = vec->next;
|
|
|
|
else
|
|
|
|
vec->frame->vecs = vec->next;
|
|
|
|
del = new_deletion(dt_vec);
|
|
|
|
del->u.vec.ref = vec;
|
|
|
|
del->u.vec.prev = prev;
|
2009-08-21 11:34:17 +03:00
|
|
|
|
|
|
|
delete_vecs_by_ref(vec->frame->vecs, vec);
|
|
|
|
delete_objs_by_ref(&vec->frame->objs, vec);
|
2010-04-28 03:34:32 +03:00
|
|
|
/*
|
|
|
|
* Catch measurements. During final cleanup, we may operate on an empty
|
|
|
|
* list of frames, hence the test.
|
|
|
|
*/
|
|
|
|
if (frames)
|
|
|
|
delete_objs_by_ref(&frames->objs, vec);
|
2009-08-05 03:32:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 07:33:49 +03:00
|
|
|
void delete_vec(struct vec *vec)
|
|
|
|
{
|
|
|
|
groups++;
|
|
|
|
do_delete_vec(vec);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 03:32:38 +03:00
|
|
|
static void undelete_vec(struct vec *vec, struct vec *prev)
|
|
|
|
{
|
|
|
|
if (prev) {
|
|
|
|
assert(vec->next == prev->next);
|
|
|
|
prev->next = vec;
|
|
|
|
} else {
|
|
|
|
assert(vec->next == vec->frame->vecs);
|
|
|
|
vec->frame->vecs = vec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- objects ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static void destroy_obj(struct obj *obj)
|
|
|
|
{
|
|
|
|
switch (obj->type) {
|
|
|
|
case ot_frame:
|
2009-08-07 03:48:06 +03:00
|
|
|
if (obj->u.frame.ref->active_ref == obj)
|
2009-08-21 22:50:45 +03:00
|
|
|
reset_active_ref(obj->u.frame.ref);
|
2009-08-05 03:32:38 +03:00
|
|
|
break;
|
|
|
|
case ot_pad:
|
|
|
|
free(obj->u.pad.name);
|
|
|
|
break;
|
2010-04-25 13:58:07 +03:00
|
|
|
case ot_hole:
|
|
|
|
break;
|
2009-08-05 03:32:38 +03:00
|
|
|
case ot_line:
|
2009-08-26 17:06:26 +03:00
|
|
|
if (obj->u.line.width)
|
|
|
|
free_expr(obj->u.line.width);
|
2009-08-05 03:32:38 +03:00
|
|
|
break;
|
|
|
|
case ot_rect:
|
2009-08-26 17:06:26 +03:00
|
|
|
if (obj->u.rect.width)
|
|
|
|
free_expr(obj->u.rect.width);
|
2009-08-05 03:32:38 +03:00
|
|
|
break;
|
|
|
|
case ot_arc:
|
2009-08-26 17:06:26 +03:00
|
|
|
if (obj->u.arc.width)
|
|
|
|
free_expr(obj->u.arc.width);
|
2009-08-05 03:32:38 +03:00
|
|
|
break;
|
|
|
|
case ot_meas:
|
2009-08-21 11:34:17 +03:00
|
|
|
if (obj->u.meas.label)
|
|
|
|
free(obj->u.meas.label);
|
2009-08-09 03:06:54 +03:00
|
|
|
if (obj->u.meas.offset)
|
|
|
|
free_expr(obj->u.meas.offset);
|
2009-08-05 03:32:38 +03:00
|
|
|
break;
|
2012-05-27 20:09:40 +03:00
|
|
|
case ot_iprint:
|
|
|
|
free_expr(obj->u.iprint.expr);
|
|
|
|
break;
|
2009-08-05 03:32:38 +03:00
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
free(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 07:33:49 +03:00
|
|
|
static void do_delete_obj(struct obj *obj)
|
2009-08-05 03:32:38 +03:00
|
|
|
{
|
|
|
|
struct obj *walk, *prev;
|
|
|
|
struct deletion *del;
|
|
|
|
|
|
|
|
prev = NULL;
|
|
|
|
for (walk = obj->frame->objs; walk != obj; walk = walk->next)
|
|
|
|
prev = walk;
|
|
|
|
if (prev)
|
|
|
|
prev->next = obj->next;
|
|
|
|
else
|
|
|
|
obj->frame->objs = obj->next;
|
|
|
|
del = new_deletion(dt_obj);
|
|
|
|
del->u.obj.ref = obj;
|
|
|
|
del->u.obj.prev = prev;
|
2009-08-16 02:25:05 +03:00
|
|
|
if (obj->type == ot_frame && obj->u.frame.ref->active_ref == obj)
|
2009-08-21 22:50:45 +03:00
|
|
|
reset_active_ref(obj->u.frame.ref);
|
2009-08-05 03:32:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 07:33:49 +03:00
|
|
|
void delete_obj(struct obj *obj)
|
|
|
|
{
|
|
|
|
groups++;
|
|
|
|
do_delete_obj(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 03:32:38 +03:00
|
|
|
static void undelete_obj(struct obj *obj, struct obj *prev)
|
|
|
|
{
|
|
|
|
if (prev) {
|
|
|
|
assert(obj->next == prev->next);
|
|
|
|
prev->next = obj;
|
|
|
|
} else {
|
|
|
|
assert(obj->next == obj->frame->objs);
|
|
|
|
obj->frame->objs = obj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-07 00:57:18 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* ----- rows -------------------------------------------------------------- */
|
2009-08-06 23:19:00 +03:00
|
|
|
|
|
|
|
|
2009-08-21 11:34:17 +03:00
|
|
|
static void destroy_row(struct row *row)
|
|
|
|
{
|
|
|
|
struct value *next_value;
|
|
|
|
|
|
|
|
while (row->values) {
|
|
|
|
next_value = row->values->next;
|
|
|
|
free_expr(row->values->expr);
|
|
|
|
free(row->values);
|
|
|
|
row->values = next_value;
|
|
|
|
}
|
|
|
|
free(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 23:19:00 +03:00
|
|
|
void delete_row(struct row *row)
|
|
|
|
{
|
2009-08-07 00:57:18 +03:00
|
|
|
struct deletion *del;
|
|
|
|
struct row *walk, *prev;
|
|
|
|
|
|
|
|
groups++;
|
|
|
|
prev = NULL;
|
|
|
|
for (walk = row->table->rows; walk != row; walk = walk->next)
|
|
|
|
prev = walk;
|
|
|
|
if (prev)
|
|
|
|
prev->next = row->next;
|
|
|
|
else
|
|
|
|
row->table->rows = row->next;
|
|
|
|
del = new_deletion(dt_row);
|
|
|
|
del->u.row.ref = row;
|
|
|
|
del->u.row.prev = prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void undelete_row(struct row *row, struct row *prev)
|
|
|
|
{
|
|
|
|
if (prev) {
|
|
|
|
assert(row->next == prev->next);
|
|
|
|
prev->next = row;
|
|
|
|
} else {
|
|
|
|
assert(row->next == row->table->rows);
|
|
|
|
row->table->rows = row;
|
|
|
|
}
|
2009-08-06 23:19:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-07 00:57:18 +03:00
|
|
|
/* ----- columns ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-06 23:19:00 +03:00
|
|
|
void delete_column(struct table *table, int n)
|
|
|
|
{
|
2009-08-07 03:48:06 +03:00
|
|
|
struct deletion *del;
|
|
|
|
struct column *col;
|
|
|
|
struct var **var;
|
|
|
|
struct row *row;
|
|
|
|
struct value **next, **value;
|
|
|
|
int i;
|
|
|
|
|
2009-08-07 00:57:18 +03:00
|
|
|
groups++;
|
2009-08-07 03:48:06 +03:00
|
|
|
|
|
|
|
del = new_deletion(dt_column);
|
|
|
|
col = &del->u.col;
|
|
|
|
col->table = table;
|
|
|
|
col->n = n;
|
|
|
|
|
|
|
|
var = &table->vars;
|
|
|
|
for (i = 0; i != n; i++)
|
|
|
|
var = &(*var)->next;
|
|
|
|
col->var = *var;
|
|
|
|
*var = (*var)->next;
|
|
|
|
|
|
|
|
next = &col->values;
|
|
|
|
for (row = table->rows; row; row = row->next) {
|
|
|
|
value = &row->values;
|
|
|
|
for (i = 0; i != n; i++)
|
|
|
|
value = &(*value)->next;
|
|
|
|
*next = *value;
|
|
|
|
*value = (*value)->next;
|
|
|
|
next = &(*next)->next;
|
|
|
|
}
|
|
|
|
*next = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void undelete_column(const struct column *col)
|
|
|
|
{
|
|
|
|
struct var **var;
|
|
|
|
struct row *row;
|
|
|
|
struct value **anchor, *value, *next;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
var = &col->table->vars;
|
|
|
|
for (i = 0; i != col->n; i++)
|
|
|
|
var = &(*var)->next;
|
|
|
|
col->var->next = *var;
|
|
|
|
*var = col->var;
|
|
|
|
|
|
|
|
value = col->values;
|
|
|
|
for (row = col->table->rows; row; row = row->next) {
|
|
|
|
anchor = &row->values;
|
|
|
|
for (i = 0; i != col->n; i++)
|
|
|
|
anchor = &(*anchor)->next;
|
|
|
|
next = value->next;
|
|
|
|
value->next = *anchor;
|
|
|
|
*anchor = value;
|
|
|
|
value = next;
|
|
|
|
}
|
2009-08-06 23:19:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-07 00:57:18 +03:00
|
|
|
/* ----- tables ------------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
2009-08-21 11:34:17 +03:00
|
|
|
static void destroy_table(struct table *table)
|
|
|
|
{
|
|
|
|
struct var *next_var;
|
|
|
|
|
|
|
|
while (table->vars) {
|
|
|
|
next_var = table->vars->next;
|
|
|
|
free(table->vars);
|
|
|
|
table->vars = next_var;
|
|
|
|
}
|
|
|
|
while (table->rows) {
|
|
|
|
delete_row(table->rows);
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
free(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 23:19:00 +03:00
|
|
|
void delete_table(struct table *table)
|
|
|
|
{
|
2009-08-07 00:57:18 +03:00
|
|
|
struct frame *frame = table->vars->frame;
|
|
|
|
struct deletion *del;
|
|
|
|
struct table *walk, *prev;
|
|
|
|
|
|
|
|
groups++;
|
|
|
|
prev = NULL;
|
|
|
|
for (walk = frame->tables; walk != table; walk = walk->next)
|
|
|
|
prev = walk;
|
|
|
|
if (prev)
|
|
|
|
prev->next = table->next;
|
|
|
|
else
|
|
|
|
frame->tables = table->next;
|
|
|
|
del = new_deletion(dt_table);
|
|
|
|
del->u.table.ref = table;
|
|
|
|
del->u.table.prev = prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void undelete_table(struct table *table, struct table *prev)
|
|
|
|
{
|
|
|
|
struct frame *frame = table->vars->frame;
|
|
|
|
|
|
|
|
if (prev) {
|
|
|
|
assert(table->next == prev->next);
|
|
|
|
prev->next = table;
|
|
|
|
} else {
|
|
|
|
assert(table->next == frame->tables);
|
|
|
|
frame->tables = table;
|
|
|
|
}
|
2009-08-06 23:19:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- loops ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-21 11:34:17 +03:00
|
|
|
static void destroy_loop(struct loop *loop)
|
|
|
|
{
|
|
|
|
free_expr(loop->from.expr);
|
|
|
|
free_expr(loop->to.expr);
|
|
|
|
free(loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 23:19:00 +03:00
|
|
|
void delete_loop(struct loop *loop)
|
|
|
|
{
|
2009-08-07 00:57:18 +03:00
|
|
|
struct frame *frame = loop->var.frame;
|
|
|
|
struct deletion *del;
|
|
|
|
struct loop *walk, *prev;
|
|
|
|
|
|
|
|
groups++;
|
|
|
|
prev = NULL;
|
|
|
|
for (walk = frame->loops; walk != loop; walk = walk->next)
|
|
|
|
prev = walk;
|
|
|
|
if (prev)
|
|
|
|
prev->next = loop->next;
|
|
|
|
else
|
|
|
|
frame->loops = loop->next;
|
|
|
|
del = new_deletion(dt_loop);
|
|
|
|
del->u.loop.ref = loop;
|
|
|
|
del->u.loop.prev = prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void undelete_loop(struct loop *loop, struct loop *prev)
|
|
|
|
{
|
|
|
|
struct frame *frame = loop->var.frame;
|
|
|
|
|
|
|
|
if (prev) {
|
|
|
|
assert(loop->next == prev->next);
|
|
|
|
prev->next = loop;
|
|
|
|
} else {
|
|
|
|
assert(loop->next == frame->loops);
|
|
|
|
frame->loops = loop;
|
|
|
|
}
|
2009-08-06 23:19:00 +03:00
|
|
|
}
|
|
|
|
|
2009-08-05 03:32:38 +03:00
|
|
|
|
2009-08-05 21:43:00 +03:00
|
|
|
/* ----- frames ------------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
2009-08-21 11:34:17 +03:00
|
|
|
static void destroy_frame(struct frame *frame)
|
|
|
|
{
|
|
|
|
while (frame->tables) {
|
|
|
|
delete_table(frame->tables);
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
while (frame->loops) {
|
|
|
|
delete_loop(frame->loops);
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
while (frame->vecs) {
|
|
|
|
delete_vec(frame->vecs);
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
while (frame->objs) {
|
|
|
|
delete_obj(frame->objs);
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
free(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
static int qual_ref(const struct frame_qual *qual, const struct frame *ref)
|
|
|
|
{
|
|
|
|
while (qual) {
|
|
|
|
if (qual->frame == ref)
|
|
|
|
return 1;
|
|
|
|
qual = qual->next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 21:43:00 +03:00
|
|
|
static void delete_references(const struct frame *ref)
|
|
|
|
{
|
|
|
|
struct frame *frame;
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
for (frame = frames; frame; frame = frame->next)
|
|
|
|
for (obj = frame->objs; obj; obj = obj->next)
|
2010-04-28 01:36:46 +03:00
|
|
|
switch (obj->type) {
|
|
|
|
case ot_frame:
|
2009-08-05 21:43:00 +03:00
|
|
|
if (obj->u.frame.ref == ref)
|
2009-08-21 11:34:17 +03:00
|
|
|
do_delete_obj(obj);
|
2010-04-28 01:36:46 +03:00
|
|
|
break;
|
|
|
|
case ot_meas:
|
|
|
|
if (obj->base->frame == 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
|
|
|
obj->u.meas.high->frame == ref ||
|
|
|
|
qual_ref(obj->u.meas.low_qual, ref) ||
|
|
|
|
qual_ref(obj->u.meas.high_qual, ref))
|
2010-04-28 01:36:46 +03:00
|
|
|
do_delete_obj(obj);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-08-21 22:50:45 +03:00
|
|
|
for (obj = ref->objs; obj; obj = obj->next)
|
|
|
|
if (obj->type == ot_frame)
|
|
|
|
if (obj->u.frame.ref->active_ref == obj)
|
|
|
|
reset_active_ref(obj->u.frame.ref);
|
2009-08-05 21:43:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void delete_frame(struct frame *frame)
|
|
|
|
{
|
|
|
|
struct deletion *del;
|
2010-04-28 03:34:32 +03:00
|
|
|
struct frame *walk;
|
2009-08-06 07:33:49 +03:00
|
|
|
groups++;
|
2009-08-05 21:43:00 +03:00
|
|
|
|
|
|
|
del = new_deletion(dt_frame);
|
|
|
|
del->u.frame.ref = frame;
|
2010-04-28 03:34:32 +03:00
|
|
|
del->u.frame.prev = NULL;
|
|
|
|
for (walk = frames; walk != frame; walk = walk->next)
|
|
|
|
del->u.frame.prev = walk;
|
|
|
|
if (del->u.frame.prev)
|
|
|
|
del->u.frame.prev->next = frame->next;
|
2009-08-05 21:43:00 +03:00
|
|
|
else
|
2010-04-28 03:34:32 +03:00
|
|
|
frames = frame->next; /* hmm, deleting the root frame ? */
|
2009-08-21 11:34:17 +03:00
|
|
|
|
|
|
|
delete_references(frame);
|
2009-08-05 21:43:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void undelete_frame(struct frame *frame, struct frame *prev)
|
|
|
|
{
|
|
|
|
if (prev) {
|
|
|
|
assert(frame->next == prev->next);
|
|
|
|
prev->next = frame;
|
|
|
|
} else {
|
|
|
|
assert(frame->next == frames);
|
|
|
|
frames = frame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 03:32:38 +03:00
|
|
|
/* ----- destroy/undelete interface ---------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-21 11:34:17 +03:00
|
|
|
static void destroy_one(void)
|
2009-08-05 03:32:38 +03:00
|
|
|
{
|
|
|
|
struct deletion *del;
|
|
|
|
|
|
|
|
del = deletions;
|
|
|
|
switch (del->type) {
|
|
|
|
case dt_vec:
|
|
|
|
destroy_vec(del->u.vec.ref);
|
|
|
|
break;
|
|
|
|
case dt_obj:
|
|
|
|
destroy_obj(del->u.obj.ref);
|
|
|
|
break;
|
2009-08-05 21:43:00 +03:00
|
|
|
case dt_frame:
|
2009-08-21 11:34:17 +03:00
|
|
|
destroy_frame(del->u.frame.ref);
|
|
|
|
break;
|
|
|
|
case dt_loop:
|
|
|
|
destroy_loop(del->u.loop.ref);
|
|
|
|
break;
|
|
|
|
case dt_table:
|
|
|
|
destroy_table(del->u.table.ref);
|
|
|
|
break;
|
|
|
|
case dt_row:
|
|
|
|
destroy_row(del->u.row.ref);
|
|
|
|
break;
|
|
|
|
case dt_column:
|
|
|
|
abort(); /* @@@ later */
|
2009-08-05 21:43:00 +03:00
|
|
|
break;
|
2009-08-05 03:32:38 +03:00
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
deletions = del->next;
|
|
|
|
free(del);
|
2009-08-21 11:34:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void destroy(void)
|
|
|
|
{
|
|
|
|
int group;
|
|
|
|
|
|
|
|
assert(deletions);
|
|
|
|
group = deletions->group;
|
|
|
|
while (deletions && deletions->group == group)
|
|
|
|
destroy_one();
|
2009-08-05 03:32:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-06 07:33:49 +03:00
|
|
|
static int undelete_one(void)
|
2009-08-05 03:32:38 +03:00
|
|
|
{
|
|
|
|
struct deletion *del;
|
|
|
|
|
|
|
|
if (!deletions)
|
|
|
|
return 0;
|
|
|
|
del = deletions;
|
|
|
|
switch (del->type) {
|
|
|
|
case dt_vec:
|
|
|
|
undelete_vec(del->u.vec.ref, del->u.vec.prev);
|
|
|
|
break;
|
|
|
|
case dt_obj:
|
|
|
|
undelete_obj(del->u.obj.ref, del->u.obj.prev);
|
|
|
|
break;
|
2009-08-05 21:43:00 +03:00
|
|
|
case dt_frame:
|
|
|
|
undelete_frame(del->u.frame.ref, del->u.frame.prev);
|
|
|
|
break;
|
2009-08-07 00:57:18 +03:00
|
|
|
case dt_loop:
|
|
|
|
undelete_loop(del->u.loop.ref, del->u.loop.prev);
|
|
|
|
break;
|
|
|
|
case dt_table:
|
|
|
|
undelete_table(del->u.table.ref, del->u.table.prev);
|
|
|
|
break;
|
|
|
|
case dt_row:
|
|
|
|
undelete_row(del->u.row.ref, del->u.row.prev);
|
|
|
|
break;
|
2009-08-07 03:48:06 +03:00
|
|
|
case dt_column:
|
|
|
|
undelete_column(&del->u.col);
|
|
|
|
break;
|
2009-08-05 03:32:38 +03:00
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
deletions = del->next;
|
|
|
|
free(del);
|
|
|
|
return 1;
|
|
|
|
}
|
2009-08-06 07:33:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
int undelete(void)
|
|
|
|
{
|
|
|
|
int group;
|
|
|
|
|
|
|
|
if (!deletions)
|
|
|
|
return 0;
|
|
|
|
group = deletions->group;
|
|
|
|
while (deletions && deletions->group == group)
|
|
|
|
undelete_one();
|
|
|
|
return 1;
|
|
|
|
}
|
2009-08-21 11:34:17 +03:00
|
|
|
|
|
|
|
|
|
|
|
void purge(void)
|
|
|
|
{
|
|
|
|
while (deletions)
|
|
|
|
destroy();
|
|
|
|
}
|