| Home >> All >> com >> techtrader >> modules >> tools >> [ bytecode Javadoc ] |
Source code: com/techtrader/modules/tools/bytecode/IIncInstruction.java
1 package com.techtrader.modules.tools.bytecode; 2 3 4 import java.io.IOException; 5 import java.io.DataInput; 6 import java.io.DataOutput; 7 8 import com.techtrader.modules.tools.bytecode.visitor.BCVisitor; 9 10 11 /** 12 * Represents the IINC instruction. 13 * 14 * @author Abe White 15 */ 16 public class IIncInstruction 17 extends LocalVariableInstruction 18 { 19 private int _inc = 0; 20 21 22 protected IIncInstruction (Code owner) 23 { 24 super (owner); 25 _opcode = IINC; 26 } 27 28 29 /** 30 * Set the increment on this IINC instruction. 31 * 32 * @return this Instruction, for method chaining 33 */ 34 public IIncInstruction setIncrement (int val) 35 { 36 _inc = val; 37 return this; 38 } 39 40 41 /** 42 * Return the increment for this IINC instruction. 43 */ 44 public int getIncrement () 45 { 46 return _inc; 47 } 48 49 50 public boolean equals (Object other) 51 { 52 if (this == other) 53 return true; 54 if (!(other instanceof IIncInstruction)) 55 return false; 56 if (!super.equals (other)) 57 return false; 58 59 IIncInstruction inc = (IIncInstruction) other; 60 61 return (_inc == 0 || inc._inc == 0 || _inc == inc._inc); 62 } 63 64 65 public int getLength () 66 { 67 return super.getLength () + 2; 68 } 69 70 71 protected void copy (Instruction other) 72 { 73 super.copy (other); 74 setIncrement (((IIncInstruction) other).getIncrement ()); 75 } 76 77 78 protected void readData (DataInput in) 79 throws IOException 80 { 81 setIndex (in.readUnsignedByte ()); 82 setIncrement (in.readByte ()); 83 } 84 85 86 protected void writeData (DataOutput out) 87 throws IOException 88 { 89 out.writeByte (getIndex ()); 90 out.writeByte (getIncrement ()); 91 } 92 93 94 public void acceptVisit (BCVisitor visit) 95 { 96 visit.enterIIncInstruction (this); 97 visit.exitIIncInstruction (this); 98 } 99 }