com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType Java Examples

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Param.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: Param.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: Param.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: Param.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #5
Source File: Param.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: Param.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #7
Source File: Param.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: Param.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: Param.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: Param.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source File: Param.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: CastCall.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #13
Source File: CastCall.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #14
Source File: CastCall.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #15
Source File: CastCall.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #16
Source File: CastCall.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #17
Source File: CastCall.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #18
Source File: CastCall.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #19
Source File: CastCall.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #20
Source File: CastCall.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #21
Source File: CastCall.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #22
Source File: CastCall.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
                                              getName(), this));
    }

    // The first argument must be a literal String
    Expression exp = argument(0);
    if (exp instanceof LiteralExpr) {
        _className = ((LiteralExpr) exp).getValue();
        _type = Type.newObjectType(_className);
    }
    else {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
                                              getName(), this));
    }

     // Second argument must be of type reference or object
    _right = argument(1);
    Type tright = _right.typeCheck(stable);
    if (tright != Type.Reference &&
        tright instanceof ObjectType == false)
    {
        throw new TypeCheckError(new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                              tright, _type, this));
    }

    return _type;
}
 
Example #23
Source File: FunctionCall.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
    final Vector constructors = findConstructors();
    if (constructors == null) {
        // Constructor not found in this class
        throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
            _className);

    }

    final int nConstructors = constructors.size();
    final int nArgs = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);

    // Try all constructors
    int bestConstrDistance = Integer.MAX_VALUE;
    _type = null;                   // reset
    for (int j, i = 0; i < nConstructors; i++) {
        // Check if all parameters to this constructor can be converted
        final Constructor constructor =
            (Constructor)constructors.elementAt(i);
        final Class[] paramTypes = constructor.getParameterTypes();

        Class extType = null;
        int currConstrDistance = 0;
        for (j = 0; j < nArgs; j++) {
            // Convert from internal (translet) type to external (Java) type
            extType = paramTypes[j];
            final Type intType = (Type)argsType.elementAt(j);
            Object match = _internal2Java.maps(intType, extType);
            if (match != null) {
                currConstrDistance += ((JavaType)match).distance;
            }
            else if (intType instanceof ObjectType) {
                ObjectType objectType = (ObjectType)intType;
                if (objectType.getJavaClass() == extType)
                    continue;
                else if (extType.isAssignableFrom(objectType.getJavaClass()))
                    currConstrDistance += 1;
                else {
                    currConstrDistance = Integer.MAX_VALUE;
                    break;
                }
            }
            else {
                // no mapping available
                currConstrDistance = Integer.MAX_VALUE;
                break;
            }
        }

        if (j == nArgs && currConstrDistance < bestConstrDistance ) {
            _chosenConstructor = constructor;
            _isExtConstructor = true;
            bestConstrDistance = currConstrDistance;

            _type = (_clazz != null) ? Type.newObjectType(_clazz)
                : Type.newObjectType(_className);
        }
    }

    if (_type != null) {
        return _type;
    }

    throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
}
 
Example #24
Source File: FunctionCall.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
    final Vector constructors = findConstructors();
    if (constructors == null) {
        // Constructor not found in this class
        throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
            _className);

    }

    final int nConstructors = constructors.size();
    final int nArgs = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);

    // Try all constructors
    int bestConstrDistance = Integer.MAX_VALUE;
    _type = null;                   // reset
    for (int j, i = 0; i < nConstructors; i++) {
        // Check if all parameters to this constructor can be converted
        final Constructor constructor =
            (Constructor)constructors.elementAt(i);
        final Class[] paramTypes = constructor.getParameterTypes();

        Class extType = null;
        int currConstrDistance = 0;
        for (j = 0; j < nArgs; j++) {
            // Convert from internal (translet) type to external (Java) type
            extType = paramTypes[j];
            final Type intType = (Type)argsType.elementAt(j);
            Object match = _internal2Java.maps(intType, extType);
            if (match != null) {
                currConstrDistance += ((JavaType)match).distance;
            }
            else if (intType instanceof ObjectType) {
                ObjectType objectType = (ObjectType)intType;
                if (objectType.getJavaClass() == extType)
                    continue;
                else if (extType.isAssignableFrom(objectType.getJavaClass()))
                    currConstrDistance += 1;
                else {
                    currConstrDistance = Integer.MAX_VALUE;
                    break;
                }
            }
            else {
                // no mapping available
                currConstrDistance = Integer.MAX_VALUE;
                break;
            }
        }

        if (j == nArgs && currConstrDistance < bestConstrDistance ) {
            _chosenConstructor = constructor;
            _isExtConstructor = true;
            bestConstrDistance = currConstrDistance;

            _type = (_clazz != null) ? Type.newObjectType(_clazz)
                : Type.newObjectType(_className);
        }
    }

    if (_type != null) {
        return _type;
    }

    throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
}
 
