[master] 59034c010 vcc SUB type: store C symbols for struct vcl_sub and the function

Nils Goroll nils.goroll at uplex.de
Mon Feb 8 17:52:03 UTC 2021


commit 59034c0101047c86756d3f97c3734162a740da3a
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Sat Feb 6 14:23:05 2021 +0100

    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.

diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index ec263fd8e..45eb278ca 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -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, ';');
 	}
 }
diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c
index 3331d961c..dc1d55c5b 100644
--- a/lib/libvcc/vcc_parse.c
+++ b/lib/libvcc/vcc_parse.c
@@ -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);
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index 0138c2cf6..2f8632359 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -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);


More information about the varnish-commit mailing list