File tree Expand file tree Collapse file tree 6 files changed +57
-15
lines changed
liquidjava-example/src/main/java/testSuite/classes
input_reader_correct_default_this
liquidjava-verifier/src/main/java/liquidjava/rj_language Expand file tree Collapse file tree 6 files changed +57
-15
lines changed Original file line number Diff line number Diff line change 11package testSuite .classes .input_reader_correct ;
22
3- @ SuppressWarnings ("unused" )
3+ import java .io .InputStreamReader ;
4+
45public class Test {
56 public static void main (String [] args ) throws Exception {
6- // Arrays are not well supported in LiquidJava
7-
8- // InputStreamReader isr = new InputStreamReader(new FileInputStream("test1.txt"));
9- // @Refinement("_ > -9")
10- // int a = isr.read();
11- // char[] arr = new char[20];
12- // int b = isr.read(arr, 10, 5);
13- // System.out.println(arr);
14- // isr.close();
7+ InputStreamReader is = new InputStreamReader (System .in );
8+ is .read ();
9+ is .read ();
10+ is .close ();
1511 }
1612}
Original file line number Diff line number Diff line change 1+ package testSuite .classes .input_reader_correct_default_this ;
2+
3+ import java .io .InputStream ;
4+ import liquidjava .specification .ExternalRefinementsFor ;
5+ import liquidjava .specification .Ghost ;
6+ import liquidjava .specification .Refinement ;
7+ import liquidjava .specification .RefinementPredicate ;
8+ import liquidjava .specification .StateRefinement ;
9+
10+ // https://docs.oracle.com/javase/7/docs/api/java/io/InputStreamReader.html
11+ @ ExternalRefinementsFor ("java.io.InputStreamReader" )
12+ public interface InputStreamReaderRefs {
13+
14+ @ RefinementPredicate ("boolean open(InputStreamReader i)" )
15+ @ StateRefinement (to = "open()" )
16+ public void InputStreamReader (InputStream in );
17+
18+ @ StateRefinement (from = "open()" , to = "open()" )
19+ @ Refinement ("(_ >= -1) && (_ <= 127)" )
20+ public int read ();
21+
22+ @ StateRefinement (from = "open()" , to = "!open()" )
23+ public void close ();
24+
25+ @ StateRefinement (from = "open()" , to = "open()" )
26+ @ Refinement ("_ >= -1" )
27+ public int read (
28+ @ Refinement ("length(cbuf) > 0" ) char [] cbuf ,
29+ @ Refinement ("_ >= 0" ) int offset ,
30+ @ Refinement ("(_ >= 0) && (_ + offset) <= length(cbuf)" ) int length );
31+ }
Original file line number Diff line number Diff line change 1+ package testSuite .classes .input_reader_correct_default_this ;
2+
3+ import java .io .InputStreamReader ;
4+
5+ public class Test {
6+ public static void main (String [] args ) throws Exception {
7+ InputStreamReader is = new InputStreamReader (System .in );
8+ is .read ();
9+ is .read ();
10+ is .close ();
11+ }
12+ }
Original file line number Diff line number Diff line change 66public class Test {
77
88 public static void main (String [] args ) throws IOException {
9- // java.io.InputStreamReader.InputStreamReader
109 InputStreamReader is = new InputStreamReader (System .in );
1110 is .read ();
1211 is .read ();
Original file line number Diff line number Diff line change @@ -261,9 +261,9 @@ public static Predicate createVar(String name) {
261261 return new Predicate (new Var (name ));
262262 }
263263
264- public static Predicate createInvocation (String name , Predicate ... Predicates ) {
264+ public static Predicate createInvocation (String name , Predicate ... predicates ) {
265265 List <Expression > le = new ArrayList <>();
266- for (Predicate c : Predicates )
266+ for (Predicate c : predicates )
267267 le .add (c .getExpression ());
268268 return new Predicate (new FunctionInvocation (name , le ));
269269 }
Original file line number Diff line number Diff line change @@ -161,9 +161,13 @@ else if (rc instanceof VarContext) {
161161 private Expression functionCallCreate (FunctionCallContext rc ) {
162162 if (rc .ghostCall () != null ) {
163163 GhostCallContext gc = rc .ghostCall ();
164- List <Expression > le = getArgs (gc .args ());
165164 String name = Utils .qualifyName (prefix , gc .ID ().getText ());
166- return new FunctionInvocation (name , le );
165+ List <Expression > args = getArgs (gc .args ());
166+ if (args .isEmpty ()) {
167+ // if no args provided, add "this" as default
168+ args .add (new Var ("this" ));
169+ }
170+ return new FunctionInvocation (name , args );
167171 } else {
168172 AliasCallContext gc = rc .aliasCall ();
169173 List <Expression > le = getArgs (gc .args ());
You can’t perform that action at this time.
0 commit comments