-// Some nice C/C++ macro definition to make specifications easier to write
-
------------------------------------------------------------------------------
-#define CAT(a, b) CAT_HELPER(a, b) /* Concatenate two symbols for macros! */
-#define CAT_HELPER(a, b) a ## b
-#define X(name) CAT(__##name, __LINE__) /* unique variable */
-
-
-
------------------------------------------------------------------------------
-1. ForEach --> to iterate a set, list or vector (containers that support using
-iterator to iterate)
-
-#define ForEach(item, container) \
- auto X(_container) = (container); \
- auto X(iter) = X(_container)->begin(); \
- for (auto item = *X(iter); X(iter) != X(_container)->end(); item = ((++X(iter)) != \
- X(_container)->end()) ? *X(iter) : 0)
-
------------------------------------------------------------------------------
-
-/**
- This is a common macro that is used as a constant for the name of specific
- variables. We basically have two usage scenario:
- 1. In Subset operation, we allow users to specify a condition to extract a
- subset. In that condition expression, we provide NAME, RET(type), ARG(type,
- field) and LOCAL(field) to access each item's (method call) information.
- 2. In general specification (in pre- & post- conditions and side effects),
- we would automatically generate an assignment that assign the current
- MethodCall* pointer to a variable namedd _M. With this, when we access the
- local state of the current method, we use LOCAL(field) (this is a reference
- for read/write).
-*/
-#define ITEM _M
-#define _M ME
-
-
------------------------------------------------------------------------------
-
-// 1.1 Subset(set, guard) --> to get a subset of method calls by a boolean
-// expression; This takes advantage of C++11 std::function features and C macros.
-
-// 1.2 Size(set) --> to get the size of a method set
-#define Size(set) set->size()
-
-// 1.3 Belong(set, method) --> whether method belongs to set
-#define Belong(set, method) std::find(set->begin(), set->end(), method) != set->end()
-
-// 1.4 Intersect(set1, set2) --> the intersection of two method sets
-inline MethodSet Intersect(MethodSet set1, MethodSet set2) {
- MethodSet res = NewSet;
- ForEach (m, set1) {
- if (Belong(set2, m))
- res->push_back(m);
- }
- return res;
-}
-
-// 1.5 Union(set1, set2) --> the union of two method sets
-inline MethodSet Union(MethodSet set1, MethodSet set2) {
- MethodSet res = NewSet(set1);
- ForEach (m, set2) {
- if (!Belong(set1, m))
- res->push_back(m);
- }
- return res;
-}
-
-// 1.6 Insert(set, method) --> add a method to the set
-inline bool Insert(MethodSet set, Method m) {
- if (Belong(set, m))
- return false;
- else {
- set->push_back(m);
- return true;
- }
-}
-
-// 1.7 Subtract(set1, set2) --> subtract set2 from set1
-inline MethodSet Subtract(MethodSet set1, MethodSet set2) {
- MethodSet res = NewSet;
- ForEach (m, set1) {
- if (!Belong(set2, m))
- res->push_back(m);
- }
- return res;
-}
-
-// 1.8 MakeSet(count, ...) --> Make a set from the arguments
-
-
-// 2. Local(method, field)
-#define Local(method, field) ((StateStruct*) method->localState)->field
-
-// 3. Value(method, type, field)
-#define Value(method, type, field) ((type*) method->value)->field
-3.1 Return
-#define Ret(method, type) Value(method, type, RET)
-3.2 Arguments
-#define Arg(method, type, arg) Value(method, type, arg)
-
-
-// 4. Name(mehtod)
-#defien Lable(method) method->interfaceName
-
-// 5. Prev(method)
-#define Prev(method) mehtod->prev
-
-// 6. Next(method)
-#define Next(method) mehtod->next
-
-// 7. Concurrent(method)
-#define Concurrent(method) mehtod->concurrent
-
-