001: package net.sf.jdec.jvminstructions.factory;
002:
003: import java.util.Map;
004:
005: import net.sf.jdec.core.JvmOpCodes;
006: import net.sf.jdec.jvminstructions.commandholders.D2L;
007: import net.sf.jdec.jvminstructions.commandholders.F2L;
008: import net.sf.jdec.jvminstructions.commandholders.IInstructionCommandHolder;
009: import net.sf.jdec.jvminstructions.commandholders.LADD;
010: import net.sf.jdec.jvminstructions.commandholders.Laload;
011: import net.sf.jdec.jvminstructions.commandholders.Land;
012: import net.sf.jdec.jvminstructions.commandholders.Lcmp;
013: import net.sf.jdec.jvminstructions.commandholders.Lconst_0;
014: import net.sf.jdec.jvminstructions.commandholders.Lconst_1;
015: import net.sf.jdec.jvminstructions.commandholders.Ldc;
016: import net.sf.jdec.jvminstructions.commandholders.Ldc2_w;
017: import net.sf.jdec.jvminstructions.commandholders.Ldc_w;
018: import net.sf.jdec.jvminstructions.commandholders.Ldiv;
019: import net.sf.jdec.jvminstructions.commandholders.Lload;
020: import net.sf.jdec.jvminstructions.commandholders.Lload_0;
021: import net.sf.jdec.jvminstructions.commandholders.Lload_1;
022: import net.sf.jdec.jvminstructions.commandholders.Lload_2;
023: import net.sf.jdec.jvminstructions.commandholders.Lload_3;
024: import net.sf.jdec.jvminstructions.commandholders.Lmul;
025: import net.sf.jdec.jvminstructions.commandholders.Lneg;
026: import net.sf.jdec.jvminstructions.commandholders.Lor;
027: import net.sf.jdec.jvminstructions.commandholders.Lrem;
028: import net.sf.jdec.jvminstructions.commandholders.Lshl;
029: import net.sf.jdec.jvminstructions.commandholders.Lshr;
030: import net.sf.jdec.jvminstructions.commandholders.Lsub;
031: import net.sf.jdec.jvminstructions.commandholders.Lushr;
032: import net.sf.jdec.jvminstructions.commandholders.Lxor;
033: import net.sf.jdec.jvminstructions.util.InstrConstants;
034:
035: /*
036: * LongLoadInstructionFactory.java Copyright (c) 2006,07 Swaroop Belur
037: *
038: * This program is free software; you can redistribute it and/or
039: * modify it under the terms of the GNU General Public License
040: * as published by the Free Software Foundation; either version 2
041: * of the License, or (at your option) any later version.
042:
043: * This program is distributed in the hope that it will be useful,
044: * but WITHOUT ANY WARRANTY; without even the implied warranty of
045: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
046: * GNU General Public License for more details.
047:
048: * You should have received a copy of the GNU General Public License
049: * along with this program; if not, write to the Free Software
050: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
051: *
052: */
053: public class LongLoadInstructionFactory implements IInstructionFactory {
054:
055: public IInstructionCommandHolder newInstance(Map parameters) {
056:
057: Integer temp = (Integer) parameters
058: .get(InstrConstants.OPCODE_TYPE);
059: if (temp == null) {
060: throw new IllegalArgumentException(
061: "Opcode type cannot be null");
062: }
063:
064: int opcodevalue = temp.intValue();
065: switch (opcodevalue) {
066:
067: case JvmOpCodes.D2L:
068: return new D2L();
069:
070: case JvmOpCodes.F2L:
071: return new F2L();
072:
073: case JvmOpCodes.LADD:
074: return new LADD();
075:
076: case JvmOpCodes.LALOAD:
077: return new Laload();
078:
079: case JvmOpCodes.LAND:
080: return new Land();
081:
082: case JvmOpCodes.LCMP:
083: return new Lcmp();
084:
085: case JvmOpCodes.LCONST_0:
086: return new Lconst_0();
087:
088: case JvmOpCodes.LCONST_1:
089: return new Lconst_1();
090:
091: case JvmOpCodes.LDC:
092: return new Ldc();
093:
094: case JvmOpCodes.LDC_W:
095: return new Ldc_w();
096:
097: case JvmOpCodes.LDC2_W:
098: return new Ldc2_w();
099:
100: case JvmOpCodes.LLOAD:
101: return new Lload();
102:
103: case JvmOpCodes.LDIV:
104: return new Ldiv();
105:
106: case JvmOpCodes.LLOAD_0:
107: return new Lload_0();
108:
109: case JvmOpCodes.LLOAD_1:
110: return new Lload_1();
111:
112: case JvmOpCodes.LLOAD_2:
113: return new Lload_2();
114:
115: case JvmOpCodes.LLOAD_3:
116: return new Lload_3();
117:
118: case JvmOpCodes.LMUL:
119: return new Lmul();
120:
121: case JvmOpCodes.LNEG:
122: return new Lneg();
123:
124: case JvmOpCodes.LREM:
125: return new Lrem();
126:
127: case JvmOpCodes.LOR:
128: return new Lor();
129:
130: case JvmOpCodes.LSHL:
131: return new Lshl();
132:
133: case JvmOpCodes.LSHR:
134: return new Lshr();
135:
136: case JvmOpCodes.LUSHR:
137: return new Lushr();
138:
139: case JvmOpCodes.LSUB:
140: return new Lsub();
141:
142: case JvmOpCodes.LXOR:
143: return new Lxor();
144:
145: default:
146: throw new IllegalArgumentException(
147: "Input argument opcodetype did not match any valid jvminstruction values");
148:
149: }
150: }
151: }
|