[master] f8bc0ea37 Add an empty lookup table for type based methods, while I find out how vcc_expr actually works...

Poul-Henning Kamp phk at FreeBSD.org
Mon Jun 3 13:01:09 UTC 2019


commit f8bc0ea370fe2fcbb9912531a1dd08f8ff1ad6da
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jun 3 10:38:30 2019 +0000

    Add an empty lookup table for type based methods, while I find out
    how vcc_expr actually works...

diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 9517bcca1..1221c4e9e 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -802,24 +802,50 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
 /*--------------------------------------------------------------------
  * SYNTAX:
  *    Expr4:
- *      Expr5 
+ *      Expr5
  */
 
+static const struct vcc_methods {
+	vcc_type_t		type_from;
+	vcc_type_t		type_to;
+	const char		*method;
+	const char		*impl;
+} vcc_methods[] = {
+	//{ BACKEND, BOOL,	"healthy",	"VRT_Healthy(ctx, \v1, 0)" },
+	{ NULL, NULL,		NULL,		NULL},	// XXX: For Flexelint
+	{ NULL, NULL,		NULL,		NULL},
+};
+
 static void
 vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
 {
+	const struct vcc_methods *vm;
 
 	*e = NULL;
 	vcc_expr5(tl, e, fmt);
+	ERRCHK(tl);
+	AN(*e);
 	while (tl->t->tok == '.') {
 		vcc_NextToken(tl);
 		ExpectErr(tl, ID);
-		VSB_printf(tl->sb, "Unknown property ");
-		vcc_ErrToken(tl, tl->t);
-		VSB_printf(tl->sb,
-		 " for type %s\n", (*e)->fmt->name);
-		vcc_ErrWhere(tl, tl->t);
-		return;
+
+		for(vm = vcc_methods; vm->type_from != NULL; vm++) {
+
+			if (vm->type_from == (*e)->fmt &&
+			    vcc_IdIs(tl->t, vm->method))
+				break;
+		}
+
+		if (vm->type_from == NULL) {
+			VSB_printf(tl->sb, "Unknown property ");
+			vcc_ErrToken(tl, tl->t);
+			VSB_printf(tl->sb,
+			 " for type %s\n", (*e)->fmt->name);
+			vcc_ErrWhere(tl, tl->t);
+			return;
+		}
+		vcc_NextToken(tl);
+		*e = vcc_expr_edit(tl, vm->type_to, vm->impl, *e, NULL);
 	}
 }
 


More information about the varnish-commit mailing list