[GitHub] groovy pull request #496: Add a ASMifier tab to AstBrowser

2017-02-19 Thread danielsun1106
Github user danielsun1106 closed the pull request at:

https://github.com/apache/groovy/pull/496


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #496: Add a ASMifier tab to AstBrowser

2017-02-12 Thread jwagenleitner
Github user jwagenleitner commented on a diff in the pull request:

https://github.com/apache/groovy/pull/496#discussion_r100702338
  
--- Diff: 
subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/AstBrowser.groovy
 ---
@@ -403,9 +420,13 @@ class AstBrowser {
 def tabPane = mainSplitter.bottomComponent
 int tabCount = tabPane.getTabCount()
 for (int i = 0; i < tabCount; i++) {
-if (bytecodeView.is(tabPane.getComponentAt(i))) {
+def component = tabPane.getComponentAt(i);
+if (bytecodeView.is(component)) {
 tabPane.setTitleAt(i, getByteCodeTitle())
 break
+} else if (asmifierView.is(component)) {
+tabPane.setTitleAt(i, getASMifierTitle())
+break
--- End diff --

The `ASMifier` tab title doesn't update because of the `breaks`, if both 
`breaks` are removed that should fix it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #496: Add a ASMifier tab to AstBrowser

2017-02-10 Thread danielsun1106
GitHub user danielsun1106 opened a pull request:

https://github.com/apache/groovy/pull/496

Add a ASMifier tab to AstBrowser

**Source code:**
```groovy
println 123
```

**The output of ASMifier:**
```java
import java.util.*;
import org.objectweb.asm.*;
public class script1486743662486Dump implements Opcodes {

public static byte[] dump () throws Exception {

ClassWriter cw = new ClassWriter(0);
FieldVisitor fv;
MethodVisitor mv;
AnnotationVisitor av0;

cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "script1486743662486", null, 
"groovy/lang/Script", null);

cw.visitSource("script1486743662486.groovy", null);

{
fv = cw.visitField(ACC_PRIVATE + ACC_STATIC + ACC_SYNTHETIC, 
"$staticClassInfo", "Lorg/codehaus/groovy/reflection/ClassInfo;", null, null);
fv.visitEnd();
}
{
fv = cw.visitField(ACC_PUBLIC + ACC_STATIC + ACC_TRANSIENT + ACC_SYNTHETIC, 
"__$stMC", "Z", null, null);
fv.visitEnd();
}
{
fv = cw.visitField(ACC_PRIVATE + ACC_STATIC + ACC_SYNTHETIC, 
"$callSiteArray", "Ljava/lang/ref/SoftReference;", null, null);
fv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "groovy/lang/Script", "", "()V", 
false);
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitMethodInsn(INVOKESTATIC, "script1486743662486", 
"$getCallSiteArray", "()[Lorg/codehaus/groovy/runtime/callsite/CallSite;", 
false);
mv.visitVarInsn(ASTORE, 1);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitInsn(RETURN);
mv.visitLocalVariable("this", "Lscript1486743662486;", null, l0, l1, 0);
mv.visitMaxs(1, 2);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "", "(Lgroovy/lang/Binding;)V", null, 
null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitMethodInsn(INVOKESTATIC, "script1486743662486", 
"$getCallSiteArray", "()[Lorg/codehaus/groovy/runtime/callsite/CallSite;", 
false);
mv.visitVarInsn(ASTORE, 2);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, "groovy/lang/Script", "", 
"(Lgroovy/lang/Binding;)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitInsn(RETURN);
mv.visitLocalVariable("this", "Lscript1486743662486;", null, l0, l1, 0);
mv.visitLocalVariable("context", "Lgroovy/lang/Binding;", null, l0, l1, 1);
mv.visitMaxs(2, 3);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC + ACC_VARARGS, "main", 
"([Ljava/lang/String;)V", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitMethodInsn(INVOKESTATIC, "script1486743662486", 
"$getCallSiteArray", "()[Lorg/codehaus/groovy/runtime/callsite/CallSite;", 
false);
mv.visitVarInsn(ASTORE, 1);
mv.visitVarInsn(ALOAD, 1);
mv.visitLdcInsn(new Integer(0));
mv.visitInsn(AALOAD);

mv.visitLdcInsn(Type.getType("Lorg/codehaus/groovy/runtime/InvokerHelper;"));
mv.visitLdcInsn(Type.getType("Lscript1486743662486;"));
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKEINTERFACE, 
"org/codehaus/groovy/runtime/callsite/CallSite", "call", 
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 
true);
mv.visitInsn(POP);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitInsn(RETURN);
mv.visitLocalVariable("args", "[Ljava/lang/String;", null, l0, l1, 0);
mv.visitMaxs(4, 2);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "run", "()Ljava/lang/Object;", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitMethodInsn(INVOKESTATIC, "script1486743662486", 
"$getCallSiteArray", "()[Lorg/codehaus/groovy/runtime/callsite/CallSite;", 
false);
mv.visitVarInsn(ASTORE, 1);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(1, l1);
mv.visitVarInsn(ALOAD, 1);
mv.visitLdcInsn(new Integer(1));
mv.visitInsn(AALOAD);
mv.visitVarInsn(ALOAD, 0);
mv.visitIntInsn(BIPUSH, 123);
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", 
"(I)Ljava/lang/Integer;", false);
mv.visitMethodInsn(INVOKEINTERFACE, 
"org/codehaus/groovy/runtime/callsite/CallSite", "callCurrent", 
"(Lgroovy/lang/GroovyObject;Ljava/lang/Object;)Ljava/lang/Object;", true);
mv.visitInsn(ARETURN);
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ARETURN);
mv.visitLocalVariable("this", "Lscript1486743662486;", null, l0, l2, 0);
mv.visitMaxs(3, 2);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PROTECTED + ACC_SYNTHETIC, "$getStaticMetaClass", 
"()Lgroovy/lang/MetaClass;", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "get