opcodes-doc.xsl 10.3 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
2 3
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
5
    xmlns="http://www.w3.org/1999/xhtml"
6
    exclude-result-prefixes="xsl fo">
7

8 9 10 11 12 13 14 15 16 17
<xsl:output method="html" indent="no" omit-xml-declaration="yes" encoding="UTF-8" name="html"/>
<xsl:output method="xml" indent="yes" encoding="UTF-8" name="xml"/>

<xsl:template match="opcodes">


<!-- TOC -->
<xsl:result-document format="xml" href="toc.xml">

<toc label="JVM Instruction Reference" topic="about.html">
18
<topic label="Opcodes" href="doc/opcodes.html"/>
19 20 21

<xsl:for-each select='opcode'>
  <xsl:sort/>
22
  <topic>
23 24 25 26 27 28 29 30 31
    <xsl:attribute name='label'><xsl:value-of select="name/text()"/></xsl:attribute>
    <xsl:attribute name='href'>doc/ref-<xsl:value-of select="name/text()"/>.html</xsl:attribute>
  </topic>
</xsl:for-each>

</toc>
</xsl:result-document>


32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
<!-- opcodes -->

<xsl:result-document format="html" href="opcodes.html">
<html xmlns="http://www.w3.org/1999/xhtml">
<xsl:call-template name="head"/>
<body>
<ul>
<xsl:for-each select='opcode'>
  <xsl:sort/>

  <li><a>
    <xsl:attribute name='href'>ref-<xsl:value-of select="name/text()"/>.html</xsl:attribute>
    <xsl:value-of select="name/text()"/>
  </a></li>

</xsl:for-each>
</ul>
</body>
</html>

</xsl:result-document>



56 57 58 59 60 61 62 63 64 65 66 67 68
<!-- Details -->
<xsl:apply-templates select="*">
  <xsl:sort/>
</xsl:apply-templates>

</xsl:template>

<xsl:template match="opcode">

<xsl:variable name="filename" select="concat('ref-', name, '.html')"/>
<xsl:result-document format="html" href="{$filename}">

<html>
69
<xsl:call-template name="head"/>
70 71
<body>

72
<p>
73
  <a><xsl:attribute name='name'><xsl:value-of select="name"/></xsl:attribute></a>
74
  <b><xsl:value-of select="name"/></b> :
75
  <xsl:apply-templates select="short/text()"/>
76 77
  <xsl:value-of select="string(' : ')"/><a href="opcodes.html">index</a>
  <xsl:value-of select="string(' : ')"/>
ekuleshov's avatar
ekuleshov committed
78 79 80
  <xsl:variable name="nm"><xsl:value-of select="name"/></xsl:variable>
  <xsl:choose>
    <xsl:when test="contains('getstatic putstatic getfield putfield', $nm)">
81
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitFieldInsn(int,%20java.lang.String,%20java.lang.String,%20java.lang.String)">visitFieldInsn()</a>
ekuleshov's avatar
ekuleshov committed
82 83
    </xsl:when>
    <xsl:when test="contains('iinc', $nm)">
84
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitIincInsn(int,%20int)">visitIincInsn()</a>
ekuleshov's avatar
ekuleshov committed
85 86
    </xsl:when>
    <xsl:when test="contains('nop aconst_null iconst_m1 iconst_0 iconst_1 iconst_2 iconst_3 iconst_4 iconst_5 lconst_0 lconst_1 fconst_0 fconst_1 fconst_2 dconst_0 dconst_1 iaload laload faload daload aaload baload caload saload iastore lastore fastore dastore aastore bastore castore sastore pop pop2 dup dup_x1 dup_x2 dup2 dup2_x1 dup2_x2 swap iadd ladd fadd dadd isub lsub fsub dsub imul lmul fmul dmul idiv ldiv fdiv ddiv irem lrem frem drem ineg lneg fneg dneg ishl lshl ishr lshr iushr lushr iand land ior lor ixor lxor i2l i2f i2d l2i l2f l2d f2i f2l f2d d2i d2l d2f i2b i2c i2s lcmp fcmpl fcmpg dcmpl dcmpg ireturn lreturn freturn dreturn areturn return arraylength athrow monitorenter monitorexit', $nm)">
87
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitInsn(int)">visitInsn()</a>
ekuleshov's avatar
ekuleshov committed
88 89
    </xsl:when>
    <xsl:when test="contains('bipush sipush newarray', $nm)">
90
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitIntInsn(int,%20int)">visitIntInsn()</a>
ekuleshov's avatar
ekuleshov committed
91 92
    </xsl:when>
    <xsl:when test="contains('ifeq ifne iflt ifge ifgt ifle if_icmpeq if_icmpne if_icmplt if_icmpge if_icmpgt if_icmple if_acmpeq if_acmpne goto jsr ifnull ifnonnull', $nm)">
93
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitJumpInsn(int,%20org.objectweb.asm.Label)">visitJumpInsn()</a>
ekuleshov's avatar
ekuleshov committed
94
    </xsl:when>
95
    <xsl:when test="contains('ldc ldc_w ldc2_w', $nm)">
96
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitLdcInsn(java.lang.Object)">visitLdcInsn()</a>
ekuleshov's avatar
ekuleshov committed
97 98
    </xsl:when>
    <xsl:when test="contains('lookupswitch', $nm)">
99
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitLookupSwitchInsn(org.objectweb.asm.Label,%20int[],%20org.objectweb.asm.Label[])">visitLookupSwitchInsn()</a>
ekuleshov's avatar
ekuleshov committed
100 101
    </xsl:when>
    <xsl:when test="contains('tableswitch', $nm)">
102
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitTableSwitchInsn(int,%20int,%20org.objectweb.asm.Label,%20org.objectweb.asm.Label[])">visitTableSwitchInsn()</a>
ekuleshov's avatar
ekuleshov committed
103 104
    </xsl:when>
    <xsl:when test="contains('invokevirtual invokespecial invokestatic invokeinterface', $nm)">
105
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitMethodInsn(int,%20java.lang.String,%20java.lang.String,%20java.lang.String)">visitMethodInsn()</a>
ekuleshov's avatar
ekuleshov committed
106 107
    </xsl:when>
    <xsl:when test="contains('multianewarray', $nm)">
108
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitMultiANewArrayInsn(java.lang.String,%20int)">visitMultiANewArrayInsn()</a>
ekuleshov's avatar
ekuleshov committed
109 110
    </xsl:when>
    <xsl:when test="contains('new anewarray checkcast instanceof', $nm)">
111
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitTypeInsn(int,%20java.lang.String)">visitTypeInsn()</a>
ekuleshov's avatar
ekuleshov committed
112 113
    </xsl:when>
    <xsl:when test="contains('iload lload fload dload aload istore lstore fstore dstore astore ret', $nm)">
114
      <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitVarInsn(int,%20int)">visitVarInsn()</a>
ekuleshov's avatar
ekuleshov committed
115 116
    </xsl:when>
  </xsl:choose>
117 118
</p>
<dl>
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
<xsl:apply-templates select="desc"/>
<xsl:apply-templates select="exceptions"/>
<xsl:apply-templates select="example"/>
<xsl:apply-templates select="note"/>
<xsl:apply-templates select="see"/>
<xsl:apply-templates select="stack"/>
<xsl:apply-templates select="bytecode"/>
</dl>

</body>
</html>

</xsl:result-document>

</xsl:template>


<!-- Sections -->

<xsl:template match="stack">
139
<dt>Stack</dt>
140 141 142 143
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>

<xsl:template match="desc">
144
<dt>Description</dt>
145 146 147 148
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>

<xsl:template match="bytecode">
149
<dt>Bytecode</dt>
150 151 152 153
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>

<xsl:template match="example">
154
<dt>Example</dt>
155 156 157 158
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>

<xsl:template match="note">
159
<dt>Notes</dt>
160 161 162 163
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>

<xsl:template match="see">
164
<dt>See also</dt>
165 166 167 168 169 170
<dd>
  <xsl:call-template name="seeFormat"><xsl:with-param name="string" select="text()"/></xsl:call-template>
  </dd>
</xsl:template>

<xsl:template match="exceptions">
171
<dt>Exceptions</dt>
172 173 174 175 176 177
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>


<!-- Formatting -->

178 179
<xsl:template match='pre'>
  <pre><xsl:call-template name="preFormat"><xsl:with-param name="string" select="text()"/></xsl:call-template></pre>
180 181 182 183 184
</xsl:template>

