Skip to content

Commit

Permalink
Merge pull request WebAssembly#32 from dhil/wasmfx-merge
Browse files Browse the repository at this point in the history
Merge with upstream/`wasm-3.0+exn`
  • Loading branch information
dhil committed Apr 29, 2024
2 parents 1638fad + dda380b commit 0c0fed4
Show file tree
Hide file tree
Showing 32 changed files with 828 additions and 171 deletions.
6 changes: 5 additions & 1 deletion document/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ publish-main: clean main bikeshed-keep deploy
all: pdf html bikeshed

.PHONY: main
main: pdf html
main: macrosok pdf html

# Dirty hack to avoid rebuilding the Bikeshed version for every push.
.PHONY: bikeshed-keep
Expand All @@ -97,6 +97,10 @@ GENERATED = appendix/index-instructions.rst
%.rst: %.py
(cd `dirname $@`; ./`basename $^`)

.PHONY: macrosok
macrosok: $(GENERATED)
sh util/check_macros.sh

.PHONY: pdf
pdf: $(GENERATED) latexpdf
mkdir -p $(BUILDDIR)/html/$(DOWNLOADDIR)
Expand Down
21 changes: 18 additions & 3 deletions document/core/appendix/embedding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,12 @@ Globals
\end{array}
.. index:: reference, reference type
.. index:: reference, reference type, value type, value
.. _embed-ref-type:
.. _embed-val-default:

References
~~~~~~~~~~
Values
~~~~~~

:math:`\F{ref\_type}(\store, \reff) : \reftype`
...............................................
Expand All @@ -678,6 +679,20 @@ References
In such cases, this function may return a less precise supertype.


:math:`\F{val\_default}(\valtype) : \val`
...............................................

1. If :math:`\default_{valtype}` is not defined, then return :math:`\ERROR`.

1. Else, return the :ref:`value <syntax-val>` :math:`\default_{valtype}`.

.. math::
\begin{array}{lclll}
\F{val\_default}(t) &=& v && (\iff \default_t = v) \\
\F{val\_default}(t) &=& \ERROR && (\iff \default_t = \epsilon) \\
\end{array}
.. index:: value type, external type, subtyping
.. _embed-match-valtype:
.. _embed-match-externtype:
Expand Down
2 changes: 1 addition & 1 deletion document/core/appendix/index-instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
Instruction(r'\BRONCASTFAIL~t_1~t_2', r'\hex{FB}~\hex{19}', r'[t_1] \to [t_2]', r'valid-br_on_cast_fail', r'exec-br_on_cast_fail'),
Instruction(r'\ANYCONVERTEXTERN', r'\hex{FB}~\hex{1A}', r'[(\REF~\NULL~\EXTERN)] \to [(\REF~\NULL~\ANY)]', r'valid-any.convert_extern', r'exec-any.convert_extern'),
Instruction(r'\EXTERNCONVERTANY', r'\hex{FB}~\hex{1B}', r'[(\REF~\NULL~\ANY)] \to [(\REF~\NULL~\EXTERN)]', r'valid-extern.convert_any', r'exec-extern.convert_any'),
Instruction(r'\REFI31', r'\hex{FB}~\hex{1C}', r'[\I32] \to [\I31REF]', r'valid-ref.i31', r'exec-ref.i31'),
Instruction(r'\REFI31', r'\hex{FB}~\hex{1C}', r'[\I32] \to [(\REF~\I31)]', r'valid-ref.i31', r'exec-ref.i31'),
Instruction(r'\I31GETS', r'\hex{FB}~\hex{1D}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'),
Instruction(r'\I31GETU', r'\hex{FB}~\hex{1E}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'),
Instruction(None, r'\hex{FB}~\hex{1E} \dots'),
Expand Down
4 changes: 2 additions & 2 deletions document/core/appendix/properties.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In order to state and prove soundness precisely, the typing rules must be extend


