Commit 8ae3d978 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Extend the syntax to 'import vmod [as name] [from "path"];'

There are a surprising number of subtle corner cases here, and I
think I have handled them all correctly, but caveat emptor...
parent 659f2af4
......@@ -11,10 +11,12 @@ varnish v1 -vcl+backend {
import debug;
import vtc;
import debug; // again
import debug as dbg;
import debug as dbg; // again
sub vcl_init {
new objx = debug.obj();
debug.vsc_new();
new objx = dbg.obj();
dbg.vsc_new();
}
sub vcl_synth {
......
......@@ -12,6 +12,11 @@ varnish v1 -errvcl {Module debug conflicts with other symbol.} {
}
}
varnish v1 -errvcl {Another module already imported as foo} {
import debug as foo;
import directors as foo;
}
server s1 {
rxreq
txresp
......
......@@ -144,7 +144,7 @@ struct symbol {
int hirev;
struct symbol *parent;
const struct symbol *vmod;
const char *vmod_name;
sym_wildcard_t *wildcard;
vcc_kind_t kind;
......
......@@ -359,10 +359,10 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym)
struct procprivhead *marklist = NULL;
AN(sym);
AN(sym->vmod);
AN(sym->vmod_name);
if (!strcmp(p, "PRIV_VCL"))
return (vcc_mk_expr(VOID, "&vmod_priv_%s", sym->vmod->name));
return (vcc_mk_expr(VOID, "&vmod_priv_%s", sym->vmod_name));
if (!strcmp(p, "PRIV_CALL")) {
bprintf(buf, "vmod_priv_%u", tl->unique++);
......@@ -383,9 +383,9 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym)
}
AN(f);
AN(marklist);
bprintf(buf, "ARG_priv_%s_%s", f, sym->vmod->name);
bprintf(buf, "ARG_priv_%s_%s", f, sym->vmod_name);
if (vcc_MarkPriv(tl, marklist, sym->vmod->name) == NULL)
if (vcc_MarkPriv(tl, marklist, sym->vmod_name) == NULL)
VSB_printf(tl->curproc->prologue,
" struct vmod_priv *%s = "
"VRT_priv_%s(ctx, &VGC_vmod_%s);\n"
......@@ -394,7 +394,7 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym)
"for vmod %s\");\n"
" return;\n"
" }\n",
buf, f, sym->vmod->name, buf, f, sym->vmod->name);
buf, f, sym->vmod_name, buf, f, sym->vmod_name);
return (vcc_mk_expr(VOID, "%s", buf));
}
......
This diff is collapsed.
......@@ -603,7 +603,7 @@ class ModuleStanza(Stanza):
write_rst_hdr(fo, "SYNOPSIS", "=")
fo.write("\n")
fo.write(".. parsed-literal::\n\n")
fo.write(' import %s [from "path"]\n' % self.vcc.modname)
fo.write(' import %s [as name] [from "path"]\n' % self.vcc.modname)
fo.write(" \n")
for c in self.vcc.contents:
c.synopsis(fo, man)
......
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