1 package serp.bytecode;
2
3 import java.io.*;
4
5 import serp.bytecode.visitor.*;
6
7
8
9
10
11
12
13 public class MultiANewArrayInstruction extends ClassInstruction {
14 private int _dims = -1;
15
16 MultiANewArrayInstruction(Code owner) {
17 super(owner, Constants.MULTIANEWARRAY);
18 }
19
20 int getLength() {
21 return super.getLength() + 1;
22 }
23
24 public int getStackChange() {
25 return -_dims + 1;
26 }
27
28
29
30
31 public int getDimensions() {
32 return _dims;
33 }
34
35
36
37
38
39
40 public MultiANewArrayInstruction setDimensions(int dims) {
41 _dims = dims;
42 return this;
43 }
44
45
46
47
48
49 public boolean equalsInstruction(Instruction other) {
50 if (other == this)
51 return true;
52 if (!(other instanceof MultiANewArrayInstruction))
53 return false;
54 if (!super.equalsInstruction(other))
55 return false;
56
57 MultiANewArrayInstruction ins = (MultiANewArrayInstruction) other;
58 int dims = getDimensions();
59 int otherDims = ins.getDimensions();
60 return dims == -1 || otherDims == -1 || dims == otherDims;
61 }
62
63 public void acceptVisit(BCVisitor visit) {
64 visit.enterMultiANewArrayInstruction(this);
65 visit.exitMultiANewArrayInstruction(this);
66 }
67
68 void read(Instruction orig) {
69 super.read(orig);
70 _dims = ((MultiANewArrayInstruction) orig).getDimensions();
71 }
72
73 void read(DataInput in) throws IOException {
74 super.read(in);
75 _dims = in.readUnsignedByte();
76 }
77
78 void write(DataOutput out) throws IOException {
79 super.write(out);
80 out.writeByte(_dims);
81 }
82 }