Example #25
Source File: FunctionCall.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
    final Vector constructors = findConstructors();
    if (constructors == null) {
        // Constructor not found in this class
        throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
            _className);

    }

    final int nConstructors = constructors.size();
    final int nArgs = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);

    // Try all constructors
    int bestConstrDistance = Integer.MAX_VALUE;
    _type = null;                   // reset
    for (int j, i = 0; i < nConstructors; i++) {
        // Check if all parameters to this constructor can be converted
        final Constructor constructor =
            (Constructor)constructors.elementAt(i);
        final Class[] paramTypes = constructor.getParameterTypes();

        Class<?> extType;
        int currConstrDistance = 0;
        for (j = 0; j < nArgs; j++) {
            // Convert from internal (translet) type to external (Java) type
            extType = paramTypes[j];
            final Type intType = (Type)argsType.elementAt(j);
            JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
            if (match != null) {
                currConstrDistance += match.distance;
            }
            else if (intType instanceof ObjectType) {
                ObjectType objectType = (ObjectType)intType;
                if (objectType.getJavaClass() == extType)
                    continue;
                else if (extType.isAssignableFrom(objectType.getJavaClass()))
                    currConstrDistance += 1;
                else {
                    currConstrDistance = Integer.MAX_VALUE;
                    break;
                }
            }
            else {
                // no mapping available
                currConstrDistance = Integer.MAX_VALUE;
                break;
            }
        }

        if (j == nArgs && currConstrDistance < bestConstrDistance ) {
            _chosenConstructor = constructor;
            _isExtConstructor = true;
            bestConstrDistance = currConstrDistance;

            _type = (_clazz != null) ? Type.newObjectType(_clazz)
                : Type.newObjectType(_className);
        }
    }

    if (_type != null) {
        return _type;
    }

    throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
}
 
Example #26
Source File: FunctionCall.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
    final Vector constructors = findConstructors();
    if (constructors == null) {
        // Constructor not found in this class
        throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
            _className);

    }

    final int nConstructors = constructors.size();
    final int nArgs = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);

    // Try all constructors
    int bestConstrDistance = Integer.MAX_VALUE;
    _type = null;                   // reset
    for (int j, i = 0; i < nConstructors; i++) {
        // Check if all parameters to this constructor can be converted
        final Constructor constructor =
            (Constructor)constructors.elementAt(i);
        final Class[] paramTypes = constructor.getParameterTypes();

        Class<?> extType;
        int currConstrDistance = 0;
        for (j = 0; j < nArgs; j++) {
            // Convert from internal (translet) type to external (Java) type
            extType = paramTypes[j];
            final Type intType = (Type)argsType.elementAt(j);
            JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
            if (match != null) {
                currConstrDistance += match.distance;
            }
            else if (intType instanceof ObjectType) {
                ObjectType objectType = (ObjectType)intType;
                if (objectType.getJavaClass() == extType)
                    continue;
                else if (extType.isAssignableFrom(objectType.getJavaClass()))
                    currConstrDistance += 1;
                else {
                    currConstrDistance = Integer.MAX_VALUE;
                    break;
                }
            }
            else {
                // no mapping available
                currConstrDistance = Integer.MAX_VALUE;
                break;
            }
        }

        if (j == nArgs && currConstrDistance < bestConstrDistance ) {
            _chosenConstructor = constructor;
            _isExtConstructor = true;
            bestConstrDistance = currConstrDistance;

            _type = (_clazz != null) ? Type.newObjectType(_clazz)
                : Type.newObjectType(_className);
        }
    }

    if (_type != null) {
        return _type;
    }

    throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
}
 
