double lhs = D1.doubleValue(); double rhs = D2.doubleValue(); switch(kind) { // boolean case LT: case LTX: return new Boolean(lhs < rhs); case GT: case GTX: return new Boolean(lhs > rhs); case EQ: return new Boolean(lhs == rhs); case LE: case LEX: return new Boolean(lhs <= rhs); case GE: case GEX: return new Boolean(lhs >= rhs); case NE: return new Boolean(lhs != rhs); // arithmetic case PLUS: return new Double(lhs + rhs); case MINUS: return new Double(lhs - rhs); case STAR: return new Double(lhs * rhs); case SLASH: return new Double(lhs / rhs); case MOD: return new Double(lhs % rhs); // can't shift floating-point values case LSHIFT: case LSHIFTX: case RSIGNEDSHIFT: case RSIGNEDSHIFTX: case RUNSIGNEDSHIFT: case RUNSIGNEDSHIFTX: throw new UtilEvalError("Can't shift doubles"); default: throw new InterpreterError( "Unimplemented binary double operator"); }
float lhs = F1.floatValue(); float rhs = F2.floatValue(); switch(kind) { // boolean case LT: case LTX: return new Boolean(lhs < rhs); case GT: case GTX: return new Boolean(lhs > rhs); case EQ: return new Boolean(lhs == rhs); case LE: case LEX: return new Boolean(lhs <= rhs); case GE: case GEX: return new Boolean(lhs >= rhs); case NE: return new Boolean(lhs != rhs); // arithmetic case PLUS: return new Float(lhs + rhs); case MINUS: return new Float(lhs - rhs); case STAR: return new Float(lhs * rhs); case SLASH: return new Float(lhs / rhs); case MOD: return new Float(lhs % rhs); // can't shift floats case LSHIFT: case LSHIFTX: case RSIGNEDSHIFT: case RSIGNEDSHIFTX: case RUNSIGNEDSHIFT: case RUNSIGNEDSHIFTX: throw new UtilEvalError("Can't shift floats "); default: throw new InterpreterError( "Unimplemented binary float operator"); }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/bsh/Primitive.java File path: /jEdit-4.2/src/bsh/Primitive.java
Method name: Object doubleBinaryOperation(Double, Double, int) Method name: Object floatBinaryOperation(Float, Float, int)
Number of AST nodes: 38 Number of AST nodes: 38
1
double lhs = D1.doubleValue();
1
float lhs = F1.floatValue();
2
        double rhs = D2.doubleValue();
2
        float rhs = F2.floatValue();
3
        switch(kind)
3
        switch(kind)
4
        {
4
        {
5
            // boolean
5
            // boolean
6
            case LT:
6
            case LT:
7
            case LTX:
7
            case LTX:
8
                return new Boolean(lhs < rhs);
8
                return new Boolean(lhs < rhs);
9
            case GT:
9
            case GT:
10
            case GTX:
10
            case GTX:
11
                return new Boolean(lhs > rhs);
11
                return new Boolean(lhs > rhs);
12
            case EQ:
12
            case EQ:
13
                return new Boolean(lhs == rhs);
13
                return new Boolean(lhs == rhs);
14
            case LE:
14
            case LE:
15
            case LEX:
15
            case LEX:
16
                return new Boolean(lhs <= rhs);
16
                return new Boolean(lhs <= rhs);
17
            case GE:
17
            case GE:
18
            case GEX:
18
            case GEX:
19
                return new Boolean(lhs >= rhs);
19
                return new Boolean(lhs >= rhs);
20
            case NE:
20
            case NE:
21
                return new Boolean(lhs != rhs);
21
                return new Boolean(lhs != rhs);
22
            // arithmetic
22
            // arithmetic
23
            case PLUS:
23
            case PLUS:
24
                return new Double(lhs + rhs);
24
                return new Float(lhs + rhs);
25
            case MINUS:
25
            case MINUS:
26
                return new Double(lhs - rhs);
26
                return new Float(lhs - rhs);
27
            case STAR:
27
            case STAR:
28
                return new Double(lhs * rhs);
28
                return new Float(lhs * rhs);
29
            case SLASH:
29
            case SLASH:
30
                return new Double(lhs / rhs);
30
                return new Float(lhs / rhs);
31
            case MOD:
31
            case MOD:
32
                return new Double(lhs % rhs);
32
                return new Float(lhs % rhs);
33
            // can't shift floating-point values
33
            // can't shift floats
34
            case LSHIFT:
34
            case LSHIFT:
35
            case LSHIFTX:
35
            case LSHIFTX:
36
            case RSIGNEDSHIFT:
36
            case RSIGNEDSHIFT:
37
            case RSIGNEDSHIFTX:
37
            case RSIGNEDSHIFTX:
38
            case RUNSIGNEDSHIFT:
38
            case RUNSIGNEDSHIFT:
39
            case RUNSIGNEDSHIFTX:
39
            case RUNSIGNEDSHIFTX:
40
                throw new UtilEvalError("Can't shift doubles");
40
                throw new UtilEvalError("Can't shift floats ");
41
            default:
41
            default:
42
                throw new InterpreterError(
42
                throw new InterpreterError(
43
					"Unimplemented binary double operator");
43
					"Unimplemented binary float operator");
44
        }
44
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons648
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements36
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)53.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                              
    1
    float lhs = F1.floatValue();
    1
    double lhs = D1.doubleValue();
                                                                  
                                                              
    2
    float rhs = F2.floatValue();
    2
    double rhs = D2.doubleValue();
                                                                  
    3
    switch (kind)
    3
    switch (kind)
    4
    case LT:
    4
    case LT:
    5
    case LTX:
    5
    case LTX:
    6
    return new Boolean(lhs < rhs);
    6
    return new Boolean(lhs < rhs);
    6
    return new Boolean(lhs < rhs);
    Differences
    Expression1Expression2Difference
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    6
    return new Boolean(lhs < rhs);
    7
    case GT:
    7
    case GT:
    8
    case GTX:
    8
    case GTX:
    9
    return new Boolean(lhs > rhs);
    9
    return new Boolean(lhs > rhs);
    9
    return new Boolean(lhs > rhs);
    Differences
    Expression1Expression2Difference
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    9
    return new Boolean(lhs > rhs);
    10
    case EQ:
    10
    case EQ:
    11
    return new Boolean(lhs == rhs);
    11
    return new Boolean(lhs == rhs);
    11
    return new Boolean(lhs == rhs);
    Differences
    Expression1Expression2Difference
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    11
    return new Boolean(lhs == rhs);
    12
    case LE:
    12
    case LE:
    13
    case LEX:
    13
    case LEX:
    14
    return new Boolean(lhs <= rhs);
    14
    return new Boolean(lhs <= rhs);
    14
    return new Boolean(lhs <= rhs);
    Differences
    Expression1Expression2Difference
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    14
    return new Boolean(lhs <= rhs);
    15
    case GE:
    15
    case GE:
    16
    case GEX:
    16
    case GEX:
    17
    return new Boolean(lhs >= rhs);
    17
    return new Boolean(lhs >= rhs);
    17
    return new Boolean(lhs >= rhs);
    Differences
    Expression1Expression2Difference
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    17
    return new Boolean(lhs >= rhs);
    18
    case NE:
    18
    case NE:
    19
    return new Boolean(lhs != rhs);
    19
    return new Boolean(lhs != rhs);
    19
    return new Boolean(lhs != rhs);
    Differences
    Expression1Expression2Difference
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    19
    return new Boolean(lhs != rhs);
    20
    case PLUS:
    20
    case PLUS:
    21
    return new Double(lhs + rhs);
    21
    return new Double(lhs + rhs);
    21
    return new Float(lhs + rhs);
    Differences
    Expression1Expression2Difference
    java.lang.Doublejava.lang.FloatSUBCLASS_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression new Double(lhs + rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Float(lhs + rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    21
    return new Float(lhs + rhs);
    22
    case MINUS:
    22
    case MINUS:
    23
    return new Double(lhs - rhs);
    23
    return new Double(lhs - rhs);
    23
    return new Float(lhs - rhs);
    Differences
    Expression1Expression2Difference
    java.lang.Doublejava.lang.FloatSUBCLASS_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression new Double(lhs - rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Float(lhs - rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    23
    return new Float(lhs - rhs);
    24
    case STAR:
    24
    case STAR:
    25
    return new Double(lhs * rhs);
    25
    return new Double(lhs * rhs);
    25
    return new Float(lhs * rhs);
    Differences
    Expression1Expression2Difference
    java.lang.Doublejava.lang.FloatSUBCLASS_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression new Double(lhs * rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Float(lhs * rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    25
    return new Float(lhs * rhs);
    26
    case SLASH:
    26
    case SLASH:
    27
    return new Double(lhs / rhs);
    27
    return new Double(lhs / rhs);
    27
    return new Float(lhs / rhs);
    Differences
    Expression1Expression2Difference
    java.lang.Doublejava.lang.FloatSUBCLASS_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression new Double(lhs / rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Float(lhs / rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    27
    return new Float(lhs / rhs);
    28
    case MOD:
    28
    case MOD:
    29
    return new Double(lhs % rhs);
    29
    return new Double(lhs % rhs);
    29
    return new Float(lhs % rhs);
    Differences
    Expression1Expression2Difference
    java.lang.Doublejava.lang.FloatSUBCLASS_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    doublefloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression new Double(lhs % rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Float(lhs % rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type double of variable lhs does not match with type float of variable lhs
    Type double of variable rhs does not match with type float of variable rhs
    29
    return new Float(lhs % rhs);
    30
    case LSHIFT:
    30
    case LSHIFT:
    31
    case LSHIFTX:
    31
    case LSHIFTX:
    32
    case RSIGNEDSHIFT:
    32
    case RSIGNEDSHIFT:
    33
    case RSIGNEDSHIFTX:
    33
    case RSIGNEDSHIFTX:
    34
    case RUNSIGNEDSHIFT:
    34
    case RUNSIGNEDSHIFT:
    35
    case RUNSIGNEDSHIFTX:
    35
    case RUNSIGNEDSHIFTX:
    36
    throw new UtilEvalError("Can't shift doubles");
    36
    throw new UtilEvalError("Can't shift doubles");
    36
    throw new UtilEvalError("Can't shift floats ");
    Differences
    Expression1Expression2Difference
    "Can't shift doubles""Can't shift floats "LITERAL_VALUE_MISMATCH
    36
    throw new UtilEvalError("Can't shift floats ");
    37
    default:
    37
    default:
    38
    throw new InterpreterError("Unimplemented binary double operator");
    38
    throw new InterpreterError("Unimplemented binary double operator");
    38
    throw new InterpreterError("Unimplemented binary float operator");
    Differences
    Expression1Expression2Difference
    "Unimplemented binary double operator""Unimplemented binary float operator"LITERAL_VALUE_MISMATCH
    38
    throw new InterpreterError("Unimplemented binary float operator");
    Precondition Violations (32)
    Row Violation
    1Type double of variable lhs does not match with type float of variable lhs
    2Type double of variable rhs does not match with type float of variable rhs
    3Type double of variable lhs does not match with type float of variable lhs
    4Type double of variable rhs does not match with type float of variable rhs
    5Type double of variable lhs does not match with type float of variable lhs
    6Type double of variable rhs does not match with type float of variable rhs
    7Type double of variable lhs does not match with type float of variable lhs
    8Type double of variable rhs does not match with type float of variable rhs
    9Type double of variable lhs does not match with type float of variable lhs
    10Type double of variable rhs does not match with type float of variable rhs
    11Type double of variable lhs does not match with type float of variable lhs
    12Type double of variable rhs does not match with type float of variable rhs
    13Expression new Double(lhs + rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression new Float(lhs + rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Type double of variable lhs does not match with type float of variable lhs
    16Type double of variable rhs does not match with type float of variable rhs
    17Expression new Double(lhs - rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression new Float(lhs - rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Type double of variable lhs does not match with type float of variable lhs
    20Type double of variable rhs does not match with type float of variable rhs
    21Expression new Double(lhs * rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression new Float(lhs * rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Type double of variable lhs does not match with type float of variable lhs
    24Type double of variable rhs does not match with type float of variable rhs
    25Expression new Double(lhs / rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression new Float(lhs / rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27Type double of variable lhs does not match with type float of variable lhs
    28Type double of variable rhs does not match with type float of variable rhs
    29Expression new Double(lhs % rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30Expression new Float(lhs % rhs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    31Type double of variable lhs does not match with type float of variable lhs
    32Type double of variable rhs does not match with type float of variable rhs