KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gov > nasa > jpf > jvm > AtomicData


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.jvm;
20
21 import gov.nasa.jpf.util.HashData;
22
23
24 /**
25  * helper object to store per thread information about atomic line
26  * execution
27  * <2do> check if we can't do this less expensive. atomic-lines is not
28  * the default anymore
29  */

30 public class AtomicData {
31   /**
32    * The method in which the line step started.
33    */

34   public MethodInfo currentMethod;
35
36   /**
37    * The line at which the line step started.
38    */

39   public int line;
40
41   /**
42    * Set to true if we still are in the same method in which we were
43    * when the line step started.
44    */

45   public boolean inSameMethod;
46
47   public Object JavaDoc clone () {
48     AtomicData a = new AtomicData();
49
50     a.currentMethod = currentMethod;
51     a.line = line;
52     a.inSameMethod = inSameMethod;
53
54     return a;
55   }
56
57   public boolean equals (Object JavaDoc o) {
58     if (o == null) {
59       return false;
60     }
61
62     if (!(o instanceof AtomicData)) {
63       return false;
64     }
65
66     AtomicData a = (AtomicData) o;
67
68     if (currentMethod != a.currentMethod) {
69       return false;
70     }
71
72     if (line != a.line) {
73       return false;
74     }
75
76     if (inSameMethod != a.inSameMethod) {
77       return false;
78     }
79
80     return true;
81   }
82
83   /**
84    * Computes a hash code with the object data.
85    */

86   public void hash (HashData hd) {
87     hd.add(line);
88     hd.add(inSameMethod ? 1 : 0);
89   }
90
91   /**
92    * Returns a hash code for the object.
93    */

94   public int hashCode () {
95     HashData hd = new HashData();
96
97     hash(hd);
98
99     return hd.getValue();
100   }
101 }
102
Popular Tags