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.
19 package gov.nasa.jpf.vm;
21 import gov.nasa.jpf.util.HashData;
22 import gov.nasa.jpf.util.IntVector;
24 import java.io.PrintStream;
27 * element values for byte[] objects
29 public class ByteArrayFields extends ArrayFields {
33 public ByteArrayFields (int length) {
34 values = new byte[length];
38 public byte[] asByteArray() {
43 public void copyElements (ArrayFields src, int srcPos, int dstPos, int len){
44 ByteArrayFields a = (ByteArrayFields) src;
45 System.arraycopy(a.values, srcPos, values, dstPos, len);
49 protected void printValue(PrintStream ps, int idx){
50 ps.print(values[idx]);
54 public Object getValues(){
59 public int arrayLength() {
64 public int getHeapSize() {
69 public boolean equals (Object o) {
70 if (o instanceof ByteArrayFields) {
71 ByteArrayFields other = (ByteArrayFields)o;
74 byte[] vOther = other.values;
75 if (v.length != vOther.length) {
79 for (int i=0; i<v.length; i++) {
80 if (v[i] != vOther[i]) {
85 return compareAttrs(other);
93 public ByteArrayFields clone(){
94 ByteArrayFields f = (ByteArrayFields)cloneFields();
95 f.values = values.clone();
100 public void setByteValue (int pos, byte b) {
105 public byte getByteValue (int pos) {
110 public void appendTo (IntVector v) {
111 v.appendPacked(values);
115 public void hash(HashData hd) {
117 for (int i=0; i < v.length; i++) {