.. index:: context, recursive type, recursive type index
.. context-rec:
.. _context-ext:

Contexts
~~~~~~~~
Expand Down Expand Up @@ -832,7 +832,7 @@ where :math:`\val_1 \gg^+_S \val_2` denotes the transitive closure of the follow
* Let :math:`x^\ast` be the sequence of :ref:`function indices <syntax-funcidx>` from :math:`0` to :math:`m-1`.

* Then the module instance is valid with :ref:`context <context>`
:math:`\{\CTYPES~\deftype^\ast,` :math:`\CFUNCS~\functype^\ast,` :math:`\CTABLES~\tabletype^\ast,` :math:`\CMEMS~\memtype^\ast,` :math:`\CGLOBALS~\globaltype^\ast,` \CTAGS~\tagtype^\ast, :math:`\CELEMS~\reftype^\ast,` :math:`\CDATAS~{\ok}^n\}`.
:math:`\{\CTYPES~\deftype^\ast,` :math:`\CFUNCS~\functype^\ast,` :math:`\CTABLES~\tabletype^\ast,` :math:`\CMEMS~\memtype^\ast,` :math:`\CGLOBALS~\globaltype^\ast,` \CTAGS~\tagtype^\ast, :math:`\CELEMS~\reftype^\ast,` :math:`\CDATAS~{\ok}^n,` :math:`\CREFS~x^\ast\}`.

