Skip to content

Commit

Permalink
Finally do something about prettyprinting. Also add endpoint expressi…
Browse files Browse the repository at this point in the history
…ons around branch unanimity condition
  • Loading branch information
bobismijnnaam committed Dec 20, 2024
1 parent 661c2fc commit 163776b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/col/vct/col/ast/unsorted/CommTargetRangeImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import vct.col.check.{CheckContext, CheckError}
trait CommTargetRangeImpl[G]
extends CommTargetRangeOps[G] with CommunicateTargetImpl[G] {
this: CommTargetRange[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(ref)) <> range

override def check(context: CheckContext[G]): Seq[CheckError] =
super.check(context) ++ {
Expand Down
3 changes: 2 additions & 1 deletion src/col/vct/col/ast/unsorted/EndpointFamilyExprImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import vct.col.print._

trait EndpointFamilyExprImpl[G] extends EndpointFamilyExprOps[G] {
this: EndpointFamilyExpr[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(ref))
override def precedence: Int = Precedence.ATOMIC

override def t: Type[G] = TSeq(ref.decl.t)
}
2 changes: 1 addition & 1 deletion src/col/vct/col/ast/unsorted/PVLCommTargetRangeImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import vct.col.print._

trait PVLCommTargetRangeImpl[G] extends PVLCommTargetRangeOps[G] {
this: PVLCommTargetRange[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
override def layout(implicit ctx: Ctx): Doc = Text(name) <> range

override def t: Type[G] = ref.get.decl.t
}
3 changes: 2 additions & 1 deletion src/col/vct/col/ast/unsorted/RangeBinderImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import vct.col.ast.ops.{RangeBinderFamilyOps, RangeBinderOps}
trait RangeBinderImpl[G]
extends RangeBinderOps[G] with RangeBinderFamilyOps[G] {
this: RangeBinder[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
override def layout(implicit ctx: Ctx): Doc =
Text("[") <> ctx.name(binder) <+> ":=" <+> low <+> ".." <+> high <> "]"
require(binder.t == TInt[G]())
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,16 @@ case class EncodeChorBranchUnanimity[Pre <: Generation](enabled: Boolean)
alpha match {
case r @ (_: CommTargetEndpoint[Pre] | _: CommTargetIndex[Pre]) =>
partialProject(expr, r) |===| b
case CommTargetRange(f, RangeBinder(oldV, low, high)) =>
variables.scope(forall(
TInt(),
v => {
variables.succeedOnly(oldV, v.ref.decl)
case target @ CommTargetRange(f, RangeBinder(oldV, low, high)) =>
variables.scope {
val newTarget = target.rewriteDefault()
val v = newTarget.range.binder.get
EndpointExpr(
newTarget,
((dispatch(low) <= v) && (v < dispatch(high))) ==>
partialProject(expr, CommTargetIndex(f, oldV.get)) |===| b
},
))

partialProject(expr, CommTargetIndex(f, oldV.get)) |===| b,
)
}
}
}

Expand Down

0 comments on commit 163776b

Please sign in to comment.