public Type typeCheck(SymbolTable stable) throws TypeCheckError { final int length = _components.length; for (int i = 0; i < length; i++) { if (_components[i].typeCheck(stable) != Type.NodeSet) { _components[i] = new CastExpr(_components[i], Type.NodeSet); } } return _type = Type.NodeSet; }
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; }
/** * */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { _langType = _lang.typeCheck(stable); if (!(_langType instanceof StringType)) { _lang = new CastExpr(_lang, Type.String); } return Type.Boolean; }
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; }
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; }
public Type typeCheck(SymbolTable stable) throws TypeCheckError { final Type tselect = _select.typeCheck(stable); if (tselect instanceof NodeType || tselect instanceof NodeSetType || tselect instanceof ReferenceType || tselect instanceof ResultTreeType) { // falls through } else { _select = new CastExpr(_select, Type.String); } return Type.Void; }
public Type typeCheck(SymbolTable stable) throws TypeCheckError { final Vector contents = getContents(); final int n = contents.size(); for (int i = 0; i < n; i++) { final Expression exp = (Expression)contents.elementAt(i); if (!exp.typeCheck(stable).identicalTo(Type.String)) { contents.setElementAt(new CastExpr(exp, Type.String), i); } } return _type = Type.String; }
/** * Type checks the 'file' attribute (must be able to convert it to a str). */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { final Type type = _filename.typeCheck(stable); if (type instanceof StringType == false) { _filename = new CastExpr(_filename, Type.String); } typeCheckContents(stable); return Type.Void; }
public Type typeCheck(SymbolTable stable) throws TypeCheckError { // Type check match pattern _match.typeCheck(stable); // Cast node values to string values (except for nodesets) _useType = _use.typeCheck(stable); if (_useType instanceof StringType == false && _useType instanceof NodeSetType == false) { _use = new CastExpr(_use, Type.String); } return Type.Void; }
/** * Type-check the "test" expression and contents of this element. * The contents will be ignored if we know the test will always fail. */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { // Type-check the "test" expression if (_test.typeCheck(stable) instanceof BooleanType == false) { _test = new CastExpr(_test, Type.Boolean); } // Type check the element contents if (!_ignore) { typeCheckContents(stable); } return Type.Void; }
/** * 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 { typeCheckContents(stable); } return Type.Void; }
/** * Type-check this when element. The test should always be type checked, * while we do not bother with the contents if we know the test fails. * This is important in cases where the "test" expression tests for * the support of a non-available element, and the <xsl:when> body contains * this non-available element. */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { // Type-check the test expression if (_test.typeCheck(stable) instanceof BooleanType == false) { _test = new CastExpr(_test, Type.Boolean); } // Type-check the contents (if necessary) if (!_ignore) { typeCheckContents(stable); } return Type.Void; }
/** * Type-checks the parameter. The parameter type is determined by the * 'select' expression (if present) or is a result tree if the parameter * element has a body and no 'select' expression. */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { if (_select != null) { _type = _select.typeCheck(stable); if (_type instanceof ReferenceType == false && !(_type instanceof ObjectType)) { _select = new CastExpr(_select, Type.Reference); } } else if (hasContents()) { typeCheckContents(stable); } _type = Type.Reference; // This element has no type (the parameter does, but the parameter // element itself does not). return Type.Void; }
public Type typeCheck(SymbolTable stable) throws TypeCheckError { _type = _select.typeCheck(stable); if (_type instanceof ReferenceType || _type instanceof NodeType) { _select = new CastExpr(_select, Type.NodeSet); typeCheckContents(stable); return Type.Void; } if (_type instanceof NodeSetType||_type instanceof ResultTreeType) { typeCheckContents(stable); return Type.Void; } throw new TypeCheckError(this); }
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); }
/** * Type check the two parameters for this function */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { // Check that the function was passed exactly two arguments if (argumentCount() != 2) { 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; }
public Type typeCheck(SymbolTable stable) throws TypeCheckError { for (int i = 0; i < argumentCount(); i++) { final Expression exp = argument(i); if (!exp.typeCheck(stable).identicalTo(Type.String)) { setArgument(i, new CastExpr(exp, Type.String)); } } return _type = Type.String; }
public Type typeCheck(SymbolTable stable) throws TypeCheckError { if (_select != null) { _type = _select.typeCheck(stable); if (_type instanceof NodeType || _type instanceof ReferenceType) { _select = new CastExpr(_select, Type.NodeSet); _type = Type.NodeSet; } if (_type instanceof NodeSetType||_type instanceof ResultTreeType) { typeCheckContents(stable); // with-params return Type.Void; } throw new TypeCheckError(this); } else { typeCheckContents(stable); // with-params return Type.Void; } }
public Type typeCheck(SymbolTable stable) throws TypeCheckError { final Type tleft = _left.typeCheck(stable); final MethodType ptype = lookupPrimop(stable, "u-", new MethodType(Type.Void, tleft)); if (ptype != null) { final Type arg1 = (Type) ptype.argsType().elementAt(0); if (!arg1.identicalTo(tleft)) { _left = new CastExpr(_left, arg1); } return _type = ptype.resultType(); } throw new TypeCheckError(this); }
/** * 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); } _order.typeCheck(stable); _caseOrder.typeCheck(stable); _dataType.typeCheck(stable); _lang.typeCheck(stable); return Type.Void; }