int lhs = I1.intValue(); int rhs = I2.intValue(); 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 Integer(lhs + rhs); case MINUS: return new Integer(lhs - rhs); case STAR: return new Integer(lhs * rhs); case SLASH: return new Integer(lhs / rhs); case MOD: return new Integer(lhs % rhs); // bitwise case LSHIFT: case LSHIFTX: return new Integer(lhs << rhs); case RSIGNEDSHIFT: case RSIGNEDSHIFTX: return new Integer(lhs >> rhs); case RUNSIGNEDSHIFT: case RUNSIGNEDSHIFTX: return new Integer(lhs >>> rhs); case BIT_AND: case BIT_ANDX: return new Integer(lhs & rhs); case BIT_OR: case BIT_ORX: return new Integer(lhs | rhs); case XOR: return new Integer(lhs ^ rhs); default: throw new InterpreterError( "Unimplemented binary integer operator"); }
long lhs = L1.longValue(); long rhs = L2.longValue(); 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 Long(lhs + rhs); case MINUS: return new Long(lhs - rhs); case STAR: return new Long(lhs * rhs); case SLASH: return new Long(lhs / rhs); case MOD: return new Long(lhs % rhs); // bitwise case LSHIFT: case LSHIFTX: return new Long(lhs << rhs); case RSIGNEDSHIFT: case RSIGNEDSHIFTX: return new Long(lhs >> rhs); case RUNSIGNEDSHIFT: case RUNSIGNEDSHIFTX: return new Long(lhs >>> rhs); case BIT_AND: case BIT_ANDX: return new Long(lhs & rhs); case BIT_OR: case BIT_ORX: return new Long(lhs | rhs); case XOR: return new Long(lhs ^ rhs); default: throw new InterpreterError( "Unimplemented binary long 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 intBinaryOperation(Integer, Integer, int) Method name: Object longBinaryOperation(Long, Long, int)
Number of AST nodes: 48 Number of AST nodes: 48
1
int lhs = I1.intValue();
1
long lhs = L1.longValue();
2
        int rhs = I2.intValue();
2
        long rhs = L2.longValue();
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 Integer(lhs + rhs);
24
                return new Long(lhs + rhs);
25
            case MINUS:
25
            case MINUS:
26
                return new Integer(lhs - rhs);
26
                return new Long(lhs - rhs);
27
            case STAR:
27
            case STAR:
28
                return new Integer(lhs * rhs);
28
                return new Long(lhs * rhs);
29
            case SLASH:
29
            case SLASH:
30
                return new Integer(lhs / rhs);
30
                return new Long(lhs / rhs);
31
            case MOD:
31
            case MOD:
32
                return new Integer(lhs % rhs);
32
                return new Long(lhs % rhs);
33
            // bitwise
33
            // bitwise
34
            case LSHIFT:
34
            case LSHIFT:
35
            case LSHIFTX:
35
            case LSHIFTX:
36
                return new Integer(lhs << rhs);
36
                return new Long(lhs << rhs);
37
            case RSIGNEDSHIFT:
37
            case RSIGNEDSHIFT:
38
            case RSIGNEDSHIFTX:
38
            case RSIGNEDSHIFTX:
39
                return new Integer(lhs >> rhs);
39
                return new Long(lhs >> rhs);
40
            case RUNSIGNEDSHIFT:
40
            case RUNSIGNEDSHIFT:
41
            case RUNSIGNEDSHIFTX:
41
            case RUNSIGNEDSHIFTX:
42
                return new Integer(lhs >>> rhs);
42
                return new Long(lhs >>> rhs);
43
            case BIT_AND:
43
            case BIT_AND:
44
            case BIT_ANDX:
44
            case BIT_ANDX:
45
                return new Integer(lhs & rhs);
45
                return new Long(lhs & rhs);
46
            case BIT_OR:
46
            case BIT_OR:
47
            case BIT_ORX:
