Class EmitterFactory
- java.lang.Object
-
- org.glassfish.pfl.dynamic.codegen.impl.EmitterFactory
-
public final class EmitterFactory extends java.lang.Object
This class provides methods that allow the construction of an object that can later be used to emit a bytecode. This is useful when multiple visitors are needed for first preparing an AST, then generating the bytecode.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EmitterFactory.CompoundEmitter
static interface
EmitterFactory.Emitter
Simple wrapper class around a UnaryVoidFunction.private static class
EmitterFactory.FieldInsnEmitter
private static class
EmitterFactory.IntOperandEmitter
static class
EmitterFactory.NullEmitter
static class
EmitterFactory.SimpleEmitter
-
Field Summary
Fields Modifier and Type Field Description private static EmitterFactory.Emitter
arrayLength
private static EmitterFactory.Emitter
arrayLoad
private static EmitterFactory.Emitter
arrayStore
private static int
MAX_OPCODE
private static java.lang.String[]
opcodeNames
private static java.util.BitSet
specialOpcodeSet
private static java.util.BitSet
validOpcodeSet
private static java.util.BitSet
visitFieldInsnSet
private static java.util.BitSet
visitInsnSet
private static java.util.BitSet
visitIntInsnSet
private static java.util.BitSet
visitJumpInsnSet
private static java.util.BitSet
visitMethodInsnSet
private static java.util.BitSet
visitTypeInsnSet
private static java.util.BitSet
visitVarInsnSet
-
Constructor Summary
Constructors Modifier Constructor Description private
EmitterFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
check(java.util.BitSet validOps, int op)
private static int
getVarInsnOpcode(Type type, boolean isStore)
private static java.util.BitSet
makeBitSet(int... args)
static EmitterFactory.Emitter
makeEmitter(ExpressionFactory.ArrayIndexExpression expr, boolean isStore)
Create an emitter that generates the instruction needed to either store the TOS value into an array (aastore) (isStore==true) or push the array element's value onto the stack (aaload) (isStore==false).static EmitterFactory.Emitter
makeEmitter(ExpressionFactory.ArrayLengthExpression expr)
static EmitterFactory.Emitter
makeEmitter(ExpressionFactory.NonStaticFieldAccessExpression expr, boolean isStore)
Create an emitter that generates the instruction needed to either store the TOS value into the non-static field (isStore==true) or push the non-static fields's value onto the stack (isStore==false).static EmitterFactory.Emitter
makeEmitter(ExpressionFactory.StaticFieldAccessExpression expr, boolean isStore)
Create an emitter that generates the instruction needed to either store the TOS value into the static field (isStore==true) or push the static fields's value onto the stack (isStore==false).static EmitterFactory.Emitter
makeEmitter(Variable var, boolean isStore)
Create an emitter that generates the instruction needed to either store the TOS value into the variable (isStore==true) or push the variable's value onto the stack (isStore==false).private static EmitterFactory.Emitter
makeFieldInsnEmitter(boolean isStore, boolean isStatic, Type targetType, java.lang.String name, Type varType)
-
-
-
Field Detail
-
MAX_OPCODE
private static final int MAX_OPCODE
- See Also:
- Constant Field Values
-
opcodeNames
private static java.lang.String[] opcodeNames
-
visitInsnSet
private static java.util.BitSet visitInsnSet
-
visitIntInsnSet
private static java.util.BitSet visitIntInsnSet
-
visitVarInsnSet
private static java.util.BitSet visitVarInsnSet
-
visitFieldInsnSet
private static java.util.BitSet visitFieldInsnSet
-
visitMethodInsnSet
private static java.util.BitSet visitMethodInsnSet
-
visitTypeInsnSet
private static java.util.BitSet visitTypeInsnSet
-
visitJumpInsnSet
private static java.util.BitSet visitJumpInsnSet
-
specialOpcodeSet
private static java.util.BitSet specialOpcodeSet
-
validOpcodeSet
private static java.util.BitSet validOpcodeSet
-
arrayStore
private static final EmitterFactory.Emitter arrayStore
-
arrayLoad
private static final EmitterFactory.Emitter arrayLoad
-
arrayLength
private static final EmitterFactory.Emitter arrayLength
-
-
Method Detail
-
makeBitSet
private static java.util.BitSet makeBitSet(int... args)
-
check
private static void check(java.util.BitSet validOps, int op)
-
getVarInsnOpcode
private static int getVarInsnOpcode(Type type, boolean isStore)
-
makeFieldInsnEmitter
private static EmitterFactory.Emitter makeFieldInsnEmitter(boolean isStore, boolean isStatic, Type targetType, java.lang.String name, Type varType)
-
makeEmitter
public static EmitterFactory.Emitter makeEmitter(Variable var, boolean isStore)
Create an emitter that generates the instruction needed to either store the TOS value into the variable (isStore==true) or push the variable's value onto the stack (isStore==false). The stack index must be set on var in the stackFrameSlot attribute.
-
makeEmitter
public static EmitterFactory.Emitter makeEmitter(ExpressionFactory.NonStaticFieldAccessExpression expr, boolean isStore)
Create an emitter that generates the instruction needed to either store the TOS value into the non-static field (isStore==true) or push the non-static fields's value onto the stack (isStore==false).
-
makeEmitter
public static EmitterFactory.Emitter makeEmitter(ExpressionFactory.StaticFieldAccessExpression expr, boolean isStore)
Create an emitter that generates the instruction needed to either store the TOS value into the static field (isStore==true) or push the static fields's value onto the stack (isStore==false).
-
makeEmitter
public static EmitterFactory.Emitter makeEmitter(ExpressionFactory.ArrayIndexExpression expr, boolean isStore)
Create an emitter that generates the instruction needed to either store the TOS value into an array (aastore) (isStore==true) or push the array element's value onto the stack (aaload) (isStore==false). This emitter assumes that arrayref and index are already on the stack, and value is on the stack either before (aastore) or after (aaload) the instruction executes.
-
makeEmitter
public static EmitterFactory.Emitter makeEmitter(ExpressionFactory.ArrayLengthExpression expr)
-
-