jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java
changeset 17538 d8d911c4e5d4
parent 12458 d601e4bba306
child 21467 ed77f0ff062c
equal deleted inserted replaced
17537:50528ec0ea37 17538:d8d911c4e5d4
    52 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType;
    52 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType;
    53 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType;
    53 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType;
    54 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
    54 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
    55 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
    55 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
    56 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
    56 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
       
    57 import java.util.Objects;
    57 
    58 
    58 /**
    59 /**
    59  * @author Jacek Ambroziak
    60  * @author Jacek Ambroziak
    60  * @author Santiago Pericas-Geertsen
    61  * @author Santiago Pericas-Geertsen
    61  * @author Morten Jorgensen
    62  * @author Morten Jorgensen
   154 
   155 
   155         public JavaType(Class type, int distance){
   156         public JavaType(Class type, int distance){
   156             this.type = type;
   157             this.type = type;
   157             this.distance = distance;
   158             this.distance = distance;
   158         }
   159         }
       
   160 
       
   161         @Override
       
   162         public int hashCode() {
       
   163             return Objects.hashCode(this.type);
       
   164         }
       
   165 
       
   166         @Override
   159         public boolean equals(Object query){
   167         public boolean equals(Object query){
   160             return query.equals(type);
   168             return query != null && query.equals(type);
   161         }
   169         }
   162     }
   170     }
   163 
   171 
   164     /**
   172     /**
   165      * Defines 2 conversion tables:
   173      * Defines 2 conversion tables:
   275 
   283 
   276     public String getName() {
   284     public String getName() {
   277         return(_fname.toString());
   285         return(_fname.toString());
   278     }
   286     }
   279 
   287 
       
   288     @Override
   280     public void setParser(Parser parser) {
   289     public void setParser(Parser parser) {
   281         super.setParser(parser);
   290         super.setParser(parser);
   282         if (_arguments != null) {
   291         if (_arguments != null) {
   283             final int n = _arguments.size();
   292             final int n = _arguments.size();
   284             for (int i = 0; i < n; i++) {
   293             for (int i = 0; i < n; i++) {
   317 
   326 
   318     /**
   327     /**
   319      * Type check a function call. Since different type conversions apply,
   328      * Type check a function call. Since different type conversions apply,
   320      * type checking is different for standard and external (Java) functions.
   329      * type checking is different for standard and external (Java) functions.
   321      */
   330      */
       
   331     @Override
   322     public Type typeCheck(SymbolTable stable)
   332     public Type typeCheck(SymbolTable stable)
   323         throws TypeCheckError
   333         throws TypeCheckError
   324     {
   334     {
   325         if (_type != null) return _type;
   335         if (_type != null) return _type;
   326 
   336 
   678 
   688 
   679     /**
   689     /**
   680      * Compile the function call and treat as an expression
   690      * Compile the function call and treat as an expression
   681      * Update true/false-lists.
   691      * Update true/false-lists.
   682      */
   692      */
       
   693     @Override
   683     public void translateDesynthesized(ClassGenerator classGen,
   694     public void translateDesynthesized(ClassGenerator classGen,
   684                                        MethodGenerator methodGen)
   695                                        MethodGenerator methodGen)
   685     {
   696     {
   686         Type type = Type.Boolean;
   697         Type type = Type.Boolean;
   687         if (_chosenMethodType != null)
   698         if (_chosenMethodType != null)
   698 
   709 
   699     /**
   710     /**
   700      * Translate a function call. The compiled code will leave the function's
   711      * Translate a function call. The compiled code will leave the function's
   701      * return value on the JVM's stack.
   712      * return value on the JVM's stack.
   702      */
   713      */
       
   714     @Override
   703     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
   715     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
   704         final int n = argumentCount();
   716         final int n = argumentCount();
   705         final ConstantPoolGen cpg = classGen.getConstantPool();
   717         final ConstantPoolGen cpg = classGen.getConstantPool();
   706         final InstructionList il = methodGen.getInstructionList();
   718         final InstructionList il = methodGen.getInstructionList();
   707         final boolean isSecureProcessing = classGen.getParser().getXSLTC().isSecureProcessing();
   719         final boolean isSecureProcessing = classGen.getParser().getXSLTC().isSecureProcessing();
   855             _type.translateFrom(classGen, methodGen,
   867             _type.translateFrom(classGen, methodGen,
   856                                 _chosenMethod.getReturnType());
   868                                 _chosenMethod.getReturnType());
   857         }
   869         }
   858     }
   870     }
   859 
   871 
       
   872     @Override
   860     public String toString() {
   873     public String toString() {
   861         return "funcall(" + _fname + ", " + _arguments + ')';
   874         return "funcall(" + _fname + ", " + _arguments + ')';
   862     }
   875     }
   863 
   876 
   864     public boolean isStandard() {
   877     public boolean isStandard() {
  1067      * Note: dashes only appear in middle of an EXSLT function or element name.
  1080      * Note: dashes only appear in middle of an EXSLT function or element name.
  1068      */
  1081      */
  1069     protected static String replaceDash(String name)
  1082     protected static String replaceDash(String name)
  1070     {
  1083     {
  1071         char dash = '-';
  1084         char dash = '-';
  1072         StringBuffer buff = new StringBuffer("");
  1085         final StringBuilder buff = new StringBuilder("");
  1073         for (int i = 0; i < name.length(); i++) {
  1086         for (int i = 0; i < name.length(); i++) {
  1074         if (i > 0 && name.charAt(i-1) == dash)
  1087         if (i > 0 && name.charAt(i-1) == dash)
  1075             buff.append(Character.toUpperCase(name.charAt(i)));
  1088             buff.append(Character.toUpperCase(name.charAt(i)));
  1076         else if (name.charAt(i) != dash)
  1089         else if (name.charAt(i) != dash)
  1077             buff.append(name.charAt(i));
  1090             buff.append(name.charAt(i));