r5205 - trunk/varnish-cache/lib/libvcl
phk at varnish-cache.org
phk at varnish-cache.org
Tue Sep 14 11:07:15 CEST 2010
Author: phk
Date: 2010-09-14 11:07:15 +0200 (Tue, 14 Sep 2010)
New Revision: 5205
Modified:
trunk/varnish-cache/lib/libvcl/vcc_action.c
trunk/varnish-cache/lib/libvcl/vcc_compile.h
trunk/varnish-cache/lib/libvcl/vcc_expr.c
Log:
Add support for calling VMOD-procedures as actions in compound statements.
A procedure is simply a function which returns VOID.
Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2010-09-14 08:37:50 UTC (rev 5204)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2010-09-14 09:07:15 UTC (rev 5205)
@@ -434,6 +434,7 @@
{
struct token *at;
struct action_table *atp;
+ const struct symbol *sym;
at = tl->t;
assert (at->tok == ID);
@@ -443,8 +444,13 @@
vcc_AddUses(tl, at, atp->bitmask,
"not a valid action");
atp->func(tl);
- return(1);
+ return (1);
}
}
+ sym = VCC_FindSymbol(tl, tl->t);
+ if (sym != NULL && sym->kind == SYM_PROC) {
+ vcc_Expr_Call(tl, sym);
+ return (1);
+ }
return (0);
}
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2010-09-14 08:37:50 UTC (rev 5204)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2010-09-14 09:07:15 UTC (rev 5205)
@@ -242,6 +242,7 @@
unsigned vcc_UintVal(struct vcc *tl);
double vcc_DoubleVal(struct vcc *tl);
void vcc_Expr(struct vcc *tl, enum var_type typ);
+void vcc_Expr_Call(struct vcc *tl, const struct symbol *sym);
/* vcc_dir_dns.c */
parsedirector_f vcc_ParseDnsDirector;
Modified: trunk/varnish-cache/lib/libvcl/vcc_expr.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_expr.c 2010-09-14 08:37:50 UTC (rev 5204)
+++ trunk/varnish-cache/lib/libvcl/vcc_expr.c 2010-09-14 09:07:15 UTC (rev 5205)
@@ -453,6 +453,15 @@
} else {
vcc_expr0(tl, &e1, fmt);
ERRCHK(tl);
+ if (e1->fmt != fmt) {
+ vsb_printf(tl->sb, "Wrong argument type.");
+ vsb_printf(tl->sb, " Expected %s.",
+ vcc_Type(fmt));
+ vsb_printf(tl->sb, " Got %s.\n",
+ vcc_Type(e1->fmt));
+ vcc_ErrWhere2(tl, e1->t1, tl->t);
+ return;
+ }
assert(e1->fmt == fmt);
if (e1->fmt == STRING_LIST) {
e1 = vcc_expr_edit(STRING_LIST,
@@ -560,7 +569,7 @@
vcc_ErrWhere(tl, tl->t);
return;
default:
- vsb_printf(tl->sb, "Wrong kind of symbol.\n");
+ vsb_printf(tl->sb, "Symbol is not a function.\n");
vcc_ErrWhere(tl, tl->t);
return;
}
@@ -921,3 +930,26 @@
}
vcc_delete_expr(e);
}
+
+/*--------------------------------------------------------------------
+ */
+
+void
+vcc_Expr_Call(struct vcc *tl, const struct symbol *sym)
+{
+
+ struct expr *e;
+ struct token *t1;
+
+ t1 = tl->t;
+ e = vcc_new_expr();
+ vcc_expr_call(tl, &e, sym);
+ if (!tl->err) {
+ vcc_expr_fmt(tl->fb, tl->indent, e);
+ vsb_cat(tl->fb, ";\n");
+ } else if (t1 != tl->t) {
+ vcc_ErrWhere2(tl, t1, tl->t);
+ }
+ vcc_delete_expr(e);
+}
+
More information about the varnish-commit
mailing list