CSPEC

AcronymDefinition
CSPECControl Specification
CSPECCommon Systems Planning and Engineering Center (Qwest)
References in periodicals archive ?
Statements (and compound statements) are considered to have type void; an object of type void cspec inside a backquote expression cannot be used inside an expression, but can be composed as an expression statement:
void cspec hello = `{ printf("hello "); }; void cspec world - `{ printf("world\n"); }; void cspec greeting = `{ @hello; @world; }; 2.3.2 The $ Operator.
intx = 1; void cspec c = `{ printf("$x = %d, x = %d\n", $x, x); }; x = 14; (*compile(c, void))(); /* Compile and run: will print "$x = 1, x = 14".*/ The use of $ enables specialization of code based on run-time constants.
void cspec mkscale(int **m, int n, int s) { return '{ int i, j; for (i = 0; i < $n; i++) { /* Loop can be dynamically unrolled */ int *v = ($m)[i]; for (j = 0;j < $n; j++) v[j] = v[j] * Ss; /* Multiplication can be strength-reduced */ } }; } 2.3.3 Discussion.
void cspec f(int j); int g(int j); void main() { int vspec v; void cspec c1 = `{ @f(v); };/* error: v is the wrong type */ void cspec c2 - `{ $g(v); }; /* error: v is the wrong type */ } The storage class of a variable declared within the scope of dynamic code is determined dynamically.
void cspec f(int vspec j); /* f must take an int vspec ...
The `C Special Forms (T denotes a type) Category Name Synopsis Management of compile T (*compile(void cspec code, T))() dynamic code free_code void free_code(T) Dynamic variables local T vspec local(T) Dynamic function param T vspec param(T, int param-num) arguments push_init void cspec push_init(void) push void push(void cspec args, T cspec next-arg) Dynamic control label void cspec label() flow jump void cspec jump(void cspec target) self T self(T, other-args ...) 2.4.1 Management of Dynamic Code.
`C allows programmers to construct functions with dynamic numbers of arguments, construct_sum creates a function that takes n arguments and adds them, construct_call creates a cspec that invokes a dynamic function: it initializes an argument stack by invoking push_init, and dynamically adds arguments to this list by calling push.
*/ 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); } Whereas param serves to create the formal parameters of a dynamic function, push_init and push are used together to dynamically build argument lists for function calls, push_init returns a cspec that corresponds to a new (initially empty) dynamic argument list, push adds the code specification for the next argument, next-arg, to the dynamically generated list of arguments args.
Two special forms, label and jump, are used for inter-cspec control flow: jump returns the cspec of a jump to its argument, target.
For each cspec, tcc performs internal type checking.
int j, k; int cspec i = `5; void cspec c = `{ return i+$j*k; }; tcc implements the assignments to these cspecs by assignments to pointers to closures, as illustrated in Figure 5.