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"); }
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"); }
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 floatBinaryOperation(Float, Float, int) Method name: Object doubleBinaryOperation(Double, Double, int)
Number of AST nodes: 38 Number of AST nodes: 38
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
        {
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 Float(lhs + rhs);
24
                return new Double(lhs + rhs);
25
            case MINUS:
25
            case MINUS:
26
                return new Float(lhs - rhs);
26
                return new Double(lhs - rhs);
27
            case STAR:
27
            case STAR:
28
                return new Float(lhs * rhs);
28
                return new Double(lhs * rhs);
29
            case SLASH:
29
            case SLASH:
30
                return new Float(lhs / rhs);
30
                return new Double(lhs / rhs);
31
            case MOD:
31
            case MOD:
32
                return new Float(lhs % rhs);
32
                return new Double(lhs % rhs);
33
            // can't shift floats
33
            // can't shift floating-point values
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 floats ");
40
                throw new UtilEvalError("Can't shift doubles");
41
            default:
41
            default:
42
                throw new InterpreterError(
42
                throw new InterpreterError(
43
					"Unimplemented binary float operator");
43
					"Unimplemented binary double 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.1
Clones locationClones are declared in the same class
Number of node comparisons703
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements25
    Number of unmapped statements in the first code fragment13
    Number of unmapped statements in the second code fragment13
    Time elapsed for statement mapping (ms)27.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                  
    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
    case LT:
    4
    case LT:
    5
    case LTX:
    5
    case LTX:
                                                                      
    6
    return new Boolean(lhs < rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs < rhs);
    6
    return new Boolean(lhs < rhs);
    6
    return new Boolean(lhs < rhs);
    6
    return new Boolean(lhs < rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs < rhs);
                                                                      
    7
    case GT:
    7
    case GT:
    8
    case GTX:
    8
    case GTX:
                                                                      
    9
    return new Boolean(lhs > rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs > rhs);
    9
    return new Boolean(lhs > rhs);
    9
    return new Boolean(lhs > rhs);
    9
    return new Boolean(lhs > rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs > rhs);
                                                                      
    10
    case EQ:
    10
    case EQ:
                                                                          
    11
    return new Boolean(lhs == rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs == rhs);
    11
    return new Boolean(lhs == rhs);
    11
    return new Boolean(lhs == rhs);
    11
    return new Boolean(lhs == rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs == rhs);
                                                                          
    12
    case LE:
    12
    case LE:
    13
    case LEX:
    13
    case LEX:
                                                                          
    14
    return new Boolean(lhs <= rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs <= rhs);
    14
    return new Boolean(lhs <= rhs);
    14
    return new Boolean(lhs <= rhs);
    14
    return new Boolean(lhs <= rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs <= rhs);
                                                                          
    15
    case GE:
    15
    case GE:
    16
    case GEX:
    16
    case GEX:
                                                                          
    17
    return new Boolean(lhs >= rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs >= rhs);
    17
    return new Boolean(lhs >= rhs);
    17
    return new Boolean(lhs >= rhs);
    17
    return new Boolean(lhs >= rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs >= rhs);
                                                                          
    18
    case NE:
    18
    case NE:
                                                                          
    19
    return new Boolean(lhs != rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs != rhs);
    19
    return new Boolean(lhs != rhs);
    19
    return new Boolean(lhs != rhs);
    19
    return new Boolean(lhs != rhs);
    Preondition Violations
    Unmatched return new Boolean(lhs != rhs);
                                                                          
    20
    case PLUS:
    20
    case PLUS:
                                                                      
    21
    return new Double(lhs + rhs);
    Preondition Violations
    Unmatched return new Double(lhs + rhs);
    21
    return new Double(lhs + rhs);
    21
    return new Float(lhs + rhs);
    21
    return new Float(lhs + rhs);
    Preondition Violations
    Unmatched return new Float(lhs + rhs);
                                                                    
    22
    case MINUS:
    22
    case MINUS:
                                                                      
    23
    return new Double(lhs - rhs);
    Preondition Violations
    Unmatched return new Double(lhs - rhs);
    23
    return new Double(lhs - rhs);
    23
    return new Float(lhs - rhs);
    23
    return new Float(lhs - rhs);
    Preondition Violations
    Unmatched return new Float(lhs - rhs);
                                                                    
    24
    case STAR:
    24
    case STAR:
                                                                      
    25
    return new Double(lhs * rhs);
    Preondition Violations
    Unmatched return new Double(lhs * rhs);
    25
    return new Double(lhs * rhs);
    25
    return new Float(lhs * rhs);
    25
    return new Float(lhs * rhs);
    Preondition Violations
    Unmatched return new Float(lhs * rhs);
                                                                    
    26
    case SLASH:
    26
    case SLASH:
                                                                      
    27
    return new Double(lhs / rhs);
    Preondition Violations
    Unmatched return new Double(lhs / rhs);
    27
    return new Double(lhs / rhs);
    27
    return new Float(lhs / rhs);
    27
    return new Float(lhs / rhs);
    Preondition Violations
    Unmatched return new Float(lhs / rhs);
                                                                    
    28
    case MOD:
    28
    case MOD:
                                                                      
    29
    return new Double(lhs % rhs);
    Preondition Violations
    Unmatched return new Double(lhs % rhs);
    29
    return new Double(lhs % rhs);
    29
    return new Float(lhs % rhs);
    29
    return new Float(lhs % rhs);
    Preondition Violations
    Unmatched 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 floats ");
    36
    throw new UtilEvalError("Can't shift floats ");
    36
    throw new UtilEvalError("Can't shift doubles");
    Differences
    Expression1Expression2Difference
    "Can't shift floats ""Can't shift doubles"LITERAL_VALUE_MISMATCH
    36
    throw new UtilEvalError("Can't shift doubles");
    37
    default:
    37
    default:
    38
    throw new InterpreterError("Unimplemented binary float operator");
    38
    throw new InterpreterError("Unimplemented binary float operator");
    38
    throw new InterpreterError("Unimplemented binary double operator");
    Differences
    Expression1Expression2Difference
    "Unimplemented binary float operator""Unimplemented binary double operator"LITERAL_VALUE_MISMATCH
    38
    throw new InterpreterError("Unimplemented binary double operator");
    Precondition Violations (22)
    Row Violation
    1Unmatched return new Boolean(lhs < rhs);
    2Unmatched return new Boolean(lhs < rhs);
    3Unmatched return new Boolean(lhs > rhs);
    4Unmatched return new Boolean(lhs > rhs);
    5Unmatched return new Boolean(lhs == rhs);
    6Unmatched return new Boolean(lhs == rhs);
    7Unmatched return new Boolean(lhs <= rhs);
    8Unmatched return new Boolean(lhs <= rhs);
    9Unmatched return new Boolean(lhs >= rhs);
    10Unmatched return new Boolean(lhs >= rhs);
    11Unmatched return new Boolean(lhs != rhs);
    12Unmatched return new Boolean(lhs != rhs);
    13Unmatched return new Double(lhs + rhs);
    14Unmatched return new Float(lhs + rhs);
    15Unmatched return new Double(lhs - rhs);
    16Unmatched return new Float(lhs - rhs);
    17Unmatched return new Double(lhs * rhs);
    18Unmatched return new Float(lhs * rhs);
    19Unmatched return new Double(lhs / rhs);
    20Unmatched return new Float(lhs / rhs);
    21Unmatched return new Double(lhs % rhs);
    22Unmatched return new Float(lhs % rhs);