1 23 24 25 package com.sun.jdo.api.persistence.enhancer.classfile; 26 27 28 import java.io.PrintStream ; 29 30 34 35 public class InsnTargetOp extends Insn { 36 37 InsnTarget targetOp; 38 39 40 41 public int nStackArgs() { 42 return VMOp.ops[opcode()].nStackArgs(); 43 } 44 45 public int nStackResults() { 46 return VMOp.ops[opcode()].nStackResults(); 47 } 48 49 public String argTypes() { 50 return VMOp.ops[opcode()].argTypes(); 51 } 52 53 public String resultTypes() { 54 return VMOp.ops[opcode()].resultTypes(); 55 } 56 57 public boolean branches() { 58 return true; 59 } 60 61 64 public void markTargets() { 65 targetOp.setBranchTarget(); 66 } 67 68 71 public InsnTarget target() { 72 return targetOp; 73 } 74 75 76 77 void print (PrintStream out, int indent) { 78 ClassPrint.spaces(out, indent); 79 80 out.println(offset() + " " + opName(opcode()) + " " + targetOp.offset()); 82 } 83 84 int store(byte[] buf, int index) { 85 buf[index++] = (byte) opcode(); 86 int off = targetOp.offset() - offset(); 87 if (opcode() == opc_goto_w || opcode() == opc_jsr_w) 88 return storeInt(buf, index, off); 89 else 90 return storeShort(buf, index, (short)off); 91 } 92 93 int size() { 94 if (opcode() == opc_goto_w || opcode() == opc_jsr_w) 95 return 5; 96 return 3; 97 } 98 99 InsnTargetOp (int theOpcode, InsnTarget theOperand, int pc) { 100 super(theOpcode, pc); 101 targetOp = theOperand; 102 } 103 104 InsnTargetOp (int theOpcode, InsnTarget theOperand) { 105 super(theOpcode, NO_OFFSET); 106 107 targetOp = theOperand; 108 109 switch(theOpcode) { 110 case opc_ifeq: 111 case opc_ifne: 112 case opc_iflt: 113 case opc_ifge: 114 case opc_ifgt: 115 case opc_ifle: 116 case opc_if_icmpeq: 117 case opc_if_icmpne: 118 case opc_if_icmplt: 119 case opc_if_icmpge: 120 case opc_if_icmpgt: 121 case opc_if_icmple: 122 case opc_if_acmpeq: 123 case opc_if_acmpne: 124 case opc_goto: 125 case opc_jsr: 126 case opc_ifnull: 127 case opc_ifnonnull: 128 case opc_goto_w: 129 case opc_jsr_w: 130 131 if (theOperand == null) 132 throw new InsnError ("attempt to create an " + opName(theOpcode) + " with a null Target operand"); break; 135 136 default: 137 throw new InsnError ("attempt to create an " + opName(theOpcode) + " with an InsnTarget operand"); } 140 } 141 } 142 | Popular Tags |