@Interface: Load
@PreCondition:
- Subset(PREV, subset, LOCAL(x) == RET);
- return Size(subset) > 0;
+ Size(Subset(PREV, LOCAL(x) == RET)) > 0;
@SideEffect: LOCAL(x) = RET;
int load(int *loc);
*********************************************
-
-TODO:We want subset operation by the equality and inequality of the interface
-name, a specific (or combined) state and a specific (or combined) of the value
-(RET & arguments)
-
-// 1.1 Subset(set, name) --> to get a subset of method calls by name
-inline vector<MethodCall*>* Subset(vector<MethodCall*> *set, string name) {
- vector<MethodCall*> _subset = new vector<MethodCall*>;
- for (int i = 0; i < set->size(); i++) {
- MethodCall *_m = (*set)[i];
- if (_m->interfaceName == name)
- _subset->push_back(_m);
- }
- return _subset;
-}
+// 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()
// 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
// Auto generated code
// MethodCall *ME = ((SomeTypeConversion) info)->method;
- Subset(Prev, readSet1, LOCAL(x) == RET);
- if (Size(readSet1) > 0) return true;
- Subset(Concurrent, readSet2, NAME == "Store" && VALUE(Store, val) == RET);
- return Size(readSet2) > 0;
+ int count = Size(Subset(Prev, LOCAL(x) == RET))
+ + Size(Subset(CONCURRENT, NAME == "Store" && ARG(Store, val) == RET))
+ return count > 0;
@SideEffect: LOCAL(x) = RET;
int load(int *loc);
// Otherwise check there must be other concurrent dequeuers
ForEach (item, Local(q)) {
// Check there's some concurrent dequeuer for this item
- Subset(CONCURRENT, concurSet, NAME == "Deq" && VALUE(Deq, RET) &&
- *VALUE(Deq, res) == item);
- if (Size(concurSet) == 0) return false;
+ if (Size(Subset(CONCURRENT, NAME == "Deq" && RET(Deq) &&
+ *ARG(Deq, res) == item)) == 0) return false;
}
return true;
} else { // Check the global queue state