| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.style; |
| 9 | |
| 10 | import net.sf.saxon.expr.Component; |
| 11 | import net.sf.saxon.expr.instruct.Actor; |
| 12 | import net.sf.saxon.expr.instruct.SlotManager; |
| 13 | import net.sf.saxon.expr.parser.Optimizer; |
| 14 | import net.sf.saxon.trans.SymbolicName; |
| 15 | import net.sf.saxon.trans.XPathException; |
| 16 | |
| 17 | /** |
| 18 | * This interface is implemented by all top-level XSL elements that can contain local variable declarations. |
| 19 | * Specifically, a top-level xsl:template, xsl:variable, xsl:param, or xsl:function element |
| 20 | * or an xsl:attribute-set, xsl:accumulator, or xsl:key element. |
| 21 | */ |
| 22 | |
| 23 | public interface StylesheetComponent { |
| 24 | |
| 25 | /** |
| 26 | * Get the SlotManager associated with this stylesheet construct. The SlotManager contains the |
| 27 | * information needed to manage the local stack frames used by run-time instances of the code. |
| 28 | * |
| 29 | * @return the associated SlotManager object |
| 30 | */ |
| 31 | |
| 32 | SlotManager getSlotManager(); |
| 33 | |
| 34 | /** |
| 35 | * Optimize the stylesheet construct |
| 36 | * |
| 37 | * @param declaration the combination of the source XSLT element defining the component, and the |
| 38 | * module in which it appears |
| 39 | */ |
| 40 | |
| 41 | void optimize(ComponentDeclaration declaration) throws XPathException; |
| 42 | |
| 43 | /** |
| 44 | * Generate byte code if appropriate |
| 45 | * @param opt the optimizer |
| 46 | * @throws XPathException if bytecode generation fails |
| 47 | */ |
| 48 | |
| 49 | void generateByteCode(Optimizer opt) throws XPathException; |
| 50 | |
| 51 | /** |
| 52 | * Get the corresponding Actor object that results from the compilation of this |
| 53 | * StylesheetComponent |
| 54 | * @return the compiled ComponentCode |
| 55 | * @throws XPathException if generating the ComponentBody fails |
| 56 | * @throws UnsupportedOperationException for second-class components such as keys that support outwards references |
| 57 | * but not inwards references |
| 58 | */ |
| 59 | |
| 60 | Actor getActor() throws XPathException; |
| 61 | |
| 62 | /** |
| 63 | * Get the symbolic name of the component, that is, the combination of the component kind and |
| 64 | * the qualified name |
| 65 | * @return the component's symbolic name |
| 66 | */ |
| 67 | |
| 68 | SymbolicName getSymbolicName(); |
| 69 | |
| 70 | /** |
| 71 | * Check the compatibility of this component with another component that it is overriding |
| 72 | * @param component the overridden component |
| 73 | * @throws XPathException if the components are not compatible (differing signatures) |
| 74 | */ |
| 75 | |
| 76 | void checkCompatibility(Component component) throws XPathException; |
| 77 | } |
| 78 |