File: make-opcode-def.xsl

package info (click to toggle)
mono 4.6.2.7+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 778,148 kB
  • ctags: 914,052
  • sloc: cs: 5,779,509; xml: 2,773,713; ansic: 432,645; sh: 14,749; makefile: 12,361; perl: 2,488; python: 1,434; cpp: 849; asm: 531; sql: 95; sed: 16; php: 1
file content (100 lines) | stat: -rw-r--r-- 2,818 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?xml version="1.0" encoding="iso-8859-1"?>


<!--
 | make-opcode-def.xsl: Translates opcodes from the CIL-opcodes.xml into
 |                      a spec compliant opcodes.def file
 |                      Converted to XSLT from make-opcodes-def.pl
 |
 | See: Common Language Infrastructure (CLI) Part 5: Annexes
 |
 | Author: Sergey Chaban
 |
 | $Id$
  -->



<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">



<xsl:output method="text"/>


<xsl:template match="/">
  <xsl:apply-templates/>
  <xsl:call-template name="print-trailer"/>
</xsl:template>

<xsl:template name="to-upper">
  <xsl:param name="string"/>
  <xsl:value-of select="translate($string,
                        'abcdefghijklmnopqrstuvwxyz.-',
                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ__')"/>
</xsl:template>


<xsl:template name="get-flow">
  <xsl:param name="flow" select="@flow"/>
  <xsl:choose>
    <xsl:when
         test="contains('next call return branch meta cond-branch',$flow)">
      <xsl:call-template name="to-upper">
        <xsl:with-param name="string" select="$flow"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise><xsl:value-of select="'ERROR'"/></xsl:otherwise>
  </xsl:choose>     
</xsl:template>


<xsl:template match="opdesc/opcode">
  <xsl:variable name="uname">
    <xsl:call-template name="to-upper">
      <xsl:with-param name="string" select="@name"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="o1">
    <xsl:call-template name="to-upper">
      <xsl:with-param name="string" select="@o1"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="f">
    <xsl:call-template name="get-flow"/>
  </xsl:variable>
  <xsl:variable name="count"
       select="number(not(contains($o1,'FF')))+1"/>OPDEF(CEE_<xsl:value-of
               select="concat($uname,', &#x22;',@name,'&#x22;, ',
                              @input,', ',@output,', ',@args,', X, ',
                              $count,', ',@o1,', ',@o2,', ',$f
                       )"/>)
</xsl:template>


<xsl:template name="print-trailer">
#ifndef OPALIAS
#define _MONO_CIL_OPALIAS_DEFINED_
#define OPALIAS(a,s,r)
#endif

OPALIAS(CEE_BRNULL,     "brnull",    CEE_BRFALSE)
OPALIAS(CEE_BRNULL_S,   "brnull.s",  CEE_BRFALSE_S)
OPALIAS(CEE_BRZERO,     "brzero",    CEE_BRFALSE)
OPALIAS(CEE_BRZERO_S,   "brzero.s",  CEE_BRFALSE_S)
OPALIAS(CEE_BRINST,     "brinst",    CEE_BRTRUE)
OPALIAS(CEE_BRINST_S,   "brinst.s",  CEE_BRTRUE_S)
OPALIAS(CEE_LDIND_U8,   "ldind.u8",  CEE_LDIND_I8)
OPALIAS(CEE_LDELEM_U8,  "ldelem.u8", CEE_LDELEM_I8)
OPALIAS(CEE_LDX_I4_MIX, "ldc.i4.M1", CEE_LDC_I4_M1)
OPALIAS(CEE_ENDFAULT,   "endfault",  CEE_ENDFINALLY)

#ifdef _MONO_CIL_OPALIAS_DEFINED_
#undef OPALIAS
#undef _MONO_CIL_OPALIAS_DEFINED_
#endif
</xsl:template>


</xsl:stylesheet>