home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / reflect / ClassFileAssembler.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  6.4 KB  |  620 lines

  1. package sun.reflect;
  2.  
  3. class ClassFileAssembler implements ClassFileConstants {
  4.    private ByteVector vec;
  5.    private short cpIdx;
  6.    private int stack;
  7.    private int maxStack;
  8.    private int maxLocals;
  9.  
  10.    public ClassFileAssembler() {
  11.       this(ByteVectorFactory.create());
  12.    }
  13.  
  14.    public ClassFileAssembler(ByteVector var1) {
  15.       this.cpIdx = 0;
  16.       this.stack = 0;
  17.       this.maxStack = 0;
  18.       this.maxLocals = 0;
  19.       this.vec = var1;
  20.    }
  21.  
  22.    public ByteVector getData() {
  23.       return this.vec;
  24.    }
  25.  
  26.    public short getLength() {
  27.       return (short)this.vec.getLength();
  28.    }
  29.  
  30.    public void emitMagicAndVersion() {
  31.       this.emitInt(-889275714);
  32.       this.emitShort((short)0);
  33.       this.emitShort((short)49);
  34.    }
  35.  
  36.    public void emitInt(int var1) {
  37.       this.emitByte((byte)(var1 >> 24));
  38.       this.emitByte((byte)(var1 >> 16 & 255));
  39.       this.emitByte((byte)(var1 >> 8 & 255));
  40.       this.emitByte((byte)(var1 & 255));
  41.    }
  42.  
  43.    public void emitShort(short var1) {
  44.       this.emitByte((byte)(var1 >> 8 & 255));
  45.       this.emitByte((byte)(var1 & 255));
  46.    }
  47.  
  48.    void emitShort(short var1, short var2) {
  49.       this.vec.put(var1, (byte)(var2 >> 8 & 255));
  50.       this.vec.put(var1 + 1, (byte)(var2 & 255));
  51.    }
  52.  
  53.    public void emitByte(byte var1) {
  54.       this.vec.add(var1);
  55.    }
  56.  
  57.    public void append(ClassFileAssembler var1) {
  58.       this.append(var1.vec);
  59.    }
  60.  
  61.    public void append(ByteVector var1) {
  62.       for(int var2 = 0; var2 < var1.getLength(); ++var2) {
  63.          this.emitByte(var1.get(var2));
  64.       }
  65.  
  66.    }
  67.  
  68.    public short cpi() {
  69.       if (this.cpIdx == 0) {
  70.          throw new RuntimeException("Illegal use of ClassFileAssembler");
  71.       } else {
  72.          return this.cpIdx;
  73.       }
  74.    }
  75.  
  76.    public void emitConstantPoolUTF8(String var1) {
  77.       byte[] var2 = UTF8.encode(var1);
  78.       this.emitByte((byte)1);
  79.       this.emitShort((short)var2.length);
  80.  
  81.       for(int var3 = 0; var3 < var2.length; ++var3) {
  82.          this.emitByte(var2[var3]);
  83.       }
  84.  
  85.       ++this.cpIdx;
  86.    }
  87.  
  88.    public void emitConstantPoolClass(short var1) {
  89.       this.emitByte((byte)7);
  90.       this.emitShort(var1);
  91.       ++this.cpIdx;
  92.    }
  93.  
  94.    public void emitConstantPoolNameAndType(short var1, short var2) {
  95.       this.emitByte((byte)12);
  96.       this.emitShort(var1);
  97.       this.emitShort(var2);
  98.       ++this.cpIdx;
  99.    }
  100.  
  101.    public void emitConstantPoolFieldref(short var1, short var2) {
  102.       this.emitByte((byte)9);
  103.       this.emitShort(var1);
  104.       this.emitShort(var2);
  105.       ++this.cpIdx;
  106.    }
  107.  
  108.    public void emitConstantPoolMethodref(short var1, short var2) {
  109.       this.emitByte((byte)10);
  110.       this.emitShort(var1);
  111.       this.emitShort(var2);
  112.       ++this.cpIdx;
  113.    }
  114.  
  115.    public void emitConstantPoolInterfaceMethodref(short var1, short var2) {
  116.       this.emitByte((byte)11);
  117.       this.emitShort(var1);
  118.       this.emitShort(var2);
  119.       ++this.cpIdx;
  120.    }
  121.  
  122.    public void emitConstantPoolString(short var1) {
  123.       this.emitByte((byte)8);
  124.       this.emitShort(var1);
  125.       ++this.cpIdx;
  126.    }
  127.  
  128.    private void incStack() {
  129.       this.setStack(this.stack + 1);
  130.    }
  131.  
  132.    private void decStack() {
  133.       --this.stack;
  134.    }
  135.  
  136.    public short getMaxStack() {
  137.       return (short)this.maxStack;
  138.    }
  139.  
  140.    public short getMaxLocals() {
  141.       return (short)this.maxLocals;
  142.    }
  143.  
  144.    public void setMaxLocals(int var1) {
  145.       this.maxLocals = var1;
  146.    }
  147.  
  148.    public int getStack() {
  149.       return this.stack;
  150.    }
  151.  
  152.    public void setStack(int var1) {
  153.       this.stack = var1;
  154.       if (this.stack > this.maxStack) {
  155.          this.maxStack = this.stack;
  156.       }
  157.  
  158.    }
  159.  
  160.    public void opc_aconst_null() {
  161.       this.emitByte((byte)1);
  162.       this.incStack();
  163.    }
  164.  
  165.    public void opc_sipush(short var1) {
  166.       this.emitByte((byte)17);
  167.       this.emitShort(var1);
  168.       this.incStack();
  169.    }
  170.  
  171.    public void opc_ldc(byte var1) {
  172.       this.emitByte((byte)18);
  173.       this.emitByte(var1);
  174.       this.incStack();
  175.    }
  176.  
  177.    public void opc_iload_0() {
  178.       this.emitByte((byte)26);
  179.       if (this.maxLocals < 1) {
  180.          this.maxLocals = 1;
  181.       }
  182.  
  183.       this.incStack();
  184.    }
  185.  
  186.    public void opc_iload_1() {
  187.       this.emitByte((byte)27);
  188.       if (this.maxLocals < 2) {
  189.          this.maxLocals = 2;
  190.       }
  191.  
  192.       this.incStack();
  193.    }
  194.  
  195.    public void opc_iload_2() {
  196.       this.emitByte((byte)28);
  197.       if (this.maxLocals < 3) {
  198.          this.maxLocals = 3;
  199.       }
  200.  
  201.       this.incStack();
  202.    }
  203.  
  204.    public void opc_iload_3() {
  205.       this.emitByte((byte)29);
  206.       if (this.maxLocals < 4) {
  207.          this.maxLocals = 4;
  208.       }
  209.  
  210.       this.incStack();
  211.    }
  212.  
  213.    public void opc_lload_0() {
  214.       this.emitByte((byte)30);
  215.       if (this.maxLocals < 2) {
  216.          this.maxLocals = 2;
  217.       }
  218.  
  219.       this.incStack();
  220.       this.incStack();
  221.    }
  222.  
  223.    public void opc_lload_1() {
  224.       this.emitByte((byte)31);
  225.       if (this.maxLocals < 3) {
  226.          this.maxLocals = 3;
  227.       }
  228.  
  229.       this.incStack();
  230.       this.incStack();
  231.    }
  232.  
  233.    public void opc_lload_2() {
  234.       this.emitByte((byte)32);
  235.       if (this.maxLocals < 4) {
  236.          this.maxLocals = 4;
  237.       }
  238.  
  239.       this.incStack();
  240.       this.incStack();
  241.    }
  242.  
  243.    public void opc_lload_3() {
  244.       this.emitByte((byte)33);
  245.       if (this.maxLocals < 5) {
  246.          this.maxLocals = 5;
  247.       }
  248.  
  249.       this.incStack();
  250.       this.incStack();
  251.    }
  252.  
  253.    public void opc_fload_0() {
  254.       this.emitByte((byte)34);
  255.       if (this.maxLocals < 1) {
  256.          this.maxLocals = 1;
  257.       }
  258.  
  259.       this.incStack();
  260.    }
  261.  
  262.    public void opc_fload_1() {
  263.       this.emitByte((byte)35);
  264.       if (this.maxLocals < 2) {
  265.          this.maxLocals = 2;
  266.       }
  267.  
  268.       this.incStack();
  269.    }
  270.  
  271.    public void opc_fload_2() {
  272.       this.emitByte((byte)36);
  273.       if (this.maxLocals < 3) {
  274.          this.maxLocals = 3;
  275.       }
  276.  
  277.       this.incStack();
  278.    }
  279.  
  280.    public void opc_fload_3() {
  281.       this.emitByte((byte)37);
  282.       if (this.maxLocals < 4) {
  283.          this.maxLocals = 4;
  284.       }
  285.  
  286.       this.incStack();
  287.    }
  288.  
  289.    public void opc_dload_0() {
  290.       this.emitByte((byte)38);
  291.       if (this.maxLocals < 2) {
  292.          this.maxLocals = 2;
  293.       }
  294.  
  295.       this.incStack();
  296.       this.incStack();
  297.    }
  298.  
  299.    public void opc_dload_1() {
  300.       this.emitByte((byte)39);
  301.       if (this.maxLocals < 3) {
  302.          this.maxLocals = 3;
  303.       }
  304.  
  305.       this.incStack();
  306.       this.incStack();
  307.    }
  308.  
  309.    public void opc_dload_2() {
  310.       this.emitByte((byte)40);
  311.       if (this.maxLocals < 4) {
  312.          this.maxLocals = 4;
  313.       }
  314.  
  315.       this.incStack();
  316.       this.incStack();
  317.    }
  318.  
  319.    public void opc_dload_3() {
  320.       this.emitByte((byte)41);
  321.       if (this.maxLocals < 5) {
  322.          this.maxLocals = 5;
  323.       }
  324.  
  325.       this.incStack();
  326.       this.incStack();
  327.    }
  328.  
  329.    public void opc_aload_0() {
  330.       this.emitByte((byte)42);
  331.       if (this.maxLocals < 1) {
  332.          this.maxLocals = 1;
  333.       }
  334.  
  335.       this.incStack();
  336.    }
  337.  
  338.    public void opc_aload_1() {
  339.       this.emitByte((byte)43);
  340.       if (this.maxLocals < 2) {
  341.          this.maxLocals = 2;
  342.       }
  343.  
  344.       this.incStack();
  345.    }
  346.  
  347.    public void opc_aload_2() {
  348.       this.emitByte((byte)44);
  349.       if (this.maxLocals < 3) {
  350.          this.maxLocals = 3;
  351.       }
  352.  
  353.       this.incStack();
  354.    }
  355.  
  356.    public void opc_aload_3() {
  357.       this.emitByte((byte)45);
  358.       if (this.maxLocals < 4) {
  359.          this.maxLocals = 4;
  360.       }
  361.  
  362.       this.incStack();
  363.    }
  364.  
  365.    public void opc_aaload() {
  366.       this.emitByte((byte)50);
  367.       this.decStack();
  368.    }
  369.  
  370.    public void opc_astore_0() {
  371.       this.emitByte((byte)75);
  372.       if (this.maxLocals < 1) {
  373.          this.maxLocals = 1;
  374.       }
  375.  
  376.       this.decStack();
  377.    }
  378.  
  379.    public void opc_astore_1() {
  380.       this.emitByte((byte)76);
  381.       if (this.maxLocals < 2) {
  382.          this.maxLocals = 2;
  383.       }
  384.  
  385.       this.decStack();
  386.    }
  387.  
  388.    public void opc_astore_2() {
  389.       this.emitByte((byte)77);
  390.       if (this.maxLocals < 3) {
  391.          this.maxLocals = 3;
  392.       }
  393.  
  394.       this.decStack();
  395.    }
  396.  
  397.    public void opc_astore_3() {
  398.       this.emitByte((byte)78);
  399.       if (this.maxLocals < 4) {
  400.          this.maxLocals = 4;
  401.       }
  402.  
  403.       this.decStack();
  404.    }
  405.  
  406.    public void opc_pop() {
  407.       this.emitByte((byte)87);
  408.       this.decStack();
  409.    }
  410.  
  411.    public void opc_dup() {
  412.       this.emitByte((byte)89);
  413.       this.incStack();
  414.    }
  415.  
  416.    public void opc_dup_x1() {
  417.       this.emitByte((byte)90);
  418.       this.incStack();
  419.    }
  420.  
  421.    public void opc_swap() {
  422.       this.emitByte((byte)95);
  423.    }
  424.  
  425.    public void opc_i2l() {
  426.       this.emitByte((byte)-123);
  427.    }
  428.  
  429.    public void opc_i2f() {
  430.       this.emitByte((byte)-122);
  431.    }
  432.  
  433.    public void opc_i2d() {
  434.       this.emitByte((byte)-121);
  435.    }
  436.  
  437.    public void opc_l2f() {
  438.       this.emitByte((byte)-119);
  439.    }
  440.  
  441.    public void opc_l2d() {
  442.       this.emitByte((byte)-118);
  443.    }
  444.  
  445.    public void opc_f2d() {
  446.       this.emitByte((byte)-115);
  447.    }
  448.  
  449.    public void opc_ifeq(short var1) {
  450.       this.emitByte((byte)-103);
  451.       this.emitShort(var1);
  452.       this.decStack();
  453.    }
  454.  
  455.    public void opc_ifeq(Label var1) {
  456.       short var2 = this.getLength();
  457.       this.emitByte((byte)-103);
  458.       var1.add(this, var2, this.getLength(), this.getStack() - 1);
  459.       this.emitShort((short)-1);
  460.    }
  461.  
  462.    public void opc_if_icmpeq(short var1) {
  463.       this.emitByte((byte)-97);
  464.       this.emitShort(var1);
  465.       this.setStack(this.getStack() - 2);
  466.    }
  467.  
  468.    public void opc_if_icmpeq(Label var1) {
  469.       short var2 = this.getLength();
  470.       this.emitByte((byte)-97);
  471.       var1.add(this, var2, this.getLength(), this.getStack() - 2);
  472.       this.emitShort((short)-1);
  473.    }
  474.  
  475.    public void opc_goto(short var1) {
  476.       this.emitByte((byte)-89);
  477.       this.emitShort(var1);
  478.    }
  479.  
  480.    public void opc_goto(Label var1) {
  481.       short var2 = this.getLength();
  482.       this.emitByte((byte)-89);
  483.       var1.add(this, var2, this.getLength(), this.getStack());
  484.       this.emitShort((short)-1);
  485.    }
  486.  
  487.    public void opc_ifnull(short var1) {
  488.       this.emitByte((byte)-58);
  489.       this.emitShort(var1);
  490.       this.decStack();
  491.    }
  492.  
  493.    public void opc_ifnull(Label var1) {
  494.       short var2 = this.getLength();
  495.       this.emitByte((byte)-58);
  496.       var1.add(this, var2, this.getLength(), this.getStack() - 1);
  497.       this.emitShort((short)-1);
  498.       this.decStack();
  499.    }
  500.  
  501.    public void opc_ifnonnull(short var1) {
  502.       this.emitByte((byte)-57);
  503.       this.emitShort(var1);
  504.       this.decStack();
  505.    }
  506.  
  507.    public void opc_ifnonnull(Label var1) {
  508.       short var2 = this.getLength();
  509.       this.emitByte((byte)-57);
  510.       var1.add(this, var2, this.getLength(), this.getStack() - 1);
  511.       this.emitShort((short)-1);
  512.       this.decStack();
  513.    }
  514.  
  515.    public void opc_ireturn() {
  516.       this.emitByte((byte)-84);
  517.       this.setStack(0);
  518.    }
  519.  
  520.    public void opc_lreturn() {
  521.       this.emitByte((byte)-83);
  522.       this.setStack(0);
  523.    }
  524.  
  525.    public void opc_freturn() {
  526.       this.emitByte((byte)-82);
  527.       this.setStack(0);
  528.    }
  529.  
  530.    public void opc_dreturn() {
  531.       this.emitByte((byte)-81);
  532.       this.setStack(0);
  533.    }
  534.  
  535.    public void opc_areturn() {
  536.       this.emitByte((byte)-80);
  537.       this.setStack(0);
  538.    }
  539.  
  540.    public void opc_return() {
  541.       this.emitByte((byte)-79);
  542.       this.setStack(0);
  543.    }
  544.  
  545.    public void opc_getstatic(short var1, int var2) {
  546.       this.emitByte((byte)-78);
  547.       this.emitShort(var1);
  548.       this.setStack(this.getStack() + var2);
  549.    }
  550.  
  551.    public void opc_putstatic(short var1, int var2) {
  552.       this.emitByte((byte)-77);
  553.       this.emitShort(var1);
  554.       this.setStack(this.getStack() - var2);
  555.    }
  556.  
  557.    public void opc_getfield(short var1, int var2) {
  558.       this.emitByte((byte)-76);
  559.       this.emitShort(var1);
  560.       this.setStack(this.getStack() + var2 - 1);
  561.    }
  562.  
  563.    public void opc_putfield(short var1, int var2) {
  564.       this.emitByte((byte)-75);
  565.       this.emitShort(var1);
  566.       this.setStack(this.getStack() - var2 - 1);
  567.    }
  568.  
  569.    public void opc_invokevirtual(short var1, int var2, int var3) {
  570.       this.emitByte((byte)-74);
  571.       this.emitShort(var1);
  572.       this.setStack(this.getStack() - var2 - 1 + var3);
  573.    }
  574.  
  575.    public void opc_invokespecial(short var1, int var2, int var3) {
  576.       this.emitByte((byte)-73);
  577.       this.emitShort(var1);
  578.       this.setStack(this.getStack() - var2 - 1 + var3);
  579.    }
  580.  
  581.    public void opc_invokestatic(short var1, int var2, int var3) {
  582.       this.emitByte((byte)-72);
  583.       this.emitShort(var1);
  584.       this.setStack(this.getStack() - var2 + var3);
  585.    }
  586.  
  587.    public void opc_invokeinterface(short var1, int var2, byte var3, int var4) {
  588.       this.emitByte((byte)-71);
  589.       this.emitShort(var1);
  590.       this.emitByte(var3);
  591.       this.emitByte((byte)0);
  592.       this.setStack(this.getStack() - var2 - 1 + var4);
  593.    }
  594.  
  595.    public void opc_arraylength() {
  596.       this.emitByte((byte)-66);
  597.    }
  598.  
  599.    public void opc_new(short var1) {
  600.       this.emitByte((byte)-69);
  601.       this.emitShort(var1);
  602.       this.incStack();
  603.    }
  604.  
  605.    public void opc_athrow() {
  606.       this.emitByte((byte)-65);
  607.       this.setStack(1);
  608.    }
  609.  
  610.    public void opc_checkcast(short var1) {
  611.       this.emitByte((byte)-64);
  612.       this.emitShort(var1);
  613.    }
  614.  
  615.    public void opc_instanceof(short var1) {
  616.       this.emitByte((byte)-63);
  617.       this.emitShort(var1);
  618.    }
  619. }
  620.