Commits

Tim Vernum committed 704c780

Minor tweaks

  • Participants
  • Parent commits 1751c38

Comments (0)

Files changed (7)

source/ant/version.properties

-project.version=0.2.0
+project.version=0.2.1

source/java/core/org/adjective/stout/asm/AbstractASMVisitor.java

+/* ------------------------------------------------------------------------
+ * Copyright 2010 Tim Vernum
+ * ------------------------------------------------------------------------
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ------------------------------------------------------------------------
+ */
+
+package org.adjective.stout.asm;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * @author <a href="http://blog.adjective.org/">Tim Vernum</a>
+ */
+public abstract class AbstractASMVisitor extends AbstractClassVisitor implements MethodVisitor, FieldVisitor, AnnotationVisitor
+{
+    public AnnotationVisitor visitAnnotationDefault()
+    {
+        return this;
+    }
+
+    public void visitCode()
+    {
+        // Stub
+    }
+
+    public void visitFieldInsn(int opcode, String owner, String name, String desc)
+    {
+        // Stub
+    }
+
+    public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack)
+    {
+        // Stub
+    }
+
+    public void visitIincInsn(int var, int increment)
+    {
+        // Stub
+    }
+
+    public void visitInsn(int opcode)
+    {
+        // Stub
+    }
+
+    public void visitIntInsn(int opcode, int operand)
+    {
+        // Stub
+    }
+
+    public void visitJumpInsn(int opcode, Label label)
+    {
+        // Stub
+    }
+
+    public void visitLabel(Label label)
+    {
+        // Stub
+    }
+
+    public void visitLdcInsn(Object cst)
+    {
+        // Stub
+    }
+
+    public void visitLineNumber(int line, Label start)
+    {
+        // Stub
+    }
+
+    public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)
+    {
+        // Stub
+    }
+
+    public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)
+    {
+        // Stub
+    }
+
+    public void visitMaxs(int maxStack, int maxLocals)
+    {
+        // Stub
+    }
+
+    public void visitMethodInsn(int opcode, String owner, String name, String desc)
+    {
+        // Stub
+    }
+
+    public void visitMultiANewArrayInsn(String desc, int dims)
+    {
+        // Stub
+    }
+
+    public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible)
+    {
+        return this;
+    }
+
+    public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels)
+    {
+        // Stub
+    }
+
+    public void visitTryCatchBlock(Label start, Label end, Label handler, String type)
+    {
+        // Stub
+    }
+
+    public void visitTypeInsn(int opcode, String type)
+    {
+        // Stub
+    }
+
+    public void visitVarInsn(int opcode, int var)
+    {
+        // Stub
+    }
+
+    public void visit(String name, Object value)
+    {
+        // Stub
+    }
+
+    public AnnotationVisitor visitAnnotation(String name, String desc)
+    {
+        return this;
+    }
+
+    public AnnotationVisitor visitArray(String name)
+    {
+        return this;
+    }
+
+    public void visitEnum(String name, String desc, String value)
+    {
+        // Stub
+    }
+    
+    public AnnotationVisitor visitAnnotation(String desc, boolean visible)
+    {
+        return this;
+    }
+    
+    public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
+    {
+        return this;
+    }
+    
+    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
+    {
+        return this;
+    }
+    
+}

source/java/core/org/adjective/stout/asm/AbstractClassVisitor.java

+/* ------------------------------------------------------------------------
+ * Copyright 2010 Tim Vernum
+ * ------------------------------------------------------------------------
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ------------------------------------------------------------------------
+ */
+
+package org.adjective.stout.asm;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+
+/**
+ * @author <a href="http://blog.adjective.org/">Tim Vernum</a>
+ */
+public abstract class AbstractClassVisitor implements ClassVisitor
+{
+    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
+    {
+        // Stub
+    }
+
+    public AnnotationVisitor visitAnnotation(String desc, boolean visible)
+    {
+        // Stub
+        return null;
+    }
+
+    public void visitAttribute(Attribute attr)
+    {
+        // Stub
+    }
+
+    public void visitEnd()
+    {
+        // Stub
+    }
+
+    public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
+    {
+        // Stub
+        return null;
+    }
+
+    public void visitInnerClass(String name, String outerName, String innerName, int access)
+    {
+        // Stub
+    }
+
+    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
+    {
+        // Stub
+        return null;
+    }
+
+    public void visitOuterClass(String owner, String name, String desc)
+    {
+        // Stub
+    }
+
+    public void visitSource(String source, String debug)
+    {
+        // Stub
+    }
+
+}

source/java/core/org/adjective/stout/core/ClassMember.java

 public interface ClassMember
 {
     public Set<ElementModifier> getModifiers();
-
     public String getName();
-
     public AnnotationDescriptor[] getAnnotations();
 }

source/java/core/org/adjective/stout/impl/ConstructorSignatureImpl.java

         return _type;
     }
 
+    public String toString()
+    {
+        StringBuilder builder = new StringBuilder();
+        builder.append(_type);
+        if (_parameterTypes.length == 0)
+        {
+            builder.append("( )");
+        }
+        else
+        {
+            builder.append('(');
+            for (UnresolvedType arg : _parameterTypes)
+            {
+                builder.append(arg);
+                builder.append(',');
+            }
+            builder.setCharAt(builder.length() - 1, ')');
+        }
+        return builder.toString();
+    }
+
 }

source/java/core/org/adjective/stout/loop/IterableLoopSpec.java

         return withBody(StatementOperations.toStatementArray(body));
     }
 
-    public IterableLoopSpec withBody(Statement[] body)
+    public IterableLoopSpec withBody(Statement... body)
     {
         _body = body;
         return this;

source/java/core/org/adjective/stout/operation/CreateArrayExpression.java

  */
 public class CreateArrayExpression extends SmartExpression
 {
+    private static final GenericInstruction DUPLICATE = new GenericInstruction(Opcodes.DUP);
     private final ExtendedType _componentType;
     private final Expression[] _elements;
 
 
     public void getInstructions(ExecutionStack stack, InstructionCollector collector)
     {
-        addInstruction(collector,ConstantIntegerExpression.getInstruction(_elements.length));
-        
+        addInstruction(collector, ConstantIntegerExpression.getInstruction(_elements.length));
+
         Instruction store;
         Class< ? > componentClass = _componentType.getRawClass();
         if (componentClass.isPrimitive())
         {
-            addInstruction(collector,new IntInstruction(Opcodes.NEWARRAY, getTypeCode(componentClass)));
+            addInstruction(collector, new IntInstruction(Opcodes.NEWARRAY, getTypeCode(componentClass)));
             store = new GenericInstruction(Type.getType(componentClass).getOpcode(Opcodes.IASTORE));
         }
         else
         {
-            addInstruction(collector,new TypeInstruction(Opcodes.ANEWARRAY, _componentType.getInternalName()));
+            addInstruction(collector, new TypeInstruction(Opcodes.ANEWARRAY, _componentType.getInternalName()));
             store = new GenericInstruction(Opcodes.AASTORE);
         }
-        
-        GenericInstruction dup = new GenericInstruction(Opcodes.DUP);
+
         for (int i = 0; i < _elements.length; i++)
         {
-            addInstruction(collector,dup);
-            addInstruction(collector,ConstantIntegerExpression.getInstruction(i));
+            addInstruction(collector, DUPLICATE);
+            addInstruction(collector, ConstantIntegerExpression.getInstruction(i));
             _elements[i].getInstructions(stack, collector);
-            addInstruction(collector,store);
+            addInstruction(collector, store);
         }
-        
+
     }
 
-    private int getTypeCode(Class< ? > type)
+    public static int getTypeCode(Class< ? > type)
     {
         if (type == Character.TYPE)
         {