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"); }
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"); }
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 longBinaryOperation(Long, Long, int) Method name: Object intBinaryOperation(Integer, Integer, int)
Number of AST nodes: 46 Number of AST nodes: 46
1
switch(kind)
1
switch(kind)
2
        {
2
        {
3
            // boolean
3
            // boolean
4
            case LT:
4
            case LT:
5
            case LTX:
5
            case LTX:
6
                return new Boolean(lhs < 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);
10
            case EQ:
10
            case EQ:
11
                return new Boolean(lhs == 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);
15
            case GE:
15
            case GE:
16
            case GEX:
16
            case GEX:
17
                return new Boolean(lhs >= 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);
20
            // arithmetic
20
            // arithmetic
21
            case PLUS:
21
            case PLUS:
22
                return new Long(lhs + rhs);
22
                return new Integer(lhs + rhs);
23
            case MINUS:
23
            case MINUS:
24
                return new Long(lhs - rhs);
24
                return new Integer(lhs - rhs);
25
            case STAR:
25
            case STAR:
26
                return new Long(lhs * rhs);
26
                return new Integer(lhs * rhs);
27
            case SLASH:
27
            case SLASH:
28
                return new Long(lhs / rhs);
28
                return new Integer(lhs / rhs);
29
            case MOD:
29
            case MOD:
30
                return new Long(lhs % rhs);
30
                return new Integer(lhs % rhs);
31
            // bitwise
31
            // bitwise
32
            case LSHIFT:
32
            case LSHIFT:
33
            case LSHIFTX:
33
            case LSHIFTX:
34
                return new Long(lhs << rhs);
34
                return new Integer(lhs << rhs);
35
            case RSIGNEDSHIFT:
35
            case RSIGNEDSHIFT:
36
            case RSIGNEDSHIFTX:
36
            case RSIGNEDSHIFTX:
37
                return new Long(lhs >> rhs);
37
                return new Integer(lhs >> rhs);
38
            case RUNSIGNEDSHIFT:
38
            case RUNSIGNEDSHIFT:
39
            case RUNSIGNEDSHIFTX:
39
            case RUNSIGNEDSHIFTX:
40
                return new Long(lhs >>> rhs);
40
                return new Integer(lhs >>> rhs);
41
            case BIT_AND:
41
            case BIT_AND:
42
            case BIT_ANDX:
42
            case BIT_ANDX:
43
                return new Long(lhs & rhs);
43
                return new Integer(lhs & rhs);
44
            case BIT_OR:
44
            case BIT_OR:
45
            case BIT_ORX:
45
            case BIT_ORX:
46
                return new Long(lhs | rhs);
46
                return new Integer(lhs | rhs);
47
            case XOR:
47
            case XOR:
48
                return new Long(lhs ^ rhs);
48
                return new Integer(lhs ^ rhs);
49
            default:
49
            default:
50
                throw new InterpreterError(
50
                throw new InterpreterError(
51
					"Unimplemented binary long operator");
51
					"Unimplemented binary integer operator");
52
        }
52
        }
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 comparisons1190
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements29
    Number of unmapped statements in the first code fragment17
    Number of unmapped statements in the second code fragment17
    Time elapsed for statement mapping (ms)101.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    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 Integer(lhs + rhs);
    Preondition Violations
    Unmatched return new Integer(lhs + rhs);
    21
    return new Integer(lhs + rhs);
    21
    return new Long(lhs + rhs);
    21
    return new Long(lhs + rhs);
    Preondition Violations
    Unmatched return new Long(lhs + rhs);
                                                                  
    22
    case MINUS:
    22
    case MINUS:
                                                                        
    23
    return new Integer(lhs - rhs);
    Preondition Violations
    Unmatched return new Integer(lhs - rhs);
    23
    return new Integer(lhs - rhs);
    23
    return new Long(lhs - rhs);
    23
    return new Long(lhs - rhs);
    Preondition Violations
    Unmatched return new Long(lhs - rhs);
                                                                  
    24
    case STAR:
    24
    case STAR:
                                                                        
    25
    return new Integer(lhs * rhs);
    Preondition Violations
    Unmatched return new Integer(lhs * rhs);
    25
    return new Integer(lhs * rhs);
    25
    return new Long(lhs * rhs);
    25
    return new Long(lhs * rhs);
    Preondition Violations
    Unmatched return new Long(lhs * rhs);
                                                                  
    26
    case SLASH:
    26
    case SLASH:
                                                                        
    27
    return new Integer(lhs / rhs);
    Preondition Violations
    Unmatched return new Integer(lhs / rhs);
    27
    return new Integer(lhs / rhs);
    27
    return new Long(lhs / rhs);
    27
    return new Long(lhs / rhs);
    Preondition Violations
    Unmatched return new Long(lhs / rhs);
                                                                  
    28
    case MOD:
    28
    case MOD:
                                                                        
    29
    return new Integer(lhs % rhs);
    Preondition Violations
    Unmatched return new Integer(lhs % rhs);
    29
    return new Integer(lhs % rhs);
    29
    return new Long(lhs % rhs);
    29
    return new Long(lhs % rhs);
    Preondition Violations
    Unmatched return new Long(lhs % rhs);
                                                                  
    30
    case LSHIFT:
    30
    case LSHIFT:
    31
    case LSHIFTX:
    31
    case LSHIFTX:
                                                                          
    32
    return new Integer(lhs << rhs);
    Preondition Violations
    Unmatched return new Integer(lhs << rhs);
    32
    return new Integer(lhs << rhs);
    32
    return new Long(lhs << rhs);
    32
    return new Long(lhs << rhs);
    Preondition Violations
    Unmatched return new Long(lhs << rhs);
                                                                    
    33
    case RSIGNEDSHIFT:
    33
    case RSIGNEDSHIFT:
    34
    case RSIGNEDSHIFTX:
    34
    case RSIGNEDSHIFTX:
                                                                          
    35
    return new Integer(lhs >> rhs);
    Preondition Violations
    Unmatched return new Integer(lhs >> rhs);
    35
    return new Integer(lhs >> rhs);
    35
    return new Long(lhs >> rhs);
    35
    return new Long(lhs >> rhs);
    Preondition Violations
    Unmatched return new Long(lhs >> rhs);
                                                                    
    36
    case RUNSIGNEDSHIFT:
    36
    case RUNSIGNEDSHIFT:
    37
    case RUNSIGNEDSHIFTX:
    37
    case RUNSIGNEDSHIFTX:
                                                                            
    38
    return new Integer(lhs >>> rhs);
    Preondition Violations
    Unmatched return new Integer(lhs >>> rhs);
    38
    return new Integer(lhs >>> rhs);
    38
    return new Long(lhs >>> rhs);
    38
    return new Long(lhs >>> rhs);
    Preondition Violations
    Unmatched return new Long(lhs >>> rhs);
                                                                      
    39
    case BIT_AND:
    39
    case BIT_AND:
    40
    case BIT_ANDX:
    40
    case BIT_ANDX:
                                                                        
    41
    return new Integer(lhs & rhs);
    Preondition Violations
    Unmatched return new Integer(lhs & rhs);
    41
    return new Integer(lhs & rhs);
    41
    return new Long(lhs & rhs);
    41
    return new Long(lhs & rhs);
    Preondition Violations
    Unmatched return new Long(lhs & rhs);
                                                                  
    42
    case BIT_OR:
    42
    case BIT_OR:
    43
    case BIT_ORX:
    43
    case BIT_ORX:
                                                                        
    44
    return new Integer(lhs | rhs);
    Preondition Violations
    Unmatched return new Integer(lhs | rhs);
    44
    return new Integer(lhs | rhs);
    44
    return new Long(lhs | rhs);
    44
    return new Long(lhs | rhs);
    Preondition Violations
    Unmatched return new Long(lhs | rhs);
                                                                  
    45
    case XOR:
    45
    case XOR:
                                                                        
    46
    return new Integer(lhs ^ rhs);
    Preondition Violations
    Unmatched return new Integer(lhs ^ rhs);
    46
    return new Integer(lhs ^ rhs);
    46
    return new Long(lhs ^ rhs);
    46
    return new Long(lhs ^ rhs);
    Preondition Violations
    Unmatched return new Long(lhs ^ rhs);
                                                                  
    47
    default:
    47
    default:
    48
    throw new InterpreterError("Unimplemented binary long operator");
    48
    throw new InterpreterError("Unimplemented binary long operator");
    48
    throw new InterpreterError("Unimplemented binary integer operator");
    Differences
    Expression1Expression2Difference
    "Unimplemented binary long operator""Unimplemented binary integer operator"LITERAL_VALUE_MISMATCH
    48
    throw new InterpreterError("Unimplemented binary integer 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 Integer(lhs + rhs);
    14Unmatched return new Long(lhs + rhs);
    15Unmatched return new Integer(lhs - rhs);
    16Unmatched return new Long(lhs - rhs);
    17Unmatched return new Integer(lhs * rhs);
    18Unmatched return new Long(lhs * rhs);
    19Unmatched return new Integer(lhs / rhs);
    20Unmatched return new Long(lhs / rhs);
    21Unmatched return new Integer(lhs % rhs);
    22Unmatched return new Long(lhs % rhs);
    23Unmatched return new Integer(lhs << rhs);
    24Unmatched return new Long(lhs << rhs);
    25Unmatched return new Integer(lhs >> rhs);
    26Unmatched return new Long(lhs >> rhs);
    27Unmatched return new Integer(lhs >>> rhs);
    28Unmatched return new Long(lhs >>> rhs);
    29Unmatched return new Integer(lhs & rhs);
    30Unmatched return new Long(lhs & rhs);
    31Unmatched return new Integer(lhs | rhs);
    32Unmatched return new Long(lhs | rhs);
    33Unmatched return new Integer(lhs ^ rhs);
    34Unmatched return new Long(lhs ^ rhs);