-
Notifications
You must be signed in to change notification settings - Fork 69
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
Brian Huffman
committed
Oct 31, 2020
1 parent
c276700
commit 2a052cc
Showing
5 changed files
with
126 additions
and
0 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,2 @@ | ||
%.class: %.java | ||
javac -g $< |
Binary file not shown.
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,29 @@ | ||
class Test | ||
{ | ||
long val; | ||
|
||
public Test() { | ||
val = 0; | ||
} | ||
public Test(long x) { | ||
val = x; | ||
} | ||
public Test(int x) { | ||
val = x; | ||
} | ||
public long get() { | ||
return val; | ||
} | ||
public void increment() { | ||
val = val + 1; | ||
} | ||
public void increment(long x) { | ||
val = val + x; | ||
} | ||
public void increment(int x) { | ||
val = val + (long)x; | ||
} | ||
public void increment(Test x) { | ||
val = val + x.val; | ||
} | ||
} |
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,94 @@ | ||
enable_experimental; | ||
c <- java_load_class "Test"; | ||
|
||
crucible_jvm_verify c "get" [] false | ||
do { | ||
this <- jvm_alloc_object "Test"; | ||
val <- jvm_fresh_var "val" java_long; | ||
jvm_field_is this "Test.val" (jvm_term val); | ||
jvm_execute_func [this]; | ||
jvm_return (jvm_term val); | ||
} | ||
z3; | ||
|
||
|
||
print "********************************************************************************"; | ||
// FIXME: saw-script can't verify constructor functions | ||
fails ( | ||
crucible_jvm_verify c "Test(L)V" [] false | ||
do { | ||
x <- jvm_fresh_var "x" java_long; | ||
jvm_execute_func [jvm_term x]; | ||
this <- jvm_alloc_object "Test"; | ||
jvm_field_is this "Test.val" (jvm_term x); | ||
jvm_return this; | ||
} | ||
z3); | ||
|
||
print "********************************************************************************"; | ||
print "increment"; | ||
fails ( | ||
crucible_jvm_verify c "increment" [] false | ||
do { | ||
this <- jvm_alloc_object "Test"; | ||
val <- jvm_fresh_var "val" java_long; | ||
jvm_field_is this "Test.val" (jvm_term val); | ||
jvm_execute_func [this]; | ||
jvm_field_is this "Test.val" (jvm_term {{ val + 1 }}); | ||
} | ||
z3); | ||
|
||
print "********************************************************************************"; | ||
print "increment()V"; | ||
crucible_jvm_verify c "increment()V" [] false | ||
do { | ||
this <- jvm_alloc_object "Test"; | ||
val <- jvm_fresh_var "val" java_long; | ||
jvm_field_is this "Test.val" (jvm_term val); | ||
jvm_execute_func [this]; | ||
jvm_field_is this "Test.val" (jvm_term {{ val + 1 }}); | ||
} | ||
z3; | ||
|
||
print "********************************************************************************"; | ||
print "increment(J)V"; | ||
crucible_jvm_verify c "increment(J)V" [] false | ||
do { | ||
this <- jvm_alloc_object "Test"; | ||
val <- jvm_fresh_var "val" java_long; | ||
jvm_field_is this "Test.val" (jvm_term val); | ||
x <- jvm_fresh_var "x" java_long; | ||
jvm_execute_func [this, jvm_term x]; | ||
jvm_field_is this "Test.val" (jvm_term {{ val + x }}); | ||
} | ||
z3; | ||
|
||
print "********************************************************************************"; | ||
print "increment(I)V"; | ||
crucible_jvm_verify c "increment(I)V" [] false | ||
do { | ||
this <- jvm_alloc_object "Test"; | ||
val <- jvm_fresh_var "val" java_long; | ||
jvm_field_is this "Test.val" (jvm_term val); | ||
x <- jvm_fresh_var "x" java_int; | ||
jvm_execute_func [this, jvm_term x]; | ||
jvm_field_is this "Test.val" (jvm_term {{ val + sext x }}); | ||
} | ||
z3; | ||
|
||
print "********************************************************************************"; | ||
print "increment(LTest;)V"; | ||
crucible_jvm_verify c "increment(LTest;)V" [] false | ||
do { | ||
this <- jvm_alloc_object "Test"; | ||
val <- jvm_fresh_var "val" java_long; | ||
jvm_field_is this "Test.val" (jvm_term val); | ||
|
||
x <- jvm_alloc_object "Test"; | ||
x_val <- jvm_fresh_var "x_val" java_long; | ||
jvm_field_is x "Test.val" (jvm_term x_val); | ||
|
||
jvm_execute_func [this, x]; | ||
jvm_field_is this "Test.val" (jvm_term {{ val + x_val }}); | ||
} | ||
z3; |
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 @@ | ||
$SAW test.saw |