Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
1a5ca1ef
Commit
1a5ca1ef
authored
Jan 31, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dispatch function calls through sym->action
parent
63fb2ecb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
34 deletions
+39
-34
vcc_action.c
lib/libvcc/vcc_action.c
+19
-17
vcc_compile.h
lib/libvcc/vcc_compile.h
+4
-4
vcc_expr.c
lib/libvcc/vcc_expr.c
+5
-2
vcc_parse.c
lib/libvcc/vcc_parse.c
+6
-9
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+5
-2
No files found.
lib/libvcc/vcc_action.c
View file @
1a5ca1ef
...
@@ -39,10 +39,9 @@
...
@@ -39,10 +39,9 @@
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
static
void
v_matchproto_
(
sym_act_f
)
parse_call
(
struct
vcc
*
tl
)
parse_call
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
struct
symbol
*
sym
;
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
ID
);
ExpectErr
(
tl
,
ID
);
...
@@ -86,10 +85,9 @@ static const struct arith {
...
@@ -86,10 +85,9 @@ static const struct arith {
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
static
void
v_matchproto_
(
sym_act_f
)
parse_set
(
struct
vcc
*
tl
)
parse_set
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
const
struct
symbol
*
sym
;
const
struct
arith
*
ap
;
const
struct
arith
*
ap
;
const
struct
token
*
t
;
const
struct
token
*
t
;
vcc_type_t
fmt
;
vcc_type_t
fmt
;
...
@@ -143,10 +141,9 @@ parse_set(struct vcc *tl)
...
@@ -143,10 +141,9 @@ parse_set(struct vcc *tl)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
static
void
v_matchproto_
(
sym_act_f
)
parse_unset
(
struct
vcc
*
tl
)
parse_unset
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
const
struct
symbol
*
sym
;
const
struct
token
*
t
;
const
struct
token
*
t
;
/* XXX: Wrong, should use VCC_Expr(HEADER) */
/* XXX: Wrong, should use VCC_Expr(HEADER) */
...
@@ -169,10 +166,11 @@ parse_unset(struct vcc *tl)
...
@@ -169,10 +166,11 @@ parse_unset(struct vcc *tl)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
static
void
v_matchproto_
(
sym_act_f
)
parse_ban
(
struct
vcc
*
tl
)
parse_ban
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
(
void
)
sym
;
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
'('
);
ExpectErr
(
tl
,
'('
);
...
@@ -191,9 +189,11 @@ parse_ban(struct vcc *tl)
...
@@ -191,9 +189,11 @@ parse_ban(struct vcc *tl)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
static
void
v_matchproto_
(
sym_act_f
)
parse_hash_data
(
struct
vcc
*
tl
)
parse_hash_data
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
(
void
)
sym
;
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
SkipToken
(
tl
,
'('
);
SkipToken
(
tl
,
'('
);
...
@@ -287,12 +287,13 @@ parse_return_vcl(struct vcc *tl)
...
@@ -287,12 +287,13 @@ parse_return_vcl(struct vcc *tl)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
static
void
v_matchproto_
(
sym_act_f
)
parse_return
(
struct
vcc
*
tl
)
parse_return
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
unsigned
hand
;
unsigned
hand
;
const
char
*
h
;
const
char
*
h
;
(
void
)
sym
;
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
AN
(
tl
->
curproc
);
AN
(
tl
->
curproc
);
if
(
tl
->
t
->
tok
==
';'
&&
tl
->
curproc
->
method
==
NULL
)
{
if
(
tl
->
t
->
tok
==
';'
&&
tl
->
curproc
->
method
==
NULL
)
{
...
@@ -345,11 +346,12 @@ parse_return(struct vcc *tl)
...
@@ -345,11 +346,12 @@ parse_return(struct vcc *tl)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
void
static
void
v_matchproto_
(
sym_act_f
)
parse_synthetic
(
struct
vcc
*
tl
)
parse_synthetic
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
(
void
)
sym
;
ExpectErr
(
tl
,
'('
);
ExpectErr
(
tl
,
'('
);
ERRCHK
(
tl
);
ERRCHK
(
tl
);
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
...
...
lib/libvcc/vcc_compile.h
View file @
1a5ca1ef
...
@@ -108,7 +108,7 @@ typedef void sym_expr_t(struct vcc *tl, struct expr **,
...
@@ -108,7 +108,7 @@ typedef void sym_expr_t(struct vcc *tl, struct expr **,
struct
symbol
*
sym
,
vcc_type_t
);
struct
symbol
*
sym
,
vcc_type_t
);
typedef
void
sym_wildcard_t
(
struct
vcc
*
,
struct
symbol
*
,
struct
symbol
*
);
typedef
void
sym_wildcard_t
(
struct
vcc
*
,
struct
symbol
*
,
struct
symbol
*
);
typedef
void
sym_act_f
(
struct
vcc
*
tl
);
typedef
void
sym_act_f
(
struct
vcc
*
,
struct
symbol
*
);
struct
symbol
{
struct
symbol
{
unsigned
magic
;
unsigned
magic
;
...
@@ -279,7 +279,7 @@ char *TlDup(struct vcc *tl, const char *s);
...
@@ -279,7 +279,7 @@ char *TlDup(struct vcc *tl, const char *s);
/* vcc_expr.c */
/* vcc_expr.c */
void
vcc_Expr
(
struct
vcc
*
tl
,
vcc_type_t
typ
);
void
vcc_Expr
(
struct
vcc
*
tl
,
vcc_type_t
typ
);
void
vcc_Expr_Call
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
;
sym_act_f
vcc_ParseCall
;
void
vcc_Expr_Init
(
struct
vcc
*
tl
);
void
vcc_Expr_Init
(
struct
vcc
*
tl
);
sym_expr_t
vcc_Eval_Var
;
sym_expr_t
vcc_Eval_Var
;
sym_expr_t
vcc_Eval_Handle
;
sym_expr_t
vcc_Eval_Handle
;
...
@@ -294,7 +294,7 @@ void vcc_Var_Init(struct vcc *);
...
@@ -294,7 +294,7 @@ void vcc_Var_Init(struct vcc *);
/* vcc_parse.c */
/* vcc_parse.c */
void
vcc_Parse
(
struct
vcc
*
tl
);
void
vcc_Parse
(
struct
vcc
*
tl
);
void
vcc_ParseIf
(
struct
vcc
*
tl
)
;
sym_act_f
vcc_ParseIf
;
/* vcc_utils.c */
/* vcc_utils.c */
const
char
*
vcc_regexp
(
struct
vcc
*
tl
);
const
char
*
vcc_regexp
(
struct
vcc
*
tl
);
...
@@ -350,7 +350,7 @@ sym_wildcard_t vcc_Var_Wildcard;
...
@@ -350,7 +350,7 @@ sym_wildcard_t vcc_Var_Wildcard;
/* vcc_vmod.c */
/* vcc_vmod.c */
void
vcc_ParseImport
(
struct
vcc
*
tl
);
void
vcc_ParseImport
(
struct
vcc
*
tl
);
void
vcc_ParseNew
(
struct
vcc
*
tl
)
;
sym_act_f
vcc_ParseNew
;
/* vcc_xref.c */
/* vcc_xref.c */
void
vcc_AddRef
(
struct
vcc
*
,
struct
symbol
*
);
void
vcc_AddRef
(
struct
vcc
*
,
struct
symbol
*
);
...
...
lib/libvcc/vcc_expr.c
View file @
1a5ca1ef
...
@@ -1261,8 +1261,8 @@ vcc_Expr(struct vcc *tl, vcc_type_t fmt)
...
@@ -1261,8 +1261,8 @@ vcc_Expr(struct vcc *tl, vcc_type_t fmt)
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
*/
*/
void
void
v_matchproto_
(
sym_act_f
)
vcc_
Expr_
Call
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
vcc_
Parse
Call
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
struct
expr
*
e
;
struct
expr
*
e
;
...
@@ -1273,6 +1273,7 @@ vcc_Expr_Call(struct vcc *tl, struct symbol *sym)
...
@@ -1273,6 +1273,7 @@ vcc_Expr_Call(struct vcc *tl, struct symbol *sym)
vcc_Eval_SymFunc
(
tl
,
&
e
,
sym
,
VOID
);
vcc_Eval_SymFunc
(
tl
,
&
e
,
sym
,
VOID
);
if
(
!
tl
->
err
)
{
if
(
!
tl
->
err
)
{
vcc_expr_fmt
(
tl
->
fb
,
tl
->
indent
,
e
);
vcc_expr_fmt
(
tl
->
fb
,
tl
->
indent
,
e
);
SkipToken
(
tl
,
';'
);
VSB_cat
(
tl
->
fb
,
";
\n
"
);
VSB_cat
(
tl
->
fb
,
";
\n
"
);
}
else
if
(
t1
!=
tl
->
t
)
{
}
else
if
(
t1
!=
tl
->
t
)
{
vcc_ErrWhere2
(
tl
,
t1
,
tl
->
t
);
vcc_ErrWhere2
(
tl
,
t1
,
tl
->
t
);
...
@@ -1290,11 +1291,13 @@ vcc_Expr_Init(struct vcc *tl)
...
@@ -1290,11 +1291,13 @@ vcc_Expr_Init(struct vcc *tl)
sym
=
VCC_MkSym
(
tl
,
"regsub"
,
SYM_FUNC
);
sym
=
VCC_MkSym
(
tl
,
"regsub"
,
SYM_FUNC
);
AN
(
sym
);
AN
(
sym
);
sym
->
action
=
vcc_ParseCall
;
sym
->
eval
=
vcc_Eval_Regsub
;
sym
->
eval
=
vcc_Eval_Regsub
;
sym
->
eval_priv
=
NULL
;
sym
->
eval_priv
=
NULL
;
sym
=
VCC_MkSym
(
tl
,
"regsuball"
,
SYM_FUNC
);
sym
=
VCC_MkSym
(
tl
,
"regsuball"
,
SYM_FUNC
);
AN
(
sym
);
AN
(
sym
);
sym
->
action
=
vcc_ParseCall
;
sym
->
eval
=
vcc_Eval_Regsub
;
sym
->
eval
=
vcc_Eval_Regsub
;
sym
->
eval_priv
=
sym
;
sym
->
eval_priv
=
sym
;
...
...
lib/libvcc/vcc_parse.c
View file @
1a5ca1ef
...
@@ -79,10 +79,11 @@ vcc_Conditional(struct vcc *tl)
...
@@ -79,10 +79,11 @@ vcc_Conditional(struct vcc *tl)
* null
* null
*/
*/
void
void
v_matchproto_
(
sym_act_f
)
vcc_ParseIf
(
struct
vcc
*
tl
)
vcc_ParseIf
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
(
void
)
sym
;
SkipToken
(
tl
,
ID
);
SkipToken
(
tl
,
ID
);
Fb
(
tl
,
1
,
"if "
);
Fb
(
tl
,
1
,
"if "
);
vcc_Conditional
(
tl
);
vcc_Conditional
(
tl
);
...
@@ -178,18 +179,14 @@ vcc_Compound(struct vcc *tl)
...
@@ -178,18 +179,14 @@ vcc_Compound(struct vcc *tl)
tl
->
err
=
1
;
tl
->
err
=
1
;
return
;
return
;
case
ID
:
case
ID
:
sym
=
VCC_SymbolGet
(
tl
,
SYM_NONE
,
SYMTAB_NOERR
,
XREF_NONE
);
sym
=
VCC_SymbolGet
(
tl
,
SYM_NONE
,
SYMTAB_NOERR
,
XREF_NONE
);
if
(
sym
!=
NULL
&&
sym
->
action
!=
NULL
)
{
if
(
sym
!=
NULL
&&
sym
->
action
!=
NULL
)
{
if
(
sym
->
action_mask
!=
0
)
if
(
sym
->
action_mask
!=
0
)
vcc_AddUses
(
tl
,
t
,
NULL
,
vcc_AddUses
(
tl
,
t
,
NULL
,
sym
->
action_mask
,
sym
->
action_mask
,
"Not a valid action"
);
"Not a valid action"
);
sym
->
action
(
tl
);
sym
->
action
(
tl
,
sym
);
break
;
}
if
(
sym
!=
NULL
&&
sym
->
kind
==
SYM_FUNC
)
{
vcc_Expr_Call
(
tl
,
sym
);
SkipToken
(
tl
,
';'
);
break
;
break
;
}
}
/* FALLTHROUGH */
/* FALLTHROUGH */
...
...
lib/libvcc/vcc_vmod.c
View file @
1a5ca1ef
...
@@ -245,6 +245,7 @@ vcc_ParseImport(struct vcc *tl)
...
@@ -245,6 +245,7 @@ vcc_ParseImport(struct vcc *tl)
sym
=
VCC_MkSym
(
tl
,
p
,
SYM_FUNC
);
sym
=
VCC_MkSym
(
tl
,
p
,
SYM_FUNC
);
ERRCHK
(
tl
);
ERRCHK
(
tl
);
AN
(
sym
);
AN
(
sym
);
sym
->
action
=
vcc_ParseCall
;
sym
->
vmod
=
msym
->
name
;
sym
->
vmod
=
msym
->
name
;
sym
->
eval
=
vcc_Eval_SymFunc
;
sym
->
eval
=
vcc_Eval_SymFunc
;
p
+=
strlen
(
p
)
+
1
;
p
+=
strlen
(
p
)
+
1
;
...
@@ -265,8 +266,8 @@ vcc_ParseImport(struct vcc *tl)
...
@@ -265,8 +266,8 @@ vcc_ParseImport(struct vcc *tl)
Fh
(
tl
,
0
,
"
\n
/* --- END VMOD %.*s --- */
\n\n
"
,
PF
(
mod
));
Fh
(
tl
,
0
,
"
\n
/* --- END VMOD %.*s --- */
\n\n
"
,
PF
(
mod
));
}
}
void
void
v_matchproto_
(
sym_act_f
)
vcc_ParseNew
(
struct
vcc
*
tl
)
vcc_ParseNew
(
struct
vcc
*
tl
,
struct
symbol
*
sym
)
{
{
struct
symbol
*
sy1
,
*
sy2
,
*
sy3
;
struct
symbol
*
sy1
,
*
sy2
,
*
sy3
;
struct
inifin
*
ifp
;
struct
inifin
*
ifp
;
...
@@ -275,6 +276,7 @@ vcc_ParseNew(struct vcc *tl)
...
@@ -275,6 +276,7 @@ vcc_ParseNew(struct vcc *tl)
char
buf1
[
128
];
char
buf1
[
128
];
char
buf2
[
128
];
char
buf2
[
128
];
(
void
)
sym
;
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
ID
);
ExpectErr
(
tl
,
ID
);
vcc_ExpectVid
(
tl
,
"VCL object"
);
vcc_ExpectVid
(
tl
,
"VCL object"
);
...
@@ -335,6 +337,7 @@ vcc_ParseNew(struct vcc *tl)
...
@@ -335,6 +337,7 @@ vcc_ParseNew(struct vcc *tl)
bprintf
(
buf2
,
"%s%s"
,
sy1
->
name
,
p
);
bprintf
(
buf2
,
"%s%s"
,
sy1
->
name
,
p
);
sy3
=
VCC_MkSym
(
tl
,
buf2
,
SYM_FUNC
);
sy3
=
VCC_MkSym
(
tl
,
buf2
,
SYM_FUNC
);
AN
(
sy3
);
AN
(
sy3
);
sy3
->
action
=
vcc_ParseCall
;
sy3
->
eval
=
vcc_Eval_SymFunc
;
sy3
->
eval
=
vcc_Eval_SymFunc
;
p
+=
strlen
(
p
)
+
1
;
p
+=
strlen
(
p
)
+
1
;
sy3
->
eval_priv
=
p
;
sy3
->
eval_priv
=
p
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment