Variable instruction AST. @author Matt
| 12 | * @author Matt |
| 13 | */ |
| 14 | public class VarInsnAST extends InsnAST implements VariableReference { |
| 15 | private final NameAST variable; |
| 16 | |
| 17 | /** |
| 18 | * @param line |
| 19 | * Line number this node is written on. |
| 20 | * @param start |
| 21 | * Offset from line start this node starts at. |
| 22 | * @param opcode |
| 23 | * Opcode AST. |
| 24 | * @param variable |
| 25 | * Variable name AST. |
| 26 | */ |
| 27 | public VarInsnAST(int line, int start, OpcodeAST opcode, NameAST variable) { |
| 28 | super(line, start, opcode); |
| 29 | this.variable = variable; |
| 30 | addChild(variable); |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public NameAST getVariableName() { |
| 35 | return variable; |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public int getVariableSort() { |
| 40 | int opcode = getOpcode().getOpcode(); |
| 41 | switch (opcode) { |
| 42 | case Opcodes.ILOAD: |
| 43 | case Opcodes.ISTORE: |
| 44 | return Type.INT; |
| 45 | case Opcodes.LLOAD: |
| 46 | case Opcodes.LSTORE: |
| 47 | return Type.LONG; |
| 48 | case Opcodes.DLOAD: |
| 49 | case Opcodes.DSTORE: |
| 50 | return Type.DOUBLE; |
| 51 | case Opcodes.FLOAD: |
| 52 | case Opcodes.FSTORE: |
| 53 | return Type.FLOAT; |
| 54 | case Opcodes.ALOAD: |
| 55 | case Opcodes.ASTORE: |
| 56 | default: |
| 57 | return Type.OBJECT; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public String print() { |
| 63 | return getOpcode().print() + " " + variable.print(); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public void compile(MethodCompilation compilation) throws AssemblerException { |
| 68 | compilation.addInstruction(new VarInsnNode(getOpcode().getOpcode(), |
| 69 | getVariableIndex(compilation.getVariableNameCache())), this); |
| 70 | } |
| 71 | } |
nothing calls this directly
no outgoing calls
no test coverage detected