File path: /jruby-1.4.0/src/org/jruby/compiler/impl/StandardInvocationCompiler.java | File path: /jruby-1.4.0/src/org/jruby/compiler/impl/StandardInvocationCompiler.java | |||
Method name: void opElementAsgnWithOr(CompilerCallback, ArgumentsCallback, CompilerCallback)
|
Method name: void opElementAsgnWithAnd(CompilerCallback, ArgumentsCallback, CompilerCallback)
|
|||
Number of AST nodes: 45 | Number of AST nodes: 45 | |||
1 | methodCompiler.getScriptCompiler().getCacheCompiler().cacheCallSite(methodCompiler, "[]", CallType.FUNCTIONAL);↵ | 1 | methodCompiler.getScriptCompiler().getCacheCompiler().cacheCallSite(methodCompiler, "[]", CallType.FUNCTIONAL);↵ | |
2 | methodCompiler.loadThreadContext();↵ | 2 | methodCompiler.loadThreadContext();↵ | |
3 | methodCompiler.loadSelf();↵ | 3 | methodCompiler.loadSelf();↵ | |
4 | ↵ | 4 | ↵ | |
5 | // evaluate and save receiver and args↵ | 5 | // evaluate and save receiver and args↵ | |
6 | receiver.call(methodCompiler);↵ | 6 | receiver.call(methodCompiler);↵ | |
7 | args.call(methodCompiler);↵ | 7 | args.call(methodCompiler);↵ | |
8 | method.dup2();↵ | 8 | method.dup2();↵ | |
9 | int argsLocal = methodCompiler.getVariableCompiler().grabTempLocal();↵ | 9 | int argsLocal = methodCompiler.getVariableCompiler().grabTempLocal();↵ | |
10 | methodCompiler.getVariableCompiler().setTempLocal(argsLocal);↵ | 10 | methodCompiler.getVariableCompiler().setTempLocal(argsLocal);↵ | |
11 | int receiverLocal = methodCompiler.getVariableCompiler().grabTempLocal();↵ | 11 | int receiverLocal = methodCompiler.getVariableCompiler().grabTempLocal();↵ | |
12 | methodCompiler.getVariableCompiler().setTempLocal(receiverLocal);↵ | 12 | methodCompiler.getVariableCompiler().setTempLocal(receiverLocal);↵ | |
13 | ↵ | 13 | ↵ | |
14 | // invoke↵ | 14 | // invoke↵ | |
15 | switch (args.getArity()) {↵ | 15 | switch (args.getArity()) {↵ | |
16 | case 1:↵ | 16 | case 1:↵ | |
17 | method.invokevirtual(p(CallSite.class), "call", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject.class));↵ | 17 | method.invokevirtual(p(CallSite.class), "call", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject.class));↵ | |
18 | break;↵ | 18 | break;↵ | |
19 | default:↵ | 19 | default:↵ | |
20 | method.invokevirtual(p(CallSite.class), "call", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class));↵ | 20 | method.invokevirtual(p(CallSite.class), "call", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class));↵ | |
21 | }↵ | 21 | }↵ | |
22 | ↵ | 22 | ↵ | |
23 | // check if it's true, ending if so↵ | 23 | // check if it's true, ending if not↵ | |
24 | method.dup();↵ | 24 | method.dup();↵ | |
25 | methodCompiler.invokeIRubyObject("isTrue", sig(boolean.class));↵ | 25 | methodCompiler.invokeIRubyObject("isTrue", sig(boolean.class));↵ | |
26 | Label done = new Label();↵ | 26 | Label done = new Label();↵ | |
27 | method.ifne(done);↵ | 27 | method.ifeq(done);↵ | |
28 | ↵ | 28 | ↵ | |
29 | // not true, eval value and assign↵ | 29 | // not true, eval value and assign↵ | |
30 | method.pop();↵ | 30 | method.pop();↵ | |
31 | // thread context, receiver and original args↵ | 31 | // thread context, receiver and original args↵ | |
32 | methodCompiler.loadThreadContext();↵ | 32 | methodCompiler.loadThreadContext();↵ | |
33 | methodCompiler.loadSelf();↵ | 33 | methodCompiler.loadSelf();↵ | |
34 | methodCompiler.getVariableCompiler().getTempLocal(receiverLocal);↵ | 34 | methodCompiler.getVariableCompiler().getTempLocal(receiverLocal);↵ | |
35 | methodCompiler.getVariableCompiler().getTempLocal(argsLocal);↵ | 35 | methodCompiler.getVariableCompiler().getTempLocal(argsLocal);↵ | |
36 | ↵ | 36 | ↵ | |
37 | // eval value for assignment↵ | 37 | // eval value and save it↵ | |
38 | valueCallback.call(methodCompiler);↵ | 38 | valueCallback.call(methodCompiler);↵ | |
39 | ↵ | 39 | ↵ | |
40 | // call site↵ | 40 | // call site↵ | |
41 | methodCompiler.getScriptCompiler().getCacheCompiler().cacheCallSite(methodCompiler, "[]=", CallType.FUNCTIONAL);↵ | 41 | methodCompiler.getScriptCompiler().getCacheCompiler().cacheCallSite(methodCompiler, "[]=", CallType.FUNCTIONAL);↵ | |
42 | ↵ | 42 | ↵ | |
43 | // depending on size of original args, call appropriate utility method↵ | 43 | // depending on size of original args, call appropriate utility method↵ | |
44 | switch (args.getArity()) {↵ | 44 | switch (args.getArity()) {↵ | |
45 | case 0:↵ | 45 | case 0:↵ | |
46 | throw new NotCompilableException("Op Element Asgn with zero-arity args");↵ | 46 | throw new NotCompilableException("Op Element Asgn with zero-arity args");↵ | |
47 | case 1:↵ | 47 | case 1:↵ | |
48 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoOneArg", ↵ | 48 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoOneArg", ↵ | |
49 | sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject.class, IRubyObject.class, CallSite.class));↵ | 49 | sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject.class, IRubyObject.class, CallSite.class));↵ | |
50 | break;↵ | 50 | break;↵ | |
51 | case 2:↵ | 51 | case 2:↵ | |
52 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoTwoArgs", ↵ | 52 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoTwoArgs", ↵ | |
53 | sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class));↵ | 53 | sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class));↵ | |
54 | break;↵ | 54 | break;↵ | |
55 | case 3:↵ | 55 | case 3:↵ | |
56 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoThreeArgs", ↵ | 56 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoThreeArgs", ↵ | |
57 | sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class));↵ | 57 | sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class));↵ | |
58 | break;↵ | 58 | break;↵ | |
59 | default:↵ | 59 | default:↵ | |
60 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoNArgs", ↵ | 60 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoNArgs", ↵ | |
61 | sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class));↵ | 61 | sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class));↵ | |
62 | break;↵ | 62 | break;↵ | |
63 | }↵ | 63 | }↵ | |
64 | ↵ | 64 | ↵ | |
65 | method.label(done);↵ | 65 | method.label(done);↵ | |
66 | ↵ | 66 | ↵ | |
67 | methodCompiler.getVariableCompiler().releaseTempLocal();↵ | 67 | methodCompiler.getVariableCompiler().releaseTempLocal();↵ | |
68 | methodCompiler.getVariableCompiler().releaseTempLocal(); | 68 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.6 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 508 |
Number of mapped statements | 45 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 197.3 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | methodCompiler.getScriptCompiler().getCacheCompiler().cacheCallSite(methodCompiler, "[]", CallType.FUNCTIONAL); | 1 | methodCompiler.getScriptCompiler().getCacheCompiler().cacheCallSite(methodCompiler, "[]", CallType.FUNCTIONAL); | |||||||||||||||
2 | methodCompiler.loadThreadContext(); | 2 | methodCompiler.loadThreadContext(); | |||||||||||||||
3 | methodCompiler.loadSelf(); | 3 | methodCompiler.loadSelf(); | |||||||||||||||
4 | receiver.call(methodCompiler); | 4 | receiver.call(methodCompiler); | |||||||||||||||
5 | args.call(methodCompiler); | 5 | args.call(methodCompiler); | |||||||||||||||
6 | method.dup2(); | 6 | method.dup2(); | |||||||||||||||
7 | int argsLocal = methodCompiler.getVariableCompiler().grabTempLocal(); | 7 | int argsLocal = methodCompiler.getVariableCompiler().grabTempLocal(); | |||||||||||||||
8 | methodCompiler.getVariableCompiler().setTempLocal(argsLocal); | 8 | methodCompiler.getVariableCompiler().setTempLocal(argsLocal); | |||||||||||||||
9 | int receiverLocal = methodCompiler.getVariableCompiler().grabTempLocal(); | 9 | int receiverLocal = methodCompiler.getVariableCompiler().grabTempLocal(); | |||||||||||||||
10 | methodCompiler.getVariableCompiler().setTempLocal(receiverLocal); | 10 | methodCompiler.getVariableCompiler().setTempLocal(receiverLocal); | |||||||||||||||
11 | switch (args.getArity()) | 11 | switch (args.getArity()) | |||||||||||||||
12 | case 1: | 12 | case 1: | |||||||||||||||
13 | method.invokevirtual(p(CallSite.class), "call", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject.class)); | 13 | method.invokevirtual(p(CallSite.class), "call", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject.class)); | |||||||||||||||
14 | break; | 14 | break; | |||||||||||||||
15 | default: | 15 | default: | |||||||||||||||
16 | method.invokevirtual(p(CallSite.class), "call", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class)); | 16 | method.invokevirtual(p(CallSite.class), "call", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class)); | |||||||||||||||
17 | method.dup(); | 17 | method.dup(); | |||||||||||||||
18 | methodCompiler.invokeIRubyObject("isTrue", sig(boolean.class)); | 18 | methodCompiler.invokeIRubyObject("isTrue", sig(boolean.class)); | |||||||||||||||
19 | Label done = new Label(); | 19 | Label done = new Label(); | |||||||||||||||
20 | method.ifne(done); |
| 20 | method.ifeq(done); | ||||||||||||||
21 | method.pop(); | 21 | method.pop(); | |||||||||||||||
22 | methodCompiler.loadThreadContext(); | 22 | methodCompiler.loadThreadContext(); | |||||||||||||||
23 | methodCompiler.loadSelf(); | 23 | methodCompiler.loadSelf(); | |||||||||||||||
24 | methodCompiler.getVariableCompiler().getTempLocal(receiverLocal); | 24 | methodCompiler.getVariableCompiler().getTempLocal(receiverLocal); | |||||||||||||||
25 | methodCompiler.getVariableCompiler().getTempLocal(argsLocal); | 25 | methodCompiler.getVariableCompiler().getTempLocal(argsLocal); | |||||||||||||||
26 | valueCallback.call(methodCompiler); | 26 | valueCallback.call(methodCompiler); | |||||||||||||||
27 | methodCompiler.getScriptCompiler().getCacheCompiler().cacheCallSite(methodCompiler, "[]=", CallType.FUNCTIONAL); | 27 | methodCompiler.getScriptCompiler().getCacheCompiler().cacheCallSite(methodCompiler, "[]=", CallType.FUNCTIONAL); | |||||||||||||||
28 | switch (args.getArity()) | 28 | switch (args.getArity()) | |||||||||||||||
29 | case 0: | 29 | case 0: | |||||||||||||||
30 | throw new NotCompilableException("Op Element Asgn with zero-arity args"); | 30 | throw new NotCompilableException("Op Element Asgn with zero-arity args"); | |||||||||||||||
31 | case 1: | 31 | case 1: | |||||||||||||||
32 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoOneArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject.class, IRubyObject.class, CallSite.class)); | 32 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoOneArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject.class, IRubyObject.class, CallSite.class)); | |||||||||||||||
33 | break; | 33 | break; | |||||||||||||||
34 | case 2: | 34 | case 2: | |||||||||||||||
35 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoTwoArgs", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class)); | 35 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoTwoArgs", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class)); | |||||||||||||||
36 | break; | 36 | break; | |||||||||||||||
37 | case 3: | 37 | case 3: | |||||||||||||||
38 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoThreeArgs", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class)); | 38 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoThreeArgs", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class)); | |||||||||||||||
39 | break; | 39 | break; | |||||||||||||||
40 | default: | 40 | default: | |||||||||||||||
41 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoNArgs", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class)); | 41 | methodCompiler.invokeUtilityMethod("opElementAsgnWithOrPartTwoNArgs", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, IRubyObject[].class, IRubyObject.class, CallSite.class)); | |||||||||||||||
42 | break; | 42 | break; | |||||||||||||||
43 | method.label(done); | 43 | method.label(done); | |||||||||||||||
44 | methodCompiler.getVariableCompiler().releaseTempLocal(); | 44 | methodCompiler.getVariableCompiler().releaseTempLocal(); | |||||||||||||||
45 | methodCompiler.getVariableCompiler().releaseTempLocal(); | 45 | methodCompiler.getVariableCompiler().releaseTempLocal(); |
Row | Violation |
---|---|
1 | Expression method.ifne(done) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression method.ifeq(done) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression method.ifne(done) is a void method call, and thus it cannot be parameterized |
4 | Expression method.ifeq(done) is a void method call, and thus it cannot be parameterized |