Skip to content
Permalink
Browse files

Use vmod symbol instead of vmod name

  • Loading branch information...
bsdphk committed May 17, 2019
1 parent f0cba1d commit f4f41c51cb5c3f9dd2e21b9e785ae94bffcb85e7
Showing with 19 additions and 15 deletions.
  1. +3 −2 lib/libvcc/vcc_compile.h
  2. +11 −9 lib/libvcc/vcc_expr.c
  3. +1 −1 lib/libvcc/vcc_symb.c
  4. +4 −3 lib/libvcc/vcc_vmod.c
@@ -144,7 +144,7 @@ struct symbol {
int hirev;

struct symbol *parent;
const char *vmod;
const struct symbol *vmod;

sym_wildcard_t *wildcard;
vcc_kind_t kind;
@@ -356,7 +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 *);
struct symbol *VCC_SymbolGetTok(struct vcc *, vcc_kind_t, const char *,
const char *, const 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);
@@ -355,22 +355,24 @@ vcc_priv_arg(struct vcc *tl, const char *p, const struct symbol *sym)
{
char buf[64];
struct inifin *ifp;
const char *vmod, *f = NULL;
const char *f = NULL;
struct procprivhead *marklist = NULL;

AN(sym);
AN(sym->vmod);
vmod = sym->vmod;

if (!strcmp(p, "PRIV_VCL")) {
return (vcc_mk_expr(VOID, "&vmod_priv_%s", vmod));
} else if (!strcmp(p, "PRIV_CALL")) {
if (!strcmp(p, "PRIV_VCL"))
return (vcc_mk_expr(VOID, "&vmod_priv_%s", sym->vmod->name));

if (!strcmp(p, "PRIV_CALL")) {
bprintf(buf, "vmod_priv_%u", tl->unique++);
ifp = New_IniFin(tl);
Fh(tl, 0, "static struct vmod_priv %s;\n", buf);
VSB_printf(ifp->fin, "\tVRT_priv_fini(&%s);", buf);
return (vcc_mk_expr(VOID, "&%s", buf));
} else if (!strcmp(p, "PRIV_TASK")) {
}

if (!strcmp(p, "PRIV_TASK")) {
f = "task";
marklist = &tl->curproc->priv_tasks;
} else if (!strcmp(p, "PRIV_TOP")) {
@@ -381,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, vmod);
bprintf(buf, "ARG_priv_%s_%s", f, sym->vmod->name);

if (vcc_MarkPriv(tl, marklist, vmod) == 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"
@@ -392,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, vmod, buf, f, vmod);
buf, f, sym->vmod->name, buf, f, sym->vmod->name);
return (vcc_mk_expr(VOID, "%s", buf));
}

@@ -199,7 +199,7 @@ const char SYMTAB_CREATE[] = "sym_create";

struct symbol *
VCC_SymbolGetTok(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x,
struct token *t)
const struct token *t)
{
struct symbol *sym;

@@ -57,7 +57,8 @@ vcc_path_dlopen(void *priv, const char *fn)
}

static void
func_sym(struct symbol *sym, const char *vmod, const struct vjsn_val *v)
func_sym(struct symbol *sym, const struct symbol *vmod,
const struct vjsn_val *v)
{

assert(v->type == VJSN_ARRAY);
@@ -139,13 +140,13 @@ vcc_json_wildcard(struct vcc *tl, struct symbol *msym, struct symbol *tsym)
!strcmp(vv2->value, tsym->name)) {
tsym->kind = SYM_FUNC;
tsym->noref = 1;
func_sym(tsym, msym->name, VTAILQ_NEXT(vv2, list));
func_sym(tsym, msym, VTAILQ_NEXT(vv2, list));
return;
} else if (!strcmp(vv1->value, "$OBJ") &&
!strcmp(vv2->value, tsym->name)) {
tsym->kind = SYM_OBJECT;
tsym->eval_priv = vv2;
tsym->vmod = msym->name;
tsym->vmod = msym;
return;
}
}

0 comments on commit f4f41c5

Please sign in to comment.
You can’t perform that action at this time.