KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gov > nasa > jpf > search > Simulation


1 //
2
// Copyright (C) 2005 United States Government as represented by the
3
// Administrator of the National Aeronautics and Space Administration
4
// (NASA). All Rights Reserved.
5
//
6
// This software is distributed under the NASA Open Source Agreement
7
// (NOSA), version 1.3. The NOSA has been approved by the Open Source
8
// Initiative. See the file NOSA-1.3-JPF at the top of the distribution
9
// directory tree for the complete NOSA document.
10
//
11
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18
//
19
package gov.nasa.jpf.search;
20
21
22 import gov.nasa.jpf.*;
23 import gov.nasa.jpf.util.Debug;
24
25
26 /**
27  * this is a straight execution pseudo-search - it doesn't search at
28  * all (i.e. it doesn't backtrack), but just behaves like a 'normal' VM,
29  * going forward() until there is no next state
30  *
31  * <2do> pcm - of course it doesn't quite behave like a normal VM, since it
32  * doesn't honor thread priorities yet (needs a special scheduler)
33  *
34  * <?> pcm - it's not really clear to me how this differs from a 'PathSearch'
35  * other than using a different scheduler. Looks like there should be just one
36  *
37  */

38 public class Simulation extends AbstractSearch {
39   public Simulation (Config config, VM vm) {
40     super(config, vm);
41
42     Debug.println(Debug.WARNING, "Simulation Search");
43   }
44
45   public void search () {
46     int depth = 0;
47
48     depth++;
49
50     if (hasPropertyTermination()) {
51       return;
52     }
53
54     while (!done) {
55       boolean next = vm.forward();
56
57       if (next) {
58         if (hasPropertyTermination()) {
59           return;
60         }
61
62         depth++;
63       } else { // no next state
64

65         // <2do> we could check for more things here. If the last insn wasn't
66
// the main return, or a System.exit() call, we could flag a JPFException
67
isPropertyViolated();
68         done = true;
69       }
70     }
71   }
72 }
73
Popular Tags