Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 as promised make the last ops table auto...
details: https://anonhg.NetBSD.org/src/rev/8c68140dbbc9
branches: trunk
changeset: 761705:8c68140dbbc9
user: christos <christos%NetBSD.org@localhost>
date: Sat Feb 05 17:14:14 2011 +0000
description:
as promised make the last ops table auto-generated.
diffstat:
usr.bin/xlint/lint1/externs1.h | 3 +-
usr.bin/xlint/lint1/mkops | 34 ++++++++-
usr.bin/xlint/lint1/op.h | 4 +-
usr.bin/xlint/lint1/ops.def | 124 ++++++++++++++++++------------------
usr.bin/xlint/lint1/tree.c | 137 +----------------------------------------
5 files changed, 96 insertions(+), 206 deletions(-)
diffs (truncated from 403 to 300 lines):
diff -r c7b305fb28a1 -r 8c68140dbbc9 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sat Feb 05 16:59:24 2011 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sat Feb 05 17:14:14 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.29 2009/10/02 21:04:03 christos Exp $ */
+/* $NetBSD: externs1.h,v 1.30 2011/02/05 17:14:14 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -187,7 +187,6 @@
/*
* tree.c
*/
-extern void initmtab(void);
extern type_t *incref(type_t *, tspec_t);
extern type_t *tincref(type_t *, tspec_t);
extern tnode_t *getcnode(type_t *, val_t *);
diff -r c7b305fb28a1 -r 8c68140dbbc9 usr.bin/xlint/lint1/mkops
--- a/usr.bin/xlint/lint1/mkops Sat Feb 05 16:59:24 2011 +0000
+++ b/usr.bin/xlint/lint1/mkops Sat Feb 05 17:14:14 2011 +0000
@@ -1,5 +1,5 @@
#!/bin/sh -
-# $NetBSD: mkops,v 1.1 2011/02/05 16:10:17 christos Exp $
+# $NetBSD: mkops,v 1.2 2011/02/05 17:14:14 christos Exp $
#
# Copyright (c) 2003 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -51,7 +51,7 @@
{
printf(fmt, last);
if (comment != "")
- printf("\t%s", comment);
+ printf("\t/* pseudo op not used in trees */");
printf("\n");
}
@@ -66,7 +66,12 @@
if (v == "c") {
printf("#include <sys/types.h>\n");
printf("#include \"op.h\"\n");
- printf("static const char *opnames[] = {\n");
+ printf("#include \"param.h\"\n");
+ printf("mod_t modtab[NOPS];\n");
+ printf("static const struct {\n");
+ printf("\tmod_t\tm;\n");
+ printf("\tuint8_t\tok;\n");
+ printf("} imods[] = {\n");
}
}
@@ -81,10 +86,17 @@
}
FIRST = LAST;
LAST = $2;
- LASTCOMMENT = $3;
+ LASTCOMMENT = $4;
}
if (v == "c") {
- printf("\t\"%s\",\t/* %s */\n", $1, $2);
+ if ($3 == "X") {
+ m = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,";
+ act = 0;
+ } else {
+ m = $3;
+ act = 1;
+ }
+ printf("\t{ /* %s */\t{ %s \"%s\" }, %d },\n", $2, m, $1, act);
}
}
@@ -94,12 +106,22 @@
printf("#define\tNOPS\t((int)%s + 1)\n", LAST);
printf("} op_t;\n");
printf("const char *getopname(op_t);\n");
+ printf("void initmtab(void);\n");
}
if (v == "c") {
printf("};\n");
printf("const char *\n");
printf("getopname(op_t op) {\n");
- printf("\treturn opnames[op];\n");
+ printf("\treturn imods[op].m.m_name;\n");
+ printf("}\n");
+ printf("void\n");
+ printf("initmtab(void)\n");
+ printf("{\n");
+ printf("\tsize_t i;\n");
+ printf("\n");
+ printf("\tfor (i = 0; __arraycount(imods); i++)\n");
+ printf("\t\tif (imods[i].ok)\n");
+ printf("\t\t\tSTRUCT_ASSIGN(modtab[i], imods[i].m);\n");
printf("}\n");
}
}
diff -r c7b305fb28a1 -r 8c68140dbbc9 usr.bin/xlint/lint1/op.h
--- a/usr.bin/xlint/lint1/op.h Sat Feb 05 16:59:24 2011 +0000
+++ b/usr.bin/xlint/lint1/op.h Sat Feb 05 17:14:14 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: op.h,v 1.5 2011/02/04 23:32:44 christos Exp $ */
+/* $NetBSD: op.h,v 1.6 2011/02/05 17:14:14 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -56,4 +56,6 @@
const char *m_name; /* name of op. */
} mod_t;
+extern mod_t modtab[];
+
#include "ops.h"
diff -r c7b305fb28a1 -r 8c68140dbbc9 usr.bin/xlint/lint1/ops.def
--- a/usr.bin/xlint/lint1/ops.def Sat Feb 05 16:59:24 2011 +0000
+++ b/usr.bin/xlint/lint1/ops.def Sat Feb 05 17:14:14 2011 +0000
@@ -1,62 +1,62 @@
-no-op NOOP
--> ARROW
-. POINT
-! NOT
-~ COMPL
-p + 1 INC
-p - 1 DEC
-++p INCBEF
---p DECBEF
-p++ INCAFT
-p-- DECAFT
-+p UPLUS
--p UMINUS
-*p STAR
-& AMPER
-p * p MULT
-p / p DIV
-p % p MOD
-p + p PLUS
-p - p MINUS
-p << p SHL
-p >> p SHR
-p < p LT
-p <= p LE
-p > p GT
-p >= p GE
-p == p EQ
-p != p NE
-p & p AND
-p ^ p XOR
-p | p OR
-p && p LOGAND
-p || p LOGOR
-? QUEST
-: COLON
-p = p ASSIGN
-p *= p MULASS
-p /= p DIVASS
-p %= p MODASS
-p += p ADDASS
-p -= p SUBASS
-p << p SHLASS
-p >> p SHRASS
-p &= p ANDASS
-p ^= p XORASS
-p |= p ORASS
-n NAME
-const CON
-char * STRING
-fsel FSEL
-p() CALL
-, COMMA
-(cast)p CVT
-icall ICALL
-load LOAD
-push PUSH
-return RETURN
-p.re REAL
-p.im IMAG
-p = {} INIT /* pseudo op not used in trees */
-case CASE /* pseudo op not used in trees */
-f(p) FARG /* pseudo op not used in trees */
+no-op NOOP X
+-> ARROW 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
+. POINT 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+! NOT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0,0,0,0,0,0,0,0,0,0,
+p() CALL 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
+, COMMA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
+(cast)p CVT 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
+icall ICALL 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
+load LOAD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+push PUSH 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
+return RETURN 1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,
+p.re REAL X
+p.im IMAG X
+p = {} INIT 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0, pseudo
+case CASE X pseudo
+f(p) FARG 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0, pseudo
diff -r c7b305fb28a1 -r 8c68140dbbc9 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Feb 05 16:59:24 2011 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Feb 05 17:14:14 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.67 2011/02/04 23:31:23 christos Exp $ */
+/* $NetBSD: tree.c,v 1.68 2011/02/05 17:14:14 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.67 2011/02/04 23:31:23 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.68 2011/02/05 17:14:14 christos Exp $");
#endif
#include <stdlib.h>
@@ -51,9 +51,6 @@
#include "cgram.h"
#include "externs1.h"
-/* Various flags for each operator. */
-static mod_t modtab[NOPS];
-
static tnode_t *getinode(tspec_t, int64_t);
static void ptrcmpok(op_t, tnode_t *, tnode_t *);
static int asgntypok(op_t, int, tnode_t *, tnode_t *);
@@ -93,136 +90,6 @@
extern sig_atomic_t fpe;
/*
- * Initialize mods of operators.
- */
-void
-initmtab(void)
-{
- static struct {
- op_t op;
- mod_t m;
- } imods[] = {
- { ARROW, { 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
- "->" } },
- { POINT, { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- "." } },
- { NOT, { 0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,1,0,0,
- "!" } },
- { COMPL, { 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1,
- "~" } },
- { INCBEF, { 0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,
- "prefix++" } },
- { DECBEF, { 0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,
- "prefix--" } },
- { INCAFT, { 0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,
- "postfix++" } },
- { DECAFT, { 0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,
- "postfix--" } },
- { UPLUS, { 0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,0,
- "unary +" } },
- { UMINUS, { 0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,0,
- "unary -" } },
- { STAR, { 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
Home |
Main Index |
Thread Index |
Old Index