org.apache.xalan.xsltc.compiler
Class FunctionCall

java.lang.Object
  extended by org.apache.xalan.xsltc.compiler.SyntaxTreeNode
      extended by org.apache.xalan.xsltc.compiler.Expression
          extended by org.apache.xalan.xsltc.compiler.FunctionCall
All Implemented Interfaces:
Constants
Direct Known Subclasses:
BooleanCall, CastCall, CeilingCall, ConcatCall, ContainsCall, CurrentCall, DocumentCall, ElementAvailableCall, FloorCall, FormatNumberCall, FunctionAvailableCall, GenerateIdCall, KeyCall, LangCall, LastCall, NameBase, NotCall, NumberCall, PositionCall, RoundCall, StartsWithCall, StringCall, StringLengthCall, UnparsedEntityUriCall

 class FunctionCall
extends Expression


Nested Class Summary
(package private) static class FunctionCall.JavaType
          inner class to used in internal2Java mappings, contains the Java type and the distance between the internal type and the Java type.
 
Field Summary
private  java.util.Vector _arguments
           
private  java.lang.reflect.Constructor _chosenConstructor
           
private  java.lang.reflect.Method _chosenMethod
           
private  MethodType _chosenMethodType
           
private  java.lang.String _className
           
private  java.lang.Class _clazz
           
private static java.util.Hashtable _extensionFunctionTable
           
private static java.util.Hashtable _extensionNamespaceTable
           
private  QName _fname
           
private static MultiHashtable _internal2Java
           
private  boolean _isExtConstructor
           
private  boolean _isStatic
           
private static java.util.Hashtable _java2Internal
           
private  int _namespace_format
           
(package private)  Expression _thisArgument
          Stores reference to object for non-static Java calls
private static java.util.Vector EMPTY_ARG_LIST
           
protected static java.lang.String EXSLT_COMMON
           
protected static java.lang.String EXSLT_DATETIME
           
protected static java.lang.String EXSLT_MATH
           
protected static java.lang.String EXSLT_SETS
           
protected static java.lang.String EXSLT_STRINGS
           
protected static java.lang.String EXT_XALAN
           
protected static java.lang.String EXT_XSLTC
           
protected static java.lang.String JAVA_EXT_XALAN
           
protected static java.lang.String JAVA_EXT_XALAN_OLD
           
protected static java.lang.String JAVA_EXT_XSLTC
           
protected static int NAMESPACE_FORMAT_CLASS
           
protected static int NAMESPACE_FORMAT_CLASS_OR_PACKAGE
           
protected static int NAMESPACE_FORMAT_JAVA
           
protected static int NAMESPACE_FORMAT_PACKAGE
           
private  boolean unresolvedExternal
           
 
Fields inherited from class org.apache.xalan.xsltc.compiler.Expression
_falseList, _trueList, _type
 
Fields inherited from class org.apache.xalan.xsltc.compiler.SyntaxTreeNode
_attributes, _parent, _qname, Dummy, IndentIncrement, UNKNOWN_STYLESHEET_NODE_ID
 
