-
Nils Goroll authored
Until now, the VCC SUB type represented the literal name of a vcc-generated C function, which was used to expand the VCL "call" action. We now add a struct to describe VCL subs and calculate a bitmask which represents the bilt-in subs which a SUB may be called from (the "okmask"), This is in preparation of the goal to add a VCL_SUB vmod type which will allow VMODs to call into vcl subs. We add to the vcl shared object a struct vcl_sub for each sub, which contains: - a methods bitmask defining which built-in subs this sub may be called from (directly or indirectly) - the name as seen from vcl - a pointer back to the VCL_conf - the function pointer to the vcl_func_f - a unique number About the methods bitmask: It contains the VCL_MET_* bits of of built-in subs (traditionally called methods) which are allowed to call this sub. It is intended for checks like if (sub->methods & ctx->method) { sub->func(ctx); return; } else { VRT_fail(ctx, "not allowed here"); return; } In existing compile-time calls, we already check if used objects and returned actions are allowed within the respective calling context. To build the methods bitmask, we begin with a VCL_MET_TASK_ALL bitfield and clear the bits of methods which would not be allowed for any used object or returned action. About the VCL_conf pointer: Each VCL SUB belongs to a VCL, this pointer will allow to check that it is only ever used from the right VCL. About the unique number: By numbering vcl subs (per VCL), we can later implement a recursion check using a bitmask. In struct VCL_conf, we record the total number of subs.