2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 package gov.nasa.jpf.vm;
22 import gov.nasa.jpf.util.HashData;
23 import gov.nasa.jpf.util.IntVector;
25 import java.io.PrintStream;
28 * element values for boolean[] objects
30 public class BooleanArrayFields extends ArrayFields {
34 public BooleanArrayFields (int length) {
35 values = new boolean[length];
39 public void copyElements (ArrayFields src, int srcPos, int dstPos, int len){
40 BooleanArrayFields a = (BooleanArrayFields) src;
41 System.arraycopy(a.values, srcPos, values, dstPos, len);
45 protected void printValue(PrintStream ps, int idx){
46 ps.print(values[idx] ? 't' : 'f');
50 public boolean[] asBooleanArray() {
55 public Object getValues(){
60 public int arrayLength() {
65 public int getHeapSize() {
66 return values.length * 4;
70 * we check for type and equal element values
73 public boolean equals (Object o) {
74 if (o instanceof BooleanArrayFields) {
75 BooleanArrayFields other = (BooleanArrayFields)o;
78 boolean[] vOther = other.values;
79 if (v.length != vOther.length) {
83 for (int i=0; i<v.length; i++) {
84 if (v[i] != vOther[i]) {
89 return compareAttrs(other);
97 public BooleanArrayFields clone(){
98 BooleanArrayFields f = (BooleanArrayFields)cloneFields();
99 f.values = values.clone();
105 public void appendTo(IntVector v) {
106 v.appendPacked(values);
110 public boolean getBooleanValue (int pos) {
115 public void setBooleanValue (int pos, boolean v) {
120 public void hash (HashData hd) {
121 boolean[] v = values;
122 for (int i=0; i < v.length; i++) {