VSpec

AcronymDefinition
VSpecVictory Specification (Nissan)
References in periodicals archive ?
In addition, local enables dynamic code to have an arbitrary number of local variables, local returns an object of type T vspec that denotes a dynamic local variable of type T in the current dynamic function.
The param special form is used to create parameters of dynamic functions, param returns an object of type T vspec that denotes a formal parameter of the current dynamic function, param-num is the parameter's position in the function's parameter list, whereas T denotes its evaluation type.
void cspec construct_sum(int n) { int i, cspec c = `0; for (i = 0;i < n; i++) { int vspec v = param(int, i); /* Create a parameter */ c = `(c + v); /* Add param 'v' to current sum */ } return `{ return c; }; } int cspec construct_call(int nargs, int *arg_vec) { int (,sum)() = compile(construct_sum(nargs), int); void cspec args = push_init(); /* Initialize argument list */ i.
write_ptr mkwrite(struct tcb ,tcb) { char * vspec msg = param(char * 0); int vspec nbytes = param(int, 1); return compile('( return write($tcb, msg, nbytes); }, int); }
hptr mk_hash(struct ht *ht) { int vspec val = param(int, 0); void cspec code = `{ struct hte *hte = ($ht [right arrow] hte)[(val * $ht [right arrow] scatter) / $ht [right arrow] norm]; while (hte && hte [right arrow] val
typedef int (*ip)(int key); ip mksearch(int n, int *x) { int vspec key = param(int, 0);/.
Code to create a specialized exponentiation function typedef double (*dptr) (); dptr mkpow(int exp) { double vspec base = param(double, 0); /* Argument: the base */ double vspec result = local(register double); /, Local: running product */ void cspec squares; int bit = 2; /* Initialize the running product */ if (1&exp) squares = `{ result=base; }; else squares = `{ result=1.
typedef void (*fp)(void *, void *); fp mk_swap(int size) { long * vspec src = param(long *, 0); /* Arg 0: source */ long * vspec dst = param(long *, 1); /* Arg 1: destination */ long vspec tmp= local(long); /* Temporary for swaps */ void cspec s = `{}; /* Code to be built up, initially empty */ int i; for (i = 0; i < size/sizeof(long); i++) /* Build swap code */ s = `{ @s; tmp = src[$i]; src[$i] = dst[$i]; dst[$i] = tmp; }; return (fp)compile(s, void); }
Then, for every type in the type vector, it creates a vspec that refers to the corresponding parameter, and constructs code to store the parameter's value into the byte vector at a distinct run-time constant offset.
typedef int (*fptr)(); /* Type of the function we will be calling */ void cspec mk_unmarshal(type_t *types, int nargs) { int i; fptr vspec fp = param(fptr, 0); /* Arg 0: the function to invoke */ type *vspec m = param(type *, 1); /* Arg 1: the vector to unmarshal */ void cspec args = push_init(); /* Initialize the dynamic argument list */ for (i = 0; i < nargs; i++) { /* Build up the dynamic argument list */ switch(types[i]) { case INTEGER: push(args, `m[$i].
In the calls f(p0) and fprime(p0), p0 is passed as a vspec argument.
Function that constructs a cspec to compute f(x) = (x+1)^2 */ double cspec f(double vspec x) { return `((x + 1.