final NextNode nextNode = (NextNode) node; CompilerCallback valueCallback = new CompilerCallback() { public void call(BodyCompiler context) { if (nextNode.getValueNode() != null) { compile(nextNode.getValueNode(), context,true); } else { context.loadNil(); } } }; context.pollThreadEvents(); context.issueNextEvent(valueCallback); // TODO: don't require pop if (!expr) context.consumeCurrentValue();
final PostExeNode postExeNode = (PostExeNode) node; // create the closure class and instantiate it final CompilerCallback closureBody = new CompilerCallback() { public void call(BodyCompiler context) { if (postExeNode.getBodyNode() != null) { compile(postExeNode.getBodyNode(), context, true); } else { context.loadNil(); } } }; context.createNewEndBlock(closureBody); // TODO: don't require pop if (!expr) context.consumeCurrentValue();
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/compiler/ASTCompiler.java File path: /jruby-1.4.0/src/org/jruby/compiler/ASTCompiler.java
Method name: void compileNext(Node, BodyCompiler, boolean) Method name: void compilePostExe(Node, BodyCompiler, boolean)
Number of AST nodes: 6 Number of AST nodes: 5
1
final NextNode nextNode = (NextNode) node;
1
final PostExeNode postExeNode = (PostExeNode) node;
2
        
2
        // create the closure class and instantiate it
3
CompilerCallback valueCallback = new CompilerCallback() {
3
        final CompilerCallback closureBody = new CompilerCallback() {
4
                    public void call(BodyCompiler context) {
4
                    public void call(BodyCompiler context) {
5
                        if (nextNode.getValueNode() != null) {
5
                        if (postExeNode.getBodyNode() != null) {
6
                            compile(nextNode.getValueNode(), context,true);
6
                            compile(postExeNode.getBodyNode(), context, true);
7
                        } else {
7
                        } else {
8
                            context.loadNil();
8
                            context.loadNil();
9
                        }
9
                        }
10
                    }
10
                    }
11
                };
11
                };
12
        context.pollThreadEvents();
12
        context.
13
        context.issueNextEvent(valueCallback);
13
createNewEndBlock(closureBody);
14
        // TODO: don't require pop
14
        // TODO: don't require pop
15
        if (!expr) context.consumeCurrentValue();
15
        if (!expr) context.consumeCurrentValue();
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 comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)2.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    final NextNode nextNode = (NextNode)node;
    1
    final NextNode nextNode = (NextNode)node;
    1
    final PostExeNode postExeNode = (PostExeNode)node;
    Differences
    Expression1Expression2Difference
    org.jruby.ast.NextNodeorg.jruby.ast.PostExeNodeSUBCLASS_TYPE_MISMATCH
    nextNodepostExeNodeVARIABLE_NAME_MISMATCH
    org.jruby.ast.NextNodeorg.jruby.ast.PostExeNodeSUBCLASS_TYPE_MISMATCH
    org.jruby.ast.NextNodeorg.jruby.ast.PostExeNodeSUBCLASS_TYPE_MISMATCH
    1
    final PostExeNode postExeNode = (PostExeNode)node;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    2
    final CompilerCallback closureBody = new CompilerCallback() {...};
    Preondition Violations
    Unmatched statement final CompilerCallback closureBody=new CompilerCallback(){ public void call( BodyCompiler context){ if (postExeNode.getBodyNode() != null) { compile(postExeNode.getBodyNode(),context,true); } else { context.loadNil(); } } } ; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    final CompilerCallback closureBody = new CompilerCallback() {...};
    2
    CompilerCallback valueCallback = new CompilerCallback() {...};
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    3
    context.pollThreadEvents();
    3
    context.pollThreadEvents();
    3
    context.createNewEndBlock(closureBody);
    Differences
    Expression1Expression2Difference
    pollThreadEventscreateNewEndBlockMETHOD_INVOCATION_NAME_MISMATCH
    context.pollThreadEvents()context.createNewEndBlock(closureBody)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression context.pollThreadEvents() is a void method call, and thus it cannot be parameterized
    Expression context.createNewEndBlock(closureBody) is a void method call, and thus it cannot be parameterized
    Expression context.pollThreadEvents() is a void method call, and thus it cannot be parameterized
    Expression context.createNewEndBlock(closureBody) is a void method call, and thus it cannot be parameterized
    3
    context.createNewEndBlock(closureBody);
    4
    context.issueNextEvent(valueCallback);
                                                                                      
    5
    if (!expr)
    4
    if (!expr)
    6
    context.consumeCurrentValue();
    5
    context.consumeCurrentValue();
    Precondition Violations (6)
    Row Violation
    1Unmatched statement final CompilerCallback closureBody=new CompilerCallback(){ public void call( BodyCompiler context){ if (postExeNode.getBodyNode() != null) { compile(postExeNode.getBodyNode(),context,true); } else { context.loadNil(); } } } ; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression context.pollThreadEvents() is a void method call, and thus it cannot be parameterized
    3Expression context.createNewEndBlock(closureBody) is a void method call, and thus it cannot be parameterized
    4Expression context.pollThreadEvents() is a void method call, and thus it cannot be parameterized
    5Expression context.createNewEndBlock(closureBody) is a void method call, and thus it cannot be parameterized
    6Clone fragment #1 returns variable nextNode with type org.jruby.ast.NextNode , while Clone fragment #2 returns variable postExeNode with type org.jruby.ast.PostExeNode