mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-18 00:49:23 +02:00
- dumping now labels all vectors, even those we only reference as .
- dump objects only after all the vectors they reference have been dumped - instead of relying on clever algorithms to dump each object only once, just mark them - left "dump" enabled in "main", oops git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5392 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
68b4fec921
commit
b5dd18c564
84
dump.c
84
dump.c
@ -82,17 +82,11 @@ static void dump_loop(FILE *file, const struct loop *loop, const char *indent)
|
|||||||
/* ----- vectors and objects ----------------------------------------------- */
|
/* ----- vectors and objects ----------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
static char *base_name(const struct vec *vec, const struct vec *base)
|
static char *generate_name(const struct vec *base)
|
||||||
{
|
{
|
||||||
const struct vec *walk;
|
const struct vec *walk;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (!base)
|
|
||||||
return stralloc("@");
|
|
||||||
if (vec && base->next == vec)
|
|
||||||
return stralloc(".");
|
|
||||||
if (base->name)
|
|
||||||
return stralloc(base->name);
|
|
||||||
n = 0;
|
n = 0;
|
||||||
for (walk = base->frame->vecs; walk != base; walk = walk->next)
|
for (walk = base->frame->vecs; walk != base; walk = walk->next)
|
||||||
n++;
|
n++;
|
||||||
@ -101,11 +95,23 @@ static char *base_name(const struct vec *vec, const struct vec *base)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *base_name(const struct vec *base, const struct vec *next)
|
||||||
|
{
|
||||||
|
if (!base)
|
||||||
|
return stralloc("@");
|
||||||
|
if (next && base->next == next)
|
||||||
|
return stralloc(".");
|
||||||
|
if (base->name)
|
||||||
|
return stralloc(base->name);
|
||||||
|
return generate_name(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *obj_base_name(const struct vec *base, const struct vec *prev)
|
static char *obj_base_name(const struct vec *base, const struct vec *prev)
|
||||||
{
|
{
|
||||||
if (base && base == prev)
|
if (base && base == prev)
|
||||||
return stralloc(".");
|
return stralloc(".");
|
||||||
return base_name(NULL, base);
|
return base_name(base, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,40 +156,70 @@ static int need(const struct vec *base, const struct vec *prev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dump_obj(FILE *file, const struct obj *obj, const char *indent,
|
/*
|
||||||
const struct vec *prev)
|
* If we need a vector that's defined later, we have to defer dumping the
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int later(const struct vec *base, const struct vec *prev)
|
||||||
{
|
{
|
||||||
char *base, *s1, *s2, *s3;
|
while (prev) {
|
||||||
int n;
|
if (base == prev)
|
||||||
|
return 1;
|
||||||
|
prev = prev->next;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int may_dump_obj_now(const struct obj *obj, const struct vec *prev)
|
||||||
|
{
|
||||||
|
int n, l;
|
||||||
|
|
||||||
n = need(obj->base, prev);
|
n = need(obj->base, prev);
|
||||||
|
l = later(obj->base, prev);
|
||||||
|
|
||||||
switch (obj->type) {
|
switch (obj->type) {
|
||||||
case ot_frame:
|
case ot_frame:
|
||||||
break;
|
break;
|
||||||
case ot_line:
|
case ot_line:
|
||||||
n |= need(obj->u.line.other, prev);
|
n |= need(obj->u.line.other, prev);
|
||||||
|
l |= later(obj->u.line.other, prev);
|
||||||
break;
|
break;
|
||||||
case ot_rect:
|
case ot_rect:
|
||||||
n |= need(obj->u.rect.other, prev);
|
n |= need(obj->u.rect.other, prev);
|
||||||
|
l |= later(obj->u.rect.other, prev);
|
||||||
break;
|
break;
|
||||||
case ot_pad:
|
case ot_pad:
|
||||||
n |= need(obj->u.pad.other, prev);
|
n |= need(obj->u.pad.other, prev);
|
||||||
|
l |= later(obj->u.pad.other, prev);
|
||||||
break;
|
break;
|
||||||
case ot_arc:
|
case ot_arc:
|
||||||
n |= need(obj->u.arc.start, prev);
|
n |= need(obj->u.arc.start, prev);
|
||||||
n |= need(obj->u.arc.end, prev);
|
n |= need(obj->u.arc.end, prev);
|
||||||
|
l |= later(obj->u.arc.start, prev);
|
||||||
|
l |= later(obj->u.arc.end, prev);
|
||||||
break;
|
break;
|
||||||
case ot_meas:
|
case ot_meas:
|
||||||
n |= need(obj->u.meas.other, prev);
|
n |= need(obj->u.meas.other, prev);
|
||||||
|
l |= later(obj->u.meas.other, prev);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev ? !n : n)
|
return n && !l;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void dump_obj(FILE *file, struct obj *obj, const char *indent,
|
||||||
|
const struct vec *prev)
|
||||||
|
{
|
||||||
|
char *base, *s1, *s2, *s3;
|
||||||
|
|
||||||
|
if (obj->dumped)
|
||||||
|
return;
|
||||||
|
obj->dumped = 1;
|
||||||
base = obj_base_name(obj->base, prev);
|
base = obj_base_name(obj->base, prev);
|
||||||
switch (obj->type) {
|
switch (obj->type) {
|
||||||
case ot_frame:
|
case ot_frame:
|
||||||
@ -248,22 +284,26 @@ static void dump_obj(FILE *file, const struct obj *obj, const char *indent,
|
|||||||
static void recurse_vec(FILE *file, const struct vec *vec, const char *indent)
|
static void recurse_vec(FILE *file, const struct vec *vec, const char *indent)
|
||||||
{
|
{
|
||||||
const struct vec *next;
|
const struct vec *next;
|
||||||
const struct obj *obj;
|
struct obj *obj;
|
||||||
char *base, *x, *y;
|
char *base, *x, *y, *s;
|
||||||
|
|
||||||
base = base_name(vec, vec->base);
|
base = base_name(vec->base, vec);
|
||||||
x = unparse(vec->x);
|
x = unparse(vec->x);
|
||||||
y = unparse(vec->y);
|
y = unparse(vec->y);
|
||||||
if (vec->name)
|
if (vec->name)
|
||||||
fprintf(file, "%s%s: vec %s(%s, %s)\n",
|
fprintf(file, "%s%s: vec %s(%s, %s)\n",
|
||||||
indent, vec->name, base, x, y);
|
indent, vec->name, base, x, y);
|
||||||
else
|
else {
|
||||||
fprintf(file, "%svec %s(%s, %s)\n", indent, base, x, y);
|
s = generate_name(vec);
|
||||||
|
fprintf(file, "%s%s: vec %s(%s, %s)\n", indent, s, base, x, y);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
free(base);
|
free(base);
|
||||||
free(x);
|
free(x);
|
||||||
free(y);
|
free(y);
|
||||||
|
|
||||||
for (obj = vec->frame->objs; obj; obj = obj->next)
|
for (obj = vec->frame->objs; obj; obj = obj->next)
|
||||||
|
if (may_dump_obj_now(obj, vec))
|
||||||
dump_obj(file, obj, indent, vec);
|
dump_obj(file, obj, indent, vec);
|
||||||
if (n_vec_refs(vec) == 1) {
|
if (n_vec_refs(vec) == 1) {
|
||||||
for (next = vec->next; next->base != vec; next = next->next);
|
for (next = vec->next; next->base != vec; next = next->next);
|
||||||
@ -290,13 +330,17 @@ static void dump_frame(FILE *file, const struct frame *frame,
|
|||||||
{
|
{
|
||||||
const struct table *table;
|
const struct table *table;
|
||||||
const struct loop *loop;
|
const struct loop *loop;
|
||||||
const struct obj *obj;
|
struct obj *obj;
|
||||||
|
|
||||||
for (table = frame->tables; table; table = table->next)
|
for (table = frame->tables; table; table = table->next)
|
||||||
dump_table(file, table, indent);
|
dump_table(file, table, indent);
|
||||||
for (loop = frame->loops; loop; loop = loop->next)
|
for (loop = frame->loops; loop; loop = loop->next)
|
||||||
dump_loop(file, loop, indent);
|
dump_loop(file, loop, indent);
|
||||||
|
for (obj = frame->objs; obj; obj = obj->next)
|
||||||
|
obj->dumped = 0;
|
||||||
dump_vecs(file, frame->vecs, indent);
|
dump_vecs(file, frame->vecs, indent);
|
||||||
|
|
||||||
|
/* duh. do we need this ? */
|
||||||
for (obj = frame->objs; obj; obj = obj->next)
|
for (obj = frame->objs; obj; obj = obj->next)
|
||||||
dump_obj(file, obj, indent, NULL);
|
dump_obj(file, obj, indent, NULL);
|
||||||
}
|
}
|
||||||
|
2
fped.c
2
fped.c
@ -54,7 +54,7 @@ int main(int argc, char **argv)
|
|||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
dump(stdout);
|
// dump(stdout);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user