@DefineFunc:
@Interface_cluster:
...
- @Happens-before:
+ @Happens_before:
...
+ @Commutativity: // This is to define the admissibility condition
+ // Enq <-> Enq (_M1.q != _M2.q)
+ // Enq <-> Deq (_M1.q != _M2.q)
+ // Deq <-> Deq (_M1.q != _M2.q)
+ // Enq <-> Deq (_M1.q == _M2.q && _M2.__RET__ == NULL)
@End
b) Interface construct
import edu.uci.eecs.specCompiler.specExtraction.GlobalConstruct;
import edu.uci.eecs.specCompiler.specExtraction.InterfaceConstruct;
import edu.uci.eecs.specCompiler.specExtraction.PotentialCPDefineConstruct;
+import edu.uci.eecs.specCompiler.specExtraction.CommutativityRule;
import edu.uci.eecs.specCompiler.specExtraction.CPDefineConstruct;
import edu.uci.eecs.specCompiler.specExtraction.CPDefineCheckConstruct;
import edu.uci.eecs.specCompiler.specExtraction.CPClearConstruct;
<DECLARE_VAR: "@DeclareVar:">
|
<INIT_VAR: "@InitVar:">
+|
+ <CLEANUP: "@Finalize:">
|
<DEFINE_FUNC: "@DefineFunc:">
|
<INTERFACE_CLUSTER: "@Interface_cluster:">
|
<HAPPENS_BEFORE: "@Happens_before:">
+|
+ <COMMUTATIVITY: "@Commutativity:">
|
<INTERFACE: "@Interface:">
|
<CLOSE_BRACE: "}">
|
<HB_SYMBOL: "->">
+|
+ <COMMUTATIVITY_SYMBOL: "<->">
|
<COMMA: ",">
|
{ res = new GlobalConstruct(_file, _content.size(), code, options); }
(Interface_clusters(res))?
(Happens_before(res))?
+ (Commutativity(res))?
<END>
{
res.unfoldInterfaceCluster();
SequentialDefineSubConstruct Global_define() :
{
- ArrayList<String> initVar, defineFunc, code, declareStruct;
+ ArrayList<String> initVar, cleanup, defineFunc, code, declareStruct;
ArrayList<ArrayList<String>> defineFuncs;
ArrayList<VariableDeclaration> declareVars;
ArrayList<ArrayList<String>> declareStructs;
{
{
declareVars = new ArrayList<VariableDeclaration>();
- initVar = null;
+ initVar = new ArrayList<String>();
+ cleanup = new ArrayList<String>();
defineFuncs = new ArrayList<ArrayList<String>>();
declareStructs = new ArrayList<ArrayList<String>>();
}
(<DECLARE_VAR> ((declareVar = TypeParam() <SEMI_COLON> {
declareVars.add(declareVar); } )*))?
(<INIT_VAR> (code = C_CPP_CODE(null) { initVar = code; } ))?
+ (<CLEANUP> (code = C_CPP_CODE(null) { cleanup = code; } ))?
(<DEFINE_FUNC> (defineFunc = C_CPP_CODE(null) { defineFuncs.add(defineFunc); }))*
{
SequentialDefineSubConstruct res = new
- SequentialDefineSubConstruct(declareStructs, declareVars, initVar, defineFuncs);
+ SequentialDefineSubConstruct(declareStructs, declareVars, initVar, cleanup, defineFuncs);
//System.out.println(res);
return res;
}
)+
}
+void Commutativity(GlobalConstruct inst) :
+{
+ String method1, method2, condition;
+ ArrayList<String> content;
+}
+{
+ {
+ content = new ArrayList<String>();
+ }
+
+ (
+ <COMMUTATIVITY>
+ method1 = <IDENTIFIER>.image <COMMUTATIVITY_SYMBOL>
+ method2 = <IDENTIFIER>.image
+ <COLON>
+ content = C_CPP_CODE(null)
+ { condition = stringArray2String(content); }
+ {
+ inst.addCommutativityRule(method1, method2, condition);
+ }
+ )+
+}
+
InterfaceConstruct Interface() :
{
InterfaceConstruct res;