001: package net.sf.saxon.instruct;
002:
003: import net.sf.saxon.expr.ComputedExpression;
004: import net.sf.saxon.expr.Container;
005: import net.sf.saxon.expr.Expression;
006: import net.sf.saxon.expr.ExpressionTool;
007: import net.sf.saxon.event.LocationProvider;
008:
009: import java.io.Serializable;
010:
011: /**
012: * This object represents the compiled form of a user-written function, template, attribute-set, etc
013: * (the source can be either an XSLT stylesheet function or an XQuery function).
014: *
015: * <p>It is assumed that type-checking, of both the arguments and the results,
016: * has been handled at compile time. That is, the expression supplied as the body
017: * of the function must be wrapped in code to check or convert the result to the
018: * required type, and calls on the function must be wrapped at compile time to check or
019: * convert the supplied arguments.
020: */
021:
022: public class Procedure implements Serializable, Container,
023: LocationProvider {
024:
025: private Expression body;
026: private Executable executable;
027: private String systemId;
028: private int lineNumber;
029: private SlotManager stackFrameMap;
030:
031: public Procedure() {
032: };
033:
034: public void setBody(Expression body) {
035: this .body = body;
036: ExpressionTool.makeParentReferences(body);
037: if (body instanceof ComputedExpression) {
038: ((ComputedExpression) body).setParentExpression(this );
039: }
040: }
041:
042: public final Expression getBody() {
043: return body;
044: }
045:
046: public void setStackFrameMap(SlotManager map) {
047: stackFrameMap = map;
048: }
049:
050: public SlotManager getStackFrameMap() {
051: return stackFrameMap;
052: }
053:
054: public final Executable getExecutable() {
055: return executable;
056: }
057:
058: public void setExecutable(Executable executable) {
059: this .executable = executable;
060: }
061:
062: /**
063: * Get the LocationProvider allowing location identifiers to be resolved.
064: */
065:
066: public LocationProvider getLocationProvider() {
067: return this ;
068: }
069:
070: public void setLineNumber(int lineNumber) {
071: this .lineNumber = lineNumber;
072: }
073:
074: public void setSystemId(String systemId) {
075: this .systemId = systemId;
076: }
077:
078: public int getLineNumber() {
079: return lineNumber;
080: }
081:
082: public String getSystemId() {
083: return systemId;
084: }
085:
086: public int getColumnNumber() {
087: return -1;
088: }
089:
090: public String getPublicId() {
091: return null;
092: }
093:
094: public String getSystemId(int locationId) {
095: return systemId;
096: }
097:
098: public int getLineNumber(int locationId) {
099: return lineNumber;
100: }
101:
102: }
103:
104: //
105: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
106: // you may not use this file except in compliance with the License. You may obtain a copy of the
107: // License at http://www.mozilla.org/MPL/
108: //
109: // Software distributed under the License is distributed on an "AS IS" basis,
110: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
111: // See the License for the specific language governing rights and limitations under the License.
112: //
113: // The Original Code is: all this file.
114: //
115: // The Initial Developer of the Original Code is Michael H. Kay
116: //
117: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
118: //
119: // Contributor(s): none
120: //
|