Fields inherited from interface org.apache.xalan.xsltc.compiler.Constants
ABSOLUTE_ITERATOR, ACC_FINAL, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_SUPER, ADD_ATTRIBUTE, ADD_ATTRIBUTE_SIG, ADD_ITERATOR, ADD_ITERATOR_SIG, ADD_PARAMETER, ADD_PARAMETER_SIG, APPLY_TEMPLATES, ATTR_SET_SIG, ATTRIBUTE_LIST_FIELD, ATTRIBUTE_LIST_IMPL_CLASS, ATTRIBUTE_LIST_IMPL_SIG, ATTRIBUTES_SIG, BASIS_LIBRARY_CLASS, BOOLEAN_CLASS, BOOLEAN_VALUE, BOOLEAN_VALUE_SIG, CACHED_NODE_LIST_ITERATOR_CLASS, CHARACTERS, CHARACTERS_SIG, CHARACTERSW, CHARACTERSW_SIG, CLEAR_ATTRIBUTES, CLEAR_ATTRIBUTES_SIG, COLLATOR_CLASS, COLLATOR_SIG, COMPILER_PACKAGE, CURRENT_NODE_LIST_FILTER, CURRENT_NODE_LIST_FILTER_SIG, CURRENT_NODE_LIST_ITERATOR, CURRENT_NODE_LIST_ITERATOR_SIG, DEFAULT_NODE_COUNTER, DEFAULT_NODE_COUNTER_SIG, DOCUMENT_PNAME, DOM_ADAPTER_CLASS, DOM_ADAPTER_SIG, DOM_FIELD, DOM_IMPL, DOM_IMPL_CLASS, DOM_IMPL_SIG, DOM_INTF, DOM_INTF_SIG, DOM_PNAME, DOUBLE_CLASS, DOUBLE_SIG, DOUBLE_VALUE, DOUBLE_VALUE_SIG, DUP_FILTERED_ITERATOR, EMPTYATTR_FIELD, EMPTYSTRING, ERROR, EXPAND_STYLESHEET_QNAME_REF, EXPAND_STYLESHEET_QNAME_SIG, FALLBACK_CLASS, FATAL, FILTER_INTERFACE, FILTER_INTERFACE_SIG, FILTER_ITERATOR, FILTER_STEP_ITERATOR, FORMAT_SYMBOLS_FIELD, GET_ATTRIBUTE_VALUE, GET_ATTRIBUTE_VALUE_SIG, GET_CHILDREN, GET_CHILDREN_SIG, GET_ELEMENT_VALUE, GET_ELEMENT_VALUE_SIG, GET_ITERATOR_SIG, GET_NODE_NAME, GET_NODE_NAME_SIG, GET_NODE_TYPE, GET_NODE_TYPE_SIG, GET_NODE_VALUE, GET_NODE_VALUE_ITERATOR, GET_NODE_VALUE_ITERATOR_SIG, GET_NODE_VALUE_SIG, GET_PARAMETER, GET_PARAMETER_SIG, GET_PARENT, GET_PARENT_SIG, GET_TYPED_CHILDREN, GET_TYPED_CHILDREN_SIG, GET_UNPARSED_ENTITY_URI, GET_UNPARSED_ENTITY_URI_SIG, HAS_ATTRIBUTE, HAS_ATTRIBUTE_SIG, HASIDCALL_INDEX, HASIDCALL_INDEX_SIG, INT_VALUE, INT_VALUE_SIG, INTEGER_CLASS, INTEGER_SIG, INTERNAL, INVOKE_METHOD, ITERATOR_FIELD_SIG, ITERATOR_PNAME, KEY_INDEX_CLASS, KEY_INDEX_ITERATOR_SIG, KEY_INDEX_SIG, LAST_INDEX, LOAD_DOCUMENT_CLASS, LOCALE_CLASS, LOCALE_SIG, LOOKUP_STYLESHEET_QNAME_NS_REF, LOOKUP_STYLESHEET_QNAME_NS_SIG, MAKE_NODE, MAKE_NODE_LIST, MAKE_NODE_LIST_SIG, MAKE_NODE_LIST_SIG2, MAKE_NODE_SIG, MAKE_NODE_SIG2, MATCHING_ITERATOR, MATH_CLASS, MULTI_DOM_CLASS, MULTI_DOM_SIG, NAMES_INDEX, NAMES_INDEX_SIG, NAMESPACE_FEATURE, NAMESPACE_INDEX, NAMESPACE_INDEX_SIG, NEXT, NEXT_SIG, NEXTID, NODE, NODE_COUNTER, NODE_COUNTER_SIG, NODE_FIELD, NODE_FIELD_SIG, NODE_ITERATOR, NODE_ITERATOR_BASE, NODE_ITERATOR_SIG, NODE_PNAME, NODE_SIG, NODE_SORT_FACTORY, NODE_SORT_FACTORY_SIG, NODE_SORT_RECORD, NODE_SORT_RECORD_SIG, NS_ANCESTORS_INDEX_SIG, NTH_ITERATOR_CLASS, OBJECT_CLASS, OBJECT_SIG, ORDER_ITERATOR, ORDER_ITERATOR_SIG, OUTPUT_BASE, OUTPUT_HANDLER, OUTPUT_HANDLER_SIG, POP_PARAM_FRAME, POP_PARAM_FRAME_SIG, POSITION_INDEX, PREFIX_URIS_ARRAY_SIG, PREFIX_URIS_IDX_SIG, PUSH_PARAM_FRAME, PUSH_PARAM_FRAME_SIG, REDIRECT_URI, RESET, RESET_SIG, RTF_INITIAL_SIZE, RUNTIME_NODE_CLASS, RUNTIME_PACKAGE, SAX_IMPL, SAX_IMPL_CLASS, SAX_IMPL_SIG, SET_START_NODE, SET_START_NODE_SIG, SINGLETON_ITERATOR, SORT_ITERATOR, SORT_ITERATOR_SIG, STATIC_CHAR_DATA_FIELD, STATIC_CHAR_DATA_FIELD_SIG, STATIC_NAMES_ARRAY_FIELD, STATIC_NAMESPACE_ARRAY_FIELD, STATIC_NS_ANCESTORS_ARRAY_FIELD, STATIC_PREFIX_URIS_ARRAY_FIELD, STATIC_PREFIX_URIS_IDX_ARRAY_FIELD, STATIC_TYPES_ARRAY_FIELD, STATIC_URIS_ARRAY_FIELD, STEP_ITERATOR_CLASS, STREAM_XML_OUTPUT, STRING, STRING_BUFFER_CLASS, STRING_BUFFER_SIG, STRING_CLASS, STRING_SIG, STRING_TO_INT, STRING_TO_INT_SIG, STRING_TO_REAL, STRING_TO_REAL_SIG, STRING_VALUE_HANDLER, STRING_VALUE_HANDLER_SIG, STRING_WRITER, STRIP_SPACE, STRIP_SPACE_INTF, STRIP_SPACE_PARAMS, STRIP_SPACE_SIG, TRANSLET_CLASS, TRANSLET_FIELD, TRANSLET_FIELD_SIG, TRANSLET_INTF, TRANSLET_INTF_SIG, TRANSLET_OUTPUT_BASE, TRANSLET_OUTPUT_INTERFACE, TRANSLET_OUTPUT_PNAME, TRANSLET_OUTPUT_SIG, TRANSLET_PNAME, TRANSLET_SIG, TRANSLET_URI, TRANSLET_VERSION_INDEX, TRANSLET_VERSION_INDEX_SIG, TYPES_INDEX, TYPES_INDEX_SIG, UNION_ITERATOR_CLASS, UNION_ITERATOR_SIG, UNSUPPORTED, URIS_INDEX, URIS_INDEX_SIG, WARNING, WRITER_SIG, XHTML_URI, XMLNS_PREFIX, XMLNS_STRING, XMLNS_URI, XSLT_PACKAGE, XSLT_URI
 
