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

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType. 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: LogicalExpr.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = haveType.argsType().get(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = haveType.argsType().get(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #2
Source File: BinOpExpr.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: UnaryOpExpr.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: BinOpExpr.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: UnaryOpExpr.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: BinOpExpr.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: UnaryOpExpr.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #8
Source File: LogicalExpr.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #9
Source File: BinOpExpr.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
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);
}
 
Example #10
Source File: LogicalExpr.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #11
Source File: UnaryOpExpr.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #12
Source File: BinOpExpr.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #13
Source File: LogicalExpr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #14
Source File: LogicalExpr.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #15
Source File: BinOpExpr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #16
Source File: UnaryOpExpr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #17
Source File: UnaryOpExpr.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
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 = ptype.argsType().get(0);
        if (!arg1.identicalTo(tleft)) {
            _left = new CastExpr(_left, arg1);
        }
        return _type = ptype.resultType();
    }

    throw new TypeCheckError(this);
}
 
Example #18
Source File: BinOpExpr.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
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 = ptype.argsType().get(0);
        if (!arg1.identicalTo(tleft)) {
            _left = new CastExpr(_left, arg1);
        }
        final Type arg2 = ptype.argsType().get(1);
        if (!arg2.identicalTo(tright)) {
            _right = new CastExpr(_right, arg1);
        }
        return _type = ptype.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #19
Source File: LogicalExpr.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #20
Source File: UnaryOpExpr.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #21
Source File: BinOpExpr.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #22
Source File: LogicalExpr.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #23
Source File: UnaryOpExpr.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #24
Source File: BinOpExpr.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #25
Source File: LogicalExpr.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #26
Source File: UnaryOpExpr.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #27
Source File: BinOpExpr.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #28
Source File: LogicalExpr.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Type-check this expression, and possibly child expressions.
 */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    // Get the left and right operand types
    Type tleft = _left.typeCheck(stable);
    Type tright = _right.typeCheck(stable);

    // Check if the operator supports the two operand types
    MethodType wantType = new MethodType(Type.Void, tleft, tright);
    MethodType haveType = lookupPrimop(stable, Ops[_op], wantType);

    // Yes, the operation is supported
    if (haveType != null) {
        // Check if left-hand side operand must be type casted
        Type arg1 = (Type)haveType.argsType().elementAt(0);
        if (!arg1.identicalTo(tleft))
            _left = new CastExpr(_left, arg1);
        // Check if right-hand side operand must be type casted
        Type arg2 = (Type) haveType.argsType().elementAt(1);
        if (!arg2.identicalTo(tright))
            _right = new CastExpr(_right, arg1);
        // Return the result type for the operator we will use
        return _type = haveType.resultType();
    }
    throw new TypeCheckError(this);
}
 
Example #29
Source File: UnaryOpExpr.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #30
Source File: BinOpExpr.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}