1 package com.sun.org.apache.bcel.internal.verifier.statics; 2 3 56 57 import com.sun.org.apache.bcel.internal.Constants; 58 import com.sun.org.apache.bcel.internal.generic.Type; 59 import com.sun.org.apache.bcel.internal.verifier.exc.*; 60 import java.util.Hashtable ; 61 62 71 public class LocalVariableInfo{ 72 73 74 private Hashtable types = new Hashtable (); 75 76 private Hashtable names = new Hashtable (); 77 78 82 private void setName(int offset, String name){ 83 names.put( ((Integer.toString(offset))), name); 84 } 85 89 private void setType(int offset, Type t){ 90 types.put( ((Integer.toString(offset))), t); 91 } 92 93 101 public Type getType(int offset){ 102 return (Type) types.get(Integer.toString(offset)); 103 } 104 112 public String getName(int offset){ 113 return (String ) (names.get(Integer.toString(offset))); 114 } 115 120 public void add(String name, int startpc, int length, Type t) throws LocalVariableInfoInconsistentException{ 121 for (int i=startpc; i<=startpc+length; i++){ add(i,name,t); 123 } 124 } 125 126 131 private void add(int offset, String name, Type t) throws LocalVariableInfoInconsistentException{ 132 if (getName(offset) != null){ 133 if (! getName(offset).equals(name)){ 134 throw new LocalVariableInfoInconsistentException("At bytecode offset '"+offset+"' a local variable has two different names: '"+getName(offset)+"' and '"+name+"'."); 135 } 136 } 137 if (getType(offset) != null){ 138 if (! getType(offset).equals(t)){ 139 throw new LocalVariableInfoInconsistentException("At bytecode offset '"+offset+"' a local variable has two different types: '"+getType(offset)+"' and '"+t+"'."); 140 } 141 } 142 setName(offset, name); 143 setType(offset, t); 144 } 145 } 146 | Popular Tags |