| 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.query; |
| 9 | |
| 10 | import net.sf.saxon.expr.BindingReference; |
| 11 | import net.sf.saxon.expr.instruct.Executable; |
| 12 | import net.sf.saxon.expr.instruct.GlobalVariable; |
| 13 | import net.sf.saxon.trans.XPathException; |
| 14 | |
| 15 | import java.util.Collections; |
| 16 | |
| 17 | /** |
| 18 | * An UndeclaredVariable object is created when a reference is encountered to a variable |
| 19 | * that has not yet been declared. This can happen as a result of recursive module imports. |
| 20 | * These references are resolved at the end of query parsing. |
| 21 | */ |
| 22 | |
| 23 | public class UndeclaredVariable extends GlobalVariable { |
| 24 | |
| 25 | public UndeclaredVariable() { |
| 26 | } |
| 27 | |
| 28 | public void transferReferences(GlobalVariable var) { |
| 29 | for (BindingReference ref : references) { |
| 30 | var.registerReference(ref); |
| 31 | } |
| 32 | references = Collections.emptyList(); |
| 33 | } |
| 34 | |
| 35 | /*@NotNull*/ |
| 36 | public void compile(Executable exec, int slot) throws XPathException { |
| 37 | throw new UnsupportedOperationException("Attempt to compile a place-holder for an undeclared variable"); |
| 38 | } |
| 39 | } |
| 40 |