Home | History | Annotate | Download | only in program
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package dexfuzz.program;
     18 
     19 import java.util.LinkedList;
     20 import java.util.List;
     21 
     22 /**
     23  * A subclass of the MInsnWithData, that also has multiple jump targets.
     24  */
     25 public class MSwitchInsn extends MInsnWithData {
     26   /**
     27    * The MInsns this switch instruction branches to.
     28    */
     29   public List<MInsn> targets = new LinkedList<MInsn>();
     30 
     31   public boolean packed;
     32 
     33   public int[] keys;
     34 
     35   /**
     36    * Clone this MSwitchInsn, and clone the wrapped Instruction.
     37    */
     38   public MSwitchInsn clone() {
     39     MSwitchInsn newInsn = new MSwitchInsn();
     40     newInsn.insn = insn.clone();
     41     newInsn.dataTarget = dataTarget;
     42     newInsn.packed = packed;
     43     for (MInsn target : targets) {
     44       newInsn.targets.add(target);
     45     }
     46     newInsn.keys = new int[keys.length];
     47     System.arraycopy(keys, 0, newInsn.keys, 0, keys.length);
     48     return newInsn;
     49   }
     50 }