Commit ac5864cc authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give VCC symbols a kind, and use SYM_VMOD to complain if a VMOD is

attempted imported more than once.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5201 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent c720f22e
......@@ -48,3 +48,9 @@ varnish v1 -cliok "vcl.list"
varnish v1 -cliok "debug.vmod"
varnish v1 -expect vmods == 0
varnish v1 -badvcl {
import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so.1" ;
import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so.1" ;
}
......@@ -68,17 +68,31 @@ struct token {
char *dec;
};
enum symkind {
SYM_NONE,
SYM_VAR,
SYM_FUNC,
SYM_PROC,
SYM_VMOD
};
struct symbol {
unsigned magic;
#define SYMBOL_MAGIC 0x3368c9fb
VTAILQ_ENTRY(symbol) list;
char *name;
unsigned nlen;
unsigned wildcard;
enum symkind kind;
enum var_type fmt;
struct token *def_b, *def_e;
const char *cfunc;
const char *args;
const struct var *var;
enum var_type fmt;
unsigned r_methods;
};
......
......@@ -46,20 +46,45 @@ vcc_ParseImport(struct vcc *tl)
{
void *hdl;
char fn[1024];
struct token *mod;
struct token *mod, *t1;
const char *modname;
const char *proto;
const char **spec;
struct symbol *sym;
const struct symbol *osym;
const char *p;
// int *modlen;
SkipToken(tl, ID);
t1 = tl->t;
SkipToken(tl, ID); /* "import" */
ExpectErr(tl, ID);
mod = tl->t;
vcc_NextToken(tl);
osym = VCC_FindSymbol(tl, mod);
if (osym != NULL && osym->kind != SYM_VMOD) {
vsb_printf(tl->sb, "Module %.*s conflics with other symbol.\n",
PF(mod));
vcc_ErrWhere2(tl, t1, tl->t);
return;
}
if (osym != NULL) {
vsb_printf(tl->sb, "Module %.*s already imported.\n",
PF(mod));
vcc_ErrWhere2(tl, t1, tl->t);
vsb_printf(tl->sb, "Previous import was here:\n");
vcc_ErrWhere2(tl, osym->def_b, osym->def_e);
return;
}
bprintf(fn, "%.*s", PF(mod));
sym = VCC_AddSymbol(tl, fn);
sym->kind = SYM_VMOD;
sym->def_b = t1;
sym->def_e = tl->t;
if (tl->t->tok == ID) {
vcc_NextToken(tl);
ExpectErr(tl, CSTR);
......
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