use of org.eclipse.wst.xml.xpath2.processor.internal.ast.SingleType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit cast expression
*
* @param cexp
* is the cast expression.
* @return a new function
*/
public Object visit(CastExpr cexp) {
ResultSequence rs = (ResultSequence) cexp.left().accept(this);
SingleType st = (SingleType) cexp.right();
rs = FnData.atomize(rs);
if (rs.size() > 1)
report_error(TypeError.invalid_type(null));
if (rs.empty()) {
if (st.qmark())
return rs;
else
report_error(TypeError.invalid_type(null));
}
AnyType at = (AnyType) rs.item(0);
if (!(at instanceof AnyAtomicType))
report_error(TypeError.invalid_type(null));
AnyAtomicType aat = (AnyAtomicType) at;
QName type = st.type();
// prepare args from function
Collection args = new ArrayList();
args.add(ResultSequenceFactory.create_new(aat));
try {
Function function = cexp.function();
if (function == null) {
function = _sc.resolveFunction(type.asQName(), args.size());
cexp.set_function(function);
}
if (function == null)
report_error(TypeError.invalid_type(null));
return function.evaluate(args, _ec);
} catch (DynamicError err) {
report_error(err);
// unreach
return null;
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.SingleType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit castable expression
*
* @param cexp
* is the castable expression.
* @return a new function
*/
public Object visit(CastableExpr cexp) {
boolean castable = false;
try {
CastExpr ce = new CastExpr((Expr) cexp.left(), (SingleType) cexp.right());
visit(ce);
castable = true;
} catch (Throwable t) {
castable = false;
}
return ResultSequenceFactory.create_new(new XSBoolean(castable));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.SingleType in project webtools.sourceediting by eclipse.
the class StaticNameResolver method visit.
/**
* Validate a cast expression.
*
* @param cexp
* is the expression.
* @return null.
*/
public Object visit(CastExpr cexp) {
printBinExpr("CAST", cexp);
SingleType st = (SingleType) cexp.right();
QName type = st.type();
javax.xml.namespace.QName qName = type.asQName();
Function f = _sc.resolveFunction(qName, 1);
if (f == null)
reportError(new StaticFunctNameError("Type does not exist: " + type.toString()));
cexp.set_function(f);
_resolvedFunctions.add(qName);
return null;
}
Aggregations