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

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


  return _type = Type.String;
    }

    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final InstructionList il = methodGen.getInstructionList();
  Type targ;

  if (argumentCount() == 0) {
      il.append(methodGen.loadContextNode());
      targ = Type.Node;
  }
  else {
      final Expression arg = argument();
      arg.translate(classGen, methodGen);
      arg.startIterator(classGen, methodGen);
      targ = arg.getType();
  }

  if (!targ.identicalTo(Type.String)) {
      targ.translateTo(classGen, methodGen, Type.String);
  }
    }
View Full Code Here


     * Type check a FilterParentPath. If the filter is not a node-set add a
     * cast to node-set only if it is of reference type. This type coercion is
     * needed for expressions like $x/LINE where $x is a parameter reference.
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  final Type ftype = _filterExpr.typeCheck(stable);
  if (ftype instanceof NodeSetType == false) {
      if (ftype instanceof ReferenceType)  {
    _filterExpr = new CastExpr(_filterExpr, Type.NodeSet);
      }
      /*
      else if (ftype instanceof ResultTreeType)  {
    _filterExpr = new CastExpr(_filterExpr, Type.NodeSet);
      }
      */
      else if (ftype instanceof NodeType)  {
    _filterExpr = new CastExpr(_filterExpr, Type.NodeSet);
      }
      else {
    throw new TypeCheckError(this);
      }
  }

  // Wrap single node path in a node set
  final Type ptype = _path.typeCheck(stable);
  if (!(ptype instanceof NodeSetType)) {
      _path = new CastExpr(_path, Type.NodeSet);
  }

  return _type = Type.NodeSet; 
View Full Code Here

      (_path != null ? _path.toString() : "null") + ')';
    }
 
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  if (_path != null) {
      final Type ptype = _path.typeCheck(stable);
      if (ptype instanceof NodeType) {    // promote to node-set
    _path = new CastExpr(_path, Type.NodeSet);
      }
  }
  return _type = Type.NodeSet; 
View Full Code Here

      throw new TypeCheckError(err);
  }

  // The first argument must be a String, or cast to a String
  _base = argument(0);
  Type baseType = _base.typeCheck(stable)
  if (baseType != Type.String)
      _base = new CastExpr(_base, Type.String);

  // The second argument must also be a String, or cast to a String
  _token = argument(1);
  Type tokenType = _token.typeCheck(stable)
  if (tokenType != Type.String)
      _token = new CastExpr(_token, Type.String);

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

  _left.setParser(parser);
  _right.setParser(parser);
    }
   
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  final Type tleft = _left.typeCheck(stable);
  final Type tright = _right.typeCheck(stable);
  final MethodType ptype = lookupPrimop(stable, Ops[_op],
                new MethodType(Type.Void,
                   tleft, tright));
  if (ptype != null) {
      final Type arg1 = (Type) ptype.argsType().elementAt(0);
      if (!arg1.identicalTo(tleft)) {
    _left = new CastExpr(_left, arg1);
      }
      final Type arg2 = (Type) ptype.argsType().elementAt(1);
      if (!arg2.identicalTo(tright)) {
    _right = new CastExpr(_right, arg1);
      }
      return _type = ptype.resultType();
  }
  throw new TypeCheckError(this);
View Full Code Here

      throw new TypeCheckError(ErrorMsg.ILLEGAL_ARG_ERR, getName(), this);
  }

  // The first argument must be a String, or cast to a String
  _base = argument(0);
  Type baseType = _base.typeCheck(stable)
  if (baseType != Type.String)
      _base = new CastExpr(_base, Type.String);

  // The second argument must also be a String, or cast to a String
  _token = argument(1);
  Type tokenType = _token.typeCheck(stable)
  if (tokenType != Type.String)
      _token = new CastExpr(_token, Type.String);

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

      test.translateDesynthesized(classGen, methodGen);

      if (test instanceof FunctionCall) {
    FunctionCall call = (FunctionCall)test;
    try {
        Type type = call.typeCheck(getParser().getSymbolTable());
        if (type != Type.Boolean) {
      test._falseList.add(il.append(new IFEQ(null)));
        }
    }
    catch (TypeCheckError e) {
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

  final MethodType ptype =
      lookupPrimop(stable, _fname.getLocalPart(), args);

  if (ptype != null) {
      for (int i = 0; i < n; i++) {
    final Type argType = (Type) ptype.argsType().elementAt(i);
    final Expression exp = (Expression)_arguments.elementAt(i);
    if (!argType.identicalTo(exp.getType())) {
        try {
      _arguments.setElementAt(new CastExpr(exp, argType), i);
        }
        catch (TypeCheckError e) {
      throw new TypeCheckError(this)// invalid conversion
View Full Code Here

      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) {
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.