.. math::
~\\[-1ex]
Expand Down
6 changes: 3 additions & 3 deletions document/core/binary/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ It decodes into a vector of :ref:`element segments <syntax-elem>` that represent
\production{element segment} & \Belem &::=&
0{:}\Bu32~~e{:}\Bexpr~~y^\ast{:}\Bvec(\Bfuncidx)
&\Rightarrow& \\&&&\quad
\{ \ETYPE~(\REF~\NULL~\FUNC), \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|&
\{ \ETYPE~(\REF~\FUNC), \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|&
1{:}\Bu32~~\X{et}:\Belemkind~~y^\ast{:}\Bvec(\Bfuncidx)
&\Rightarrow& \\&&&\quad
\{ \ETYPE~\X{et}, \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EPASSIVE \} \\ &&|&
Expand All @@ -362,7 +362,7 @@ It decodes into a vector of :ref:`element segments <syntax-elem>` that represent
\{ \ETYPE~\X{et}, \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EDECLARATIVE \} \\ &&|&
4{:}\Bu32~~e{:}\Bexpr~~\X{el}^\ast{:}\Bvec(\Bexpr)
&\Rightarrow& \\&&&\quad
\{ \ETYPE~(\REF~\NULL~\FUNC), \EINIT~\X{el}^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|&
\{ \ETYPE~(\REF~\FUNC), \EINIT~\X{el}^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|&
5{:}\Bu32~~\X{et}:\Breftype~~\X{el}^\ast{:}\Bvec(\Bexpr)
&\Rightarrow& \\&&&\quad
\{ \ETYPE~et, \EINIT~\X{el}^\ast, \EMODE~\EPASSIVE \} \\ &&|&
Expand All @@ -373,7 +373,7 @@ It decodes into a vector of :ref:`element segments <syntax-elem>` that represent
&\Rightarrow& \\&&&\quad
\{ \ETYPE~et, \EINIT~\X{el}^\ast, \EMODE~\EDECLARATIVE \} \\
\production{element kind} & \Belemkind &::=&
\hex{00} &\Rightarrow& \FUNCREF \\
\hex{00} &\Rightarrow& (\REF~\FUNC) \\
\end{array}
.. note::
Expand Down
44 changes: 22 additions & 22 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,14 @@ Reference Instructions
S; F; (\I32.\CONST~s)~(\I32.\CONST~n)~(\ARRAYNEWDATA~x~y) &\stepto& \TRAP
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
\land & s + n\cdot|\X{ft}|/8 > |S.\SDATAS[F.\AMODULE.\MIDATAS[y]].\DIDATA|)
\end{array} \\
\\[1ex]
S; F; (\I32.\CONST~s)~(\I32.\CONST~n)~(\ARRAYNEWDATA~x~y) &\stepto& (t.\CONST~c)^n~(\ARRAYNEWFIXED~x~n)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
\land & t = \unpacktype(\X{ft}) \\
\land & \concat((\bytes_{\X{ft}}(c))^n) = S.\SDATAS[F.\AMODULE.\MIDATAS[y]].\DIDATA[s \slice n\cdot|\X{ft}|/8] \\
\end{array} \\
Expand Down Expand Up @@ -1065,7 +1065,7 @@ Reference Instructions

12. Assert: due to :ref:`validation <valid-array.fill>`, the :ref:`array instance <syntax-arrayinst>` :math:`S.\SARRAYS[a]` exists.

13. If :math:`d + n` is larger than or equal to the length of :math:`S.\SARRAYS[a].\AIFIELDS`, then:
13. If :math:`d + n` is larger than the length of :math:`S.\SARRAYS[a].\AIFIELDS`, then:

a. Trap.

Expand Down Expand Up @@ -1102,13 +1102,13 @@ Reference Instructions
(\iff d + n > |S.\SARRAYS[a].\AIFIELDS|)
\\[1ex]
S; (\REFARRAYADDR~a)~(\I32.\CONST~d)~\val~(\I32.\CONST~0)~(\ARRAYFILL~x)
\quad\stepto\quad S; \epsilon
\quad\stepto\quad \epsilon
\\ \qquad
(\otherwise)
\\[1ex]
S; (\REFARRAYADDR~a)~(\I32.\CONST~d)~\val~(\I32.\CONST~n+1)~(\ARRAYFILL~x)
\quad\stepto
\\ \quad S;
\\ \quad
\begin{array}[t]{@{}l@{}}
(\REFARRAYADDR~a)~(\I32.\CONST~d)~\val~(\ARRAYSET~x) \\
(\REFARRAYADDR~a)~(\I32.\CONST~d+1)~\val~(\I32.\CONST~n)~(\ARRAYFILL~x) \\
Expand Down Expand Up @@ -1175,11 +1175,11 @@ Reference Instructions

23. Assert: due to :ref:`validation <valid-array.copy>`, the :ref:`array instance <syntax-arrayinst>` :math:`S.\SARRAYS[a_2]` exists.

24. If :math:`d + n` is larger than or equal to the length of :math:`S.\SARRAYS[a_1].\AIFIELDS`, then:
24. If :math:`d + n` is larger than the length of :math:`S.\SARRAYS[a_1].\AIFIELDS`, then:

a. Trap.

25. If :math:`s + n` is larger than or equal to the length of :math:`S.\SARRAYS[a_2].\AIFIELDS`, then:
25. If :math:`s + n` is larger than the length of :math:`S.\SARRAYS[a_2].\AIFIELDS`, then:

a. Trap.

Expand Down Expand Up @@ -1252,7 +1252,7 @@ Reference Instructions
(\iff d + n > |S.\SARRAYS[a_1].\AIFIELDS| \vee s + n > |S.\SARRAYS[a_2].\AIFIELDS|)
\\[1ex]
S; F; (\REFARRAYADDR~a_1)~(\I32.\CONST~d)~(\REFARRAYADDR~a_2)~(\I32.\CONST~s)~(\I32.\CONST~0)~(\ARRAYCOPY~x~y)
\quad\stepto\quad S; \epsilon
\quad\stepto\quad \epsilon
\\ \qquad
(\otherwise)
\\[1ex]
Expand Down Expand Up @@ -1391,13 +1391,13 @@ Where:
\end{array}
\\[1ex]
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~0)~(\ARRAYINITDATA~x~y)
\quad\stepto\quad S; F; \epsilon
\quad\stepto\quad \epsilon
\\ \qquad
(\otherwise)
\\[1ex]
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~n+1)~(\ARRAYINITDATA~x~y)
\quad\stepto
\\ \quad S; F;
\\ \quad
\begin{array}[t]{@{}l@{}}
(\REFARRAYADDR~a)~(\I32.\CONST~d)~(t.\CONST~c)~(\ARRAYSET~x) \\
(\REFARRAYADDR~a)~(\I32.\CONST~d+1)~(\I32.\CONST~s+|\X{ft}|/8)~(\I32.\CONST~n)~(\ARRAYINITDATA~x~y) \\
Expand Down Expand Up @@ -1497,13 +1497,13 @@ Where:
\end{array}
\\[1ex]
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~0)~(\ARRAYINITELEM~x~y)
\quad\stepto\quad S; F; \epsilon
\quad\stepto\quad \epsilon
\\ \qquad
(\otherwise)
\\[1ex]
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~n+1)~(\ARRAYINITELEM~x~y)
\quad\stepto
\\ \quad S; F;
\\ \quad
\begin{array}[t]{@{}l@{}}
(\REFARRAYADDR~a)~(\I32.\CONST~d)~\REF~(\ARRAYSET~x) \\
(\REFARRAYADDR~a)~(\I32.\CONST~d+1)~(\I32.\CONST~s+1)~(\I32.\CONST~n)~(\ARRAYINITELEM~x~y) \\
Expand Down Expand Up @@ -1538,7 +1538,7 @@ Where:

