Commit 0d9d06d0 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Also let variable symbols carry their eval function



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5480 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 7912df11
...@@ -568,6 +568,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) ...@@ -568,6 +568,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
sym = VCC_AddSymbolStr(tl, v->name, SYM_VAR); sym = VCC_AddSymbolStr(tl, v->name, SYM_VAR);
sym->var = v; sym->var = v;
sym->fmt = v->fmt; sym->fmt = v->fmt;
sym->eval = vcc_Expr_Var;
sym->r_methods = v->r_methods; sym->r_methods = v->r_methods;
if (v->fmt == HEADER) if (v->fmt == HEADER)
sym->wildcard = 1; sym->wildcard = 1;
......
...@@ -239,6 +239,7 @@ unsigned vcc_UintVal(struct vcc *tl); ...@@ -239,6 +239,7 @@ unsigned vcc_UintVal(struct vcc *tl);
double vcc_DoubleVal(struct vcc *tl); double vcc_DoubleVal(struct vcc *tl);
void vcc_Expr(struct vcc *tl, enum var_type typ); void vcc_Expr(struct vcc *tl, enum var_type typ);
void vcc_Expr_Call(struct vcc *tl, const struct symbol *sym); void vcc_Expr_Call(struct vcc *tl, const struct symbol *sym);
sym_expr_t vcc_Expr_Var;
sym_expr_t vcc_Expr_Func; sym_expr_t vcc_Expr_Func;
/* vcc_dir_dns.c */ /* vcc_dir_dns.c */
......
...@@ -413,6 +413,26 @@ vcc_arg_type(const char **p) ...@@ -413,6 +413,26 @@ vcc_arg_type(const char **p)
return (VOID); return (VOID);
} }
/*--------------------------------------------------------------------
*/
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));
}
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
*/ */
...@@ -424,8 +444,7 @@ vcc_Expr_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) ...@@ -424,8 +444,7 @@ vcc_Expr_Func(struct vcc *tl, struct expr **e, const struct symbol *sym)
enum var_type fmt; enum var_type fmt;
char buf[32]; char buf[32];
(void)tl; assert(sym->kind == SYM_FUNC || sym->kind == SYM_PROC);
(void)e;
AN(sym->cfunc); AN(sym->cfunc);
AN(sym->args); AN(sym->args);
SkipToken(tl, ID); SkipToken(tl, ID);
...@@ -565,14 +584,8 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) ...@@ -565,14 +584,8 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
switch(sym->kind) { switch(sym->kind) {
case SYM_VAR: case SYM_VAR:
vcc_AddUses(tl, tl->t, sym->r_methods, "Not available"); ErrInternal(tl);
vp = vcc_FindVar(tl, tl->t, 0, "cannot be read"); return;
ERRCHK(tl);
assert(vp != NULL);
vsb_printf(e1->vsb, "%s", vp->rname);
e1->fmt = vp->fmt;
vcc_NextToken(tl);
break;
case SYM_FUNC: case SYM_FUNC:
ErrInternal(tl); ErrInternal(tl);
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment