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 small-fix
- Loading branch information
Showing
135 changed files
with
2,268 additions
and
621 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Box<T> { | ||
T t; | ||
context Perm(t, 1\2); | ||
ensures \result == t; | ||
T get() { | ||
return t; | ||
} | ||
} | ||
|
||
void m() { | ||
Box<int> b = new Box<int>(); | ||
int t = b.get(); | ||
int t = b.t; | ||
} |
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,65 @@ | ||
lock_invariant Perm(transfering, 1) ** Perm(exchangeValue,1); | ||
class Chan<T> { | ||
boolean transfering; | ||
T exchangeValue; | ||
|
||
ensures committed(this); | ||
constructor() { | ||
transfering = false; | ||
commit this; | ||
} | ||
|
||
context committed(this); | ||
void writeValue(T v) { | ||
lock this; | ||
|
||
loop_invariant Perm(transfering, 1) ** Perm(exchangeValue,1); | ||
loop_invariant held(this); | ||
while (!transfering) { | ||
unlock this; | ||
lock this; | ||
} | ||
|
||
transfering = false; | ||
exchangeValue = v; | ||
unlock this; | ||
} | ||
|
||
context committed(this); | ||
T readValue() { | ||
lock this; | ||
|
||
loop_invariant Perm(transfering, 1) ** Perm(exchangeValue,1); | ||
loop_invariant held(this); | ||
while (transfering) { | ||
unlock this; | ||
lock this; | ||
} | ||
|
||
T m = exchangeValue; | ||
transfering = false; | ||
unlock this; | ||
|
||
return m; | ||
} | ||
|
||
context committed(this); | ||
T noop(T t) { | ||
writeValue(t); | ||
return readValue(); | ||
} | ||
} | ||
|
||
void main() { | ||
Chan<int> intChan = new Chan<int>(); | ||
Chan<boolean> boolChan = new Chan<boolean>(); | ||
Chan<Chan<int>> intChanChan = new Chan<Chan<int>>(); | ||
|
||
intChan.writeValue(5); | ||
boolChan.writeValue(true); | ||
intChanChan.writeValue(intChan); | ||
|
||
int i = intChan.readValue(); | ||
boolean b = boolChan.readValue(); | ||
Chan<int> c = intChanChan.readValue(); | ||
} |
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,4 @@ | ||
ensures \result == t; | ||
T myProcedure<T>(T t) { | ||
return t; | ||
} |
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,13 @@ | ||
import java.lang.annotation.Retention; | ||
|
||
class C { | ||
Retention r; | ||
} | ||
|
||
class D<T> { } | ||
|
||
class E { | ||
void m() { | ||
D<?> d = null; | ||
} | ||
} |
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,23 @@ | ||
class Role<T> { | ||
T t; | ||
int i; | ||
|
||
T fromInt(int i); | ||
int toInt(T t); | ||
} | ||
|
||
class A { } | ||
|
||
class B { } | ||
|
||
seq_program genericTest() { | ||
endpoint a = Role<A>(); | ||
endpoint b = Role<B>(); | ||
|
||
requires a != b; | ||
seq_run { | ||
a.i := a.toInt(a.t); | ||
communicate a.i -> b.i; | ||
b.t := b.fromInt(b.i); | ||
} | ||
} |
Oops, something went wrong.