mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-12-23 06:02:03 +02:00
b2/: move relational operators to relop.[ch] (for sharing)
This also fixes a bug in dump_one_field, which switched > and >=
This commit is contained in:
parent
99e5777448
commit
a34702cd8d
@ -13,7 +13,8 @@ SHELL = /bin/bash
|
||||
|
||||
CFLAGS = -g -Wall $(shell pkg-config --cflags glib-2.0)
|
||||
SLOPPY = -Wno-unused -Wno-implicit-function-declaration
|
||||
OBJS = boom.o chr.o comp.o db.o dump.o eval.o param.o subex.o subst.o util.o \
|
||||
OBJS = boom.o chr.o comp.o db.o dump.o eval.o param.o relop.o \
|
||||
subex.o subst.o util.o \
|
||||
vstring.o lex.yy.o y.tab.o
|
||||
LDLIBS = -lfl $(shell pkg-config --libs glib-2.0)
|
||||
|
||||
|
21
b2/chr.c
21
b2/chr.c
@ -14,6 +14,7 @@
|
||||
|
||||
#include "util.h"
|
||||
#include "lang.h"
|
||||
#include "relop.h"
|
||||
#include "param.h"
|
||||
#include "chr.h"
|
||||
|
||||
@ -157,24 +158,8 @@ static void dump_one_field(FILE *file, const struct field *field, int level)
|
||||
for (cond = sel->cond; cond; cond = cond->next) {
|
||||
if (cond != sel->cond)
|
||||
fprintf(file, "|");
|
||||
switch (cond->relop) {
|
||||
case rel_lt:
|
||||
fprintf(file, "<");
|
||||
break;
|
||||
case rel_le:
|
||||
fprintf(file, "<=");
|
||||
break;
|
||||
case rel_eq:
|
||||
break;
|
||||
case rel_ge:
|
||||
fprintf(file, ">");
|
||||
break;
|
||||
case rel_gt:
|
||||
fprintf(file, ">=");
|
||||
break;
|
||||
default:
|
||||
fprintf(file, "?");
|
||||
}
|
||||
if (cond->relop != rel_eq)
|
||||
dump_relop(file, cond->relop);
|
||||
dump(file, field->fmt, &cond->value);
|
||||
}
|
||||
fprintf(file, ": ");
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bitset.h"
|
||||
#include "relop.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -28,14 +29,6 @@
|
||||
*/
|
||||
|
||||
|
||||
enum relop {
|
||||
rel_lt = 1 << 0,
|
||||
rel_le = 1 << 1,
|
||||
rel_eq = 1 << 2,
|
||||
rel_ge = 1 << 3,
|
||||
rel_gt = 1 << 4,
|
||||
};
|
||||
|
||||
struct equiv {
|
||||
const char *name;
|
||||
struct equiv *next;
|
||||
|
40
b2/relop.c
Normal file
40
b2/relop.c
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* relop.c - Relational operators
|
||||
*
|
||||
* Copyright 2012 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "relop.h"
|
||||
|
||||
|
||||
void dump_relop(FILE *file, enum relop op)
|
||||
{
|
||||
switch (op) {
|
||||
case rel_lt:
|
||||
fprintf(file, "<");
|
||||
break;
|
||||
case rel_le:
|
||||
fprintf(file, "<=");
|
||||
break;
|
||||
case rel_eq:
|
||||
fprintf(file, "=");
|
||||
break;
|
||||
case rel_ge:
|
||||
fprintf(file, ">=");
|
||||
break;
|
||||
case rel_gt:
|
||||
fprintf(file, ">");
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
30
b2/relop.h
Normal file
30
b2/relop.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* relop.h - Relational operators
|
||||
*
|
||||
* Copyright 2012 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef RELOP_H
|
||||
#define RELOP_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
enum relop {
|
||||
rel_lt = 1 << 0,
|
||||
rel_le = 1 << 1,
|
||||
rel_eq = 1 << 2,
|
||||
rel_ge = 1 << 3,
|
||||
rel_gt = 1 << 4,
|
||||
};
|
||||
|
||||
|
||||
void dump_relop(FILE *file, enum relop op);
|
||||
|
||||
#endif /* !RELOP_H */
|
Loading…
Reference in New Issue
Block a user