r5480 - trunk/varnish-cache/lib/libvcl
phk at varnish-cache.org
phk at varnish-cache.org
Wed Oct 27 22:07:28 CEST 2010
Author: phk
Date: 2010-10-27 22:07:28 +0200 (Wed, 27 Oct 2010)
New Revision: 5480
Modified:
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_compile.h
trunk/varnish-cache/lib/libvcl/vcc_expr.c
Log:
Also let variable symbols carry their eval function
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2010-10-27 19:40:08 UTC (rev 5479)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2010-10-27 20:07:28 UTC (rev 5480)
@@ -568,6 +568,7 @@
sym = VCC_AddSymbolStr(tl, v->name, SYM_VAR);
sym->var = v;
sym->fmt = v->fmt;
+ sym->eval = vcc_Expr_Var;
sym->r_methods = v->r_methods;
if (v->fmt == HEADER)
sym->wildcard = 1;
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2010-10-27 19:40:08 UTC (rev 5479)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2010-10-27 20:07:28 UTC (rev 5480)
@@ -239,6 +239,7 @@
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);
+sym_expr_t vcc_Expr_Var;
sym_expr_t vcc_Expr_Func;
/* vcc_dir_dns.c */
Modified: trunk/varnish-cache/lib/libvcl/vcc_expr.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_expr.c 2010-10-27 19:40:08 UTC (rev 5479)
+++ trunk/varnish-cache/lib/libvcl/vcc_expr.c 2010-10-27 20:07:28 UTC (rev 5480)
@@ -417,6 +417,26 @@
*/
void
+vcc_Expr_Var(struct vcc *tl, struct expr **e, const struct symbol *sym)
+{
+ const struct var *vp;
+
+ assert(sym->kind == SYM_VAR);
+ vcc_AddUses(tl, tl->t, sym->r_methods, "Not available");
+ vp = vcc_FindVar(tl, tl->t, 0, "cannot be read");
+ ERRCHK(tl);
+ assert(vp != NULL);
+ vsb_printf((*e)->vsb, "%s", vp->rname);
+ (*e)->fmt = vp->fmt;
+ vcc_NextToken(tl);
+ vsb_finish((*e)->vsb);
+ AZ(vsb_overflowed((*e)->vsb));
+}
+
+/*--------------------------------------------------------------------
+ */
+
+void
vcc_Expr_Func(struct vcc *tl, struct expr **e, const struct symbol *sym)
{
const char *p, *q, *r;
@@ -424,8 +444,7 @@
enum var_type fmt;
char buf[32];
- (void)tl;
- (void)e;
+ assert(sym->kind == SYM_FUNC || sym->kind == SYM_PROC);
AN(sym->cfunc);
AN(sym->args);
SkipToken(tl, ID);
@@ -565,14 +584,8 @@
switch(sym->kind) {
case SYM_VAR:
- vcc_AddUses(tl, tl->t, sym->r_methods, "Not available");
- vp = vcc_FindVar(tl, tl->t, 0, "cannot be read");
- ERRCHK(tl);
- assert(vp != NULL);
- vsb_printf(e1->vsb, "%s", vp->rname);
- e1->fmt = vp->fmt;
- vcc_NextToken(tl);
- break;
+ ErrInternal(tl);
+ return;
case SYM_FUNC:
ErrInternal(tl);
return;
More information about the varnish-commit
mailing list