Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

Commit ceb8014

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents b87700c + 704d9d9 commit ceb8014

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3675
-3045
lines changed

.travis.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
language: c++
21
language: python
32
python:
4-
- "2.7"
3+
- "3.7"
4+
dist: bionic
55

6-
sudo: on
7-
8-
before_install:
9-
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
10-
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
11-
- sudo apt-get update -qq
6+
addons:
7+
apt:
8+
sources:
9+
- sourceline: 'deb https://dl.yarnpkg.com/debian/ stable main'
10+
key_url: 'https://dl.yarnpkg.com/debian/pubkey.gpg'
11+
packages:
12+
- ocaml
13+
- ocamlbuild
14+
- texlive-full
15+
- yarn
1216

1317
install:
14-
- ./interpreter/meta/travis/install-ocaml.sh
15-
- sudo pip install sphinx==1.7.9
16-
- sudo apt-get install texlive-full yarn
18+
- pip install Sphinx==2.4.4
1719
- git clone https://github.com/tabatkins/bikeshed.git
1820
- pip install --editable $PWD/bikeshed
1921
- bikeshed update

document/core/Makefile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ STATICDIR = _static
1010
DOWNLOADDIR = _download
1111
NAME = WebAssembly
1212

13-
# Hack until we have moved to more recent Sphinx.
14-
OLDMATHJAX = https://cdn.mathjax.org/mathjax/latest/MathJax.js
15-
NEWMATHJAX = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js
16-
1713
# Internal variables.
1814
PAPEROPT_a4 = -D latex_paper_size=a4
1915
PAPEROPT_letter = -D latex_paper_size=letter
20-
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
16+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(SPHINXOPTS) .
2117
# the i18n builder cannot share the environment and doctrees with the others
2218
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
2319

@@ -111,16 +107,10 @@ html:
111107
do \
112108
sed s:BASEDIR:.:g <$$file >$$file.out; \
113109
mv -f $$file.out $$file; \
114-
sed s~$(OLDMATHJAX)~$(NEWMATHJAX)~g <$$file >$$file.out; \
115-
mv -f $$file.out $$file; \
116110
done
117111
for file in `ls $(BUILDDIR)/html/*/*.html`; \
118112
do \
119113
sed s:BASEDIR:..:g <$$file >$$file.out; \
120-
sed 's;<body; <script type="text/javascript">MathJax.Hub.Config({TeX: {MAXBUFFER: 30*1024}})</script><body;' \
121-
<$$file.out >$$file; \
122-
rm -f $$file.out; \
123-
sed s~$(OLDMATHJAX)~$(NEWMATHJAX)~g <$$file >$$file.out; \
124114
mv -f $$file.out $$file; \
125115
done
126116
@echo
@@ -268,7 +258,7 @@ latex:
268258
latexpdf:
269259
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
270260
@echo "Running LaTeX files through pdflatex..."
271-
$(MAKE) -C $(BUILDDIR)/latex all-pdf
261+
$(MAKE) -C $(BUILDDIR)/latex LATEXMKOPTS=" </dev/null" all-pdf >$(BUILDDIR)/latex/LOG 2>&1 || cat $(BUILDDIR)/latex/LOG
272262
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
273263

274264
.PHONY: latexpdfja

document/core/appendix/properties.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
218218

219219
* Or the :ref:`external value <syntax-externval>` :math:`\EVFUNC~\X{fa}` must be :ref:`valid <valid-externval-func>` with some :ref:`external type <syntax-externtype>` :math:`\ETFUNC~\X{ft}`.
220220

221-
* The :ref:`limits <syntax-limits>` :math:`\{\LMIN~n, \LMAX~m^?\}` must be :ref:`valid <valid-limits>`.
221+
* The :ref:`limits <syntax-limits>` :math:`\{\LMIN~n, \LMAX~m^?\}` must be :ref:`valid <valid-limits>` within range :math:`2^{32}`.
222222

223223
* Then the table instance is valid with :ref:`table type <syntax-tabletype>` :math:`\{\LMIN~n, \LMAX~m^?\}~\FUNCREF`.
224224

