1 28 29 package org.jibx.binding.classes; 30 31 import java.util.HashMap ; 32 33 import org.apache.bcel.Constants; 34 import org.apache.bcel.generic.*; 35 import org.jibx.runtime.JiBXException; 36 37 44 45 public class ExceptionMethodBuilder extends MethodBuilder 46 { 47 48 private HashMap m_slotMap; 49 50 60 61 public ExceptionMethodBuilder(String name, Type ret, Type[] args, 62 ClassFile cf, int access) throws JiBXException { 63 super(name, ret, args, cf, access); 64 } 65 66 75 76 public ExceptionMethodBuilder(String name, String sig, 77 ClassFile cf, int access) throws JiBXException { 78 super(name, Type.getReturnType(sig), Type.getArgumentTypes(sig), 79 cf, access); 80 } 81 82 90 91 public ExceptionMethodBuilder(String name, String sig, ClassFile cf) 92 throws JiBXException { 93 super(name, Type.getReturnType(sig), Type.getArgumentTypes(sig), 94 cf, Constants.ACC_PUBLIC | Constants.ACC_FINAL); 95 } 96 97 103 104 public void defineSlot(Object obj, Type type) { 105 if (m_slotMap == null) { 106 m_slotMap = new HashMap (); 107 } 108 LocalVariableGen var = createLocal("var" + m_slotMap.size(), type); 109 m_slotMap.put(obj, var); 110 } 111 112 119 120 public int getSlot(Object obj) { 121 if (m_slotMap != null) { 122 LocalVariableGen var = (LocalVariableGen)m_slotMap.get(obj); 123 if (var != null) { 124 return var.getIndex(); 125 } 126 } 127 return -1; 128 } 129 130 137 138 public void freeSlot(Object obj) { 139 if (m_slotMap != null) { 140 LocalVariableGen var = (LocalVariableGen)m_slotMap.get(obj); 141 if (var != null) { 142 var.setEnd(getLastInstruction()); 143 m_slotMap.remove(obj); 144 } 145 } 146 } 147 148 155 156 protected void handleExceptions() throws JiBXException { 157 for (int i = 0; i < m_exceptions.size(); i++) { 158 m_generator.addException((String )m_exceptions.get(i)); 159 } 160 } 161 } 162 | Popular Tags |