.. math::
\begin{array}{lcl@{\qquad}l}
(\REFNULL \X{ht})~\ANYCONVERTEXTERN &\stepto& (\REFNULL~\ANY) \\
(\REFNULL~\X{ht})~\ANYCONVERTEXTERN &\stepto& (\REFNULL~\ANY) \\
(\REFEXTERN~\reff)~\ANYCONVERTEXTERN &\stepto& \reff \\
\end{array}
Expand All @@ -1564,8 +1564,8 @@ Where:

.. math::
\begin{array}{lcl@{\qquad}l}
(\REFNULL \X{ht})~\EXTERNCONVERTANY &\stepto& (\REFNULL~\EXTERN) \\
\reff~\EXTERNCONVERTANY &\stepto& (\REFEXTERN~\reff) & (\iff \reff \neq (\REFNULL \X{ht})) \\
(\REFNULL~\X{ht})~\EXTERNCONVERTANY &\stepto& (\REFNULL~\EXTERN) \\
\reff~\EXTERNCONVERTANY &\stepto& (\REFEXTERN~\reff) & (\iff \reff \neq (\REFNULL~\X{ht})) \\
\end{array}
Expand Down Expand Up @@ -1776,7 +1776,7 @@ Most other vector instructions are defined in terms of numeric operators that ar
:math:`\shape\K{.}\SPLAT`
.........................

1. Let :math:`t` be the type :math:`\unpacked(\shape)`.
1. Let :math:`t` be the type :math:`\unpackshape(\shape)`.

2. Assert: due to :ref:`validation <valid-vec-splat>`, a value of :ref:`value type <syntax-valtype>` :math:`t` is on the top of the stack.