225225
.. math::
226226
\frac{
227227
((S \vdash \EVFUNC~\X{fa} : \ETFUNC~\functype)^?)^n
228228
\qquad
229-
\vdashlimits \{\LMIN~n, \LMAX~m^?\} \ok
229+
\vdashlimits \{\LMIN~n, \LMAX~m^?\} : 2^{32}
230230
}{
231231
S \vdashtableinst \{ \TIELEM~(\X{fa}^?)^n, \TIMAX~m^? \} : \{\LMIN~n, \LMAX~m^?\}~\FUNCREF
232232
}
@@ -238,13 +238,13 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
238238
:ref:`Memory Instances <syntax-meminst>` :math:`\{ \MIDATA~b^n, \MIMAX~m^? \}`
239239
..............................................................................
240240

241-
* The :ref:`limits <syntax-limits>` :math:`\{\LMIN~n, \LMAX~m^?\}` must be :ref:`valid <valid-limits>`.
241+
* The :ref:`limits <syntax-limits>` :math:`\{\LMIN~n, \LMAX~m^?\}` must be :ref:`valid <valid-limits>` within range :math:`2^{16}`.
242242

243243
* Then the memory instance is valid with :ref:`memory type <syntax-memtype>` :math:`\{\LMIN~n, \LMAX~m^?\}`.
244244

245245
.. math::
246246
\frac{
247-
\vdashlimits \{\LMIN~n, \LMAX~m^?\} \ok
247+
\vdashlimits \{\LMIN~n, \LMAX~m^?\} : 2^{16}
248248
}{
249249
S \vdashmeminst \{ \MIDATA~b^n, \MIMAX~m^? \} : \{\LMIN~n, \LMAX~m^?\}
250250
}

document/core/binary/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Their contents consist of a :ref:`name <syntax-name>` further identifying the cu
117117
\end{array}
118118
119119
.. note::
120-
If an implementation interprets the contents of a custom section, then errors in that contents, or the placement of the section, must not invalidate the module.
120+
If an implementation interprets the data of a custom section, then errors in that data, or the placement of the section, must not invalidate the module.
121121

122122

123123
.. index:: ! type section, type definition

document/core/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,9 @@
478478
rst_prolog = """
479479
.. include:: /""" + pwd + """/util/macros.def
480480
"""
481+
482+
# https://www.sphinx-doc.org/en/master/usage/extensions/math.html#confval-mathjax_config
483+
# http://docs.mathjax.org/en/v2.7-latest/options/input-processors/TeX.html
484+
mathjax_config = {
485+
'TeX': { 'MAXBUFFER': 30*1024 },
486+
}

document/core/exec/instructions.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,15 @@ Memory Instructions
591591

592592
8. Pop the value :math:`\I32.\CONST~n` from the stack.
593593

594-
9. Either, try :ref:`growing <grow-mem>` :math:`\X{mem}` by :math:`n` :ref:`pages <page-size>`:
594+
9. Let :math:`\X{err}` be the |i32| value :math:`2^{32}-1`, for which :math:`\signed_{32}(\X{err})` is :math:`-1`.
595+
596+
10. Either, try :ref:`growing <grow-mem>` :math:`\X{mem}` by :math:`n` :ref:`pages <page-size>`:
595597

596598
a. If it succeeds, push the value :math:`\I32.\CONST~\X{sz}` to the stack.
597599

598-
b. Else, push the value :math:`\I32.\CONST~(-1)` to the stack.
600+
b. Else, push the value :math:`\I32.\CONST~\X{err}` to the stack.
599601

600-
10. Or, push the value :math:`\I32.\CONST~(-1)` to the stack.
602+
11. Or, push the value :math:`\I32.\CONST~\X{err}` to the stack.
601603

602604
.. math::
603605
~\\[-1ex]
@@ -613,7 +615,7 @@ Memory Instructions
613615
\end{array}
614616
\\[1ex]
615617
\begin{array}{lcl@{\qquad}l}
616-
S; F; (\I32.\CONST~n)~\MEMORYGROW &\stepto& S; F; (\I32.\CONST~{-1})
618+
S; F; (\I32.\CONST~n)~\MEMORYGROW &\stepto& S; F; (\I32.\CONST~\signed_{32}^{-1}(-1))
617619
\end{array}
618620
\end{array}
619621

document/core/exec/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Modules
22
-------
33

4-
For modules, the execution semantics primarily defines :ref:`instantiation <exec-instantiation>`, which :ref:`allocates <alloc>` instances for a module and its contained definitions, inititializes :ref:`tables <syntax-table>` and :ref:`memories <syntax-mem>` from contained :ref:`element <syntax-elem>` and :ref:`data <syntax-data>` segments, and invokes the :ref:`start function <syntax-start>` if present. It also includes :ref:`invocation <exec-invocation>` of exported functions.
4+
For modules, the execution semantics primarily defines :ref:`instantiation <exec-instantiation>`, which :ref:`allocates <alloc>` instances for a module and its contained definitions, initializes :ref:`tables <syntax-table>` and :ref:`memories <syntax-mem>` from contained :ref:`element <syntax-elem>` and :ref:`data <syntax-data>` segments, and invokes the :ref:`start function <syntax-start>` if present. It also includes :ref:`invocation <exec-invocation>` of exported functions.
55

66
Instantiation depends on a number of auxiliary notions for :ref:`type-checking imports <exec-import>` and :ref:`allocating <alloc>` instances.
77

document/core/exec/numerics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ then its sign is non-deterministic and the :ref:`payload <syntax-payload>` is co
726726

727727
* If the payload of all NaN inputs to the operator is :ref:`canonical <canonical-nan>` (including the case that there are no NaN inputs), then the payload of the output is canonical as well.
728728

729-
* Otherwise the payload is picked non-determinsitically among all :ref:`arithmetic NaNs <arithmetic-nan>`; that is, its most significant bit is :math:`1` and all others are unspecified.
729+
* Otherwise the payload is picked non-deterministically among all :ref:`arithmetic NaNs <arithmetic-nan>`; that is, its most significant bit is :math:`1` and all others are unspecified.
730730

731731
This non-deterministic result is expressed by the following auxiliary function producing a set of allowed outputs from a set of inputs:
732732

document/core/exec/runtime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ That way, the end of the inner instruction sequence is known when part of an out
479479
When |END| is reached, i.e., the inner instruction sequence has been reduced to the empty sequence -- or rather, a sequence of :math:`n` |CONST| instructions representing the resulting values -- then the |LABEL| instruction is eliminated courtesy of its own :ref:`reduction rule <exec-label>`:
480480

481481
.. math::
482-
\LABEL_n\{\instr^n\}~\val^\ast~\END \quad\stepto\quad \val^n
482+
\LABEL_m\{\instr^\ast\}~\val^n~\END \quad\stepto\quad \val^n
483483
484484
This can be interpreted as removing the label from the stack and only leaving the locally accumulated operand values.
485485

document/core/text/modules.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,13 @@ The syntax for exports mirrors their :ref:`abstract syntax <syntax-export>` dire
422422
\text{(}~\text{export}~~\X{nm}{:}\Tname~~d{:}\Texportdesc_I~\text{)}
423423
&\Rightarrow& \{ \ENAME~\X{nm}, \EDESC~d \} \\
424424
\production{export description} & \Texportdesc_I &::=&
425-
\text{(}~\text{func}~~x{:}\Bfuncidx_I~\text{)}
425+
\text{(}~\text{func}~~x{:}\Tfuncidx_I~\text{)}
426426
&\Rightarrow& \EDFUNC~x \\ &&|&
427-
\text{(}~\text{table}~~x{:}\Btableidx_I~\text{)}
427+
\text{(}~\text{table}~~x{:}\Ttableidx_I~\text{)}
428428
&\Rightarrow& \EDTABLE~x \\ &&|&
429-
\text{(}~\text{memory}~~x{:}\Bmemidx_I~\text{)}
429+
\text{(}~\text{memory}~~x{:}\Tmemidx_I~\text{)}
430430
&\Rightarrow& \EDMEM~x \\ &&|&
431-
\text{(}~\text{global}~~x{:}\Bglobalidx_I~\text{)}
431+
\text{(}~\text{global}~~x{:}\Tglobalidx_I~\text{)}
432432
&\Rightarrow& \EDGLOBAL~x \\
433433
\end{array}
434434

