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
f0cba1de
Commit
f0cba1de
authored
May 17, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create VCC_SymbolGetTok() variant
parent
5d3d3eea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
+28
-17
vcc_compile.h
lib/libvcc/vcc_compile.h
+2
-0
vcc_symb.c
lib/libvcc/vcc_symb.c
+26
-17
No files found.
lib/libvcc/vcc_compile.h
View file @
f0cba1de
...
...
@@ -356,6 +356,8 @@ extern const char SYMTAB_NOERR[];
extern
const
char
SYMTAB_CREATE
[];
struct
symbol
*
VCC_SymbolGet
(
struct
vcc
*
,
vcc_kind_t
,
const
char
*
,
const
char
*
);
struct
symbol
*
VCC_SymbolGetTok
(
struct
vcc
*
,
vcc_kind_t
,
const
char
*
,
const
char
*
,
struct
token
*
);
typedef
void
symwalk_f
(
struct
vcc
*
tl
,
const
struct
symbol
*
s
);
void
VCC_WalkSymbols
(
struct
vcc
*
tl
,
symwalk_f
*
func
,
vcc_kind_t
);
...
...
lib/libvcc/vcc_symb.c
View file @
f0cba1de
...
...
@@ -198,30 +198,31 @@ const char SYMTAB_NOERR[] = "sym_noerror";
const
char
SYMTAB_CREATE
[]
=
"sym_create"
;
struct
symbol
*
VCC_SymbolGet
(
struct
vcc
*
tl
,
vcc_kind_t
kind
,
const
char
*
e
,
const
char
*
x
)
VCC_SymbolGetTok
(
struct
vcc
*
tl
,
vcc_kind_t
kind
,
const
char
*
e
,
const
char
*
x
,
struct
token
*
t
)
{
struct
symbol
*
sym
;
AN
(
e
);
if
(
tl
->
syntax
>=
VCL_41
&&
e
==
SYMTAB_CREATE
&&
kind
!=
SYM_SUB
&&
(
t
l
->
t
->
b
[
0
]
==
'v'
||
tl
->
t
->
b
[
0
]
==
'V'
)
&&
(
t
l
->
t
->
b
[
1
]
==
'c'
||
tl
->
t
->
b
[
1
]
==
'C'
)
&&
(
t
l
->
t
->
b
[
2
]
==
'l'
||
tl
->
t
->
b
[
2
]
==
'L'
)
&&
(
t
l
->
t
->
b
[
3
]
==
'_'
))
{
(
t
->
b
[
0
]
==
'v'
||
t
->
b
[
0
]
==
'V'
)
&&
(
t
->
b
[
1
]
==
'c'
||
t
->
b
[
1
]
==
'C'
)
&&
(
t
->
b
[
2
]
==
'l'
||
t
->
b
[
2
]
==
'L'
)
&&
(
t
->
b
[
3
]
==
'_'
))
{
VSB_printf
(
tl
->
sb
,
"Symbols named 'vcl_*' are reserved.
\n
At:"
);
vcc_ErrWhere
(
tl
,
t
l
->
t
);
vcc_ErrWhere
(
tl
,
t
);
return
(
NULL
);
}
sym
=
VCC_Symbol
(
tl
,
NULL
,
t
l
->
t
->
b
,
tl
->
t
->
e
,
kind
,
sym
=
VCC_Symbol
(
tl
,
NULL
,
t
->
b
,
t
->
e
,
kind
,
e
==
SYMTAB_CREATE
?
1
:
0
,
tl
->
syntax
,
tl
->
syntax
);
if
(
sym
==
NULL
&&
e
==
SYMTAB_NOERR
)
return
(
sym
);
if
(
sym
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"%s: "
,
e
);
vcc_ErrToken
(
tl
,
t
l
->
t
);
sym
=
VCC_Symbol
(
tl
,
NULL
,
t
l
->
t
->
b
,
tl
->
t
->
e
,
kind
,
0
,
vcc_ErrToken
(
tl
,
t
);
sym
=
VCC_Symbol
(
tl
,
NULL
,
t
->
b
,
t
->
e
,
kind
,
0
,
VCL_LOW
,
VCL_HIGH
);
if
(
sym
!=
NULL
)
{
VSB_printf
(
tl
->
sb
,
" (Only available when"
);
...
...
@@ -233,16 +234,16 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x)
VSB_printf
(
tl
->
sb
,
")"
);
}
VSB_cat
(
tl
->
sb
,
"
\n
At: "
);
vcc_ErrWhere
(
tl
,
t
l
->
t
);
vcc_ErrWhere
(
tl
,
t
);
return
(
NULL
);
}
assert
(
sym
->
lorev
<=
tl
->
syntax
&&
sym
->
hirev
>=
tl
->
syntax
);
if
(
kind
!=
SYM_NONE
&&
kind
!=
sym
->
kind
)
{
VSB_printf
(
tl
->
sb
,
"Symbol "
);
vcc_ErrToken
(
tl
,
t
l
->
t
);
vcc_ErrToken
(
tl
,
t
);
VSB_printf
(
tl
->
sb
,
" has wrong type (%s): "
,
sym
->
kind
->
name
);
VSB_cat
(
tl
->
sb
,
"
\n
At: "
);
vcc_ErrWhere
(
tl
,
t
l
->
t
);
vcc_ErrWhere
(
tl
,
t
);
if
(
sym
->
def_b
!=
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Symbol was defined here: "
);
vcc_ErrWhere
(
tl
,
sym
->
def_b
);
...
...
@@ -256,22 +257,30 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x)
}
if
(
x
==
XREF_DEF
)
{
if
(
sym
->
def_b
==
NULL
)
sym
->
def_b
=
t
l
->
t
;
sym
->
def_b
=
t
;
sym
->
ndef
++
;
}
else
if
(
x
==
XREF_REF
)
{
if
(
sym
->
ref_b
==
NULL
)
sym
->
ref_b
=
t
l
->
t
;
sym
->
ref_b
=
t
;
sym
->
nref
++
;
}
else
{
assert
(
x
==
XREF_NONE
);
}
vcc_NextToken
(
tl
);
return
(
sym
);
}
struct
symbol
*
VCC_MkSym
(
struct
vcc
*
tl
,
const
char
*
b
,
vcc_kind_t
kind
,
int
vlo
,
int
vhi
)
VCC_SymbolGet
(
struct
vcc
*
tl
,
vcc_kind_t
kind
,
const
char
*
e
,
const
char
*
x
)
{
struct
symbol
*
sym
;
sym
=
VCC_SymbolGetTok
(
tl
,
kind
,
e
,
x
,
tl
->
t
);
if
(
sym
!=
NULL
)
vcc_NextToken
(
tl
);
return
(
sym
);
}
struct
symbol
*
VCC_MkSym
(
struct
vcc
*
tl
,
const
char
*
b
,
vcc_kind_t
kind
,
int
vlo
,
int
vhi
)
{
struct
symbol
*
sym
;
...
...
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