286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 2001-2004 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * @author Jacek Ambroziak 286N/A * @author Santiago Pericas-Geertsen 286N/A * @author Morten Jorgensen 286N/A * @author Erwin Bolwidt <ejb@klomp.org> 286N/A // Name of this function call 286N/A // Arguments to this function call (might not be any) 286N/A // Empty argument list, used for certain functions 286N/A // Valid namespaces for Java function-call extension 286N/A // Namespace format constants 286N/A * Stores reference to object for non-static Java calls 286N/A // Encapsulates all unsupported external function calls 286N/A // If FunctionCall is a external java constructor 286N/A // If the java method is static 286N/A // Legal conversions between internal and Java types. 286N/A // Legal conversions between Java and internal types. 286N/A // The mappings between EXSLT extension namespaces and implementation classes 286N/A // Extension functions that are implemented in BasisLibrary 286N/A * inner class to used in internal2Java mappings, contains 286N/A * the Java type and the distance between the internal type and 286N/A * Defines 2 conversion tables: 286N/A * 1. From internal types to Java types and 286N/A * 2. From Java types to internal types. 286N/A * These two tables are used when calling external (Java) functions. 286N/A // -- Internal to Java -------------------------------------------- 286N/A // Type.Boolean -> { boolean(0), Boolean(1), Object(2) } 286N/A // Type.Real -> { double(0), Double(1), float(2), long(3), int(4), 286N/A // short(5), byte(6), char(7), Object(8) } 286N/A // Type.Int must be the same as Type.Real 286N/A // Type.String -> { String(0), Object(1) } 286N/A // Type.NodeSet -> { NodeList(0), Node(1), Object(2), String(3) } 286N/A // Type.Node -> { Node(0), NodeList(1), Object(2), String(3) } 286N/A // Type.ResultTree -> { NodeList(0), Node(1), Object(2), String(3) } 286N/A // Possible conversions between Java and internal types 286N/A // Initialize the extension namespace table 286N/A // Initialize the extension function table 286N/A for (
int i =
0; i < n; i++) {
286N/A * Type check a function call. Since different type conversions apply, 286N/A * type checking is different for standard and external (Java) functions. 286N/A // Handle extension functions (they all have a namespace) 286N/A * Type check a call to a standard function. Insert CastExprs when needed. 286N/A * If as a result of the insertion of a CastExpr a type check error is 286N/A * thrown, then catch it and re-throw it with a new "this". 286N/A for (
int i =
0; i < n; i++) {
286N/A // Constructor not found in this class 286N/A // Try all constructors 286N/A // Check if all parameters to this constructor can be converted 286N/A // Convert from internal (translet) type to external (Java) type 286N/A // no mapping available 286N/A * Type check a call to an external (Java) method. 286N/A * The method must be static an public, and a legal type conversion 286N/A * must exist for all its arguments and its return type. 286N/A * Every method of name <code>_fname</code> is inspected 286N/A * as a possible candidate. 286N/A // check if function is a contructor 'new' 286N/A // check if we are calling an instance method 286N/A * Warn user if external function could not be resolved. 286N/A * Warning will _NOT_ be issued is the call is properly 286N/A * wrapped in an <xsl:if> or <xsl:when> element. For details 286N/A * see If.parserContents() and When.parserContents() 286N/A // Method not found in this class 286N/A // Try all methods to identify the best fit 286N/A // Check if all paramteters to this method can be converted 286N/A // Convert from internal (translet) type to external (Java) type 286N/A // no mapping available 286N/A // Allow a Reference type to match any external (Java) type at 286N/A // the moment. The real type checking is performed at runtime. 286N/A // Check if the return type can be converted 286N/A // Use this method if all parameters & return type match 286N/A // It is an error if the chosen method is an instance menthod but we don't 286N/A // have a this argument. 286N/A * Type check the actual arguments of this function call. 286N/A * Compile the function call and treat as an expression 286N/A * Translate a function call. The compiled code will leave the function's 286N/A * return value on the JVM's stack. 286N/A // Translate calls to methods in the BasisLibrary 286N/A for (
int i =
0; i < n; i++) {
286N/A // append "F" to the function's name 286N/A // Special precautions for some method calls 286N/A // Invoke the method in the basis library 286N/A // Add call to BasisLibrary.unresolved_externalF() to generate 286N/A // run-time error message for unsupported external functions 286N/A "unresolved_externalF",
286N/A // Backwards branches are prohibited if an uninitialized object is 286N/A // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed. 286N/A // We don't know whether this code might contain backwards branches 286N/A // so we mustn't create the new object until after we've created 286N/A // the suspect arguments to its constructor. Instead we calculate 286N/A // the values of the arguments to the constructor first, store them 286N/A // in temporary variables, create the object and reload the 286N/A // arguments from the temporaries to avoid the problem. 286N/A for (
int i =
0; i < n; i++) {
286N/A // Convert the argument to its Java type 286N/A for (
int i =
0; i < n; i++) {
286N/A // Convert the return type back to our internal type 286N/A // Invoke function calls that are handled in separate classes 286N/A // Push "this" if it is an instance method 286N/A for (
int i =
0; i < n; i++) {
286N/A // Convert the argument to its Java type 286N/A // Convert the return type back to our internal type 286N/A * Returns a vector with all methods named <code>_fname</code> 286N/A * after stripping its namespace or <code>null</code> 286N/A * if no such methods exist. 286N/A // Is it public and same number of args ? 286N/A * Returns a vector with all constructors named <code>_fname</code> 286N/A * after stripping its namespace or <code>null</code> 286N/A * if no such methods exist. 286N/A // Is it public, static and same number of args ? 286N/A * Compute the JVM signature for the class. 286N/A * Compute the JVM method descriptor for the method. 286N/A * Compute the JVM constructor descriptor for the constructor. 286N/A * Return the signature of the current method 286N/A * To support EXSLT extensions, convert names with dash to allowable Java names: 286N/A * e.g., convert abc-xyz to abcXyz. 286N/A * Note: dashes only appear in middle of an EXSLT function or element name. 286N/A * Translate code to call the BasisLibrary.unallowed_extensionF(String) 286N/A "unallowed_extension_functionF",