MutableMethodImplementation.java revision 897832aa150cdf53ed7fa2f17dee132d2408e2f3
1package org.jf.dexlib2.builder; 2 3import com.google.common.collect.Lists; 4import org.jf.dexlib2.iface.MethodImplementation; 5import org.jf.dexlib2.iface.reference.Reference; 6import org.jf.dexlib2.iface.reference.TypeReference; 7 8import javax.annotation.Nonnull; 9import javax.annotation.Nullable; 10import java.util.ArrayList; 11import java.util.Collections; 12import java.util.List; 13 14public class MutableMethodImplementation<ReferenceType extends Reference> { 15 final ArrayList<MethodLocation> instructionList = Lists.newArrayList(new MethodLocation(null, 0, 0)); 16 private final ArrayList<BuilderTryBlock> tryBlocks = Lists.newArrayList(); 17 18 public MutableMethodImplementation() { 19 } 20 21 public MethodImplementation buildMethodImplementation() { 22 return null; 23 } 24 25 public List<MethodLocation> getInstruction() { 26 return Collections.unmodifiableList(instructionList); 27 } 28 29 public void addCatch(@Nullable TypeReference type, @Nonnull LabelMethodItem from, 30 @Nonnull LabelMethodItem to, @Nonnull LabelMethodItem handler) { 31 tryBlocks.add(new BuilderTryBlock(from, to, type, handler)); 32 } 33 34 public void addCatch(@Nullable String type, @Nonnull LabelMethodItem from, @Nonnull LabelMethodItem to, 35 @Nonnull LabelMethodItem handler) { 36 tryBlocks.add(new BuilderTryBlock(from, to, type, handler)); 37 } 38 39 public void addCatch(@Nonnull LabelMethodItem from, @Nonnull LabelMethodItem to, @Nonnull LabelMethodItem handler) { 40 tryBlocks.add(new BuilderTryBlock(from, to, handler)); 41 } 42} 43