Constructor Summary
FunctionCall(QName fname)
           
FunctionCall(QName fname, java.util.Vector arguments)
           
 
Method Summary
protected  Expression argument()
           
protected  Expression argument(int i)
           
protected  int argumentCount()
           
private  java.util.Vector findConstructors()
          Returns a vector with all constructors named _fname after stripping its namespace or null if no such methods exist.
private  java.util.Vector findMethods()
          Returns a vector with all methods named _fname after stripping its namespace or null if no such methods exist.
 java.lang.String getClassNameFromUri(java.lang.String uri)
           
private  java.lang.String getMethodSignature(java.util.Vector argsType)
          Return the signature of the current method
 java.lang.String getName()
           
(package private) static java.lang.String getSignature(java.lang.Class clazz)
          Compute the JVM signature for the class.
(package private) static java.lang.String getSignature(java.lang.reflect.Constructor cons)
          Compute the JVM constructor descriptor for the constructor.
(package private) static java.lang.String getSignature(java.lang.reflect.Method meth)
          Compute the JVM method descriptor for the method.
 boolean isExtension()
           
 boolean isStandard()
           
protected static java.lang.String replaceDash(java.lang.String name)
          To support EXSLT extensions, convert names with dash to allowable Java names: e.g., convert abc-xyz to abcXyz.
protected  void setArgument(int i, Expression exp)
           
 void setParser(Parser parser)
          Set this node's parser.
 java.lang.String toString()
           
 void translate(ClassGenerator classGen, MethodGenerator methodGen)
          Translate a function call.
 void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen)
          Compile the function call and treat as an expression Update true/false-lists.
