*/
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;