01: /*
02: * JvmUtil.java Copyright (c) 2006,07 Swaroop Belur
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08:
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13:
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17: *
18: */
19:
20: package net.sf.jdec.core;
21:
22: import java.util.ArrayList;
23: import java.util.HashMap;
24:
25: public class JvmUtil {
26:
27: private static HashMap instructionMap = new HashMap();
28: private static int totalOpCodesToMap = JvmOpCodes.totalJvmOpCodes;
29:
30: static {
31: JvmOpCodes.storeAllOpcodes();
32: JvmOpCodes.bytesToSkip();
33: }
34:
35: public JvmUtil() {
36:
37: }
38:
39: public void populateMap() {
40: ArrayList allOpcodes = JvmOpCodes.getAllJvmOpcodes();
41: ArrayList bytesToSkip = JvmOpCodes.getBytesToSkip();
42:
43: /**
44: * Adding a check here. This should never happen actually
45: * Need to be careful to ensure that correct number of opcodes
46: * are stored.
47: */
48:
49: if (totalOpCodesToMap != allOpcodes.size())
50: totalOpCodesToMap = allOpcodes.size();
51:
52: for (int start = 0; start < totalOpCodesToMap; start++) {
53: Integer jvmInst = (Integer) allOpcodes.get(start);
54: Integer skip = (Integer) bytesToSkip.get(start);
55: instructionMap.put(jvmInst, skip);
56: }
57:
58: net.sf.jdec.main.ConsoleLauncher.setInstrMap(instructionMap);
59: }
60:
61: }
|