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.
Added qualifers (const, unique), const pointers, decrease fix
- Loading branch information
Showing
49 changed files
with
988 additions
and
309 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
adt `const_pointer`<A> { | ||
pure `const_pointer`<A> const_pointer_of(seq<A> b, int offset); | ||
pure seq<A> const_pointer_block(`const_pointer`<A> p); | ||
pure int const_pointer_offset(`const_pointer`<A> p); | ||
|
||
// the block offset is valid wrt the length of the block | ||
axiom (∀ `const_pointer`<A> p; | ||
const_pointer_offset(p) >= 0 && | ||
const_pointer_offset(p) < |const_pointer_block(p)|); | ||
|
||
// const_pointer_of is injective: a (block, offset) pair indicates a unique const_pointer value | ||
axiom (∀seq<A> b, int offset; | ||
{:const_pointer_block(const_pointer_of(b, offset)):} == b && | ||
{:const_pointer_offset(const_pointer_of(b, offset)):} == offset); | ||
} | ||
|
||
decreases; | ||
pure A const_ptr_deref<A>(`const_pointer`<A> p) = | ||
`const_pointer`<A>.const_pointer_block(p)[`const_pointer`<A>.const_pointer_offset(p)]; | ||
|
||
decreases; | ||
requires 0 <= `const_pointer`<A>.const_pointer_offset(p) + offset; | ||
requires `const_pointer`<A>.const_pointer_offset(p) + offset < |`const_pointer`<A>.const_pointer_block(p)|; | ||
pure `const_pointer`<A> const_ptr_add<A>(`const_pointer`<A> p, int offset) = | ||
`const_pointer`<A>.const_pointer_of( | ||
`const_pointer`<A>.const_pointer_block(p), | ||
`const_pointer`<A>.const_pointer_offset(p) + offset); |
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
9 changes: 9 additions & 0 deletions
9
src/col/vct/col/ast/expr/heap/alloc/NewConstPointerArrayImpl.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,9 @@ | ||
package vct.col.ast.expr.heap.alloc | ||
|
||
import vct.col.ast.{NewConstPointerArray, TConstPointer, Type} | ||
import vct.col.ast.ops.NewConstPointerArrayOps | ||
import vct.col.print._ | ||
|
||
trait NewConstPointerArrayImpl[G] extends NewConstPointerArrayOps[G] { this: NewConstPointerArray[G] => | ||
override lazy val t: Type[G] = TConstPointer[G](element) | ||
} |
9 changes: 3 additions & 6 deletions
9
src/col/vct/col/ast/expr/heap/alloc/NewPointerArrayImpl.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,14 +1,11 @@ | ||
package vct.col.ast.expr.heap.alloc | ||
|
||
import vct.col.ast.{NewPointerArray, TPointer, Type} | ||
import vct.col.ast.{NewPointerArray, TPointer, TUniquePointer, Type} | ||
import vct.col.print._ | ||
import vct.col.ast.ops.NewPointerArrayOps | ||
|
||
trait NewPointerArrayImpl[G] extends NewPointerArrayOps[G] { | ||
this: NewPointerArray[G] => | ||
override lazy val t: Type[G] = TPointer(element) | ||
|
||
override def precedence: Int = Precedence.POSTFIX | ||
override def layout(implicit ctx: Ctx): Doc = | ||
Text("new") <+> element <> "[" <> size <> "]" | ||
override lazy val t: Type[G] = unique.map(TUniquePointer[G](element,_)) | ||
.getOrElse(TPointer[G](element)) | ||
} |
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,16 @@ | ||
package vct.col.ast.expr.heap.alloc | ||
|
||
import vct.col.ast.{Expr, NewPointer, Type} | ||
import vct.col.origin.{ArraySizeError, Blame} | ||
import vct.col.print._ | ||
|
||
trait NewPointerImpl[G] { | ||
this: NewPointer[G] => | ||
val blame: Blame[ArraySizeError] | ||
val element: Type[G] | ||
val size: Expr[G] | ||
|
||
override def precedence: Int = Precedence.POSTFIX | ||
override def layout(implicit ctx: Ctx): Doc = | ||
Text("new") <+> element <> "[" <> size <> "]" | ||
} |
9 changes: 9 additions & 0 deletions
9
src/col/vct/col/ast/family/coercion/CoerceBetweenUniqueImpl.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,9 @@ | ||
package vct.col.ast.family.coercion | ||
|
||
import vct.col.ast.{CoerceBetweenUnique, TUnique} | ||
import vct.col.ast.ops.CoerceBetweenUniqueOps | ||
import vct.col.print._ | ||
|
||
trait CoerceBetweenUniqueImpl[G] extends CoerceBetweenUniqueOps[G] { this: CoerceBetweenUnique[G] => | ||
override def target = TUnique(innerCoercion.target, targetId) | ||
} |
3 changes: 1 addition & 2 deletions
3
...nsorted/CoerceDecreasePrecisionImpl.scala → ...oercion/CoerceDecreasePrecisionImpl.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,10 +1,9 @@ | ||
package vct.col.ast.unsorted | ||
package vct.col.ast.family.coercion | ||
|
||
import vct.col.ast.CoerceDecreasePrecision | ||
import vct.col.ast.ops.CoerceDecreasePrecisionOps | ||
import vct.col.print._ | ||
|
||
trait CoerceDecreasePrecisionImpl[G] extends CoerceDecreasePrecisionOps[G] { | ||
this: CoerceDecreasePrecision[G] => | ||
// override def layout(implicit ctx: Ctx): Doc = ??? | ||
} |
9 changes: 9 additions & 0 deletions
9
src/col/vct/col/ast/family/coercion/CoerceFromConstImpl.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,9 @@ | ||
package vct.col.ast.family.coercion | ||
|
||
import vct.col.ast.{CoerceFromConst, TConst, Type} | ||
import vct.col.ast.ops.CoerceFromConstOps | ||
import vct.col.print._ | ||
|
||
trait CoerceFromConstImpl[G] extends CoerceFromConstOps[G] { this: CoerceFromConst[G] => | ||
val source: Type[G] = TConst[G](target) | ||
} |
9 changes: 9 additions & 0 deletions
9
src/col/vct/col/ast/family/coercion/CoerceFromUniqueImpl.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,9 @@ | ||
package vct.col.ast.family.coercion | ||
|
||
import vct.col.ast.CoerceFromUnique | ||
import vct.col.ast.ops.CoerceFromUniqueOps | ||
import vct.col.print._ | ||
|
||
trait CoerceFromUniqueImpl[G] extends CoerceFromUniqueOps[G] { this: CoerceFromUnique[G] => | ||
// override def layout(implicit ctx: Ctx): Doc = ??? | ||
} |
3 changes: 1 addition & 2 deletions
3
...nsorted/CoerceIncreasePrecisionImpl.scala → ...oercion/CoerceIncreasePrecisionImpl.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,10 +1,9 @@ | ||
package vct.col.ast.unsorted | ||
package vct.col.ast.family.coercion | ||
|
||
import vct.col.ast.CoerceIncreasePrecision | ||
import vct.col.ast.ops.CoerceIncreasePrecisionOps | ||
import vct.col.print._ | ||
|
||
trait CoerceIncreasePrecisionImpl[G] extends CoerceIncreasePrecisionOps[G] { | ||
this: CoerceIncreasePrecision[G] => | ||
// override def layout(implicit ctx: Ctx): Doc = ??? | ||
} |
3 changes: 1 addition & 2 deletions
3
src/col/vct/col/ast/family/coercion/CoerceNullPointerImpl.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,8 @@ | ||
package vct.col.ast.family.coercion | ||
|
||
import vct.col.ast.{CoerceNullPointer, TPointer} | ||
import vct.col.ast.{CoerceNullPointer} | ||
import vct.col.ast.ops.CoerceNullPointerOps | ||
|
||
trait CoerceNullPointerImpl[G] extends CoerceNullPointerOps[G] { | ||
this: CoerceNullPointer[G] => | ||
override def target: TPointer[G] = TPointer(pointerElementType) | ||
} |
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,9 @@ | ||
package vct.col.ast.family.coercion | ||
|
||
import vct.col.ast.{CoerceToConst, TConst, Type} | ||
import vct.col.ast.ops.CoerceToConstOps | ||
import vct.col.print._ | ||
|
||
trait CoerceToConstImpl[G] extends CoerceToConstOps[G] { this: CoerceToConst[G] => | ||
val target: Type[G] = TConst[G](source) | ||
} |
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,9 @@ | ||
package vct.col.ast.family.coercion | ||
|
||
import vct.col.ast.{CoerceToUnique, TUnique} | ||
import vct.col.ast.ops.CoerceToUniqueOps | ||
import vct.col.print._ | ||
|
||
trait CoerceToUniqueImpl[G] extends CoerceToUniqueOps[G] { this: CoerceToUnique[G] => | ||
override def target = TUnique(source, targetId) | ||
} |
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
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,9 @@ | ||
package vct.col.ast.lang.c | ||
|
||
import vct.col.ast.{CPointerType, Type} | ||
|
||
trait CPointerTypeImpl[G] { | ||
this: CPointerType[G] => | ||
|
||
val innerType: Type[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 |
---|---|---|
@@ -1,36 +1,8 @@ | ||
package vct.col.ast.statement.terminal | ||
|
||
import vct.col.ast.{Assign, EndpointName, Local} | ||
import vct.col.check.{CheckContext, CheckError, SeqProgEndpointAssign} | ||
import vct.col.print._ | ||
import vct.col.ast.Assign | ||
import vct.col.ast.ops.AssignOps | ||
import vct.col.print._ | ||
|
||
trait AssignImpl[G] | ||
extends NormallyCompletingStatementImpl[G] with AssignOps[G] { | ||
this: Assign[G] => | ||
override def check(context: CheckContext[G]): Seq[CheckError] = | ||
super.check(context) ++ | ||
(target match { | ||
case Local(ref) => | ||
context.checkInWriteScope(context.roScopeReason, this, ref) | ||
case EndpointName(_) if context.currentChoreography.isDefined => | ||
Seq(SeqProgEndpointAssign(this)) | ||
case _ => Nil | ||
}) | ||
|
||
def layoutAsExpr(implicit ctx: Ctx): Doc = | ||
Group( | ||
target.show <+> | ||
(if (ctx.syntax == Ctx.Silver) | ||
":=" | ||
else | ||
"=") <>> value | ||
) | ||
|
||
override def layout(implicit ctx: Ctx): Doc = | ||
layoutAsExpr <> | ||
(if (ctx.syntax == Ctx.Silver) | ||
Empty | ||
else | ||
Text(";")) | ||
trait AssignImpl[G] extends AssignOps[G] { this: Assign[G] => | ||
} |
9 changes: 9 additions & 0 deletions
9
src/col/vct/col/ast/statement/terminal/AssignInitialImpl.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,9 @@ | ||
package vct.col.ast.statement.terminal | ||
|
||
import vct.col.ast.AssignInitial | ||
import vct.col.ast.ops.AssignInitialOps | ||
import vct.col.print._ | ||
|
||
trait AssignInitialImpl[G] extends AssignInitialOps[G] { this: AssignInitial[G] => | ||
|
||
} |
Oops, something went wrong.