Changes between Version 2 and Version 3 of Function_Contracts


Ignore:
Timestamp:
01/11/16 16:56:17 (10 years ago)
Author:
zmanchun
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Function_Contracts

    v2 v3  
    2121            | 'Disjoint' (id (',' id)*)?
    2222            ;
     23}}}
     24
     25Example
     26{{{
     27fun[atomic] sendRecv(Int cmd, Pointer buf): Integer
     28  Reads deref(buf);
     29  Behavior send:
     30    Depends writes(buf);
     31    Assigns nothing;
     32  Behavior receive:
     33    Depends access(deref(buf));
     34    Assigns deref(buf);
     35{
     36  begin choose
     37  when eq(cmd, 0)
     38     do CALL send, <buf, ...>; goto L1;
     39  when eq(cmd, 1)
     40    do CALL recv, <buf, ...>; goto L1;
     41  when and(neq(cmd, 0), neq(cmd, 1))
     42    do NOOP; goto L1;
     43  end choose
     44L1:
     45}
     46
    2347}}}
    2448