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

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


     * at compile time if its type is number or not. Hence, expressions of
     * reference type are always converted to booleans.
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {

  Type texp = _exp.typeCheck(stable);

  // We need explicit type information for reference types - no good!
  if (texp instanceof ReferenceType) {
      _exp = new CastExpr(_exp, texp = Type.Real);
  }
View Full Code Here


  if (_exp instanceof EqualityExpr) {
      EqualityExpr exp = (EqualityExpr)_exp;
      Expression left = exp.getLeft();
      Expression right = exp.getRight();

      Type tleft = left.getType();
      Type tright = right.getType();

     
      if (left instanceof CastExpr) left = ((CastExpr)left).getExpr();
      if (right instanceof CastExpr) right = ((CastExpr)right).getExpr();
     
View Full Code Here

  final int length = (_closureVars == null) ? 0 : _closureVars.size();

  for (int i = 0; i < length; i++) {
      VariableRefBase varRef = (VariableRefBase) _closureVars.get(i);
      VariableBase var = varRef.getVariable();
      Type varType = var.getType();

      il.append(DUP);

      // Find nearest closure implemented as an inner class
      Closure variableClosure = _parentClosure;
      while (variableClosure != null) {
    if (variableClosure.inInnerClass()) break;
    variableClosure = variableClosure.getParentClosure();
      }

      // Use getfield if in an inner class
      if (variableClosure != null) {
    il.append(ALOAD_0);
    il.append(new GETFIELD(
        cpg.addFieldref(variableClosure.getInnerClassName(),
      var.getVariable(), varType.toSignature())));
      }
      else {
    // Use a load of instruction if in translet class
    il.append(var.loadInstruction());
      }

      // Store variable in new closure
      il.append(new PUTFIELD(
        cpg.addFieldref(_className, var.getVariable(),
      varType.toSignature())));
  }
    }
View Full Code Here

  super(fname, arguments);
  _entity = argument();
    }

    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  final Type entity = _entity.typeCheck(stable);
  if (entity instanceof StringType == false) {
      _entity = new CastExpr(_entity, Type.String);
  }
  return _type = Type.String;
    }
View Full Code Here

  // Get the sort data type; default is text
  val = getAttribute("data-type");
  if (val.length() == 0) {
      try {
    final Type type = _select.typeCheck(parser.getSymbolTable());
    if (type instanceof IntType)
        val = "number";
    else
        val = "text";
      }
View Full Code Here

    /**
     * Run type checks on the attributes; expression must return a string
     * which we will use as a sort key
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  final Type tselect = _select.typeCheck(stable);

  // If the sort data-type is not set we use the natural data-type
  // of the data we will sort
  if (!(tselect instanceof StringType)) {
      _select = new CastExpr(_select, Type.String);
View Full Code Here

  // Initialize closure in record class
  final int ndups = dups.size();
  for (int i = 0; i < ndups; i++) {
      final VariableRefBase varRef = (VariableRefBase) dups.get(i);
      final VariableBase var = varRef.getVariable();
      final Type varType = var.getType();
     
      il.append(DUP);

      // Get field from factory class
      il.append(ALOAD_0);
      il.append(new GETFIELD(
    cpg.addFieldref(className,
        var.getEscapedName(), varType.toSignature())));

      // Put field in record class
      il.append(new PUTFIELD(
    cpg.addFieldref(sortRecordClass,
        var.getEscapedName(), varType.toSignature())));
  }
  il.append(POP);
  il.append(ARETURN);

  constructor.setMaxLocals();
View Full Code Here

     * is needed for expressions like $x where $x is a parameter reference.
     * All optimizations are turned off before type checking underlying
     * predicates.
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  Type ptype = _primary.typeCheck(stable);
        boolean canOptimize = _primary instanceof KeyCall;

  if (ptype instanceof NodeSetType == false) {
      if (ptype instanceof ReferenceType)  {
    _primary = new CastExpr(_primary, Type.NodeSet);
View Full Code Here

     * Type-check either the select attribute or the element body, depending
     * on which is in use.
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  if (_select != null) {
      final Type tselect = _select.typeCheck(stable);
      if (tselect instanceof ReferenceType == false) {
    _select = new CastExpr(_select, Type.Reference);
      }
  }
  else {
View Full Code Here

    /**
     * Type-check this expression, and possibly child expressions.
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  // Get the left and right operand types
  Type tleft = _left.typeCheck(stable);
  Type tright = _right.typeCheck(stable);

  // Check if the operator supports the two operand types
  MethodType wantType = new MethodType(Type.Void, tleft, tright);
  MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

  // Yes, the operation is supported
  if (haveType != null) {
      // Check if left-hand side operand must be type casted
      Type arg1 = (Type)haveType.argsType().elementAt(0);
      if (!arg1.identicalTo(tleft))
    _left = new CastExpr(_left, arg1);
      // Check if right-hand side operand must be type casted
      Type arg2 = (Type) haveType.argsType().elementAt(1);
      if (!arg2.identicalTo(tright))
    _right = new CastExpr(_right, arg1);
      // Return the result type for the operator we will use
      return _type = haveType.resultType();
  }
  throw new TypeCheckError(this);
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.