private  void translateUnallowedExtension(ConstantPoolGen cpg, InstructionList il)
          Translate code to call the BasisLibrary.unallowed_extensionF(String) method.
 Type typeCheck(SymbolTable stable)
          Type check a function call.
 java.util.Vector typeCheckArgs(SymbolTable stable)
          Type check the actual arguments of this function call.
 Type typeCheckConstructor(SymbolTable stable)
           
 Type typeCheckExternal(SymbolTable stable)
          Type check a call to an external (Java) method.
 Type typeCheckStandard(SymbolTable stable)
          Type check a call to a standard function.
 
Methods inherited from class org.apache.xalan.xsltc.compiler.Expression
backPatchFalseList, backPatchTrueList, compile, desynthesize, evaluateAtCompileTime, getFalseList, getTrueList, getType, hasLastCall, hasPositionCall, lookupPrimop, startIterator, synthesize
 
Methods inherited from class org.apache.xalan.xsltc.compiler.SyntaxTreeNode
addAttribute, addElement, addPrefixMapping, compileResultTree, contextDependent, dependentContents, display, displayContents, elementAt, elementCount, elements, getAttribute, getAttribute, getAttributes, getContents, getImportPrecedence, getLineNumber, getNodeIDForStylesheetNSLookup, getParent, getParser, getPrefixMapping, getQName, getStylesheet, getSymbolTable, getTemplate, getXSLTC, hasAttribute, hasContents, indent, isDummy, lastChild, lookupNamespace, lookupPrefix, parseChildren, parseContents, removeElement, reportError, reportWarning, setAttributes, setFirstElement, setLineNumber, setParent, setPrefixMapping, setQName, setQName, translateContents, typeCheckContents, updateScope
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_fname

private QName _fname

_arguments

private final java.util.Vector _arguments

EMPTY_ARG_LIST

private static final java.util.Vector EMPTY_ARG_LIST

EXT_XSLTC

protected static final java.lang.String EXT_XSLTC
See Also:
Constant Field Values

JAVA_EXT_XSLTC

protected static final java.lang.String JAVA_EXT_XSLTC
See Also:
Constant Field Values

EXT_XALAN

protected static final java.lang.String EXT_XALAN
See Also:
Constant Field Values

JAVA_EXT_XALAN

protected static final java.lang.String JAVA_EXT_XALAN
See Also:
Constant Field Values

JAVA_EXT_XALAN_OLD

protected static final java.lang.String JAVA_EXT_XALAN_OLD
See Also:
Constant Field Values

EXSLT_COMMON

protected static final java.lang.String EXSLT_COMMON
See Also:
Constant Field Values

EXSLT_MATH

protected static final java.lang.String EXSLT_MATH
See Also:
Constant Field Values

EXSLT_SETS

protected static final java.lang.String EXSLT_SETS
See Also:
Constant Field Values

EXSLT_DATETIME

protected static final java.lang.String EXSLT_DATETIME
See Also:
Constant Field Values

EXSLT_STRINGS

protected static final java.lang.String EXSLT_STRINGS
See Also:
Constant Field Values

NAMESPACE_FORMAT_JAVA

protected static final int NAMESPACE_FORMAT_JAVA
See Also:
Constant Field Values

NAMESPACE_FORMAT_CLASS

protected static final int NAMESPACE_FORMAT_CLASS
See Also:
Constant Field Values

NAMESPACE_FORMAT_PACKAGE

protected static final int NAMESPACE_FORMAT_PACKAGE
See Also:
Constant Field Values

NAMESPACE_FORMAT_CLASS_OR_PACKAGE

protected static final int NAMESPACE_FORMAT_CLASS_OR_PACKAGE
See Also:
Constant Field Values

_namespace_format

private int _namespace_format

_thisArgument

Expression _thisArgument
Stores reference to object for non-static Java calls


_className

private java.lang.String _className

_clazz

private java.lang.Class _clazz

_chosenMethod

private java.lang.reflect.Method _chosenMethod

_chosenConstructor

private java.lang.reflect.Constructor _chosenConstructor

_chosenMethodType

private MethodType _chosenMethodType

unresolvedExternal

private boolean unresolvedExternal

