-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
535 additions
and
42 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,34 @@ | ||
class Lock { | ||
final resource inv; | ||
|
||
given resource inv; | ||
requires inv; | ||
ensures this.inv == inv; | ||
constructor() { | ||
this.inv = inv; | ||
exhale inv; // commit the invariant | ||
} | ||
|
||
ensures inv; | ||
void getLock(); | ||
|
||
requires inv; | ||
void releaseLock(); | ||
} | ||
|
||
class Use { | ||
int a; | ||
int b; | ||
|
||
requires Perm(a, write); | ||
requires Perm(b, write); | ||
void test() { | ||
a = 4; | ||
b = 6; | ||
Lock l = new Lock() given { inv = Perm(a, write) ** Perm(b, write) ** a + b == 10 }; | ||
|
||
l.getLock(); | ||
b = 3; | ||
l.releaseLock(); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/col/vct/col/ast/expr/resource/ResourceOfResourceValueImpl.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.expr.resource | ||
|
||
import vct.col.ast.{ResourceOfResourceValue, TResource} | ||
|
||
trait ResourceOfResourceValueImpl[G] { this: ResourceOfResourceValue[G] => | ||
override def t: TResource[G] = TResource() | ||
} |
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.expr.resource | ||
|
||
import vct.col.ast.{ResourceValue, TResourceVal} | ||
|
||
trait ResourceValueImpl[G] { this: ResourceValue[G] => | ||
override def t: TResourceVal[G] = TResourceVal() | ||
} |
7 changes: 7 additions & 0 deletions
7
src/col/vct/col/ast/family/coercion/CoerceResourceResourceValImpl.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.coercion | ||
|
||
import vct.col.ast.{CoerceResourceResourceVal, TResourceVal} | ||
|
||
trait CoerceResourceResourceValImpl[G] { this: CoerceResourceResourceVal[G] => | ||
override def target: TResourceVal[G] = TResourceVal() | ||
} |
7 changes: 7 additions & 0 deletions
7
src/col/vct/col/ast/family/coercion/CoerceResourceValResourceImpl.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.coercion | ||
|
||
import vct.col.ast.{CoerceResourceValResource, TResource} | ||
|
||
trait CoerceResourceValResourceImpl[G] { this: CoerceResourceValResource[G] => | ||
override def target: TResource[G] = TResource() | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/col/vct/col/ast/family/coercion/SomethingAnyValueImpl.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.coercion | ||
|
||
import vct.col.ast.{CoerceSomethingAnyValue, TAnyValue, Type} | ||
|
||
trait SomethingAnyValueImpl[G] { this: CoerceSomethingAnyValue[G] => | ||
override def target: Type[G] = TAnyValue() | ||
} |
4 changes: 2 additions & 2 deletions
4
src/col/vct/col/ast/lang/SilverPartialADTFunctionInvocationImpl.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
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,8 +1,7 @@ | ||
package vct.col.ast.`type` | ||
|
||
import vct.col.ast.TAny | ||
import vct.col.print.{Ctx, Doc, Text} | ||
|
||
trait TAnyImpl[G] { this: TAny[G] => | ||
override def layout(implicit ctx: Ctx): Doc = Text("any") | ||
|
||
} |
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.`type` | ||
|
||
import vct.col.ast.TAnyValue | ||
import vct.col.print.{Ctx, Doc, Text} | ||
|
||
trait TAnyValueImpl[G] { this: TAnyValue[G] => | ||
override def layout(implicit ctx: Ctx): Doc = Text("any") | ||
} |
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.`type` | ||
|
||
import vct.col.ast.TResourceVal | ||
|
||
trait TResourceValImpl[G] { this: TResourceVal[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,14 +1,14 @@ | ||
package vct.col.ast.`type` | ||
|
||
import vct.col.ast.{TAny, TType, TVar} | ||
import vct.col.ast.{TAnyValue, TType, TVar} | ||
import vct.col.check.{CheckContext, CheckError, GenericTypeError} | ||
import vct.col.print.{Ctx, Doc, Text} | ||
|
||
trait TVarImpl[G] { this: TVar[G] => | ||
override def check(context: CheckContext[G]): Seq[CheckError] = | ||
context.checkInScope(this, ref) ++ | ||
(if(TType(TAny()).superTypeOf(ref.decl.t)) Nil | ||
else Seq(GenericTypeError(this, TType(TAny())))) | ||
(if(TType(TAnyValue()).superTypeOf(ref.decl.t)) Nil | ||
else Seq(GenericTypeError(this, TType(TAnyValue())))) | ||
|
||
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(ref)) | ||
} |
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
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,22 @@ | ||
package vct.col.util | ||
|
||
import vct.col.ast.Declaration | ||
import vct.col.ref.{LazyRef, Ref} | ||
|
||
import scala.reflect.ClassTag | ||
|
||
case class DeclarationBox[G, Decl <: Declaration[G]]()(implicit tag: ClassTag[Decl]) { | ||
private var decl: Option[Decl] = None | ||
|
||
def ref: Ref[G, Decl] = new LazyRef(decl.get) | ||
|
||
def isFilled: Boolean = decl.isDefined | ||
def isEmpty: Boolean = decl.isEmpty | ||
|
||
def get: Decl = decl.get | ||
|
||
def fill[T <: Decl](decl: T): T = { | ||
this.decl = Some(decl) | ||
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
Oops, something went wrong.