Package org.apache.xalan.xsltc.compiler.util

Examples of org.apache.xalan.xsltc.compiler.util.Type


      Class extType = null;
      int currConstrDistance = 0;
      for (j = 0; j < nArgs; j++) {
    // Convert from internal (translet) type to external (Java) type
    extType = paramTypes[j];
    final Type intType = (Type)argsType.elementAt(j);
    Object match = _internal2Java.maps(intType, extType);
    if (match != null) {
        currConstrDistance += ((JavaType)match).distance;
    }
    else {
View Full Code Here


          if (_namespace_format == NAMESPACE_FORMAT_JAVA
          || _namespace_format == NAMESPACE_FORMAT_PACKAGE)
           hasThisArgument = true;
       
      Expression firstArg = (Expression)_arguments.elementAt(0);
      Type firstArgType = (Type)firstArg.typeCheck(stable);
     
      if (_namespace_format == NAMESPACE_FORMAT_CLASS
          && firstArgType instanceof ObjectType
          && _clazz != null
          && _clazz.isAssignableFrom(((ObjectType)firstArgType).getJavaClass()))
          hasThisArgument = true;
     
      if (hasThisArgument) {
          _thisArgument = (Expression) _arguments.elementAt(0);
          _arguments.remove(0); nArgs--;
        if (firstArgType instanceof ObjectType) {
          _className = ((ObjectType) firstArgType).getJavaClassName();
        }
        else
          throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, name);       
      }
      }
      else if (_className.length() == 0) {
    /*
     * Warn user if external function could not be resolved.
     * Warning will _NOT_ be issued is the call is properly
     * wrapped in an <xsl:if> or <xsl:when> element. For details
     * see If.parserContents() and When.parserContents()
     */
    final Parser parser = getParser();
    if (parser != null) {
        reportWarning(this, parser, ErrorMsg.FUNCTION_RESOLVE_ERR,
          _fname.toString());
    }
    unresolvedExternal = true;
    return _type = Type.Int;  // use "Int" as "unknown"
      }
  }
 
  final Vector methods = findMethods();
 
  if (methods == null) {
      // Method not found in this class
      throw new TypeCheckError(ErrorMsg.METHOD_NOT_FOUND_ERR, _className + "." + name);
  }

  Class extType = null;
  final int nMethods = methods.size();
  final Vector argsType = typeCheckArgs(stable);

  // Try all methods to identify the best fit
  int bestMethodDistance  = Integer.MAX_VALUE;
  _type = null;                       // reset internal type
  for (int j, i = 0; i < nMethods; i++) {

      // Check if all paramteters to this method can be converted
      final Method method = (Method)methods.elementAt(i);
      final Class[] paramTypes = method.getParameterTypes();
     
      int currMethodDistance = 0;
      for (j = 0; j < nArgs; j++) {
    // Convert from internal (translet) type to external (Java) type
    extType = paramTypes[j];
    final Type intType = (Type)argsType.elementAt(j);
    Object match = _internal2Java.maps(intType, extType);
    if (match != null) {
        currMethodDistance += ((JavaType)match).distance;
    }
    else {
View Full Code Here

     * Update true/false-lists.
     */
    public void translateDesynthesized(ClassGenerator classGen,
               MethodGenerator methodGen)
    {
  Type type = Type.Boolean;
  if (_chosenMethodType != null)
      type = _chosenMethodType.resultType();

  final InstructionList il = methodGen.getInstructionList();
  translate(classGen, methodGen);
View Full Code Here

   final StringBuffer buf = new StringBuffer(_className);
        buf.append('.').append(_fname.getLocalPart()).append('(');
   
  int nArgs = argsType.size();     
  for (int i = 0; i < nArgs; i++) {
      final Type intType = (Type)argsType.elementAt(i);
      buf.append(intType.toString());
      if (i < nArgs - 1) buf.append(", ");
  }
   
  buf.append(')');
  return buf.toString();
View Full Code Here

     * to a string, and the lookup-value must be a string or a node-set.
     * @param stable The parser's symbol table
     * @throws TypeCheckError When the parameters have illegal type
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  final Type returnType = super.typeCheck(stable);

  // Run type check on the key name (first argument) - must be a string,
  // and if it is not it must be converted to one using string() rules.
  if (_name != null) {
      final Type nameType = _name.typeCheck(stable);

      if (_name instanceof LiteralExpr) {
    final LiteralExpr literal = (LiteralExpr) _name;
    _resolvedQName =
        getParser().getQNameIgnoreDefaultNs(literal.getValue());
View Full Code Here

          if (_namespace_format == NAMESPACE_FORMAT_JAVA
          || _namespace_format == NAMESPACE_FORMAT_PACKAGE)
           hasThisArgument = true;
       
      Expression firstArg = (Expression)_arguments.elementAt(0);
      Type firstArgType = (Type)firstArg.typeCheck(stable);
     
      if (_namespace_format == NAMESPACE_FORMAT_CLASS
          && firstArgType instanceof ObjectType
          && _clazz != null
          && _clazz.isAssignableFrom(((ObjectType)firstArgType).getJavaClass()))
          hasThisArgument = true;
     
      if (hasThisArgument) {
          _thisArgument = (Expression) _arguments.elementAt(0);
          _arguments.remove(0); nArgs--;
        if (firstArgType instanceof ObjectType) {
          _className = ((ObjectType) firstArgType).getJavaClassName();
        }
        else
          throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, name);       
      }
      }
      else if (_className.length() == 0) {
    /*
     * Warn user if external function could not be resolved.
     * Warning will _NOT_ be issued is the call is properly
     * wrapped in an <xsl:if> or <xsl:when> element. For details
     * see If.parserContents() and When.parserContents()
     */
    final Parser parser = getParser();
    if (parser != null) {
        reportWarning(this, parser, ErrorMsg.FUNCTION_RESOLVE_ERR,
          _fname.toString());
    }
    unresolvedExternal = true;
    return _type = Type.Int;  // use "Int" as "unknown"
      }
  }
 
  final Vector methods = findMethods();
 
  if (methods == null) {
      // Method not found in this class
      throw new TypeCheckError(ErrorMsg.METHOD_NOT_FOUND_ERR, _className + "." + name);
  }

  Class extType = null;
  final int nMethods = methods.size();
  final Vector argsType = typeCheckArgs(stable);

  // Try all methods to identify the best fit
  int bestMethodDistance  = Integer.MAX_VALUE;
  _type = null;                       // reset internal type
  for (int j, i = 0; i < nMethods; i++) {

      // Check if all paramteters to this method can be converted
      final Method method = (Method)methods.elementAt(i);
      final Class[] paramTypes = method.getParameterTypes();
     
      int currMethodDistance = 0;
      for (j = 0; j < nArgs; j++) {
    // Convert from internal (translet) type to external (Java) type
    extType = paramTypes[j];
    final Type intType = (Type)argsType.elementAt(j);
    Object match = _internal2Java.maps(intType, extType);
    if (match != null) {
        currMethodDistance += ((JavaType)match).distance;
    }
    else {
View Full Code Here

     * Update true/false-lists.
     */
    public void translateDesynthesized(ClassGenerator classGen,
               MethodGenerator methodGen)
    {
  Type type = Type.Boolean;
  if (_chosenMethodType != null)
      type = _chosenMethodType.resultType();

  final InstructionList il = methodGen.getInstructionList();
  translate(classGen, methodGen);
View Full Code Here

   final StringBuffer buf = new StringBuffer(_className);
        buf.append('.').append(_fname.getLocalPart()).append('(');
   
  int nArgs = argsType.size();     
  for (int i = 0; i < nArgs; i++) {
      final Type intType = (Type)argsType.elementAt(i);
      buf.append(intType.toString());
      if (i < nArgs - 1) buf.append(", ");
  }
   
  buf.append(')');
  return buf.toString();
View Full Code Here

        final String str = getAttribute("disable-output-escaping");
  if ((str != null) && (str.equals("yes"))) _escaping = false;
    }

    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  Type type = _select.typeCheck(stable);
  if ((type != null) && (type.identicalTo(Type.String) == false))
      _select = new CastExpr(_select, Type.String);
  return Type.Void;
    }
View Full Code Here

  }

  // Parse the second argument - the document URI base
  if (ac == 2) {
      _base = argument(1);
      final Type baseType = _base.typeCheck(stable);
     
      if (baseType.identicalTo(Type.Node)) {
    _base = new CastExpr(_base, Type.NodeSet);
      }
      else if (baseType.identicalTo(Type.NodeSet)) {
    // falls through
      }
      else {
    ErrorMsg msg = new ErrorMsg(ErrorMsg.DOCUMENT_ARG_ERR, this);
    throw new TypeCheckError(msg);
View Full Code Here

TOP

Related Classes of org.apache.xalan.xsltc.compiler.util.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.