forked from utwente-fmt/vercors
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into better-c-support
- Loading branch information
Showing
42 changed files
with
1,613 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
src/col/vct/col/ast/expr/op/bool/VeyMontConditionImpl.scala
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
src/col/vct/col/ast/family/pvlcommunicate/PVLAccessImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package vct.col.ast.family.pvlcommunicate | ||
|
||
import vct.col.ast.{PVLAccess, Type} | ||
|
||
trait PVLAccessImpl[G] { this: PVLAccess[G] => | ||
def fieldType: Type[G] = ref.get.decl.t | ||
} |
7 changes: 0 additions & 7 deletions
7
src/col/vct/col/ast/family/pvlcommunicate/PVLCommunicateAccessImpl.scala
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...mmunicate/PVLCommunicateSubjectImpl.scala → ...amily/pvlcommunicate/PVLSubjectImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package vct.col.ast.family.pvlcommunicate | ||
|
||
import vct.col.ast.{PVLCommunicateSubject, TClass, Class, Type} | ||
import vct.col.ast.{PVLSubject, TClass, Class, Type} | ||
import vct.col.resolve.ctx.RefPVLEndpoint | ||
|
||
trait PVLCommunicateSubjectImpl[G] { this: PVLCommunicateSubject[G] => | ||
trait PVLSubjectImpl[G] { this: PVLSubject[G] => | ||
def cls: Class[G] = ref.get.decl.cls.decl | ||
def ref: Option[RefPVLEndpoint[G]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package vct.col.ast.family.seqguard | ||
|
||
import vct.col.ast.EndpointGuard | ||
|
||
trait EndpointGuardImpl[G] { this: EndpointGuard[G] => | ||
def endpointOpt = Some(endpoint.decl) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package vct.col.ast.family.seqguard | ||
|
||
import vct.col.ast.{Endpoint, Expr, SeqGuard, UnpointedGuard} | ||
|
||
trait SeqGuardImpl[G] { this: SeqGuard[G] => | ||
def condition: Expr[G] | ||
def endpointOpt: Option[Endpoint[G]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package vct.col.ast.family.seqguard | ||
|
||
import vct.col.ast.UnpointedGuard | ||
|
||
trait UnpointedGuardImpl[G] { this: UnpointedGuard[G] => | ||
def endpointOpt = None | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
src/col/vct/col/ast/statement/veymont/CommunicateImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
package vct.col.ast.statement.veymont | ||
|
||
import vct.col.ast.Communicate | ||
import vct.col.ast.{Access, Communicate, EndpointName} | ||
import vct.col.check.{CheckContext, CheckError, SeqProgParticipant} | ||
import vct.col.print.{Ctx, Doc, Text} | ||
import vct.col.ref.Ref | ||
|
||
trait CommunicateImpl[G] { this: Communicate[G] => | ||
override def layout(implicit ctx: Ctx): Doc = | ||
Text("communicate") <+> receiver.show <+> "<-" <+> sender.show <> ";" | ||
|
||
override def check(context: CheckContext[G]): Seq[CheckError] = this match { | ||
case Communicate(Access(name@EndpointName(Ref(receiver)), _), _) if !context.currentParticipatingEndpoints.get.contains(receiver) => | ||
Seq(SeqProgParticipant(name)) | ||
case Communicate(_, Access(name@EndpointName(Ref(sender)), _)) if !context.currentParticipatingEndpoints.get.contains(sender) => | ||
Seq(SeqProgParticipant(name)) | ||
case _ => Nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package vct.col.ast.statement.veymont | ||
|
||
import vct.col.ast.{Access, Communicate, Endpoint, EndpointGuard, EndpointName, SeqAssign, SeqBranch, UnpointedGuard} | ||
import vct.col.ast.statement.StatementImpl | ||
import vct.col.check.{CheckContext, CheckError, SeqProgParticipant} | ||
import vct.col.ref.Ref | ||
|
||
import scala.collection.immutable.ListSet | ||
|
||
trait SeqBranchImpl[G] extends StatementImpl[G] { this: SeqBranch[G] => | ||
def hasUnpointed: Boolean = guards.exists { case _: UnpointedGuard[G] => true; case _ => false } | ||
def explicitParticipants: Seq[Endpoint[G]] = guards.collect { case EndpointGuard(Ref(endpoint), condition) => endpoint } | ||
|
||
override def enterCheckContext(context: CheckContext[G]): CheckContext[G] = { | ||
// Assume SeqProg sets participatingEndpoints | ||
assert(context.currentParticipatingEndpoints.isDefined) | ||
|
||
if (hasUnpointed) { | ||
// Everyone that is participating keeps participating, as well as any endpoints explicitly mentioned | ||
context.appendCurrentParticipatingEndpoints(explicitParticipants) | ||
} else { | ||
// We can refine the set of participants down to the set of endpoints actually present in the guard | ||
context.withCurrentParticipatingEndpoints(explicitParticipants) | ||
} | ||
} | ||
|
||
override def check(context: CheckContext[G]): Seq[CheckError] = super.check(context) ++ { | ||
// Assume SeqProg sets participatingEndpoints | ||
assert(context.currentParticipatingEndpoints.isDefined) | ||
|
||
// Ensure the set of participants is at most refined | ||
if (Set.from(explicitParticipants).subsetOf(context.currentParticipatingEndpoints.get)) { | ||
Seq() | ||
} else { | ||
// There are participants in this if that have been excluded from participation: error | ||
Seq(SeqProgParticipant(this)) | ||
} | ||
} | ||
|
||
// All participants that concretely participate in the branch by being named explicitly through the condition, | ||
// an assignment, or a communicate. | ||
def participants: Set[Endpoint[G]] = | ||
ListSet.from(subnodes.collect { | ||
case Communicate(Access(EndpointName(Ref(receiver)), _), Access(EndpointName(Ref(sender)), _)) => Seq(receiver, sender) | ||
case SeqAssign(Ref(receiver), _, _) => Seq(receiver) | ||
case branch: SeqBranch[G] => branch.explicitParticipants | ||
}.flatten) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package vct.col.ast.statement.veymont | ||
|
||
import vct.col.ast.statement.StatementImpl | ||
import vct.col.ast.{Access, Communicate, Endpoint, EndpointGuard, EndpointName, SeqAssign, SeqBranch, SeqLoop, UnpointedGuard} | ||
import vct.col.check.{CheckContext, CheckError, SeqProgParticipant} | ||
import vct.col.ref.Ref | ||
|
||
import scala.collection.immutable.ListSet | ||
|
||
trait SeqLoopImpl[G] extends StatementImpl[G] { this: SeqLoop[G] => | ||
def hasUnpointed: Boolean = guards.exists { case _: UnpointedGuard[G] => true; case _ => false } | ||
def explicitParticipants: Seq[Endpoint[G]] = guards.collect { case EndpointGuard(Ref(endpoint), condition) => endpoint } | ||
|
||
override def enterCheckContext(context: CheckContext[G]): CheckContext[G] = { | ||
// Assume SeqProg sets participatingEndpoints | ||
assert(context.currentParticipatingEndpoints.isDefined) | ||
|
||
if (hasUnpointed) { | ||
// Everyone that is participating keeps participating, as well as any endpoints explicitly mentioned | ||
context.appendCurrentParticipatingEndpoints(explicitParticipants) | ||
} else { | ||
// We can refine the set of participants down to the set of endpoints actually present in the guard | ||
context.withCurrentParticipatingEndpoints(explicitParticipants) | ||
} | ||
} | ||
|
||
override def check(context: CheckContext[G]): Seq[CheckError] = super.check(context) ++ { | ||
// Assume SeqProg sets participatingEndpoints | ||
assert(context.currentParticipatingEndpoints.isDefined) | ||
|
||
// Ensure the set of participants is at most refined | ||
if (Set.from(explicitParticipants).subsetOf(context.currentParticipatingEndpoints.get)) { | ||
Seq() | ||
} else { | ||
// There are participants in this if that have been excluded from participation: error | ||
Seq(SeqProgParticipant(this)) | ||
} | ||
} | ||
|
||
def participants: Set[Endpoint[G]] = | ||
ListSet.from(subnodes.collect { | ||
case Communicate(Access(EndpointName(Ref(receiver)), _), Access(EndpointName(Ref(sender)), _)) => Seq(receiver, sender) | ||
case SeqAssign(Ref(receiver), _, _) => Seq(receiver) | ||
case branch: SeqBranch[G] => branch.explicitParticipants | ||
}.flatten) | ||
} |
Oops, something went wrong.