home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 March / maximum-cd-1999-03.iso / Feature / Lotus / ORGANIZE / COMPNENT / LTOUIN21.ZIP / sunw / demo / classfile / Code.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-12  |  9.7 KB  |  341 lines

  1. package sunw.demo.classfile;
  2.  
  3. import java.io.DataOutputStream;
  4. import java.io.IOException;
  5. import java.util.Vector;
  6.  
  7. final class Code extends Attribute {
  8.    static final byte OP_NOP = 0;
  9.    static final byte OP_ACONST_NULL = 1;
  10.    static final byte OP_ICONST_m1 = 2;
  11.    static final byte OP_ICONST_0 = 3;
  12.    static final byte OP_ICONST_1 = 4;
  13.    static final byte OP_ICONST_2 = 5;
  14.    static final byte OP_ICONST_3 = 6;
  15.    static final byte OP_ICONST_4 = 7;
  16.    static final byte OP_ICONST_5 = 8;
  17.    static final byte OP_LCONST_0 = 9;
  18.    static final byte OP_LCONST_1 = 10;
  19.    static final byte OP_FCONST_0 = 11;
  20.    static final byte OP_FCONST_1 = 12;
  21.    static final byte OP_FCONST_2 = 13;
  22.    static final byte OP_DCONST_0 = 14;
  23.    static final byte OP_DCONST_1 = 15;
  24.    static final byte OP_BIPUSH = 16;
  25.    static final byte OP_SIPUSH = 17;
  26.    static final byte OP_LDC = 18;
  27.    static final byte OP_LDC_WIDE = 19;
  28.    static final byte OP_LDC2_WIDE = 20;
  29.    static final byte OP_ILOAD = 21;
  30.    static final byte OP_LLOAD = 22;
  31.    static final byte OP_FLOAD = 23;
  32.    static final byte OP_DLOAD = 24;
  33.    static final byte OP_ALOAD = 25;
  34.    static final byte OP_ILOAD_0 = 26;
  35.    static final byte OP_ILOAD_1 = 27;
  36.    static final byte OP_ILOAD_2 = 28;
  37.    static final byte OP_ILOAD_3 = 29;
  38.    static final byte OP_LLOAD_0 = 30;
  39.    static final byte OP_LLOAD_1 = 31;
  40.    static final byte OP_LLOAD_2 = 32;
  41.    static final byte OP_LLOAD_3 = 33;
  42.    static final byte OP_FLOAD_0 = 34;
  43.    static final byte OP_FLOAD_1 = 35;
  44.    static final byte OP_FLOAD_2 = 36;
  45.    static final byte OP_FLOAD_3 = 37;
  46.    static final byte OP_DLOAD_0 = 38;
  47.    static final byte OP_DLOAD_1 = 39;
  48.    static final byte OP_DLOAD_2 = 40;
  49.    static final byte OP_DLOAD_3 = 41;
  50.    static final byte OP_ALOAD_0 = 42;
  51.    static final byte OP_ALOAD_1 = 43;
  52.    static final byte OP_ALOAD_2 = 44;
  53.    static final byte OP_ALOAD_3 = 45;
  54.    static final byte OP_IALOAD = 46;
  55.    static final byte OP_LALOAD = 47;
  56.    static final byte OP_FALOAD = 48;
  57.    static final byte OP_DALOAD = 49;
  58.    static final byte OP_AALOAD = 50;
  59.    static final byte OP_BALOAD = 51;
  60.    static final byte OP_CALOAD = 52;
  61.    static final byte OP_SALOAD = 53;
  62.    static final byte OP_ISTORE = 54;
  63.    static final byte OP_LSTORE = 55;
  64.    static final byte OP_FSTORE = 56;
  65.    static final byte OP_DSTORE = 57;
  66.    static final byte OP_ASTORE = 58;
  67.    static final byte OP_ISTORE_0 = 59;
  68.    static final byte OP_ISTORE_1 = 60;
  69.    static final byte OP_ISTORE_2 = 61;
  70.    static final byte OP_ISTORE_3 = 62;
  71.    static final byte OP_LSTORE_0 = 63;
  72.    static final byte OP_LSTORE_1 = 64;
  73.    static final byte OP_LSTORE_2 = 65;
  74.    static final byte OP_LSTORE_3 = 66;
  75.    static final byte OP_FSTORE_0 = 67;
  76.    static final byte OP_FSTORE_1 = 68;
  77.    static final byte OP_FSTORE_2 = 69;
  78.    static final byte OP_FSTORE_3 = 70;
  79.    static final byte OP_DSTORE_0 = 71;
  80.    static final byte OP_DSTORE_1 = 72;
  81.    static final byte OP_DSTORE_2 = 73;
  82.    static final byte OP_DSTORE_3 = 74;
  83.    static final byte OP_ASTORE_0 = 75;
  84.    static final byte OP_ASTORE_1 = 76;
  85.    static final byte OP_ASTORE_2 = 77;
  86.    static final byte OP_ASTORE_3 = 78;
  87.    static final byte OP_IASTORE = 79;
  88.    static final byte OP_LASTORE = 80;
  89.    static final byte OP_FASTORE = 81;
  90.    static final byte OP_DASTORE = 82;
  91.    static final byte OP_AASTORE = 83;
  92.    static final byte OP_BASTORE = 84;
  93.    static final byte OP_CASTORE = 85;
  94.    static final byte OP_SASTORE = 86;
  95.    static final byte OP_POP = 87;
  96.    static final byte OP_POP2 = 88;
  97.    static final byte OP_DUP = 89;
  98.    static final byte OP_DUP_X1 = 90;
  99.    static final byte OP_DUP_X2 = 91;
  100.    static final byte OP_DUP2 = 92;
  101.    static final byte OP_DUP2_X1 = 93;
  102.    static final byte OP_DUP2_X2 = 94;
  103.    static final byte OP_SWAP = 95;
  104.    static final byte OP_IADD = 96;
  105.    static final byte OP_LADD = 97;
  106.    static final byte OP_FADD = 98;
  107.    static final byte OP_DADD = 99;
  108.    static final byte OP_ISUB = 100;
  109.    static final byte OP_LSUB = 101;
  110.    static final byte OP_FSUB = 102;
  111.    static final byte OP_DSUB = 103;
  112.    static final byte OP_IMUL = 104;
  113.    static final byte OP_LMUL = 105;
  114.    static final byte OP_FMUL = 106;
  115.    static final byte OP_DMUL = 107;
  116.    static final byte OP_IDIV = 108;
  117.    static final byte OP_FDIV = 110;
  118.    static final byte OP_LDIV = 109;
  119.    static final byte OP_DDIV = 111;
  120.    static final byte OP_IREM = 112;
  121.    static final byte OP_LREM = 113;
  122.    static final byte OP_FREM = 114;
  123.    static final byte OP_DREM = 115;
  124.    static final byte OP_INEG = 116;
  125.    static final byte OP_LNEG = 117;
  126.    static final byte OP_FNEG = 118;
  127.    static final byte OP_DNEG = 119;
  128.    static final byte OP_ISHL = 120;
  129.    static final byte OP_LSHL = 121;
  130.    static final byte OP_ISHR = 122;
  131.    static final byte OP_LSHR = 123;
  132.    static final byte OP_IUSHR = 124;
  133.    static final byte OP_LUSHR = 125;
  134.    static final byte OP_IAND = 126;
  135.    static final byte OP_LAND = 127;
  136.    static final byte OP_IOR = -128;
  137.    static final byte OP_LOR = -127;
  138.    static final byte OP_IXOR = -126;
  139.    static final byte OP_LXOR = -125;
  140.    static final byte OP_IINC = -124;
  141.    static final byte OP_I2L = -123;
  142.    static final byte OP_I2F = -122;
  143.    static final byte OP_I2D = -121;
  144.    static final byte OP_L2I = -120;
  145.    static final byte OP_L2F = -119;
  146.    static final byte OP_L2D = -118;
  147.    static final byte OP_F2I = -117;
  148.    static final byte OP_F2L = -116;
  149.    static final byte OP_F2D = -115;
  150.    static final byte OP_D2I = -114;
  151.    static final byte OP_D2L = -113;
  152.    static final byte OP_D2F = -112;
  153.    static final byte OP_I2B = -111;
  154.    static final byte OP_I2C = -110;
  155.    static final byte OP_I2S = -109;
  156.    static final byte OP_LCMP = -108;
  157.    static final byte OP_FCMPL = -107;
  158.    static final byte OP_FCMPG = -106;
  159.    static final byte OP_DCMPL = -105;
  160.    static final byte OP_DCMPG = -104;
  161.    static final byte OP_IFEQ = -103;
  162.    static final byte OP_IFNE = -102;
  163.    static final byte OP_IFLT = -101;
  164.    static final byte OP_IFGE = -100;
  165.    static final byte OP_IFGT = -99;
  166.    static final byte OP_IFLE = -98;
  167.    static final byte OP_IFICMPEQ = -97;
  168.    static final byte OP_IFICMPNE = -96;
  169.    static final byte OP_IFICMPLT = -95;
  170.    static final byte OP_IFICMPGE = -94;
  171.    static final byte OP_IFICMPGT = -93;
  172.    static final byte OP_IFICMPLE = -92;
  173.    static final byte OP_IFACMPEQ = -91;
  174.    static final byte OP_IFACMPNE = -90;
  175.    static final byte OP_GOTO = -89;
  176.    static final byte OP_JSR = -88;
  177.    static final byte OP_RET = -87;
  178.    static final byte OP_TABLESWITCH = -86;
  179.    static final byte OP_LOOKUP_SWITCH = -85;
  180.    static final byte OP_IRETURN = -84;
  181.    static final byte OP_LRETURN = -83;
  182.    static final byte OP_FRETURN = -82;
  183.    static final byte OP_DRETURN = -81;
  184.    static final byte OP_ARETURN = -80;
  185.    static final byte OP_RETURN = -79;
  186.    static final byte OP_GETSTATIC = -78;
  187.    static final byte OP_GETFIELD = -76;
  188.    static final byte OP_INVOKE_VIRTUAL = -74;
  189.    static final byte OP_INVOKE_STATIC = -72;
  190.    static final byte OP_INVOKE_SPECIAL = -73;
  191.    static final byte OP_INVOKE_INTERFACE = -71;
  192.    static final byte OP_NEW = -69;
  193.    static final byte OP_NEWARRAY = -67;
  194.    static final byte ARRAY_T_BOOLEAN = 4;
  195.    static final byte ARRAY_T_CHAR = 5;
  196.    static final byte ARRAY_T_FLOAT = 6;
  197.    static final byte ARRAY_T_DOUBLE = 7;
  198.    static final byte ARRAY_T_BYTE = 8;
  199.    static final byte ARRAY_T_SHORT = 9;
  200.    static final byte ARRAY_T_INT = 10;
  201.    static final byte ARRAY_T_LONG = 11;
  202.    static final byte OP_PUTSTATIC = -77;
  203.    static final byte OP_PUTFIELD = -75;
  204.    static final byte OP_ANEWARRAY = -67;
  205.    static final byte OP_ARRAYLENGTH = -66;
  206.    static final byte OP_ATHROW = -65;
  207.    static final byte OP_CHECKCAST = -64;
  208.    static final byte OP_INSTANCEOF = -63;
  209.    static final byte OP_MONITOR_ENTER = -62;
  210.    static final byte OP_MONITOR_EXIT = -61;
  211.    static final byte OP_WIDE = -60;
  212.    static final byte OP_MULTI_NEW_ARRAY = -59;
  213.    static final byte OP_IFNULL = -58;
  214.    static final byte OP_IFNONNULL = -57;
  215.    static final byte OP_GOTO_WIDE = -56;
  216.    static final byte OP_JSR_WIDE = -55;
  217.    private Vector attributes;
  218.    private int length = 12;
  219.    private short currentPC;
  220.    private short maxLocals;
  221.    private short maxStack;
  222.    private Vector byteCodes = new Vector(1);
  223.    private Vector exceptions;
  224.  
  225.    Code(ClassFile var1, short var2, short var3) {
  226.       super("Code", var1);
  227.       this.maxLocals = var2 >= 0 ? var2 : 0;
  228.       this.maxStack = var3 > 2 ? var3 : 2;
  229.    }
  230.  
  231.    void addAttribute(Attribute var1) {
  232.       if (this.attributes == null) {
  233.          this.attributes = new Vector(1);
  234.       }
  235.  
  236.       this.attributes.addElement(var1);
  237.       this.length += var1.getLength() + 6;
  238.    }
  239.  
  240.    void addExceptionTableEntry(short var1, short var2, short var3, ClassConstant var4) {
  241.       this.exceptions.addElement(new ExceptionTableEntry(var1, var2, var3, var4));
  242.       this.length += 8;
  243.    }
  244.  
  245.    void addOp(byte var1) {
  246.       this.byteCodes.addElement(new Byte(var1));
  247.       ++this.currentPC;
  248.       ++this.length;
  249.    }
  250.  
  251.    void addOp1(byte var1, byte var2) {
  252.       this.byteCodes.addElement(new Byte(var1));
  253.       this.byteCodes.addElement(new Byte(var2));
  254.       this.currentPC = (short)(this.currentPC + 2);
  255.       this.length += 2;
  256.    }
  257.  
  258.    void addOp2(byte var1, byte var2, byte var3) {
  259.       this.byteCodes.addElement(new Byte(var1));
  260.       this.byteCodes.addElement(new Byte(var2));
  261.       this.byteCodes.addElement(new Byte(var3));
  262.       this.currentPC = (short)(this.currentPC + 3);
  263.       this.length += 3;
  264.    }
  265.  
  266.    void addOp4(byte var1, byte var2, byte var3, byte var4, byte var5) {
  267.       this.byteCodes.addElement(new Byte(var1));
  268.       this.byteCodes.addElement(new Byte(var2));
  269.       this.byteCodes.addElement(new Byte(var3));
  270.       this.byteCodes.addElement(new Byte(var4));
  271.       this.byteCodes.addElement(new Byte(var5));
  272.       this.currentPC = (short)(this.currentPC + 5);
  273.       this.length += 5;
  274.    }
  275.  
  276.    void addOpInt(byte var1, int var2) {
  277.       this.addOp4(var1, (byte)(var2 >>> 24 & 255), (byte)(var2 >>> 16 & 255), (byte)(var2 >>> 8 & 255), (byte)(var2 & 255));
  278.    }
  279.  
  280.    void addOpShort(byte var1, short var2) {
  281.       this.addOp2(var1, (byte)(var2 >>> 8 & 255), (byte)(var2 & 255));
  282.    }
  283.  
  284.    public boolean equals(Object var1) {
  285.       return false;
  286.    }
  287.  
  288.    short getCurrentPC() {
  289.       return this.currentPC;
  290.    }
  291.  
  292.    int getLength() {
  293.       return this.length;
  294.    }
  295.  
  296.    public int hashCode() {
  297.       return this.length;
  298.    }
  299.  
  300.    void incrLocals(short var1) {
  301.       this.maxLocals += var1;
  302.    }
  303.  
  304.    void incrMaxStack(short var1) {
  305.       this.maxStack += var1;
  306.    }
  307.  
  308.    void write(DataOutputStream var1) throws IOException {
  309.       var1.writeShort(((Attribute)this).getNameConstantPoolIndex());
  310.       var1.writeInt(this.getLength());
  311.       var1.writeShort(this.maxStack);
  312.       var1.writeShort(this.maxLocals);
  313.       var1.writeInt(this.byteCodes.size());
  314.  
  315.       for(int var2 = 0; var2 < this.byteCodes.size(); ++var2) {
  316.          var1.writeByte((Byte)this.byteCodes.elementAt(var2));
  317.       }
  318.  
  319.       if (this.exceptions != null) {
  320.          var1.writeShort(this.exceptions.size());
  321.  
  322.          for(int var3 = 0; var3 < this.exceptions.size(); ++var3) {
  323.             ((ExceptionTableEntry)this.exceptions.elementAt(var3)).write(var1);
  324.          }
  325.       } else {
  326.          var1.writeShort(0);
  327.       }
  328.  
  329.       if (this.attributes != null) {
  330.          var1.writeShort(this.attributes.size());
  331.  
  332.          for(int var4 = 0; var4 < this.attributes.size(); ++var4) {
  333.             ((Attribute)this.attributes.elementAt(var4)).write(var1);
  334.          }
  335.       } else {
  336.          var1.writeShort(0);
  337.       }
  338.  
  339.    }
  340. }
  341.