diff options
-rw-r--r-- | .rev-xmlo | 2 | ||||
-rw-r--r-- | src/current/compiler/fragments.xsl | 43 | ||||
-rw-r--r-- | src/current/compiler/map.xsl | 10 | ||||
-rw-r--r-- | src/current/include/depgen.xsl | 20 | ||||
-rw-r--r-- | tamer/src/ld/poc.rs | 8 |
5 files changed, 66 insertions, 17 deletions
@@ -1,4 +1,4 @@ # This number is incremented for every compiler change to force rebuilding # of xmlo files. -0 +1 diff --git a/src/current/compiler/fragments.xsl b/src/current/compiler/fragments.xsl index 7a4cbad..cf41132 100644 --- a/src/current/compiler/fragments.xsl +++ b/src/current/compiler/fragments.xsl @@ -31,21 +31,42 @@ <template mode="preproc:compile-fragments" priority="9" match="lv:package"> + <copy> + <sequence select="@*" /> + + <apply-templates select="*" mode="preproc:compile-fragments-root" /> + </copy> +</template> + + +<template mode="preproc:compile-fragments-root" priority="1" + match="node()"> + <sequence select="." /> +</template> + + +<!-- Position fragments directly after dependencies. This allows TAMER to + halt processing early on, rather than having to read the rest of the + file (fragments used to be placed at the end). --> +<template mode="preproc:compile-fragments-root" priority="5" + match="preproc:sym-deps"> + <sequence select="." /> + + <variable name="package" as="element( lv:package )" + select="parent::lv:package" /> + <variable name="symtable-map" as="map( xs:string, element( preproc:sym ) )" select="map:merge( - for $sym in preproc:symtable/preproc:sym + for $sym in $package/preproc:symtable/preproc:sym return map{ string( $sym/@name ) : $sym } )" /> - <copy> - <sequence select="@*, *" /> - - <preproc:fragments> - <apply-templates mode="preproc:compile-fragments"> - <with-param name="symtable-map" select="$symtable-map" - tunnel="yes" /> - </apply-templates> - </preproc:fragments> - </copy> + <preproc:fragments> + <apply-templates select="$package/*" + mode="preproc:compile-fragments"> + <with-param name="symtable-map" select="$symtable-map" + tunnel="yes" /> + </apply-templates> + </preproc:fragments> </template> diff --git a/src/current/compiler/map.xsl b/src/current/compiler/map.xsl index e2620e4..1a1a9a2 100644 --- a/src/current/compiler/map.xsl +++ b/src/current/compiler/map.xsl @@ -123,7 +123,8 @@ <!-- final result with compiled fragments --> <lv:package> <sequence select="$pkg-with-symtable/@*, - $pkg-with-symtable/node()" /> + $pkg-with-symtable/preproc:sym-deps/preceding-sibling::*, + $pkg-with-symtable/preproc:sym-deps" /> <preproc:fragments> <!-- special fragment to be output as the head --> @@ -148,6 +149,8 @@ <text>};</text> </preproc:fragment> </preproc:fragments> + + <sequence select="$pkg-with-symtable/preproc:sym-deps/following-sibling::*" /> </lv:package> </template> @@ -197,7 +200,8 @@ <!-- final result with compiled fragments --> <lv:package> <sequence select="$pkg-with-symtable/@*, - $pkg-with-symtable/node()" /> + $pkg-with-symtable/preproc:sym-deps/preceding-sibling::*, + $pkg-with-symtable/preproc:sym-deps" /> <preproc:fragments> <!-- special fragment to be output as the head --> @@ -222,6 +226,8 @@ <text>};</text> </preproc:fragment> </preproc:fragments> + + <sequence select="$pkg-with-symtable/preproc:sym-deps/following-sibling::*" /> </lv:package> </template> diff --git a/src/current/include/depgen.xsl b/src/current/include/depgen.xsl index 8decc67..8f7c73f 100644 --- a/src/current/include/depgen.xsl +++ b/src/current/include/depgen.xsl @@ -66,13 +66,27 @@ <text>[depgen] *determining symbol dependencies...</text> </message> - <apply-templates select="preproc:symtable" mode="preproc:depgen" /> - - <sequence select="*" /> + <apply-templates select="*" mode="preproc:depgen-root" /> </copy> </template> +<template mode="preproc:depgen-root" priority="1" + match="node()"> + <sequence select="." /> +</template> + + +<template mode="preproc:depgen-root" priority="5" + match="preproc:symtable"> + <!-- Place symbol table _before_ dependencies. This simplifies + streaming processing in TAMER. --> + <sequence select="." /> + + <apply-templates select="." mode="preproc:depgen" /> +</template> + + <template match="preproc:symtable" mode="preproc:depgen" priority="9"> <variable name="symtable" select="." /> diff --git a/tamer/src/ld/poc.rs b/tamer/src/ld/poc.rs index d7f9733..2cf0100 100644 --- a/tamer/src/ld/poc.rs +++ b/tamer/src/ld/poc.rs @@ -314,6 +314,14 @@ fn load_xmlo<'a>( _ => Ok(()), } } + Ok(Event::End(ele)) => { + match ele.name() { + // We don't need to read any further than the end of + // the fragments (symtable, sym-deps, fragments) + b"preproc:fragments" => break (), + _ => Ok(()), + } + } Ok(Event::Eof) => break (), Err(e) => { panic!("Error at {}: {:?}", reader.buffer_position(), e); |