document/core/text/values.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ Floating-Point
9696
h{:}\Thexdigit~~q{:}\Thexfrac &\Rightarrow& (h+q)/16 \\ &&|&
9797
h{:}\Thexdigit~~\text{\_}~~~~p{:}\Thexdigit~~q{:}\Thexfrac &\Rightarrow& (h+(p+q)/16)/16 \\
9898
\production{decimal floating-point number} & \Tfloat &::=&
99+
p{:}\Tnum
100+
&\Rightarrow& p \\ &&|&
99101
p{:}\Tnum~\text{.}~q{:}\Tfrac
100102
&\Rightarrow& p+q \\ &&|&
101103
p{:}\Tnum~(\text{E}~|~\text{e})~{\pm}{:}\Tsign~e{:}\Tnum
102104
&\Rightarrow& p\cdot 10^{\pm e} \\ &&|&
103105
p{:}\Tnum~\text{.}~q{:}\Tfrac~(\text{E}~|~\text{e})~{\pm}{:}\Tsign~e{:}\Tnum
104106
&\Rightarrow& (p+q)\cdot 10^{\pm e} \\
105107
\production{hexadecimal floating-point number} & \Thexfloat &::=&
108+
\text{0x}~p{:}\Thexnum
109+
&\Rightarrow& p \\ &&|&
106110
\text{0x}~p{:}\Thexnum~\text{.}~q{:}\Thexfrac
107111
&\Rightarrow& p+q \\ &&|&
108112
\text{0x}~p{:}\Thexnum~(\text{P}~|~\text{p})~{\pm}{:}\Tsign~e{:}\Tnum

document/core/util/bikeshed_fixup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env python
1+
#! /usr/bin/env python3
22
# -*- coding: latin-1 -*-
33

44
import os

document/core/util/mathdef.py

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
from sphinx.ext.mathbase import math
2-
from sphinx.ext.mathbase import displaymath
3-
from sphinx.ext.mathbase import math_role
42
from sphinx.ext.mathbase import MathDirective
5-
from sphinx.ext.mathbase import latex_visit_math
6-
from sphinx.ext.mathbase import latex_visit_displaymath
7-
from sphinx.ext.mathjax import html_visit_math
8-
from sphinx.ext.mathjax import html_visit_displaymath
9-
from sphinx.util.texescape import tex_escape_map, tex_replace_map
3+
from sphinx.util.texescape import tex_replace_map
4+
from sphinx.writers.html5 import HTML5Translator
5+
from sphinx.writers.latex import LaTeXTranslator
6+
from docutils import nodes
107
from docutils.parsers.rst.directives.misc import Replace
118
from six import text_type
129
import re
@@ -20,16 +17,8 @@ def html_hyperlink(file, id):
2017
return '\\href{../%s.html#%s}' % (file, id.replace('_', '-'))
2118

2219
def html_transform_math_xref(node):
23-
node['latex'] = \
24-
xref_re.sub(lambda m: html_hyperlink(m.group(1), m.group(2)), node['latex'])
25-
26-
def ext_html_visit_math(self, node):
27-
html_transform_math_xref(node)
28-
html_visit_math(self, node)
29-
30-
def ext_html_visit_displaymath(self, node):
31-
html_transform_math_xref(node)
32-
html_visit_displaymath(self, node)
20+
new_text = xref_re.sub(lambda m: html_hyperlink(m.group(1), m.group(2)), node.astext())
21+
node.children[0] = nodes.Text(new_text)
3322

3423
# Mirrors sphinx/writers/latex
3524
def latex_hyperlink(file, id):
@@ -39,17 +28,8 @@ def latex_hyperlink(file, id):
3928
return '\\hyperref[%s:%s]' % (file, id)
4029