_isExtConstructor

private boolean _isExtConstructor

_isStatic

private boolean _isStatic

_internal2Java

private static final MultiHashtable _internal2Java

_java2Internal

private static final java.util.Hashtable _java2Internal

_extensionNamespaceTable

private static final java.util.Hashtable _extensionNamespaceTable

_extensionFunctionTable

private static final java.util.Hashtable _extensionFunctionTable
Constructor Detail

FunctionCall

public FunctionCall(QName fname,
                    java.util.Vector arguments)

FunctionCall

public FunctionCall(QName fname)
Method Detail

getName

public java.lang.String getName()

setParser

public void setParser(Parser parser)
Description copied from class: SyntaxTreeNode
Set this node's parser. The parser (the XSLT parser) gives this syntax tree node access to the symbol table and XPath parser.

Overrides:
setParser in class SyntaxTreeNode
Parameters:
parser - The XSLT parser.

getClassNameFromUri

public java.lang.String getClassNameFromUri(java.lang.String uri)

typeCheck

public Type typeCheck(SymbolTable stable)
               throws TypeCheckError
Type check a function call. Since different type conversions apply, type checking is different for standard and external (Java) functions.

Overrides:
typeCheck in class Expression
Parameters:
stable - The compiler/parser's symbol table
Throws:
TypeCheckError

typeCheckStandard

public Type typeCheckStandard(SymbolTable stable)
                       throws TypeCheckError
Type check a call to a standard function. Insert CastExprs when needed. If as a result of the insertion of a CastExpr a type check error is thrown, then catch it and re-throw it with a new "this".

Throws:
TypeCheckError

typeCheckConstructor

public Type typeCheckConstructor(SymbolTable stable)
                          throws TypeCheckError
Throws:
TypeCheckError

typeCheckExternal

public Type typeCheckExternal(SymbolTable stable)
                       throws TypeCheckError
Type check a call to an external (Java) method. The method must be static an public, and a legal type conversion must exist for all its arguments and its return type. Every method of name _fname is inspected as a possible candidate.

Throws:
TypeCheckError

typeCheckArgs

public java.util.Vector typeCheckArgs(SymbolTable stable)
                               throws TypeCheckError
Type check the actual arguments of this function call.

Throws:
TypeCheckError

argument

protected final Expression argument(int i)

argument

protected final Expression argument()

argumentCount

protected final int argumentCount()

setArgument

protected final void setArgument(int i,
                                 Expression exp)

translateDesynthesized

public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen)
Compile the function call and treat as an expression Update true/false-lists.

Overrides:
translateDesynthesized in class Expression

translate

public void translate(ClassGenerator classGen,
                      MethodGenerator methodGen)
Translate a function call. The compiled code will leave the function's return value on the JVM's stack.

Overrides:
translate in class Expression
Parameters:
classGen - BCEL Java class generator
methodGen - BCEL Java method generator

toString

public java.lang.String toString()
Specified by:
toString in class Expression

isStandard

public boolean isStandard()

isExtension

public boolean isExtension()

findMethods

private java.util.Vector findMethods()
Returns a vector with all methods named _fname after stripping its namespace or null if no such methods exist.


findConstructors

private java.util.Vector findConstructors()
Returns a vector with all constructors named _fname after stripping its namespace or null if no such methods exist.


getSignature

static final java.lang.String getSignature(java.lang.Class clazz)
Compute the JVM signature for the class.


getSignature

static final java.lang.String getSignature(java.lang.reflect.Method meth)
Compute the JVM method descriptor for the method.


getSignature

static final java.lang.String getSignature(java.lang.reflect.Constructor cons)
Compute the JVM constructor descriptor for the constructor.


getMethodSignature

private java.lang.String getMethodSignature(java.util.Vector argsType)
Return the signature of the current method


replaceDash

protected static java.lang.String replaceDash(java.lang.String name)
To support EXSLT extensions, convert names with dash to allowable Java names: e.g., convert abc-xyz to abcXyz. Note: dashes only appear in middle of an EXSLT function or element name.


translateUnallowedExtension

private void translateUnallowedExtension(ConstantPoolGen cpg,
                                         InstructionList il)
Translate code to call the BasisLibrary.unallowed_extensionF(String) method.