Example #27
Source File: FunctionCall.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
    final Vector constructors = findConstructors();
    if (constructors == null) {
        // Constructor not found in this class
        throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
            _className);

    }

    final int nConstructors = constructors.size();
    final int nArgs = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);

    // Try all constructors
    int bestConstrDistance = Integer.MAX_VALUE;
    _type = null;                   // reset
    for (int j, i = 0; i < nConstructors; i++) {
        // Check if all parameters to this constructor can be converted
        final Constructor constructor =
            (Constructor)constructors.elementAt(i);
        final Class[] paramTypes = constructor.getParameterTypes();

        Class<?> extType;
        int currConstrDistance = 0;
        for (j = 0; j < nArgs; j++) {
            // Convert from internal (translet) type to external (Java) type
            extType = paramTypes[j];
            final Type intType = (Type)argsType.elementAt(j);
            JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
            if (match != null) {
                currConstrDistance += match.distance;
            }
            else if (intType instanceof ObjectType) {
                ObjectType objectType = (ObjectType)intType;
                if (objectType.getJavaClass() == extType)
                    continue;
                else if (extType.isAssignableFrom(objectType.getJavaClass()))
                    currConstrDistance += 1;
                else {
                    currConstrDistance = Integer.MAX_VALUE;
                    break;
                }
            }
            else {
                // no mapping available
                currConstrDistance = Integer.MAX_VALUE;
                break;
            }
        }

        if (j == nArgs && currConstrDistance < bestConstrDistance ) {
            _chosenConstructor = constructor;
            _isExtConstructor = true;
            bestConstrDistance = currConstrDistance;

            _type = (_clazz != null) ? Type.newObjectType(_clazz)
                : Type.newObjectType(_className);
        }
    }

    if (_type != null) {
        return _type;
    }

    throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
}
 
Example #28
Source File: FunctionCall.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
    final List<Constructor<?>> constructors = findConstructors();
    if (constructors == null) {
        // Constructor not found in this class
        throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
            _className);

    }

    final int nConstructors = constructors.size();
    final int nArgs = _arguments.size();
    final List<Type> argsType = typeCheckArgs(stable);

    // Try all constructors
    int bestConstrDistance = Integer.MAX_VALUE;
    _type = null;                   // reset
    for (int j, i = 0; i < nConstructors; i++) {
        // Check if all parameters to this constructor can be converted
        final Constructor<?> constructor = constructors.get(i);
        final Class<?>[] paramTypes = constructor.getParameterTypes();

        Class<?> extType;
        int currConstrDistance = 0;
        for (j = 0; j < nArgs; j++) {
            // Convert from internal (translet) type to external (Java) type
            extType = paramTypes[j];
            final Type intType = argsType.get(j);
            JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
            if (match != null) {
                currConstrDistance += match.distance;
            }
            else if (intType instanceof ObjectType) {
                ObjectType objectType = (ObjectType)intType;
                if (objectType.getJavaClass() == extType)
                    continue;
                else if (extType.isAssignableFrom(objectType.getJavaClass()))
                    currConstrDistance += 1;
                else {
                    currConstrDistance = Integer.MAX_VALUE;
                    break;
                }
            }
            else {
                // no mapping available
                currConstrDistance = Integer.MAX_VALUE;
                break;
            }
        }

        if (j == nArgs && currConstrDistance < bestConstrDistance ) {
            _chosenConstructor = constructor;
            _isExtConstructor = true;
            bestConstrDistance = currConstrDistance;

            _type = (_clazz != null) ? Type.newObjectType(_clazz)
                : Type.newObjectType(_className);
        }
    }

    if (_type != null) {
        return _type;
    }

    throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
}
 
