comparison src/main/gov/nasa/jpf/vm/LocalVarInfo.java @ 0:61d41facf527

initial v8 import (history reset)
author Peter Mehlitz <Peter.C.Mehlitz@nasa.gov>
date Fri, 23 Jan 2015 10:14:01 -0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:61d41facf527
1 /*
2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
4 * All rights reserved.
5 *
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0.
11 *
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.
17 */
18
19 package gov.nasa.jpf.vm;
20
21 public class LocalVarInfo extends InfoObject {
22 private final String name;
23 private String type; // lazy initialized FQN according to JLS 6.7 (e.g. "int", "x.Y[]")
24 private final String signature; // e.g. "I", "[Lx/Y;"
25 private final String genericSignature; // non-type erased generic signature(s)
26 private final int startPC;
27 private final int endPC;
28 private final int slotIndex;
29
30 public LocalVarInfo(String name, String signature, String genericSignature, int startPC, int endPC, int slotIndex){
31
32 this.name = name;
33 this.signature = signature;
34 this.genericSignature = genericSignature;
35 this.startPC = startPC;
36 this.endPC = endPC;
37 this.slotIndex = slotIndex;
38 }
39
40 @Override
41 public String toString(){
42 StringBuilder sb = new StringBuilder();
43 sb.append("LocalVarInfo[");
44 sb.append("name=\"");
45 sb.append(name);
46 sb.append("\",signature=\"");
47 sb.append(signature);
48 sb.append("\",startPC=");
49 sb.append(startPC);
50 sb.append(",endPC=");
51 sb.append(endPC);
52 sb.append(",slotIndex=");
53 sb.append(slotIndex);
54 sb.append("]");
55
56 return sb.toString();
57 }
58
59 public String getName() {
60 return name;
61 }
62
63 public String getType() {
64 if (type == null){
65 type = Types.getTypeName(signature);
66 }
67 return type;
68 }
69
70 public String getSignature() {
71 return signature;
72 }
73
74 public String getGenericSignature() {
75 return genericSignature;
76 }
77
78 public int getStartPC() {
79 return startPC;
80 }
81
82 public int getLength() {
83 return endPC - startPC +1;
84 }
85
86 public int getSlotIndex() {
87 return slotIndex;
88 }
89
90 public boolean matches (String name, int pc){
91 return (startPC <= pc && endPC >= pc && this.name.equals(name));
92 }
93
94 public boolean matches (int slotIdx, int pc){
95 return (slotIdx == slotIndex) && (pc >= startPC) && (pc <= endPC);
96 }
97
98 public boolean isNumeric(){
99 char c = signature.charAt(0);
100 return (c == 'B' || c == 'S' || c == 'I' || c == 'J' || c == 'F' || c == 'D');
101 }
102
103 public boolean isBoolean(){
104 char c = signature.charAt(0);
105 return (c == 'Z');
106 }
107
108 public int getSlotSize(){
109 char c = signature.charAt(0);
110 if (c == 'J' || c == 'D'){
111 return 2;
112 } else {
113 return 1;
114 }
115 }
116
117 public boolean isFloatingPoint(){
118 char c = signature.charAt(0);
119 return (c == 'F' || c == 'D');
120 }
121 }
122