4130
def latex_transform_math_xref(node):
42-
node['latex'] = \
43-
xref_re.sub(lambda m: latex_hyperlink(m.group(1), m.group(2)), node['latex'])
44-
45-
def ext_latex_visit_math(self, node):
46-
latex_transform_math_xref(node)
47-
latex_visit_math(self, node)
48-
49-
def ext_latex_visit_displaymath(self, node):
50-
latex_transform_math_xref(node)
51-
latex_visit_displaymath(self, node)
52-
31+
new_text = xref_re.sub(lambda m: latex_hyperlink(m.group(1), m.group(2)), node.astext())
32+
node.children[0] = nodes.Text(new_text)
5333

5434
# Expand mathdef names in math roles and directives
5535

@@ -75,8 +55,7 @@ def replace_mathdefs(doc, s):
7555

7656
def ext_math_role(role, raw, text, line, inliner, options = {}, content = []):
7757
text = replace_mathdefs(inliner.document, raw.split('`')[1])
78-
return math_role(role, raw, text, line, inliner, options = options,
79-
content = content)
58+
return [math(raw, text)], []
8059

8160
class ExtMathDirective(MathDirective):
8261
def run(self):
@@ -85,7 +64,7 @@ def run(self):
8564
self.content[i] = replace_mathdefs(doc, s)
8665
for i, s in enumerate(self.arguments):
8766
self.arguments[i] = replace_mathdefs(doc, s)
88-
return super(ExtMathDirective, self).run()
67+
return super().run()
8968

9069
class MathdefDirective(Replace):
9170
def run(self):
@@ -99,23 +78,45 @@ def run(self):
9978
doc = self.state.document
10079
if not hasattr(doc, 'mathdefs'):
10180
doc.mathdefs = {}
81+
# TODO: we don't ever hit the case where len(self.content) > 1
10282
for i, s in enumerate(self.content):
10383
self.content[i] = replace_mathdefs(doc, s)
10484
doc.mathdefs[name] = [arity, ''.join(self.content)]
10585
self.content[0] = ':math:`' + self.content[0]
10686
self.content[-1] = self.content[-1] + '`'
107-
return super(MathdefDirective, self).run()
108-
87+
return super().run()
88+
89+
class WebAssemblyHTML5Translator(HTML5Translator):
90+
"""
91+
Customize HTML5Translator.
92+
Convert xref in math and math block nodes to hrefs.
93+
"""
94+
def visit_math(self, node, math_env = ''):
95+
html_transform_math_xref(node)
96+
super().visit_math(node, math_env)
97+
98+
def visit_math_block(self, node, math_env = ''):
99+
html_transform_math_xref(node)
100+
super().visit_math_block(node, math_env)
101+
102+
class WebAssemblyLaTeXTranslator(LaTeXTranslator):
103+
"""
104+
Customize LaTeXTranslator.
105+
Convert xref in math and math block nodes to hyperrefs.
106+
"""
107+
def visit_math(self, node):
108+
latex_transform_math_xref(node)
109+
super().visit_math(node)
110+
111+
def visit_math_block(self, node):
112+
latex_transform_math_xref(node)
113+
super().visit_math_block(node)
109114

110115
# Setup
111116

112117
def setup(app):
113-
app.add_node(math,
114-
html = (ext_html_visit_math, None),
115-
latex = (ext_latex_visit_math, None))
116-
app.add_node(displaymath,
117-
html = (ext_html_visit_displaymath, None),
118-
latex = (ext_latex_visit_displaymath, None))
118+
app.set_translator('html', WebAssemblyHTML5Translator)
119+
app.set_translator('latex', WebAssemblyLaTeXTranslator)
119120
app.add_role('math', ext_math_role)
120-
app.add_directive('math', ExtMathDirective)
121+
app.add_directive('math', ExtMathDirective, override = True)
121122
app.add_directive('mathdef', MathdefDirective)

0 commit comments

Comments
 (0)