1 17 package org.apache.bcel.verifier.statics; 18 19 20 import org.apache.bcel.generic.Type; 21 import org.apache.bcel.verifier.exc.AssertionViolatedException; 22 import org.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException; 23 24 32 public class LocalVariablesInfo{ 33 34 35 private LocalVariableInfo[] localVariableInfos; 36 37 38 LocalVariablesInfo(int max_locals){ 39 localVariableInfos = new LocalVariableInfo[max_locals]; 40 for (int i=0; i<max_locals; i++){ 41 localVariableInfos[i] = new LocalVariableInfo(); 42 } 43 } 44 45 46 public LocalVariableInfo getLocalVariableInfo(int slot){ 47 if (slot < 0 || slot >= localVariableInfos.length){ 48 throw new AssertionViolatedException("Slot number for local variable information out of range."); 49 } 50 return localVariableInfos[slot]; 51 } 52 53 59 public void add(int slot, String name, int startpc, int length, Type t) throws LocalVariableInfoInconsistentException{ 60 62 if (slot < 0 || slot >= localVariableInfos.length){ 63 throw new AssertionViolatedException("Slot number for local variable information out of range."); 64 } 65 66 localVariableInfos[slot].add(name, startpc, length, t); 67 if (t == Type.LONG) { 68 localVariableInfos[slot+1].add(name, startpc, length, LONG_Upper.theInstance()); 69 } 70 if (t == Type.DOUBLE) { 71 localVariableInfos[slot+1].add(name, startpc, length, DOUBLE_Upper.theInstance()); 72 } 73 } 74 } 75 | Popular Tags |