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 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;
30 public LocalVarInfo(String name, String signature, String genericSignature, int startPC, int endPC, int slotIndex){
33 this.signature = signature;
34 this.genericSignature = genericSignature;
35 this.startPC = startPC;
37 this.slotIndex = slotIndex;
41 public String toString(){
42 StringBuilder sb = new StringBuilder();
43 sb.append("LocalVarInfo[");
46 sb.append("\",signature=\"");
48 sb.append("\",startPC=");
52 sb.append(",slotIndex=");
59 public String getName() {
63 public String getType() {
65 type = Types.getTypeName(signature);
70 public String getSignature() {
74 public String getGenericSignature() {
75 return genericSignature;
78 public int getStartPC() {
82 public int getLength() {
83 return endPC - startPC +1;
86 public int getSlotIndex() {
90 public boolean matches (String name, int pc){
91 return (startPC <= pc && endPC >= pc && this.name.equals(name));
94 public boolean matches (int slotIdx, int pc){
95 return (slotIdx == slotIndex) && (pc >= startPC) && (pc <= endPC);
98 public boolean isNumeric(){
99 char c = signature.charAt(0);
100 return (c == 'B' || c == 'S' || c == 'I' || c == 'J' || c == 'F' || c == 'D');
103 public boolean isBoolean(){
104 char c = signature.charAt(0);
108 public int getSlotSize(){
109 char c = signature.charAt(0);
110 if (c == 'J' || c == 'D'){
117 public boolean isFloatingPoint(){
118 char c = signature.charAt(0);
119 return (c == 'F' || c == 'D');