Examples of TypeCheckError


Examples of com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError

    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
        final int argc = argumentCount();
        if (argc > 1) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this);
            throw new TypeCheckError(err);
        }

        if (argc > 0) {
            argument().typeCheck(stable);
        }
View Full Code Here

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

    if (!argType.identicalTo(exp.getType())) {
        try {
      _arguments.setElementAt(new CastExpr(exp, argType), i);
        }
        catch (TypeCheckError e) {
      throw new TypeCheckError(this)// invalid conversion
        }
    }
      }
      _chosenMethodType = ptype;
      return _type = ptype.resultType();
  }
  throw new TypeCheckError(this);
    }
View Full Code Here

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

    public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
        final Vector constructors = findConstructors();
  if (constructors == null) {
            // Constructor not found in this class
            throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
    _className);
       
  }

  final int nConstructors = constructors.size();
  final int nArgs = _arguments.size();
  final Vector argsType = typeCheckArgs(stable);

  // Try all constructors
  int bestConstrDistance = Integer.MAX_VALUE;
  _type = null;      // reset
  for (int j, i = 0; i < nConstructors; i++) {
      // Check if all parameters to this constructor can be converted
      final Constructor constructor =
    (Constructor)constructors.elementAt(i);
      final Class[] paramTypes = constructor.getParameterTypes();

      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 if (intType instanceof ObjectType) {
        ObjectType objectType = (ObjectType)intType;
        if (objectType.getJavaClass() == extType)
            continue;
        else if (extType.isAssignableFrom(objectType.getJavaClass()))
            currConstrDistance += 1;
        else {
      currConstrDistance = Integer.MAX_VALUE;
      break;
        }
    }
    else {
        // no mapping available
        currConstrDistance = Integer.MAX_VALUE;
        break;
    }
      }

      if (j == nArgs && currConstrDistance < bestConstrDistance ) {
          _chosenConstructor = constructor;
          _isExtConstructor = true;
    bestConstrDistance = currConstrDistance;
   
    if (_clazz != null)
            _type = new ObjectType(_clazz);
    else
      _type = new ObjectType(_className);
      }
  }

  if (_type != null) {
      return _type;
  }

  throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
    }
View Full Code Here

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

          _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 {
        // no mapping available
        //
        // Allow a Reference type to match any external (Java) type at
        // the moment. The real type checking is performed at runtime.
        if (intType instanceof ReferenceType) {
           currMethodDistance += 1;
        }
        else if (intType instanceof ObjectType) {
            ObjectType object = (ObjectType)intType;
            if (extType.getName().equals(object.getJavaClassName()))
                currMethodDistance += 0;
            else if (extType.isAssignableFrom(object.getJavaClass()))
                currMethodDistance += 1;
            else {
                currMethodDistance = Integer.MAX_VALUE;
                break;
            }
        }
        else {
            currMethodDistance = Integer.MAX_VALUE;
            break;
        }
    }
      }

      if (j == nArgs) {
      // Check if the return type can be converted
      extType = method.getReturnType();
   
      _type = (Type) _java2Internal.get(extType);
      if (_type == null) {
          _type = new ObjectType(extType);
      }   

      // Use this method if all parameters & return type match
      if (_type != null && currMethodDistance < bestMethodDistance) {
          _chosenMethod = method;
          bestMethodDistance = currMethodDistance;
      }
      }
  }
 
  // It is an error if the chosen method is an instance menthod but we don't
  // have a this argument.
  if (_chosenMethod != null && _thisArgument == null &&
      !Modifier.isStatic(_chosenMethod.getModifiers())) {
      throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, getMethodSignature(argsType));
  }

  if (_type != null) {
      if (_type == Type.NodeSet) {
              getXSLTC().setMultiDocument(true);
            }
      return _type;
  }

  throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
    }
View Full Code Here

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

    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  // At least one argument - two at most
  final int ac = argumentCount();
  if ((ac < 1) || (ac > 2)) {
      ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this);
      throw new TypeCheckError(msg);
  }

  // Parse the first argument - the document URI
  _uri = argument(0);
  if (_uri instanceof LiteralExpr) {
      LiteralExpr expr = (LiteralExpr)_uri;
      if (expr.getValue().equals(EMPTYSTRING)) {
    Stylesheet stylesheet = getStylesheet();
    if (stylesheet == null) {
        ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this);
        throw new TypeCheckError(msg);
    }
    _uri = new LiteralExpr(stylesheet.getSystemId(), EMPTYSTRING);
      }
  }

  _uriType = _uri.typeCheck(stable);
  if ((_uriType != Type.NodeSet) && (_uriType != Type.String)) {
      _uri = new CastExpr(_uri, Type.String);
  }

  // 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);
      }
  }

  return _type = Type.NodeSet;
    }
View Full Code Here

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

  if (template != null) {
      typeCheckContents(stable);
  }
  else {
      ErrorMsg err = new ErrorMsg(ErrorMsg.TEMPLATE_UNDEF_ERR,_name,this);
      throw new TypeCheckError(err);
  }
  return Type.Void;
    }
View Full Code Here

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

  }
  if (_type instanceof NodeSetType||_type instanceof ResultTreeType) {
      typeCheckContents(stable);
      return Type.Void;
  }
  throw new TypeCheckError(this);
    }
View Full Code Here

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

    /**
     * Run type check on the fallback element (if any).
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  if (_fallback == null) {
      throw new TypeCheckError(_message);
  }
  return(_fallback.typeCheck(stable));
    }
View Full Code Here

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

  if (_arg instanceof LiteralExpr) {
      return _type = Type.Boolean;
  }
  ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
      "function-available", this);
  throw new TypeCheckError(err);
    }
View Full Code Here

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

  if (ptype instanceof NodeSetType == false) {
      if (ptype instanceof ReferenceType)  {
    _primary = new CastExpr(_primary, Type.NodeSet);
      }
      else {
    throw new TypeCheckError(this);
      }
  }

        // Type check predicates and turn all optimizations off if appropriate
  int n = _predicates.size();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.