Search in sources :

Example 1 with MethodType

use of org.apache.xalan.xsltc.compiler.util.MethodType in project servicemix-bundles by apache.

the class FunctionCall method typeCheckStandard.

/**
 * Type check a call to a standard function. Insert CastExprs when needed.
 * If as a result of the insertion of a CastExpr a type check error is
 * thrown, then catch it and re-throw it with a new "this".
 */
public Type typeCheckStandard(SymbolTable stable) throws TypeCheckError {
    // HACK!!!
    _fname.clearNamespace();
    final int n = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);
    final MethodType args = new MethodType(Type.Void, argsType);
    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) {
                    // invalid conversion
                    throw new TypeCheckError(this);
                }
            }
        }
        _chosenMethodType = ptype;
        return _type = ptype.resultType();
    }
    throw new TypeCheckError(this);
}
Also used : MethodType(org.apache.xalan.xsltc.compiler.util.MethodType) BooleanType(org.apache.xalan.xsltc.compiler.util.BooleanType) Type(org.apache.xalan.xsltc.compiler.util.Type) ObjectType(org.apache.xalan.xsltc.compiler.util.ObjectType) IntType(org.apache.xalan.xsltc.compiler.util.IntType) MethodType(org.apache.xalan.xsltc.compiler.util.MethodType) ReferenceType(org.apache.xalan.xsltc.compiler.util.ReferenceType) Vector(java.util.Vector) TypeCheckError(org.apache.xalan.xsltc.compiler.util.TypeCheckError)

Aggregations

Vector (java.util.Vector)1 BooleanType (org.apache.xalan.xsltc.compiler.util.BooleanType)1 IntType (org.apache.xalan.xsltc.compiler.util.IntType)1 MethodType (org.apache.xalan.xsltc.compiler.util.MethodType)1 ObjectType (org.apache.xalan.xsltc.compiler.util.ObjectType)1 ReferenceType (org.apache.xalan.xsltc.compiler.util.ReferenceType)1 Type (org.apache.xalan.xsltc.compiler.util.Type)1 TypeCheckError (org.apache.xalan.xsltc.compiler.util.TypeCheckError)1