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
03ca4548
Commit
03ca4548
authored
Jun 08, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving parsing of "new" to vcc_vmod.c where it belongs.
Minor simplifications.
parent
ce467f20
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
102 deletions
+102
-102
vcc_action.c
lib/libvcc/vcc_action.c
+1
-91
vcc_compile.h
lib/libvcc/vcc_compile.h
+2
-1
vcc_expr.c
lib/libvcc/vcc_expr.c
+11
-8
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+88
-2
No files found.
lib/libvcc/vcc_action.c
View file @
03ca4548
...
...
@@ -145,96 +145,6 @@ parse_unset(struct vcc *tl)
/*--------------------------------------------------------------------*/
static
void
parse_new
(
struct
vcc
*
tl
)
{
struct
symbol
*
sy1
,
*
sy2
,
*
sy3
;
struct
inifin
*
ifp
;
const
char
*
p
,
*
s_obj
,
*
s_init
,
*
s_struct
,
*
s_fini
;
char
buf1
[
128
];
char
buf2
[
128
];
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
ID
);
vcc_ExpectCid
(
tl
,
"VCL object"
);
ERRCHK
(
tl
);
sy1
=
VCC_HandleSymbol
(
tl
,
tl
->
t
,
INSTANCE
,
"XXX"
);
ERRCHK
(
tl
);
/* We allow implicit use of VMOD objects: Pretend it's ref'ed */
sy1
->
nref
++
;
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
'='
);
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
ID
);
sy2
=
VCC_SymbolTok
(
tl
,
NULL
,
tl
->
t
,
SYM_OBJECT
,
0
);
if
(
sy2
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Symbol not found: "
);
vcc_ErrToken
(
tl
,
tl
->
t
);
VSB_printf
(
tl
->
sb
,
" at "
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
XXXAN
(
sy2
);
/*lint -save -e448 */
/* Split the first three args */
p
=
sy2
->
args
;
s_obj
=
p
;
p
+=
strlen
(
p
)
+
1
;
s_struct
=
p
;
p
+=
strlen
(
p
)
+
1
;
s_init
=
p
;
while
(
p
[
0
]
!=
'\0'
||
p
[
1
]
!=
'\0'
||
p
[
2
]
!=
'\0'
)
p
++
;
p
+=
3
;
s_fini
=
p
;
while
(
p
[
0
]
!=
'\0'
||
p
[
1
]
!=
'\0'
||
p
[
2
]
!=
'\0'
)
p
++
;
p
+=
3
;
Fh
(
tl
,
0
,
"static %s *vo_%s;
\n\n
"
,
s_struct
,
sy1
->
name
);
vcc_NextToken
(
tl
);
bprintf
(
buf1
,
", &vo_%s,
\"
%s
\"
"
,
sy1
->
name
,
sy1
->
name
);
vcc_Eval_Func
(
tl
,
s_init
,
buf1
,
sy2
->
name
,
s_init
+
strlen
(
s_init
)
+
1
,
sy2
->
vmod
);
ifp
=
New_IniFin
(
tl
);
VSB_printf
(
ifp
->
fin
,
"
\t\t
%s(&vo_%s);"
,
s_fini
,
sy1
->
name
);
ExpectErr
(
tl
,
';'
);
bprintf
(
buf1
,
", vo_%s"
,
sy1
->
name
);
/* Split the methods from the args */
while
(
*
p
!=
'\0'
)
{
p
+=
strlen
(
s_obj
);
bprintf
(
buf2
,
"%s%s"
,
sy1
->
name
,
p
);
sy3
=
VCC_Symbol
(
tl
,
NULL
,
buf2
,
NULL
,
SYM_FUNC
,
1
);
AN
(
sy3
);
sy3
->
eval
=
vcc_Eval_SymFunc
;
p
+=
strlen
(
p
)
+
1
;
sy3
->
cfunc
=
p
;
p
+=
strlen
(
p
)
+
1
;
sy3
->
args
=
p
;
sy3
->
extra
=
TlDup
(
tl
,
buf1
);
while
(
p
[
0
]
!=
'\0'
||
p
[
1
]
!=
'\0'
||
p
[
2
]
!=
'\0'
)
p
++
;
p
+=
3
;
}
sy1
->
def_e
=
tl
->
t
;
/*lint -restore */
}
/*--------------------------------------------------------------------*/
static
void
parse_ban
(
struct
vcc
*
tl
)
{
...
...
@@ -375,7 +285,7 @@ static struct action_table {
{
"ban"
,
parse_ban
},
{
"call"
,
parse_call
},
{
"hash_data"
,
parse_hash_data
,
VCL_MET_HASH
},
{
"new"
,
parse_n
ew
,
VCL_MET_INIT
},
{
"new"
,
vcc_ParseN
ew
,
VCL_MET_INIT
},
{
"return"
,
parse_return
},
{
"set"
,
parse_set
},
{
"synthetic"
,
parse_synthetic
,
...
...
lib/libvcc/vcc_compile.h
View file @
03ca4548
...
...
@@ -133,7 +133,7 @@ struct symbol {
vcc_type_t
fmt
;
sym_expr_t
*
eval
;
void
*
eval_priv
;
const
void
*
eval_priv
;
/* xref.c */
struct
proc
*
proc
;
...
...
@@ -342,6 +342,7 @@ const struct symbol *vcc_FindVar(struct vcc *tl, const struct token *t,
/* vcc_vmod.c */
void
vcc_ParseImport
(
struct
vcc
*
tl
);
void
vcc_ParseNew
(
struct
vcc
*
tl
);
/* vcc_xref.c */
int
vcc_AddDef
(
struct
vcc
*
tl
,
const
struct
token
*
t
,
enum
symkind
type
);
...
...
lib/libvcc/vcc_expr.c
View file @
03ca4548
...
...
@@ -727,16 +727,23 @@ void __match_proto__(sym_expr_t)
vcc_Eval_SymFunc
(
struct
vcc
*
tl
,
struct
expr
**
e
,
const
struct
symbol
*
sym
,
vcc_type_t
fmt
)
{
const
char
*
cfunc
;
const
char
*
args
;
const
char
*
p
;
(
void
)
fmt
;
assert
(
sym
->
kind
==
SYM_FUNC
);
/* XXX */
AN
(
sym
->
cfunc
);
AN
(
sym
->
eval_priv
);
AZ
(
sym
->
args
);
AZ
(
sym
->
cfunc
);
p
=
sym
->
eval_priv
;
cfunc
=
p
;
p
+=
strlen
(
p
)
+
1
;
args
=
p
;
AN
(
sym
->
name
);
AN
(
sym
->
args
);
SkipToken
(
tl
,
ID
);
vcc_func
(
tl
,
e
,
sym
->
cfunc
,
sym
->
extra
,
sym
->
name
,
sym
->
args
,
sym
->
vmod
);
vcc_func
(
tl
,
e
,
cfunc
,
sym
->
extra
,
sym
->
name
,
args
,
sym
->
vmod
);
}
/*--------------------------------------------------------------------
...
...
@@ -777,10 +784,6 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
kind
=
VCC_HandleKind
(
fmt
);
if
(
kind
!=
SYM_NONE
)
sym
=
VCC_SymbolTok
(
tl
,
NULL
,
tl
->
t
,
kind
,
0
);
if
(
sym
==
NULL
)
sym
=
VCC_SymbolTok
(
tl
,
NULL
,
tl
->
t
,
SYM_VAR
,
0
);
if
(
sym
==
NULL
)
sym
=
VCC_SymbolTok
(
tl
,
NULL
,
tl
->
t
,
SYM_FUNC
,
0
);
if
(
sym
==
NULL
)
sym
=
VCC_SymbolTok
(
tl
,
NULL
,
tl
->
t
,
SYM_NONE
,
0
);
if
(
sym
==
NULL
||
sym
->
eval
==
NULL
)
{
...
...
lib/libvcc/vcc_vmod.c
View file @
03ca4548
...
...
@@ -245,9 +245,8 @@ vcc_ParseImport(struct vcc *tl)
sym
->
vmod
=
msym
->
name
;
sym
->
eval
=
vcc_Eval_SymFunc
;
p
+=
strlen
(
p
)
+
1
;
sym
->
cfunc
=
p
;
sym
->
eval_priv
=
p
;
p
+=
strlen
(
p
)
+
1
;
sym
->
args
=
p
;
sym
->
fmt
=
VCC_Type
(
p
);
AN
(
sym
->
fmt
);
p
+=
strlen
(
p
)
+
1
;
...
...
@@ -264,3 +263,90 @@ vcc_ParseImport(struct vcc *tl)
Fh
(
tl
,
0
,
"
\n
%s
\n
"
,
vmd
->
proto
);
Fh
(
tl
,
0
,
"
\n
/* --- END VMOD %.*s --- */
\n\n
"
,
PF
(
mod
));
}
void
vcc_ParseNew
(
struct
vcc
*
tl
)
{
struct
symbol
*
sy1
,
*
sy2
,
*
sy3
;
struct
inifin
*
ifp
;
const
char
*
p
,
*
s_obj
,
*
s_init
,
*
s_struct
,
*
s_fini
;
char
buf1
[
128
];
char
buf2
[
128
];
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
ID
);
vcc_ExpectCid
(
tl
,
"VCL object"
);
ERRCHK
(
tl
);
sy1
=
VCC_HandleSymbol
(
tl
,
tl
->
t
,
INSTANCE
,
"XXX"
);
ERRCHK
(
tl
);
/* We allow implicit use of VMOD objects: Pretend it's ref'ed */
sy1
->
nref
++
;
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
'='
);
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
ID
);
sy2
=
VCC_SymbolTok
(
tl
,
NULL
,
tl
->
t
,
SYM_OBJECT
,
0
);
if
(
sy2
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Symbol not found: "
);
vcc_ErrToken
(
tl
,
tl
->
t
);
VSB_printf
(
tl
->
sb
,
" at "
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
XXXAN
(
sy2
);
/*lint -save -e448 */
/* Split the first three args */
p
=
sy2
->
args
;
s_obj
=
p
;
p
+=
strlen
(
p
)
+
1
;
s_struct
=
p
;
p
+=
strlen
(
p
)
+
1
;
s_init
=
p
;
while
(
p
[
0
]
!=
'\0'
||
p
[
1
]
!=
'\0'
||
p
[
2
]
!=
'\0'
)
p
++
;
p
+=
3
;
s_fini
=
p
;
while
(
p
[
0
]
!=
'\0'
||
p
[
1
]
!=
'\0'
||
p
[
2
]
!=
'\0'
)
p
++
;
p
+=
3
;
Fh
(
tl
,
0
,
"static %s *vo_%s;
\n\n
"
,
s_struct
,
sy1
->
name
);
vcc_NextToken
(
tl
);
bprintf
(
buf1
,
", &vo_%s,
\"
%s
\"
"
,
sy1
->
name
,
sy1
->
name
);
vcc_Eval_Func
(
tl
,
s_init
,
buf1
,
sy2
->
name
,
s_init
+
strlen
(
s_init
)
+
1
,
sy2
->
vmod
);
ifp
=
New_IniFin
(
tl
);
VSB_printf
(
ifp
->
fin
,
"
\t\t
%s(&vo_%s);"
,
s_fini
,
sy1
->
name
);
ExpectErr
(
tl
,
';'
);
bprintf
(
buf1
,
", vo_%s"
,
sy1
->
name
);
/* Split the methods from the args */
while
(
*
p
!=
'\0'
)
{
p
+=
strlen
(
s_obj
);
bprintf
(
buf2
,
"%s%s"
,
sy1
->
name
,
p
);
sy3
=
VCC_Symbol
(
tl
,
NULL
,
buf2
,
NULL
,
SYM_FUNC
,
1
);
AN
(
sy3
);
sy3
->
eval
=
vcc_Eval_SymFunc
;
p
+=
strlen
(
p
)
+
1
;
sy3
->
eval_priv
=
p
;
p
+=
strlen
(
p
)
+
1
;
sy3
->
fmt
=
VCC_Type
(
p
);
sy3
->
extra
=
TlDup
(
tl
,
buf1
);
while
(
p
[
0
]
!=
'\0'
||
p
[
1
]
!=
'\0'
||
p
[
2
]
!=
'\0'
)
p
++
;
p
+=
3
;
}
sy1
->
def_e
=
tl
->
t
;
/*lint -restore */
}
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