Class ByteCodeUtility
java.lang.Object
org.glassfish.pfl.dynamic.codegen.impl.ByteCodeUtility
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.objectweb.asm.ClassWriter
private boolean
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static final EmitterFactory.Emitter
private static Map
<ExpressionFactory.BinaryOperator, Integer> private String
private String
private org.objectweb.asm.MethodVisitor
(package private) EmitterFactory.Emitter[][]
private static Map
<ExpressionFactory.BinaryOperator, Map<Type, Integer>> private PrintStream
-
Constructor Summary
ConstructorsConstructorDescriptionByteCodeUtility
(org.objectweb.asm.ClassWriter cw, ClassGeneratorImpl cg) ByteCodeUtility
(org.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
Modifier and TypeMethodDescriptionvoid
addField
(FieldGenerator arg) void
callEmitter
(EmitterFactory.Emitter emitter) private void
dump()
void
void
private void
private void
void
emitBranch
(MyLabel target) void
void
emitConditionalBranch
(MyLabel falseBranch) void
emitConstantExpression
(Type type, Object value) void
emitConversion
(Type from, Type to) void
emitDup()
void
emitExceptionTableEntry
(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.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.objectweb.asm.Label label) void
private void
private void
void
emitMethodEnd
(MethodGenerator mg, org.objectweb.asm.Label returnLabel, Variable returnVariable, boolean dump) void
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
private void
emitReturn
(Type returnType) 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
void
int
-
Field Details
-
cw
private org.objectweb.asm.ClassWriter cw -
mv
private org.objectweb.asm.MethodVisitor mv -
debug
private boolean debug -
ps
-
methodName
-
methodSignature
-
typeIndex
-
E_NOP
-
E_I2B
-
E_I2C
-
E_I2S
-
E_I2L
-
E_I2F
-
E_I2D
-
E_L2I
-
E_F2I
-
E_D2I
-
E_L2F
-
E_L2D
-
E_F2L
-
E_D2L
-
E_F2D
-
E_D2F
-
E_L2B
-
E_F2B
-
E_D2B
-
E_L2S
-
E_F2S
-
E_D2S
-
E_L2C
-
E_F2C
-
E_D2C
-
numericConversions
EmitterFactory.Emitter[][] numericConversions -
opInstructions
-
ifOpInstructions
-
-
Constructor Details
-
ByteCodeUtility
public ByteCodeUtility(org.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
-
-
Method Details
-
addField
-
dump
private void dump() -
emitMethodStart
-
emitLineNumberTable
-
emitLocalVariableTable
-
emitMethodEnd
public void emitMethodEnd(MethodGenerator mg, org.objectweb.asm.Label returnLabel, Variable returnVariable, boolean dump) -
emitReturn
-
emitRet
-
emitConstantExpression
-
emitThisExpression
public void emitThisExpression() -
emitConditionalBranch
-
emitBranch
-
emitLabel
-
emitNewCall
Emit the NEW, DUP sequence required at the start of a new call. -
emitInstanceof
-
emitCast
-
emitDup
public void emitDup() -
emitArrayStore
public void emitArrayStore() -
typeCode
-
emitNewArrayCall
-
emitStaticInvoke
Emit a static INVOKE instruction. -
emitInvoke
Emit the appropriate non-static INVOKE instruction as follows:- If type is an interface, emit INVOKEINTERFACE.
- If name/sig has private access in type, emit INVOKESPECIAL. Note that the target must be "this" in this case.
- Otherwise emit INVOKEVIRTUAL.
-
emitNewInvoke
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
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.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, Type exceptionType) -
emitJsr
public void emitJsr(org.objectweb.asm.Label label) -
callEmitter
-
emitPop
public void emitPop() -
emitConversion
-
emitBooleanCodeForPrimitive
-
emitBooleanCodeForReference
-
emitBinaryOperator
-