]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expressions: kill seperate sym_type datatype for symbols
authorPatrick McHardy <kaber@trash.net>
Wed, 1 Apr 2009 10:56:44 +0000 (12:56 +0200)
committerPatrick McHardy <kaber@trash.net>
Wed, 1 Apr 2009 10:56:44 +0000 (12:56 +0200)
Signed-off-by: Patrick McHardy <kaber@trash.net>
include/expression.h
src/datatype.c
src/evaluate.c
src/expression.c
src/meta.c

index b0084c07f080d8839888fe41a1fb78fd87be23af..471033e7193be930a7287503b35e6282b429a039 100644 (file)
@@ -174,7 +174,6 @@ struct expr {
        union {
                struct {
                        /* EXPR_SYMBOL */
-                       const struct datatype   *sym_type;
                        const struct scope      *scope;
                        const char              *identifier;
                };
@@ -292,7 +291,7 @@ static inline void symbol_expr_set_type(struct expr *expr,
                                        const struct datatype *dtype)
 {
        if (expr->ops->type == EXPR_SYMBOL)
-               expr->sym_type = dtype;
+               expr->dtype = dtype;
 }
 
 extern struct expr *constant_expr_alloc(const struct location *loc,
index fece6049cd33d2303cd9a9cd2b337921b2258aab..589a35285aa679a869675bf4bd54c90d7a878b58 100644 (file)
@@ -79,7 +79,7 @@ void datatype_print(const struct expr *expr)
 struct error_record *symbol_parse(const struct expr *sym,
                                  struct expr **res)
 {
-       const struct datatype *dtype = sym->sym_type;
+       const struct datatype *dtype = sym->dtype;
 
        assert(sym->ops->type == EXPR_SYMBOL);
 
@@ -92,7 +92,7 @@ struct error_record *symbol_parse(const struct expr *sym,
 
        return error(&sym->location,
                     "Can't parse symbolic %s expressions",
-                    sym->sym_type->desc);
+                    sym->dtype->desc);
 }
 
 struct error_record *symbolic_constant_parse(const struct expr *sym,
@@ -107,7 +107,7 @@ struct error_record *symbolic_constant_parse(const struct expr *sym,
                        break;
        }
 
-       dtype = sym->sym_type;
+       dtype = sym->dtype;
        if (s->identifier == NULL)
                return error(&sym->location, "Could not parse %s", dtype->desc);
 
@@ -219,13 +219,13 @@ static struct error_record *integer_type_parse(const struct expr *sym,
        mpz_init(v);
        if (gmp_sscanf(sym->identifier, "%Zu", v) != 1) {
                mpz_clear(v);
-               if (sym->sym_type != &integer_type)
+               if (sym->dtype != &integer_type)
                        return NULL;
                return error(&sym->location, "Could not parse %s",
-                            sym->sym_type->desc);
+                            sym->dtype->desc);
        }
 
-       *res = constant_expr_alloc(&sym->location, sym->sym_type,
+       *res = constant_expr_alloc(&sym->location, sym->dtype,
                                   BYTEORDER_HOST_ENDIAN, 1, NULL);
        mpz_set((*res)->value, v);
        mpz_clear(v);
index c8625bbc9813d67128ac2317ff601a0eaface4f1..ed3c688c3be8015b3355c86ae25a5e6d92fe7bb6 100644 (file)
@@ -105,7 +105,7 @@ static int expr_evaluate_symbol(struct eval_ctx *ctx, struct expr **expr)
        struct symbol *sym;
        struct expr *new;
 
-       (*expr)->sym_type = ctx->ectx.dtype;
+       (*expr)->dtype = ctx->ectx.dtype;
 
        if ((*expr)->scope != NULL) {
                sym = symbol_lookup((*expr)->scope, (*expr)->identifier);
index 74579dd2ddf2554283a7b5a1eb0f60f20eeb8f5b..d854eb29267e940225c8d3fabcbbe03348e701f3 100644 (file)
@@ -188,7 +188,6 @@ static void symbol_expr_print(const struct expr *expr)
 
 static void symbol_expr_clone(struct expr *new, const struct expr *expr)
 {
-       new->sym_type   = expr->sym_type;
        new->scope      = expr->scope;
        new->identifier = xstrdup(expr->identifier);
 }
index c5168248cd19ecb33ba79f4d71d4b777494f8c86..d1fb791ca6eb7d9641fda34f1e3e8266e817ec20 100644 (file)
@@ -77,9 +77,9 @@ static struct error_record *tchandle_type_parse(const struct expr *sym,
 
        if (rtnl_tc_str2handle(sym->identifier, &handle) < 0)
                return error(&sym->location, "Could not parse %s",
-                            sym->sym_type->desc);
+                            sym->dtype->desc);
 
-       *res = constant_expr_alloc(&sym->location, sym->sym_type,
+       *res = constant_expr_alloc(&sym->location, sym->dtype,
                                   BYTEORDER_HOST_ENDIAN,
                                   sizeof(handle) * BITS_PER_BYTE, &handle);
        return NULL;
@@ -153,7 +153,7 @@ static struct error_record *ifindex_type_parse(const struct expr *sym,
        if (ifindex == 0)
                return error(&sym->location, "Interface does not exist");
 
-       *res = constant_expr_alloc(&sym->location, sym->sym_type,
+       *res = constant_expr_alloc(&sym->location, sym->dtype,
                                   BYTEORDER_HOST_ENDIAN,
                                   sizeof(ifindex) * BITS_PER_BYTE, &ifindex);
        return NULL;
@@ -222,7 +222,7 @@ static struct error_record *uid_type_parse(const struct expr *sym,
        if (pw == NULL)
                return error(&sym->location, "User does not exist");
 
-       *res = constant_expr_alloc(&sym->location, sym->sym_type,
+       *res = constant_expr_alloc(&sym->location, sym->dtype,
                                   BYTEORDER_HOST_ENDIAN,
                                   sizeof(pw->pw_uid) * BITS_PER_BYTE,
                                   &pw->pw_uid);
@@ -263,7 +263,7 @@ static struct error_record *gid_type_parse(const struct expr *sym,
        if (gr == NULL)
                return error(&sym->location, "Group does not exist");
 
-       *res = constant_expr_alloc(&sym->location, sym->sym_type,
+       *res = constant_expr_alloc(&sym->location, sym->dtype,
                                   BYTEORDER_HOST_ENDIAN,
                                   sizeof(gr->gr_gid) * BITS_PER_BYTE,
                                   &gr->gr_gid);