Compresses and writes #currentFrame in a new StackMapTable entry.
()
| 1850 | |
| 1851 | /** Compresses and writes {@link #currentFrame} in a new StackMapTable entry. */ |
| 1852 | private void putFrame() { |
| 1853 | final int nLocal = currentFrame[1]; |
| 1854 | final int nStack = currentFrame[2]; |
| 1855 | if (symbolTable.getMajorVersion() < Opcodes.V1_6) { |
| 1856 | // Generate a StackMap attribute entry, which are always uncompressed. |
| 1857 | stackMapTableEntries.putShort(currentFrame[0]).putShort(nLocal); |
| 1858 | putAbstractTypes(3, 3 + nLocal); |
| 1859 | stackMapTableEntries.putShort(nStack); |
| 1860 | putAbstractTypes(3 + nLocal, 3 + nLocal + nStack); |
| 1861 | return; |
| 1862 | } |
| 1863 | final int offsetDelta = |
| 1864 | stackMapTableNumberOfEntries == 0 |
| 1865 | ? currentFrame[0] |
| 1866 | : currentFrame[0] - previousFrame[0] - 1; |
| 1867 | final int previousNlocal = previousFrame[1]; |
| 1868 | final int nLocalDelta = nLocal - previousNlocal; |
| 1869 | int type = Frame.FULL_FRAME; |
| 1870 | if (nStack == 0) { |
| 1871 | switch (nLocalDelta) { |
| 1872 | case -3: |
| 1873 | case -2: |
| 1874 | case -1: |
| 1875 | type = Frame.CHOP_FRAME; |
| 1876 | break; |
| 1877 | case 0: |
| 1878 | type = offsetDelta < 64 ? Frame.SAME_FRAME : Frame.SAME_FRAME_EXTENDED; |
| 1879 | break; |
| 1880 | case 1: |
| 1881 | case 2: |
| 1882 | case 3: |
| 1883 | type = Frame.APPEND_FRAME; |
| 1884 | break; |
| 1885 | default: |
| 1886 | // Keep the FULL_FRAME type. |
| 1887 | break; |
| 1888 | } |
| 1889 | } else if (nLocalDelta == 0 && nStack == 1) { |
| 1890 | type = |
| 1891 | offsetDelta < 63 |
| 1892 | ? Frame.SAME_LOCALS_1_STACK_ITEM_FRAME |
| 1893 | : Frame.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED; |
| 1894 | } |
| 1895 | if (type != Frame.FULL_FRAME) { |
| 1896 | // Verify if locals are the same as in the previous frame. |
| 1897 | int frameIndex = 3; |
| 1898 | for (int i = 0; i < previousNlocal && i < nLocal; i++) { |
| 1899 | if (currentFrame[frameIndex] != previousFrame[frameIndex]) { |
| 1900 | type = Frame.FULL_FRAME; |
| 1901 | break; |
| 1902 | } |
| 1903 | frameIndex++; |
| 1904 | } |
| 1905 | } |
| 1906 | switch (type) { |
| 1907 | case Frame.SAME_FRAME: |
| 1908 | stackMapTableEntries.putByte(offsetDelta); |
| 1909 | break; |
no test coverage detected