Expand All @@ -1791,7 +1791,7 @@ Most other vector instructions are defined in terms of numeric operators that ar
.. math::
\begin{array}{lcl@{\qquad}l}
(t\K{.}\CONST~c_1)~\shape\K{.}\SPLAT &\stepto& (\V128\K{.}\VCONST~c)
& (\iff t = \unpacked(\shape)
& (\iff t = \unpackshape(\shape)
\wedge c = \lanes^{-1}_{\shape}(c_1^{\dim(\shape)}))
\\
\end{array}
Expand All @@ -1810,7 +1810,7 @@ Most other vector instructions are defined in terms of numeric operators that ar

4. Let :math:`i^\ast` be the result of computing :math:`\lanes_{t_1\K{x}N}(c_1)`.

5. Let :math:`t_2` be the type :math:`\unpacked(t_1\K{x}N)`.
5. Let :math:`t_2` be the type :math:`\unpackshape(t_1\K{x}N)`.

6. Let :math:`c_2` be the result of computing :math:`\extend^{sx^?}_{t_1,t_2}(i^\ast[x])`.

Expand All @@ -1823,7 +1823,7 @@ Most other vector instructions are defined in terms of numeric operators that ar
\end{array}
\\ \qquad
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & t_2 = \unpacked(t_1\K{x}N) \\
(\iff & t_2 = \unpackshape(t_1\K{x}N) \\
\wedge & c_2 = \extend^{sx^?}_{t_1,t_2}(\lanes_{t_1\K{x}N}(c_1)[x]))
\end{array}
\end{array}
Expand All @@ -1836,7 +1836,7 @@ Most other vector instructions are defined in terms of numeric operators that ar

1. Assert: due to :ref:`validation <valid-vec-replace_lane>`, :math:`x < \dim(\shape)`.

2. Let :math:`t_2` be the type :math:`\unpacked(\shape)`.
2. Let :math:`t_2` be the type :math:`\unpackshape(\shape)`.

3. Assert: due to :ref:`validation <valid-vec-replace_lane>`, a value of :ref:`value type <syntax-valtype>` :math:`t_1` is on the top of the stack.

Expand Down Expand Up @@ -4377,7 +4377,7 @@ Control Instructions
\begin{array}{lcl@{\qquad}l}
S; F; \reff~(\BRONCAST~l~\X{rt}_1~\X{rt}_2) &\stepto& \reff~(\BR~l)
& (\iff S \vdashval \reff : \X{rt}
\land \vdashreftypematch \X{rt} \matchesreftype \insttype_{F.\AMODULE}(\X{rt}_2)) \\
\land {} \vdashreftypematch \X{rt} \matchesreftype \insttype_{F.\AMODULE}(\X{rt}_2)) \\
S; F; \reff~(\BRONCAST~l~\X{rt}_1~\X{rt}_2) &\stepto& \reff
& (\otherwise) \\
\end{array}
Expand Down Expand Up @@ -4412,7 +4412,7 @@ Control Instructions
\begin{array}{lcl@{\qquad}l}
S; F; \reff~(\BRONCASTFAIL~l~\X{rt}_1~\X{rt}_2) &\stepto& \reff
& (\iff S \vdashval \reff : \X{rt}
\land \vdashreftypematch \X{rt} \matchesreftype \insttype_{F.\AMODULE}(\X{rt}_2)) \\
\land {} \vdashreftypematch \X{rt} \matchesreftype \insttype_{F.\AMODULE}(\X{rt}_2)) \\
S; F; \reff~(\BRONCASTFAIL~l~\X{rt}_1~\X{rt}_2) &\stepto& \reff~(\BR~l)
& (\otherwise) \\
\end{array}
Expand Down
3 changes: 2 additions & 1 deletion document/core/exec/runtime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ Conventions
.. math::
\begin{array}{@{}lcl}
\packval_{\valtype}(\val) &=& \val \\
\packval_{\packedtype}(\I32.\CONST~i) &=& \packedtype.\PACK~(\wrap_{32,|\packtype|}(i))
\packval_{\packedtype}(\I32.\CONST~i) &=& \packedtype.\PACK~(\wrap_{32,|\packedtype|}(i))
\end{array}
* The inverse conversion of a :ref:`field value <syntax-fieldval>` to a regular :ref:`value <syntax-val>` is defined as follows:
Expand Down Expand Up @@ -726,6 +726,7 @@ Conventions
pair:: abstract syntax; administrative instruction
.. _syntax-trap:
.. _syntax-invoke:
.. _syntax-return_invoke:
.. _syntax-instr-admin:

Administrative Instructions
Expand Down
2 changes: 1 addition & 1 deletion document/core/exec/values.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The following auxiliary typing rules specify this typing relation relative to a

* The :ref:`heap type <syntax-heaptype>` must be :ref:`valid <valid-heaptype>` under the empty :ref:`context <context>`.

* Then value is valid with :ref:`reference type <syntax-reftype>` :math:`(\REF~\NULL~t')`, where the :ref:`heap type <syntax-heaptype>` :math:`t'` that is the least type that :ref:`matches <match-heaptype>` :math:`t`.
* Then the value is valid with :ref:`reference type <syntax-reftype>` :math:`(\REF~\NULL~t')`, where the :ref:`heap type <syntax-heaptype>` :math:`t'` is the least type that :ref:`matches <match-heaptype>` :math:`t`.

.. math::
\frac{
Expand Down
10 changes: 10 additions & 0 deletions document/core/syntax/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Conventions
.. _type-concrete:
.. _syntax-i31:
.. _syntax-heaptype:
.. _syntax-absheaptype:

Heap Types
~~~~~~~~~~
Expand Down Expand Up @@ -298,12 +299,21 @@ Structures are heterogeneous, but require static indexing, while arrays need to
\end{array}
.. _bitwidth-fieldtype:
.. _aux-unpacktype:

Conventions
...........

* The notation :math:`|t|` for :ref:`bit width <bitwidth-valtype>` extends to packed types as well, that is, :math:`|\I8| = 8` and :math:`|\I16| = 16`.

* The auxiliary function :math:`\unpacktype` maps a storage type to the :ref:`value type <syntax-valtype>` obtained when accessing a field:

.. math::
\begin{array}{lll}
\unpacktype(\valtype) &=& \valtype \\
\unpacktype(\packedtype) &=& \I32 \\
\end{array}
.. index:: ! composite type, function type, aggreagate type, structure type, array type
pair: abstract syntax; composite type
Expand Down
3 changes: 2 additions & 1 deletion document/core/text/lexical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ Any token that does not fall into any of the other categories is considered *res

.. index:: ! white space, character, ASCII
single: text format; white space
.. _text-format:
.. _text-space:
.. _text-format:
.. _text-newline:

White Space
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion document/core/text/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ As another abbreviation, element segments may also be specified inline with :ref
single: data; segment
.. _text-datastring:
.. _text-data:
.. _test-memuse:
.. _text-memuse:

Data Segments
~~~~~~~~~~~~~
Expand Down
32 changes: 32 additions & 0 deletions document/core/util/check_macros.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

cd `dirname $0`/..

FILES=`ls */*.rst`
ERRORS=0

for XREF in `grep "[\\]xref" util/macros.def`; do
if echo $XREF | grep -q "[|]"; then
MACRO=`echo $XREF | sed 's/^[^|]*[|]//g' | sed 's/[|].*$//g'`
elif echo $XREF | grep -q xref; then
FILE=`echo $XREF | sed 's/^.*xref{//g' | sed 's/}.*$//g'`.rst
LABEL=`echo $XREF | sed 's/^[^}]*}{//g' | sed 's/}.*$//g'`
TARGET=".. _$LABEL:"
if ! [ -f $FILE ] || ! grep -q "$TARGET" $FILE; then
ERRORS=1
echo Undefined cross-reference $FILE:$LABEL in macro "|$MACRO|"
if ! [ -f $FILE ]; then
echo ...non-existent file $FILE
fi
if grep -q "$TARGET" $FILES; then
echo ...defined in `grep -l "$TARGET" $FILES`
fi
fi
fi
done

if [ $ERRORS -eq 0 ]; then
echo All cross-references okay.
else
exit 1;
fi
Loading

0 comments on commit 0c0fed4

Please sign in to comment.