Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TABLESWITCH.java

00001 package gov.nasa.arc.ase.jpf.jvm.bytecode;
00002 
00003 import de.fub.bytecode.classfile.ConstantPool;
00004 import gov.nasa.arc.ase.jpf.jvm.SystemState;
00005 import gov.nasa.arc.ase.jpf.jvm.KernelState;
00006 import gov.nasa.arc.ase.jpf.jvm.ThreadInfo;
00007 import gov.nasa.arc.ase.util.Debug;
00008 import de.fub.bytecode.generic.InstructionHandle;
00009 
00010 public class TABLESWITCH extends Instruction {
00011   private int target;
00012   private int[] matches;
00013   private int[] targets;
00014 
00015   public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) {
00016     int value = th.pop();
00017     
00018     for(int i = 0, l = matches.length; i < l; i++)
00019       if (value == matches[i])
00020     return th.getMethod().getInstructionAt(targets[i]);
00021 
00022     return th.getMethod().getInstructionAt(target);
00023   }  
00024   public void setPeer(de.fub.bytecode.generic.Instruction i, ConstantPool cp) {
00025     target = ((de.fub.bytecode.generic.TABLESWITCH)i).getTarget().getPosition();
00026     matches = ((de.fub.bytecode.generic.TABLESWITCH)i).getMatchs();
00027     int length = matches.length;
00028     targets = new int[length];
00029     InstructionHandle[] ih = ((de.fub.bytecode.generic.TABLESWITCH)i).getTargets();
00030 
00031     for(int j = 0; j < length; j++)
00032       targets[j] = ih[j].getPosition();
00033   }  
00034 }

Generated at Thu Feb 7 06:56:08 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001