if (specificArity) { method = new SkinnyMethodAdapter(script.getClassVisitor().visitMethod(ACC_PUBLIC | ACC_STATIC, methodName, StandardASMCompiler.getStaticMethodSignature(script.getClassname(), 4), null, null)); method.start(); // check arity in the variable-arity version method.aload(1); method.invokevirtual(p(ThreadContext.class), "getRuntime", sig(Ruby.class)); method.aload(3); method.pushInt(scope.getRequiredArgs()); method.pushInt(scope.getRequiredArgs()); method.invokestatic(p(Arity.class), "checkArgumentCount", sig(int.class, Ruby.class, IRubyObject[].class, int.class, int.class)); method.pop(); loadThis(); loadThreadContext(); loadSelf(); // FIXME: missing arity check for (int i = 0; i < scope.getRequiredArgs(); i++) { method.aload(StandardASMCompiler.ARGS_INDEX); method.ldc(i); method.arrayload(); } method.aload(StandardASMCompiler.ARGS_INDEX + 1); // load block from [] version of method method.invokestatic(script.getClassname(), methodName, getSignature()); method.areturn(); method.end(); }
if (specificArity) { method = new SkinnyMethodAdapter( script.getClassVisitor().visitMethod( ACC_PUBLIC | ACC_STATIC, methodName, StandardASMCompiler.getStaticMethodSignature(script.getClassname(), 4), null, null)); method.start(); // check arity in the variable-arity version method.aload(1); method.invokevirtual(p(ThreadContext.class), "getRuntime", sig(Ruby.class)); method.aload(3); method.pushInt(scope.getRequiredArgs()); method.pushInt(scope.getRequiredArgs()); method.invokestatic(p(Arity.class), "checkArgumentCount", sig(int.class, Ruby.class, IRubyObject[].class, int.class, int.class)); method.pop(); loadThis(); loadThreadContext(); loadSelf(); // FIXME: missing arity check for (int i = 0; i < scope.getRequiredArgs(); i++) { method.aload(StandardASMCompiler.ARGS_INDEX); method.ldc(i); method.arrayload(); } method.aload(StandardASMCompiler.ARGS_INDEX + 1); // load block from [] version of method method.invokestatic(script.getClassname(), methodName, getSignature()); method.areturn(); method.end(); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/compiler/impl/RootScopedBodyCompiler.java File path: /jruby-1.4.0/src/org/jruby/compiler/impl/MethodBodyCompiler.java
Method name: void endBody() Method name: void endBody()
Number of AST nodes: 21 Number of AST nodes: 21
1
if (specificArity) {
1
if (specificArity) {
2
            
2
            method = new SkinnyMethodAdapter(
3
            method = new SkinnyMethodAdapter(
3
script.getClassVisitor().visitMethod(ACC_PUBLIC | ACC_STATIC, methodName,
4
                    script.getClassVisitor().visitMethod(
5
                        ACC_PUBLIC | ACC_STATIC,
6
                        methodName,
4
 StandardASMCompiler.getStaticMethodSignature(script.getClassname(), 4), null,
7
                        StandardASMCompiler.getStaticMethodSignature(script.getClassname(), 4),
8
                        null,
5
 null));
9
                        null));
6
            method.start();
10
            method.start();
7
            // check arity in the variable-arity version
11
            // check arity in the variable-arity version
8
            method.aload(1);
12
            method.aload(1);
9
            method.invokevirtual(p(ThreadContext.class), "getRuntime", sig(Ruby.class));
13
            method.invokevirtual(p(ThreadContext.class), "getRuntime", sig(Ruby.class));
10
            method.aload(3);
14
            method.aload(3);
11
            method.pushInt(scope.getRequiredArgs());
15
            method.pushInt(scope.getRequiredArgs());
12
            method.pushInt(scope.getRequiredArgs());
16
            method.pushInt(scope.getRequiredArgs());
13
            method.invokestatic(p(Arity.class), "checkArgumentCount", sig(int.class, Ruby.class, IRubyObject[].class, int.class, int.class));
17
            method.invokestatic(p(Arity.class), "checkArgumentCount", sig(int.class, Ruby.class, IRubyObject[].class, int.class, int.class));
14
            method.pop();
18
            method.pop();
15
            loadThis();
19
            loadThis();
16
            loadThreadContext();
20
            loadThreadContext();
17
            loadSelf();
21
            loadSelf();
18
            // FIXME: missing arity check
22
            // FIXME: missing arity check
19
            for (int i = 0; i < scope.getRequiredArgs(); i++) {
23
            for (int i = 0; i < scope.getRequiredArgs(); i++) {
20
                method.aload(StandardASMCompiler.ARGS_INDEX);
24
                method.aload(StandardASMCompiler.ARGS_INDEX);
21
                method.ldc(i);
25
                method.ldc(i);
22
                method.arrayload();
26
                method.arrayload();
23
            }
27
            }
24
            method.aload(StandardASMCompiler.ARGS_INDEX + 1);
28
            method.aload(StandardASMCompiler.ARGS_INDEX + 1);
25
            // load block from [] version of method
29
            // load block from [] version of method
26
            method.invokestatic(script.getClassname(), methodName, getSignature());
30
            method.invokestatic(script.getClassname(), methodName, getSignature());
27
            method.areturn();
31
            method.areturn();
28
            method.end();
32
            method.end();
29
        }
33
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.7
Clones locationClones are in different classes having the same super class
Number of node comparisons305
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements21
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)163.3
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    5
    if (specificArity)
    11
    if (specificArity)
    6
    method = new SkinnyMethodAdapter(script.getClassVisitor().visitMethod(ACC_PUBLIC | ACC_STATIC, methodName, StandardASMCompiler.getStaticMethodSignature(script.getClassname(), 4), null, null));
    12
    method = new SkinnyMethodAdapter(script.getClassVisitor().visitMethod(ACC_PUBLIC | ACC_STATIC, methodName, StandardASMCompiler.getStaticMethodSignature(script.getClassname(), 4), null, null));
    7
    method.start();
    13
    method.start();
    8
    method.aload(1);
    14
    method.aload(1);
    9
    method.invokevirtual(p(ThreadContext.class), "getRuntime", sig(Ruby.class));
    15
    method.invokevirtual(p(ThreadContext.class), "getRuntime", sig(Ruby.class));
    10
    method.aload(3);
    16
    method.aload(3);
    11
    method.pushInt(scope.getRequiredArgs());
    18
    method.pushInt(scope.getRequiredArgs());
    12
    method.pushInt(scope.getRequiredArgs());
    17
    method.pushInt(scope.getRequiredArgs());
    13
    method.invokestatic(p(Arity.class), "checkArgumentCount", sig(int.class, Ruby.class, IRubyObject[].class, int.class, int.class));
    19
    method.invokestatic(p(Arity.class), "checkArgumentCount", sig(int.class, Ruby.class, IRubyObject[].class, int.class, int.class));
    14
    method.pop();
    20
    method.pop();
    15
    loadThis();
    21
    loadThis();
    16
    loadThreadContext();
    22
    loadThreadContext();
    17
    loadSelf();
    23
    loadSelf();
    18
    for (int i = 0; i < scope.getRequiredArgs(); i++)
    24
    for (int i = 0; i < scope.getRequiredArgs(); i++)
    19
    method.aload(StandardASMCompiler.ARGS_INDEX);
    25
    method.aload(StandardASMCompiler.ARGS_INDEX);
    20
    method.ldc(i);
    26
    method.ldc(i);
    21
    method.arrayload();
    27
    method.arrayload();
    22
    method.aload(StandardASMCompiler.ARGS_INDEX + 1);
    28
    method.aload(StandardASMCompiler.ARGS_INDEX + 1);
    23
    method.invokestatic(script.getClassname(), methodName, getSignature());
    29
    method.invokestatic(script.getClassname(), methodName, getSignature());
    24
    method.areturn();
    30
    method.areturn();
    25
    method.end();
    31
    method.end();
    Precondition Violations (0)
    Row Violation