Commit e80a70bd authored by Marius Bozga's avatar Marius Bozga
Browse files

observers: match actions: allow r-value expressions for in/to/from/via

parent 7d74dbb1
......@@ -1125,7 +1125,7 @@ void IfMatchInputAction::PreCompile() {
if(m_pIn) {
ok &= m_pIn->Compile();
ok &= m_pIn->Match(TYPES[IfBasicType::PID]);
ok &= m_pIn->IsReference();
// ok &= m_pIn->IsReference();
}
SetFlag(CORRECT, ok);
......@@ -1135,11 +1135,15 @@ IfExpression* IfMatchInputAction::GetObsGuard() const {
IfEventObsExpression* tmp;
IfInstanceofExpression* res;
if(m_pSignal != NULL) {
tmp = new IfEventObsExpression((m_nIsDiscard?IfEventObsExpression::DISCARD : IfEventObsExpression::INPUT), m_pSignal->GetName(), NULL/*m_pIn*/);
tmp = new IfEventObsExpression((m_nIsDiscard?IfEventObsExpression::DISCARD : IfEventObsExpression::INPUT),
m_pSignal->GetName(),
m_pIn ? (m_pIn->IsReference() ? NULL : m_pIn ) : NULL);
if(!tmp->Compile()) return NULL;
res = new IfInstanceofExpression(tmp, m_pSignal->GetName());
} else {
tmp = new IfEventObsExpression((m_nIsDiscard?IfEventObsExpression::DISCARD : IfEventObsExpression::INPUT), /*m_pSignal->GetName()*/NULL, NULL/*m_pIn*/);
tmp = new IfEventObsExpression((m_nIsDiscard?IfEventObsExpression::DISCARD : IfEventObsExpression::INPUT),
NULL,
m_pIn ? (m_pIn->IsReference() ? NULL : m_pIn ) : NULL);
if(!tmp->Compile()) return NULL;
res = new IfInstanceofExpression(tmp, NULL);
}
......@@ -1169,7 +1173,7 @@ void IfMatchInputAction::Code(FILE* file) const {
}
if(m_pSigvar) m_pSigvar->Code(file);
fprintf(file,",");
if(m_pIn) {
if(m_pIn && m_pIn->IsReference()) {
fprintf(file,"&");
m_pIn->Code(file);
} else fprintf(file,"NULL");
......@@ -1284,15 +1288,15 @@ void IfMatchOutputAction::PreCompile() {
ok &= m_pFrom ? m_pFrom->Compile() : 1;
ok &= m_pFrom ? m_pFrom->Match(TYPES[IfBasicType::PID]) : 1;
ok &= m_pFrom ? m_pFrom->IsReference() : 1;
// ok &= m_pFrom ? m_pFrom->IsReference() : 1;
ok &= m_pVia ? m_pVia->Compile() : 1;
ok &= m_pVia ? m_pVia->Match(TYPES[IfBasicType::PID]) : 1;
ok &= m_pVia ? m_pVia->IsReference() : 1;
// ok &= m_pVia ? m_pVia->IsReference() : 1;
ok &= m_pTo ? m_pTo->Compile() : 1;
ok &= m_pTo ? m_pTo->Match(TYPES[IfBasicType::PID]) : 1;
ok &= m_pTo ? m_pTo->IsReference() : 1;
// ok &= m_pTo ? m_pTo->IsReference() : 1;
SetFlag(CORRECT, ok);
}
......@@ -1301,11 +1305,21 @@ IfExpression* IfMatchOutputAction::GetObsGuard() const {
IfEventObsExpression* tmp;
IfInstanceofExpression* res;
if(m_pSignal != NULL) {
tmp = new IfEventObsExpression(IfEventObsExpression::OUTPUT, m_pSignal->GetName(), m_pOrd, /*m_pFrom*/NULL, /*m_pVia*/NULL, /*m_pTo*/NULL);
tmp = new IfEventObsExpression(IfEventObsExpression::OUTPUT,
m_pSignal->GetName(),
m_pOrd,
m_pFrom ? (m_pFrom->IsReference() ? NULL : m_pFrom ) : NULL,
m_pVia ? (m_pVia->IsReference() ? NULL : m_pVia ) : NULL,
m_pTo ? (m_pTo->IsReference() ? NULL : m_pTo ) : NULL);
if(!tmp->Compile()) return NULL;
res = new IfInstanceofExpression(tmp, m_pSignal->GetName());
} else {
tmp = new IfEventObsExpression(IfEventObsExpression::OUTPUT, /*m_pSignal->GetName()*/NULL, m_pOrd, /*m_pFrom*/NULL, /*m_pVia*/NULL, /*m_pTo*/NULL);
tmp = new IfEventObsExpression(IfEventObsExpression::OUTPUT,
NULL,
m_pOrd,
m_pFrom ? (m_pFrom->IsReference() ? NULL : m_pFrom ) : NULL,
m_pVia ? (m_pVia->IsReference() ? NULL : m_pVia ) : NULL,
m_pTo ? (m_pTo->IsReference() ? NULL : m_pTo ) : NULL);
if(!tmp->Compile()) return NULL;
res = new IfInstanceofExpression(tmp, NULL);
}
......@@ -1337,15 +1351,15 @@ void IfMatchOutputAction::Code(FILE* file) const {
if(m_pSigvar) m_pSigvar->Code(file);
fprintf(file,",");
if(m_pFrom) { fprintf(file,"&"); m_pFrom->Code(file); }
if(m_pFrom && m_pFrom->IsReference()) { fprintf(file,"&"); m_pFrom->Code(file); }
else fprintf(file,"NULL");
fprintf(file,",");
if(m_pVia) { fprintf(file,"&"); m_pVia->Code(file); }
if(m_pVia && m_pVia->IsReference()) { fprintf(file,"&"); m_pVia->Code(file); }
else fprintf(file,"NULL");
fprintf(file,",");
if(m_pTo) { fprintf(file,"&"); m_pTo->Code(file); }
if(m_pTo && m_pTo->IsReference()) { fprintf(file,"&"); m_pTo->Code(file); }
else fprintf(file,"NULL");
fprintf(file,")");
}
......@@ -1416,13 +1430,15 @@ void IfMatchForkAction::PreCompile() {
ok &= m_pIn ? m_pIn->Compile() : 1;
ok &= m_pIn ? m_pIn->Match(TYPES[IfBasicType::PID]) : 1;
ok &= m_pIn ? m_pIn->IsReference() : 1;
// ok &= m_pIn ? m_pIn->IsReference() : 1;
SetFlag(CORRECT, ok);
}
IfExpression* IfMatchForkAction::GetObsGuard() const {
IfEventObsExpression* tmp = new IfEventObsExpression(IfEventObsExpression::FORK, m_pProcess ? m_pProcess->GetName() : m_pName, /*m_pIn*/NULL);
IfEventObsExpression* tmp = new IfEventObsExpression(IfEventObsExpression::FORK,
m_pProcess ? m_pProcess->GetName() : m_pName,
m_pIn ? (m_pIn->IsReference() ? NULL : m_pIn ) : NULL);
if(!tmp->Compile()) return NULL;
return tmp;
}
......@@ -1433,7 +1449,7 @@ void IfMatchForkAction::Code(FILE* file) const {
if(m_pVar) { fprintf(file,"&"); m_pVar->Code(file); }
else fprintf(file,"NULL");
fprintf(file,",");
if(m_pIn) { fprintf(file,"&"); m_pIn->Code(file); }
if(m_pIn && m_pIn->IsReference()) { fprintf(file,"&"); m_pIn->Code(file); }
else fprintf(file,"NULL");
fprintf(file,")");
}
......@@ -1489,13 +1505,16 @@ void IfMatchKillAction::PreCompile() {
ok &= m_pIn ? m_pIn->Compile() : 1;
ok &= m_pIn ? m_pIn->Match(TYPES[IfBasicType::PID]) : 1;
ok &= m_pIn ? m_pIn->IsReference() : 1;
// ok &= m_pIn ? m_pIn->IsReference() : 1;
SetFlag(CORRECT, ok);
}
IfExpression* IfMatchKillAction::GetObsGuard() const {
IfEventObsExpression* tmp = new IfEventObsExpression(IfEventObsExpression::KILL, m_pProcess ? m_pProcess->GetName() : m_pName, /*m_pPid*/NULL, /*m_pIn*/NULL);
IfEventObsExpression* tmp = new IfEventObsExpression(IfEventObsExpression::KILL,
m_pProcess ? m_pProcess->GetName() : m_pName,
/*m_pPid*/NULL,
m_pIn ? (m_pIn->IsReference() ? NULL : m_pIn ) : NULL);
if(!tmp->Compile()) return NULL;
return tmp;
}
......@@ -1506,7 +1525,7 @@ void IfMatchKillAction::Code(FILE* file) const {
if(m_pVar) { fprintf(file,"&"); m_pVar->Code(file); }
else fprintf(file,"NULL");
fprintf(file,",");
if(m_pIn) { fprintf(file, "&"); m_pIn->Code(file); }
if(m_pIn && m_pIn->IsReference()) { fprintf(file, "&"); m_pIn->Code(file); }
else fprintf(file,"NULL");
fprintf(file,")");
}
......@@ -1574,7 +1593,7 @@ void IfMatchDeliverAction::PreCompile() {
}
ok &= m_pFrom ? m_pFrom->Compile() : 1;
ok &= m_pFrom ? m_pFrom->Match(TYPES[IfBasicType::PID]) : 1;
ok &= m_pFrom ? m_pFrom->IsReference() : 1;
// ok &= m_pFrom ? m_pFrom->IsReference() : 1;
SetFlag(CORRECT, ok);
}
......@@ -1583,11 +1602,15 @@ IfExpression* IfMatchDeliverAction::GetObsGuard() const {
IfEventObsExpression* tmp;
IfInstanceofExpression* res;
if(m_pSignal != NULL) {
tmp = new IfEventObsExpression(IfEventObsExpression::DELIVER, m_pSignal->GetName(), /*m_pFrom*/NULL);
tmp = new IfEventObsExpression(IfEventObsExpression::DELIVER,
m_pSignal->GetName(),
m_pFrom ? (m_pFrom->IsReference() ? NULL : m_pFrom ) : NULL);
if(!tmp->Compile()) return NULL;
res = new IfInstanceofExpression(tmp, m_pSignal->GetName());
} else {
tmp = new IfEventObsExpression(IfEventObsExpression::DELIVER, /*m_pSignal->GetName()*/NULL, /*m_pFrom*/NULL);
tmp = new IfEventObsExpression(IfEventObsExpression::DELIVER,
/*m_pSignal->GetName()*/NULL,
m_pFrom ? (m_pFrom->IsReference() ? NULL : m_pFrom ) : NULL);
if(!tmp->Compile()) return NULL;
res = new IfInstanceofExpression(tmp, NULL);
}
......@@ -1614,7 +1637,7 @@ void IfMatchDeliverAction::Code(FILE* file) const {
fprintf(file,"matchdeliver,,(),");
if(m_pSigvar) m_pSigvar->Code(file);
fprintf(file,",");
if(m_pFrom) { fprintf(file,"&"); m_pFrom->Code(file); }
if(m_pFrom && m_pFrom->IsReference()) { fprintf(file,"&"); m_pFrom->Code(file); }
else fprintf(file,"NULL");
fprintf(file,")");
}
......@@ -1669,13 +1692,15 @@ void IfMatchInformalAction::PreCompile() {
ok &= m_pIn ? m_pIn->Compile() : 1;
ok &= m_pIn ? m_pIn->Match(TYPES[IfBasicType::PID]) : 1;
ok &= m_pIn ? m_pIn->IsReference() : 1;
// ok &= m_pIn ? m_pIn->IsReference() : 1;
SetFlag(CORRECT, 1);
}
IfExpression* IfMatchInformalAction::GetObsGuard() const {
IfEventObsExpression* tmp = new IfEventObsExpression(IfEventObsExpression::INFORMAL, m_pName, NULL/*m_pIn*/);
IfEventObsExpression* tmp = new IfEventObsExpression(IfEventObsExpression::INFORMAL,
m_pName,
m_pIn ? (m_pIn->IsReference() ? NULL : m_pIn ) : NULL);
if(!tmp->Compile()) return NULL;
return tmp;
}
......@@ -1683,7 +1708,7 @@ IfExpression* IfMatchInformalAction::GetObsGuard() const {
void IfMatchInformalAction::Code(FILE* file) const {
IfMatchAction::Code(file);
fprintf(file,"matchinformal,%s,",m_pName);
if(m_pIn) { fprintf(file,"&"); m_pIn->Code(file); }
if(m_pIn && m_pIn->IsReference()) { fprintf(file,"&"); m_pIn->Code(file); }
else fprintf(file,"NULL");
fprintf(file,")");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment