org.glassfish.pfl.dynamic.codegen.impl
Class ByteCodeUtility

java.lang.Object
  extended by org.glassfish.pfl.dynamic.codegen.impl.ByteCodeUtility

public final class ByteCodeUtility
extends Object

Class that is responsible for low-level bytecode generation using ASM. It provides methods that directly generate bytecode in a MethodVisitor. This will often be accompanied by type analysis, such as in determining the correct sort of return instruction to use, or how to generate code for a constant.


Constructor Summary
ByteCodeUtility(org.glassfish.pfl.objectweb.asm.ClassWriter cw, ClassGeneratorImpl cg)
           
ByteCodeUtility(org.glassfish.pfl.objectweb.asm.ClassWriter cw, ClassGeneratorImpl cg, boolean debug, PrintStream ps)
          Construct an instance of ByteCodeUtility from an ASM ClassWriter and a codegen ClassGeneratorImpl.
 
Method Summary
 void addField(FieldGenerator arg)
           
 void callEmitter(EmitterFactory.Emitter emitter)
           
 void emitArrayStore()
           
 void emitBinaryOperator(ExpressionFactory.BinaryOperatorExpression arg)
           
 void emitBranch(MyLabel target)
           
 void emitCast(Type from, Type to)
           
 void emitConditionalBranch(MyLabel falseBranch)
           
 void emitConstantExpression(Type type, Object value)
           
 void emitConversion(Type from, Type to)
           
 void emitDup()
           
 void emitExceptionTableEntry(org.glassfish.pfl.objectweb.asm.Label start, org.glassfish.pfl.objectweb.asm.Label end, org.glassfish.pfl.objectweb.asm.Label handler, Type exceptionType)
           
 void emitInstanceof(Type type)
           
 void emitInvoke(Type type, String name, Signature sig)
          Emit the appropriate non-static INVOKE instruction as follows: If type is an interface, emit INVOKEINTERFACE.
 void emitJsr(org.glassfish.pfl.objectweb.asm.Label label)
           
 void emitLabel(Attribute<MyLabel> attr, Node node)
           
 void emitMethodEnd(MethodGenerator mg, org.glassfish.pfl.objectweb.asm.Label returnLabel, Variable returnVariable, boolean dump)
           
 void emitMethodStart(MethodGenerator mg)
           
 void emitNewArrayCall(Type type)
           
 void emitNewCall(Type type)
          Emit the NEW, DUP sequence required at the start of a new call.
 void emitNewInvoke(Type type, Signature sig)
          Emit the INVOKESPECIAL instruction for calling a constructor with the given signature.
 void emitPop()
           
 void emitRet(Variable var)
           
 void emitSpecialInvoke(Type type, String name, Signature sig)
          Emit the INVOKESPECIAL instruction for calling a method with the given signature.
 void emitStaticInvoke(Type type, String name, Signature sig)
          Emit a static INVOKE instruction.
 void emitThisExpression()
           
 void emitThrow()
           
 int typeCode(Type type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteCodeUtility

public ByteCodeUtility(org.glassfish.pfl.objectweb.asm.ClassWriter cw,
                       ClassGeneratorImpl cg,
                       boolean debug,
                       PrintStream ps)
Construct an instance of ByteCodeUtility from an ASM ClassWriter and a codegen ClassGeneratorImpl. If debug is true, debugText() can be called to get a text representation of the generated code for debugging purposes.


ByteCodeUtility

public ByteCodeUtility(org.glassfish.pfl.objectweb.asm.ClassWriter cw,
                       ClassGeneratorImpl cg)
Method Detail

addField

public void addField(FieldGenerator arg)

emitMethodStart

public void emitMethodStart(MethodGenerator mg)

emitMethodEnd

public void emitMethodEnd(MethodGenerator mg,
                          org.glassfish.pfl.objectweb.asm.Label returnLabel,
                          Variable returnVariable,
                          boolean dump)

emitRet

public void emitRet(Variable var)

emitConstantExpression

public void emitConstantExpression(Type type,
                                   Object value)

emitThisExpression

public void emitThisExpression()

emitConditionalBranch

public void emitConditionalBranch(MyLabel falseBranch)

emitBranch

public void emitBranch(MyLabel target)

emitLabel

public void emitLabel(Attribute<MyLabel> attr,
                      Node node)

emitNewCall

public void emitNewCall(Type type)
Emit the NEW, DUP sequence required at the start of a new call.


emitInstanceof

public void emitInstanceof(Type type)

emitCast

public void emitCast(Type from,
                     Type to)

emitDup

public void emitDup()

emitArrayStore

public void emitArrayStore()

typeCode

public int typeCode(Type type)

emitNewArrayCall

public void emitNewArrayCall(Type type)

emitStaticInvoke

public void emitStaticInvoke(Type type,
                             String name,
                             Signature sig)
Emit a static INVOKE instruction.


emitInvoke

public void emitInvoke(Type type,
                       String name,
                       Signature sig)
Emit the appropriate non-static INVOKE instruction as follows:
  1. If type is an interface, emit INVOKEINTERFACE.
  2. If name/sig has private access in type, emit INVOKESPECIAL. Note that the target must be "this" in this case.
  3. Otherwise emit INVOKEVIRTUAL.


emitNewInvoke

public void emitNewInvoke(Type type,
                          Signature sig)
Emit the INVOKESPECIAL instruction for calling a constructor with the given signature. This is used for new Foo() calls, and for super() and this() calls at the start of a constructor.


emitSpecialInvoke

public void emitSpecialInvoke(Type type,
                              String name,
                              Signature sig)
Emit the INVOKESPECIAL instruction for calling a method with the given signature. This is used for for super.name() and this.name() method calls.


emitThrow

public void emitThrow()

emitExceptionTableEntry

public void emitExceptionTableEntry(org.glassfish.pfl.objectweb.asm.Label start,
                                    org.glassfish.pfl.objectweb.asm.Label end,
                                    org.glassfish.pfl.objectweb.asm.Label handler,
                                    Type exceptionType)

emitJsr

public void emitJsr(org.glassfish.pfl.objectweb.asm.Label label)

callEmitter

public void callEmitter(EmitterFactory.Emitter emitter)

emitPop

public void emitPop()

emitConversion

public void emitConversion(Type from,
                           Type to)

emitBinaryOperator

public void emitBinaryOperator(ExpressionFactory.BinaryOperatorExpression arg)


Copyright © 2013 Oracle. All Rights Reserved.