vcc SUB type: store C symbols for struct vcl_sub and the function

We change the semantics of the rname and lname attributes of SUB
symbols: rname now is the name of the (struct vcl_sub), lname is the
cname, the name of the function to be called directly from VGC.
parent ae87e52f
......@@ -53,7 +53,7 @@ vcc_act_call(struct vcc *tl, struct token *t, struct symbol *sym)
if (sym != NULL) {
vcc_AddCall(tl, t0, sym);
VCC_GlobalSymbol(sym, SUB, "VGC_function");
Fb(tl, 1, "%s(ctx);\n", sym->rname);
Fb(tl, 1, "%s(ctx);\n", sym->lname);
SkipToken(tl, ';');
}
}
......
......@@ -251,7 +251,7 @@ vcc_ParseFunction(struct vcc *tl)
VCC_GlobalSymbol(sym, SUB, "VGC_function");
p = vcc_NewProc(tl, sym);
p->name = t;
VSB_printf(p->cname, "%s", sym->rname);
VSB_printf(p->cname, "%s", sym->lname);
} else if (p->method == NULL) {
VSB_printf(tl->sb, "Subroutine '%s' redefined\n", sym->name);
vcc_ErrWhere(tl, t);
......
......@@ -471,6 +471,14 @@ VCC_GlobalSymbol(struct symbol *sym, vcc_type_t type, const char *pfx)
VSB_printf(vsb, "%s_", pfx);
VCC_PrintCName(vsb, sym->name, NULL);
AZ(VSB_finish(vsb));
sym->lname = strdup(VSB_data(vsb));
if (type == SUB) {
VSB_destroy(&vsb);
vsb = VSB_new_auto();
AN(vsb);
VSB_printf(vsb, "sub_%s", sym->lname);
AZ(VSB_finish(vsb));
}
sym->rname = strdup(VSB_data(vsb));
AN(sym->rname);
VSB_destroy(&vsb);
......
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