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
05a95072
Commit
05a95072
authored
Feb 15, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call types types instead of formats
parent
0d0bac74
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
36 additions
and
40 deletions
+36
-40
generate.py
lib/libvcc/generate.py
+1
-1
vcc_action.c
lib/libvcc/vcc_action.c
+8
-8
vcc_compile.c
lib/libvcc/vcc_compile.c
+1
-1
vcc_compile.h
lib/libvcc/vcc_compile.h
+1
-1
vcc_expr.c
lib/libvcc/vcc_expr.c
+12
-17
vcc_storage.c
lib/libvcc/vcc_storage.c
+3
-3
vcc_symb.c
lib/libvcc/vcc_symb.c
+4
-3
vcc_var.c
lib/libvcc/vcc_var.c
+2
-2
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+3
-3
vcc_xref.c
lib/libvcc/vcc_xref.c
+1
-1
No files found.
lib/libvcc/generate.py
View file @
05a95072
...
...
@@ -1272,7 +1272,7 @@ def one_var(nm, spec):
else
:
fo
.
write
(
" SYM_VAR);
\n
"
)
fo
.
write
(
"
\t
AN(sym);
\n
"
)
fo
.
write
(
"
\t
sym->
fmt
=
%
s;
\n
"
%
spec
.
typ
)
fo
.
write
(
"
\t
sym->
type
=
%
s;
\n
"
%
spec
.
typ
)
fo
.
write
(
"
\t
sym->eval = vcc_Eval_Var;
\n
"
)
if
len
(
spec
.
rd
)
==
0
:
...
...
lib/libvcc/vcc_action.c
View file @
05a95072
...
...
@@ -88,7 +88,7 @@ static void v_matchproto_(sym_act_f)
vcc_act_set
(
struct
vcc
*
tl
,
struct
token
*
t
,
struct
symbol
*
sym
)
{
const
struct
arith
*
ap
;
vcc_type_t
fmt
;
vcc_type_t
type
;
(
void
)
t
;
ExpectErr
(
tl
,
ID
);
...
...
@@ -107,28 +107,28 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym)
vcc_AddUses
(
tl
,
t
,
tl
->
t
,
sym
->
w_methods
,
"Cannot be set"
);
Fb
(
tl
,
1
,
"%s
\n
"
,
sym
->
lname
);
tl
->
indent
+=
INDENT
;
fmt
=
sym
->
fmt
;
type
=
sym
->
type
;
for
(
ap
=
arith
;
ap
->
type
!=
VOID
;
ap
++
)
{
if
(
ap
->
type
!=
fmt
)
if
(
ap
->
type
!=
type
)
continue
;
if
(
ap
->
oper
!=
tl
->
t
->
tok
)
continue
;
if
(
ap
->
oper
!=
'='
)
Fb
(
tl
,
1
,
"%s %c "
,
sym
->
rname
,
*
tl
->
t
->
b
);
vcc_NextToken
(
tl
);
fmt
=
ap
->
want
;
type
=
ap
->
want
;
break
;
}
if
(
ap
->
type
==
VOID
)
SkipToken
(
tl
,
ap
->
oper
);
if
(
fmt
==
HEADER
)
{
if
(
type
==
HEADER
)
{
vcc_Expr
(
tl
,
STRING_LIST
);
}
else
if
(
fmt
==
STRING
)
{
}
else
if
(
type
==
STRING
)
{
vcc_Expr
(
tl
,
STRING_LIST
);
}
else
if
(
fmt
==
BODY
)
{
}
else
if
(
type
==
BODY
)
{
vcc_Expr
(
tl
,
STRING_LIST
);
}
else
{
vcc_Expr
(
tl
,
fmt
);
vcc_Expr
(
tl
,
type
);
}
ERRCHK
(
tl
);
tl
->
indent
-=
INDENT
;
...
...
lib/libvcc/vcc_compile.c
View file @
05a95072
...
...
@@ -811,7 +811,7 @@ vcc_predef_vcl(struct vcc *vcc, const char *name)
sym
=
VCC_MkSym
(
vcc
,
name
,
SYM_VCL
);
AN
(
sym
);
sym
->
fmt
=
VCL
;
sym
->
type
=
VCL
;
sym
->
r_methods
=
VCL_MET_RECV
;
}
...
...
lib/libvcc/vcc_compile.h
View file @
05a95072
...
...
@@ -129,7 +129,7 @@ struct symbol {
const
struct
token
*
def_b
,
*
def_e
,
*
ref_b
;
vcc_type_t
fmt
;
vcc_type_t
type
;
sym_expr_t
*
eval
;
const
void
*
eval_priv
;
...
...
lib/libvcc/vcc_expr.c
View file @
05a95072
...
...
@@ -328,19 +328,19 @@ vcc_Eval_BoolConst(struct vcc *tl, struct expr **e, struct token *t,
void
v_matchproto_
(
sym_expr_t
)
vcc_Eval_Handle
(
struct
vcc
*
tl
,
struct
expr
**
e
,
struct
token
*
t
,
struct
symbol
*
sym
,
vcc_type_t
fmt
)
struct
symbol
*
sym
,
vcc_type_t
type
)
{
(
void
)
t
;
(
void
)
tl
;
AN
(
sym
->
rname
);
if
(
sym
->
fmt
!=
STRING
&&
fmt
==
STRINGS
)
{
if
(
sym
->
type
!=
STRING
&&
type
==
STRINGS
)
{
*
e
=
vcc_mk_expr
(
STRINGS
,
"
\"
%s
\"
"
,
sym
->
name
);
(
*
e
)
->
nstr
=
1
;
(
*
e
)
->
constant
|=
EXPR_CONST
|
EXPR_STR_CONST
;
}
else
{
*
e
=
vcc_mk_expr
(
sym
->
fmt
,
"%s"
,
sym
->
rname
);
*
e
=
vcc_mk_expr
(
sym
->
type
,
"%s"
,
sym
->
rname
);
(
*
e
)
->
constant
=
EXPR_VAR
;
(
*
e
)
->
nstr
=
1
;
if
((
*
e
)
->
fmt
==
STRING
)
...
...
@@ -353,14 +353,14 @@ vcc_Eval_Handle(struct vcc *tl, struct expr **e, struct token *t,
void
v_matchproto_
(
sym_expr_t
)
vcc_Eval_Var
(
struct
vcc
*
tl
,
struct
expr
**
e
,
struct
token
*
t
,
struct
symbol
*
sym
,
vcc_type_t
fmt
)
struct
symbol
*
sym
,
vcc_type_t
type
)
{
(
void
)
fmt
;
(
void
)
type
;
assert
(
sym
->
kind
==
SYM_VAR
);
vcc_AddUses
(
tl
,
t
,
NULL
,
sym
->
r_methods
,
"Not available"
);
ERRCHK
(
tl
);
*
e
=
vcc_mk_expr
(
sym
->
fmt
,
"%s"
,
sym
->
rname
);
*
e
=
vcc_mk_expr
(
sym
->
type
,
"%s"
,
sym
->
rname
);
(
*
e
)
->
constant
=
EXPR_VAR
;
(
*
e
)
->
nstr
=
1
;
if
((
*
e
)
->
fmt
==
STRING
)
...
...
@@ -664,18 +664,12 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
XREF_REF
);
ERRCHK
(
tl
);
AN
(
sym
);
if
(
sym
->
kind
==
SYM_FUNC
&&
sym
->
fmt
==
VOID
)
{
if
(
sym
->
kind
==
SYM_FUNC
&&
sym
->
type
==
VOID
)
{
VSB_printf
(
tl
->
sb
,
"Function returns VOID:
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
switch
(
sym
->
kind
)
{
case
SYM_VAR
:
case
SYM_FUNC
:
case
SYM_ACL
:
case
SYM_BACKEND
:
case
SYM_STEVEDORE
:
case
SYM_PROBE
:
if
(
sym
->
eval
!=
NULL
)
{
AN
(
sym
->
eval
);
AZ
(
*
e
);
sym
->
eval
(
tl
,
e
,
t
,
sym
,
fmt
);
...
...
@@ -686,9 +680,6 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
ERRCHK
(
tl
);
}
return
;
default:
AZ
(
sym
->
eval
);
break
;
}
VSB_printf
(
tl
->
sb
,
"Symbol type (%s) can not be used in expression.
\n
"
,
...
...
@@ -1291,21 +1282,25 @@ vcc_Expr_Init(struct vcc *tl)
sym
=
VCC_MkSym
(
tl
,
"regsub"
,
SYM_FUNC
);
AN
(
sym
);
sym
->
type
=
STRING
;
sym
->
eval
=
vcc_Eval_Regsub
;
sym
->
eval_priv
=
NULL
;
sym
=
VCC_MkSym
(
tl
,
"regsuball"
,
SYM_FUNC
);
AN
(
sym
);
sym
->
type
=
STRING
;
sym
->
eval
=
vcc_Eval_Regsub
;
sym
->
eval_priv
=
sym
;
sym
=
VCC_MkSym
(
tl
,
"true"
,
SYM_FUNC
);
AN
(
sym
);
sym
->
type
=
BOOL
;
sym
->
eval
=
vcc_Eval_BoolConst
;
sym
->
eval_priv
=
sym
;
sym
=
VCC_MkSym
(
tl
,
"false"
,
SYM_FUNC
);
AN
(
sym
);
sym
->
type
=
BOOL
;
sym
->
eval
=
vcc_Eval_BoolConst
;
sym
->
eval_priv
=
NULL
;
}
lib/libvcc/vcc_storage.c
View file @
05a95072
...
...
@@ -67,7 +67,7 @@
static
struct
stvars
{
const
char
*
name
;
vcc_type_t
fmt
;
vcc_type_t
type
;
}
stvars
[]
=
{
#define VRTSTVVAR(nm, vtype, ctype, dval) { #nm, vtype },
#include "tbl/vrt_stv_var.h"
...
...
@@ -86,7 +86,7 @@ vcc_stevedore(struct vcc *vcc, const char *stv_name)
bprintf
(
buf
,
"storage.%s"
,
stv_name
);
sym
=
VCC_MkSym
(
vcc
,
buf
,
SYM_VAR
);
AN
(
sym
);
sym
->
fmt
=
STEVEDORE
;
sym
->
type
=
STEVEDORE
;
sym
->
eval
=
vcc_Eval_Var
;
bprintf
(
buf
,
"VRT_stevedore(
\"
%s
\"
)"
,
stv_name
);
sym
->
rname
=
TlDup
(
vcc
,
buf
);
...
...
@@ -96,7 +96,7 @@ vcc_stevedore(struct vcc *vcc, const char *stv_name)
bprintf
(
buf
,
"storage.%s.%s"
,
stv_name
,
sv
->
name
);
sym
=
VCC_MkSym
(
vcc
,
buf
,
SYM_VAR
);
AN
(
sym
);
sym
->
fmt
=
sv
->
fmt
;
sym
->
type
=
sv
->
type
;
sym
->
eval
=
vcc_Eval_Var
;
bprintf
(
buf
,
"VRT_Stv_%s(
\"
%s
\"
)"
,
sv
->
name
,
stv_name
);
sym
->
rname
=
TlDup
(
vcc
,
buf
);
...
...
lib/libvcc/vcc_symb.c
View file @
05a95072
...
...
@@ -101,6 +101,7 @@ vcc_new_symbol(struct vcc *tl, const char *b, const char *e)
sym
->
name
[
e
-
b
]
=
'\0'
;
sym
->
nlen
=
e
-
b
;
VTAILQ_INIT
(
&
sym
->
children
);
sym
->
type
=
VOID
;
return
(
sym
);
}
...
...
@@ -290,7 +291,7 @@ VCC_WalkSymbols(struct vcc *tl, symwalk_f *func, enum symkind kind)
}
void
VCC_GlobalSymbol
(
struct
symbol
*
sym
,
vcc_type_t
fmt
,
const
char
*
pfx
)
VCC_GlobalSymbol
(
struct
symbol
*
sym
,
vcc_type_t
type
,
const
char
*
pfx
)
{
struct
vsb
*
vsb
;
...
...
@@ -306,8 +307,8 @@ VCC_GlobalSymbol(struct symbol *sym, vcc_type_t fmt, const char *pfx)
AN
(
sym
->
rname
);
VSB_destroy
(
&
vsb
);
sym
->
fmt
=
fmt
;
sym
->
kind
=
VCC_HandleKind
(
sym
->
fmt
);
sym
->
type
=
type
;
sym
->
kind
=
VCC_HandleKind
(
sym
->
type
);
if
(
sym
->
kind
!=
SYM_NONE
)
{
AZ
(
VCT_invalid_name
(
sym
->
rname
,
NULL
));
sym
->
eval
=
vcc_Eval_Handle
;
...
...
lib/libvcc/vcc_var.c
View file @
05a95072
...
...
@@ -41,7 +41,7 @@ vcc_Var_Wildcard(struct vcc *tl, struct symbol *parent, struct symbol *sym)
{
struct
vsb
*
vsb
;
assert
(
parent
->
fmt
==
HEADER
);
assert
(
parent
->
type
==
HEADER
);
if
(
sym
->
nlen
>=
127
)
{
VSB_printf
(
tl
->
sb
,
"HTTP header (%.20s..) is too long.
\n
"
,
...
...
@@ -53,7 +53,7 @@ vcc_Var_Wildcard(struct vcc *tl, struct symbol *parent, struct symbol *sym)
AN
(
sym
);
sym
->
noref
=
1
;
sym
->
kind
=
SYM_VAR
;
sym
->
fmt
=
parent
->
fmt
;
sym
->
type
=
parent
->
type
;
sym
->
eval
=
vcc_Eval_Var
;
sym
->
r_methods
=
parent
->
r_methods
;
sym
->
w_methods
=
parent
->
w_methods
;
...
...
lib/libvcc/vcc_vmod.c
View file @
05a95072
...
...
@@ -250,8 +250,8 @@ vcc_ParseImport(struct vcc *tl)
sym
->
eval
=
vcc_Eval_SymFunc
;
p
+=
strlen
(
p
)
+
1
;
sym
->
eval_priv
=
p
;
sym
->
fmt
=
VCC_Type
(
p
);
AN
(
sym
->
fmt
);
sym
->
type
=
VCC_Type
(
p
);
AN
(
sym
->
type
);
}
else
{
VSB_printf
(
tl
->
sb
,
"Internal spec error (%s)
\n
"
,
p
);
vcc_ErrWhere
(
tl
,
mod
);
...
...
@@ -337,7 +337,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym)
sy3
->
eval
=
vcc_Eval_SymFunc
;
p
+=
strlen
(
p
)
+
1
;
sy3
->
eval_priv
=
p
;
sy3
->
fmt
=
VCC_Type
(
p
);
sy3
->
type
=
VCC_Type
(
p
);
sy3
->
extra
=
TlDup
(
tl
,
buf1
);
sy3
->
vmod
=
sy2
->
vmod
;
while
(
p
[
0
]
!=
'\0'
||
p
[
1
]
!=
'\0'
||
p
[
2
]
!=
'\0'
)
...
...
lib/libvcc/vcc_xref.c
View file @
05a95072
...
...
@@ -336,7 +336,7 @@ vcc_xreftable(struct vcc *tl, const struct symbol *sym)
{
Fc
(
tl
,
0
,
" * %-7s "
,
VCC_SymKind
(
tl
,
sym
));
Fc
(
tl
,
0
,
" %-9s "
,
sym
->
fmt
!=
NULL
?
sym
->
fmt
->
name
:
""
);
Fc
(
tl
,
0
,
" %-9s "
,
sym
->
type
->
name
);
vcc_pnam
(
tl
,
sym
);
if
(
sym
->
wildcard
!=
NULL
)
Fc
(
tl
,
0
,
"*"
);
...
...
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