47
            case BIT_ORX:
48
                return new Integer(lhs | rhs);
48
                return new Long(lhs | rhs);
49
            case XOR:
49
            case XOR:
50
                return new Integer(lhs ^ rhs);
50
                return new Long(lhs ^ rhs);
51
            default:
51
            default:
52
                throw new InterpreterError(
52
                throw new InterpreterError(
53
					"Unimplemented binary integer operator");
53
					"Unimplemented binary long operator");
54
        }
54
        }
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.2
Clones locationClones are declared in the same class
Number of node comparisons1194
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements29
    Number of unmapped statements in the first code fragment19
    Number of unmapped statements in the second code fragment19
    Time elapsed for statement mapping (ms)388.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                          
    1
    long lhs = L1.longValue();
    1
    int lhs = I1.intValue();
                                                      
                                                          
    2
    long rhs = L2.longValue();
    2
    int rhs = I2.intValue();
                                                      
    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 Long(lhs + rhs);
    Preondition Violations
    Unmatched return new Long(lhs + rhs);
    21
    return new Long(lhs + rhs);
    21
    return new Integer(lhs + rhs);
    21
    return new Integer(lhs + rhs);
    Preondition Violations
    Unmatched return new Integer(lhs + rhs);
                                                                        
    22
    case MINUS:
    22
    case MINUS:
                                                                  
    23
    return new Long(lhs - rhs);
    Preondition Violations
    Unmatched return new Long(lhs - rhs);
    23
    return new Long(lhs - rhs);
    23
    return new Integer(lhs - rhs);
    23
    return new Integer(lhs - rhs);
    Preondition Violations
    Unmatched return new Integer(lhs - rhs);
                                                                        
    24
    case STAR:
    24
    case STAR:
                                                                  
    25
    return new Long(lhs * rhs);
    Preondition Violations
    Unmatched return new Long(lhs * rhs);
    25
    return new Long(lhs * rhs);
    25
    return new Integer(lhs * rhs);
    25
    return new Integer(lhs * rhs);
    Preondition Violations
    Unmatched return new Integer(lhs * rhs);
                                                                        
    26
    case SLASH:
    26
    case SLASH:
                                                                  
    27
    return new Long(lhs / rhs);
    Preondition Violations
    Unmatched return new Long(lhs / rhs);
    27
    return new Long(lhs / rhs);
    27
    return new Integer(lhs / rhs);
    27
    return new Integer(lhs / rhs);
    Preondition Violations
    Unmatched return new Integer(lhs / rhs);
                                                                        
    28
    case MOD:
    28
    case MOD:
                                                                  
    29
    return new Long(lhs % rhs);
    Preondition Violations
    Unmatched return new Long(lhs % rhs);
    29
    return new Long(lhs % rhs);
    29
    return new Integer(lhs % rhs);
    29
    return new Integer(lhs % rhs);
    Preondition Violations
    Unmatched return new Integer(lhs % rhs);
                                                                        
    30
    case LSHIFT:
    30
    case LSHIFT:
    31
    case LSHIFTX:
    31
    case LSHIFTX:
                                                                    
    32
    return new Long(lhs << rhs);
    Preondition Violations
    Unmatched return new Long(lhs << rhs);
    32
    return new Long(lhs << rhs);
    32
    return new Integer(lhs << rhs);
    32
    return new Integer(lhs << rhs);
    Preondition Violations
    Unmatched return new Integer(lhs << rhs);
                                                                          
    33
    case RSIGNEDSHIFT:
    33
    case RSIGNEDSHIFT:
    34
    case RSIGNEDSHIFTX:
    34
    case RSIGNEDSHIFTX:
                                                                    
    35
    return new Long(lhs >> rhs);
    Preondition Violations
    Unmatched return new Long(lhs >> rhs);
    35
    return new Long(lhs >> rhs);
    35
    return new Integer(lhs >> rhs);
    35
    return new Integer(lhs >> rhs);
    Preondition Violations
    Unmatched return new Integer(lhs >> rhs);
                                                                          
    36
    case RUNSIGNEDSHIFT:
    36
    case RUNSIGNEDSHIFT:
    37
    case RUNSIGNEDSHIFTX:
    37
    case RUNSIGNEDSHIFTX:
                                                                      
    38
    return new Long(lhs >>> rhs);
    Preondition Violations
    Unmatched return new Long(lhs >>> rhs);
    38
    return new Long(lhs >>> rhs);
    38
    return new Integer(lhs >>> rhs);
    38
    return new Integer(lhs >>> rhs);
    Preondition Violations
    Unmatched return new Integer(lhs >>> rhs);
                                                                            
    39
    case BIT_AND:
    39
    case BIT_AND:
    40
    case BIT_ANDX:
    40
    case BIT_ANDX:
                                                                  
    41
    return new Long(lhs & rhs);
    Preondition Violations
    Unmatched return new Long(lhs & rhs);
    41
    return new Long(lhs & rhs);
    41
    return new Integer(lhs & rhs);
    41
    return new Integer(lhs & rhs);
    Preondition Violations
    Unmatched return new Integer(lhs & rhs);
                                                                        
    42
    case BIT_OR:
    42
    case BIT_OR:
    43
    case BIT_ORX:
    43
    case BIT_ORX:
                                                                  
    44
    return new Long(lhs | rhs);
    Preondition Violations
    Unmatched return new Long(lhs | rhs);
    44
    return new Long(lhs | rhs);
    44
    return new Integer(lhs | rhs);
    44
    return new Integer(lhs | rhs);
    Preondition Violations
    Unmatched return new Integer(lhs | rhs);
                                                                        
    45
    case XOR:
    45
    case XOR:
                                                                  
    46
    return new Long(lhs ^ rhs);
    Preondition Violations
    Unmatched return new Long(lhs ^ rhs);
    46
    return new Long(lhs ^ rhs);
    46
    return new Integer(lhs ^ rhs);
    46
    return new Integer(lhs ^ rhs);
    Preondition Violations
    Unmatched return new Integer(lhs ^ rhs);
                                                                        
    47
    default:
    47
    default:
    48
    throw new InterpreterError("Unimplemented binary integer operator");
    48
    throw new InterpreterError("Unimplemented binary integer operator");
    48
    throw new InterpreterError("Unimplemented binary long operator");
    Differences
    Expression1Expression2Difference
    "Unimplemented binary integer operator""Unimplemented binary long operator"LITERAL_VALUE_MISMATCH
    48
    throw new InterpreterError("Unimplemented binary long operator");
    Precondition Violations (34)
    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 Long(lhs + rhs);
    14Unmatched return new Integer(lhs + rhs);
    15Unmatched return new Long(lhs - rhs);
    16Unmatched return new Integer(lhs - rhs);
    17Unmatched return new Long(lhs * rhs);
    18Unmatched return new Integer(lhs * rhs);
    19Unmatched return new Long(lhs / rhs);
    20Unmatched return new Integer(lhs / rhs);
    21Unmatched return new Long(lhs % rhs);
    22Unmatched return new Integer(lhs % rhs);
    23Unmatched return new Long(lhs << rhs);
    24Unmatched return new Integer(lhs << rhs);
    25Unmatched return new Long(lhs >> rhs);
    26Unmatched return new Integer(lhs >> rhs);
    27Unmatched return new Long(lhs >>> rhs);
    28Unmatched return new Integer(lhs >>> rhs);
    29Unmatched return new Long(lhs & rhs);
    30Unmatched return new Integer(lhs & rhs);
    31Unmatched return new Long(lhs | rhs);
    32Unmatched return new Integer(lhs | rhs);
    33Unmatched return new Long(lhs ^ rhs);
    34Unmatched return new Integer(lhs ^ rhs);