int slot = exists(name); if (slot >= 0) { // mark as captured if from containing scope if (depth > 0) capture(slot); return new DVarNode(position, ((depth << 16) | slot), name); } return enclosingScope.declare(position, name, depth + 1);
int slot = exists(name); if (slot >= 0) { // mark as captured if from containing scope if (depth > 0) capture(slot); //System.out.println("LVAR: " + name + ", l: " + depth + ", i: " + slot); return new LocalVarNode(position, ((depth << 16) | slot), name); } return new VCallNode(position, name);
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/parser/BlockStaticScope.java File path: /jruby-1.4.0/src/org/jruby/parser/LocalStaticScope.java
Method name: Node declare(ISourcePosition, String, int) Method name: Node declare(ISourcePosition, String, int)
Number of AST nodes: 6 Number of AST nodes: 6
1
int slot = exists(name);
1
int slot = exists(name);
2
        
2
        
3
        if (slot >= 0) {
3
        if (slot >= 0) {
4
            // mark as captured if from containing scope
4
            // mark as captured if from containing scope
5
            if (depth > 0) capture(slot);
5
            if (depth > 0) capture(slot);
6
            
6
            
7
            //System.out.println("LVAR: " + name + ", l: " + depth + ", i: " + slot);
7
            return new DVarNode(position, ((depth << 16) | slot), name);
8
            return new LocalVarNode(position, ((depth << 16) | slot), name);
8
        }
9
        }
9
        
10
        
10
        return enclosingScope.declare(position, name, depth + 1);
11
        return new VCallNode(position, name);
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 in different classes having the same super class
Number of node comparisons12
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    int slot = exists(name);
    1
    int slot = exists(name);
    2
    if (slot >= 0)
    2
    if (slot >= 0)
    3
    if (depth > 0)
    3
    if (depth > 0)
    4
    capture(slot);
    4
    capture(slot);
    5
    return new DVarNode(position, ((depth << 16) | slot), name);
    5
    return new DVarNode(position, ((depth << 16) | slot), name);
    5
    return new LocalVarNode(position, ((depth << 16) | slot), name);
    Differences
    Expression1Expression2Difference
    org.jruby.ast.DVarNodeorg.jruby.ast.LocalVarNodeSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new DVarNode(position,((depth << 16) | slot),name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new LocalVarNode(position,((depth << 16) | slot),name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    return new LocalVarNode(position, ((depth << 16) | slot), name);
    6
    return enclosingScope.declare(position, name, depth + 1);
    6
    return enclosingScope.declare(position, name, depth + 1);
    6
    return new VCallNode(position, name);
    Differences
    Expression1Expression2Difference
    enclosingScope.declare(position,name,depth + 1)new VCallNode(position,name)TYPE_COMPATIBLE_REPLACEMENT
    6
    return new VCallNode(position, name);
    Precondition Violations (2)
    Row Violation
    1Expression new DVarNode(position,((depth << 16) | slot),name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new LocalVarNode(position,((depth << 16) | slot),name) cannot be parameterized, because it has dependencies to/from statements that will be extracted