<xsl:template match='text()'>
  <xsl:call-template name="docFormat"><xsl:with-param name="string" select="."/></xsl:call-template>
</xsl:template>
185 186 187 188

<xsl:template name="preFormat">
  <xsl:param name="string"/>
  <!-- double CRLF will be replaced with <BR><BR> -->
189
  <xsl:choose>
190 191 192 193 194 195
    <xsl:when test="contains($string, '&#xA;&#xA;')">
      <xsl:value-of select="substring-before($string, '&#xA;&#xA;')"/>
      <xsl:value-of select="string( '&#xA;')"/>
      <xsl:call-template name="preFormat">
        <xsl:with-param name="string" select="substring-after($string, '&#xA;&#xA;')"/>
      </xsl:call-template>
196
    </xsl:when>
197 198 199
    <xsl:otherwise>
      <xsl:value-of select="$string"/>
    </xsl:otherwise>
200
  </xsl:choose>
201
</xsl:template>
202

203 204 205
<xsl:template name="docFormat">
  <xsl:param name="string"/>
  <!-- double CRLF will be replaced with <BR><BR> -->
206
  <xsl:choose>
207 208
    <xsl:when test="contains($string, '&#xA;&#xA;')">
      <xsl:value-of select="substring-before($string, '&#xA;&#xA;')"/>
209
      <!-- xsl:value-of select="string( '&#xA;')"/ -->
210 211 212 213
      <br/>
      <xsl:call-template name="docFormat">
        <xsl:with-param name="string" select="substring-after($string, '&#xA;&#xA;')"/>
      </xsl:call-template>
214
    </xsl:when>
215 216 217
    <xsl:otherwise>
      <xsl:value-of select="$string"/>
    </xsl:otherwise>
218
  </xsl:choose>
219 220 221 222
</xsl:template>

<xsl:template name="seeFormat">
  <xsl:param name="string"/>
223
  <xsl:choose>
224
    <xsl:when test="contains($string, ',')">
225 226
      <xsl:call-template name="seeFormat"><xsl:with-param name="string" select="substring-before($string, ',')"/></xsl:call-template>
      <xsl:call-template name="seeFormat"><xsl:with-param name="string" select="substring-after($string, ',')"/></xsl:call-template>
227
    </xsl:when>
228 229 230 231

    <xsl:when test="contains($string, ' ')">
      <xsl:call-template name="seeFormat"><xsl:with-param name="string" select="substring-before($string, ' ')"/></xsl:call-template>
      <xsl:call-template name="seeFormat"><xsl:with-param name="string" select="substring-after($string, ' ')"/></xsl:call-template>
232
    </xsl:when>
233 234 235 236

    <xsl:when test="contains($string, '&#xA;')">
      <xsl:call-template name="seeFormat"><xsl:with-param name="string" select="substring-before($string, '&#xA;')"/></xsl:call-template>
      <xsl:call-template name="seeFormat"><xsl:with-param name="string" select="substring-after($string, '&#xA;')"/></xsl:call-template>
237
    </xsl:when>
238

239 240 241 242 243
    <xsl:otherwise>
      <a>
        <xsl:attribute name="href">ref-<xsl:value-of select="normalize-space($string)"/>.html</xsl:attribute>
        <xsl:value-of select="normalize-space($string)"/>
      </a>
ekuleshov's avatar
ekuleshov committed
244
      <xsl:value-of select="string( ' ')"/>
245
    </xsl:otherwise>
246
  </xsl:choose>
247 248 249
</xsl:template>


250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
<xsl:template name='head'>
<head>
<style type="text/css">
dt {
  font-style: italic;
  margin-top: 15px;
  margin-bottom: 3px;
  margin-left: 0px;
  border-bottom: 1px dotted black;
}
dd {
  margin-left: 10px;
}
table {
  border-collapse:collapse;
  border: 1px solid black;
  margin-top: 7px;
}
th {
  border: 1px solid black;
  padding: 3 7 3 7;
}
td {
  border: 1px solid black;
  padding: 3 7 3 7;
}
</style>
</head>
</xsl:template>


281 282 283 284 285 286 287 288 289
<!-- Copy everything else -->

<xsl:template match='*|@*'>
  <xsl:copy>
    <xsl:apply-templates select='node()|@*'/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>