Example #29
Source File: FunctionCall.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
    final Vector constructors = findConstructors();
    if (constructors == null) {
        // Constructor not found in this class
        throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
            _className);

    }

    final int nConstructors = constructors.size();
    final int nArgs = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);

    // Try all constructors
    int bestConstrDistance = Integer.MAX_VALUE;
    _type = null;                   // reset
    for (int j, i = 0; i < nConstructors; i++) {
        // Check if all parameters to this constructor can be converted
        final Constructor constructor =
            (Constructor)constructors.elementAt(i);
        final Class[] paramTypes = constructor.getParameterTypes();

        Class<?> extType;
        int currConstrDistance = 0;
        for (j = 0; j < nArgs; j++) {
            // Convert from internal (translet) type to external (Java) type
            extType = paramTypes[j];
            final Type intType = (Type)argsType.elementAt(j);
            JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
            if (match != null) {
                currConstrDistance += match.distance;
            }
            else if (intType instanceof ObjectType) {
                ObjectType objectType = (ObjectType)intType;
                if (objectType.getJavaClass() == extType)
                    continue;
                else if (extType.isAssignableFrom(objectType.getJavaClass()))
                    currConstrDistance += 1;
                else {
                    currConstrDistance = Integer.MAX_VALUE;
                    break;
                }
            }
            else {
                // no mapping available
                currConstrDistance = Integer.MAX_VALUE;
                break;
            }
        }

        if (j == nArgs && currConstrDistance < bestConstrDistance ) {
            _chosenConstructor = constructor;
            _isExtConstructor = true;
            bestConstrDistance = currConstrDistance;

            _type = (_clazz != null) ? Type.newObjectType(_clazz)
                : Type.newObjectType(_className);
        }
    }

    if (_type != null) {
        return _type;
    }

    throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
}
 
Example #30
Source File: FunctionCall.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public Type typeCheckConstructor(SymbolTable stable) throws TypeCheckError{
    final Vector constructors = findConstructors();
    if (constructors == null) {
        // Constructor not found in this class
        throw new TypeCheckError(ErrorMsg.CONSTRUCTOR_NOT_FOUND,
            _className);

    }

    final int nConstructors = constructors.size();
    final int nArgs = _arguments.size();
    final Vector argsType = typeCheckArgs(stable);

    // Try all constructors
    int bestConstrDistance = Integer.MAX_VALUE;
    _type = null;                   // reset
    for (int j, i = 0; i < nConstructors; i++) {
        // Check if all parameters to this constructor can be converted
        final Constructor constructor =
            (Constructor)constructors.elementAt(i);
        final Class[] paramTypes = constructor.getParameterTypes();

        Class<?> extType;
        int currConstrDistance = 0;
        for (j = 0; j < nArgs; j++) {
            // Convert from internal (translet) type to external (Java) type
            extType = paramTypes[j];
            final Type intType = (Type)argsType.elementAt(j);
            JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
            if (match != null) {
                currConstrDistance += match.distance;
            }
            else if (intType instanceof ObjectType) {
                ObjectType objectType = (ObjectType)intType;
                if (objectType.getJavaClass() == extType)
                    continue;
                else if (extType.isAssignableFrom(objectType.getJavaClass()))
                    currConstrDistance += 1;
                else {
                    currConstrDistance = Integer.MAX_VALUE;
                    break;
                }
            }
            else {
                // no mapping available
                currConstrDistance = Integer.MAX_VALUE;
                break;
            }
        }

        if (j == nArgs && currConstrDistance < bestConstrDistance ) {
            _chosenConstructor = constructor;
            _isExtConstructor = true;
            bestConstrDistance = currConstrDistance;

            _type = (_clazz != null) ? Type.newObjectType(_clazz)
                : Type.newObjectType(_className);
        }
    }

    if (_type != null) {
        return _type;
    }

    throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
}