Top Fields Constructors Methods
org.codehaus.groovy.classgen.asm

public Class OperandStack

extends Object
Class Inheritance
Imports
org.codehaus.groovy.GroovyBugError, org.codehaus.groovy.ast.ClassHelper, .ClassNode, .ConstructorNode, .MethodNode, .Variable, org.codehaus.groovy.ast.expr.CastExpression, .ConstantExpression, .Expression, org.codehaus.groovy.ast.tools.WideningCategories, org.codehaus.groovy.classgen.ClassGeneratorException, org.objectweb.asm.Label, .MethodVisitor, java.math.BigDecimal, .BigInteger, java.util.ArrayList, .List

Field Summary

Modifier and TypeField and Description
private final WriterController
private final List<ClassNode>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ClassNode
box()

public void
castToBool(int mark, boolean emptyDefault)

ensure last marked parameter on the stack is a primitive boolean if mark==stack size, we assume an empty expression or statement.

private boolean
private boolean
private boolean
private boolean
private boolean
public void
doAsType(ClassNode targetType)

private void
doConvertAndCast(ClassNode targetType, boolean coerce)

public void
doGroovyCast(ClassNode targetType)

do Groovy cast for top level element

public void
public void
dup()

duplicate top element

private int
public int
public ClassNode
private static boolean
isTwoSlotType(ClassNode type)

returns true for long and double

public Label
jump(int ifIns)

public void
jump(int ifIns, Label label)

public void
load(ClassNode type, int idx)

public void
loadOrStoreVariable(BytecodeVariable variable, boolean useReferenceDirectly)

private static void
public void
pop()

remove operand stack top element using bytecode pop

public void
popDownTo(int elements)

private ClassNode
popWithMessage(int last)

public void
push(ClassNode type)

push operand on stack

public void
pushBool(boolean inclusive)

public void
pushConstant(ConstantExpression expression)

load the constant on the operand stack.

public void
private static void
pushPrimitiveConstant(final MethodVisitor mv, final Object value, final ClassNode type)

public void
remove(int amount)

Remove amount elements from the operand stack, without using pop.

public void
replace(ClassNode type)

replace top level element with new element of given type

public void
replace(ClassNode type, int n)

replace n top level elements with new element of given type

public void
public void
swap()

swap two top level operands

private void
throwExceptionForNoStackElement(int size, ClassNode targetType, boolean coerce)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

controllerback to summary
private final WriterController controller
stackback to summary
private final List<ClassNode> stack

Constructor Detail

OperandStackback to summary
public OperandStack(WriterController wc)

Method Detail

boxback to summary
public ClassNode box()
castToBoolback to summary
public void castToBool(int mark, boolean emptyDefault)

ensure last marked parameter on the stack is a primitive boolean if mark==stack size, we assume an empty expression or statement. was used and we will use the value given in emptyDefault as boolean if mark==stack.size()-1 the top element will be cast to boolean using Groovy truth. In other cases we throw a GroovyBugError

convertFromDoubleback to summary
private boolean convertFromDouble(ClassNode target)
convertFromFloatback to summary
private boolean convertFromFloat(ClassNode target)
convertFromIntback to summary
private boolean convertFromInt(ClassNode target)
convertFromLongback to summary
private boolean convertFromLong(ClassNode target)
convertPrimitiveback to summary
private boolean convertPrimitive(ClassNode top, ClassNode target)
doAsTypeback to summary
public void doAsType(ClassNode targetType)
doConvertAndCastback to summary
private void doConvertAndCast(ClassNode targetType, boolean coerce)
doGroovyCastback to summary
public void doGroovyCast(ClassNode targetType)

do Groovy cast for top level element

doGroovyCastback to summary
public void doGroovyCast(Variable v)
dupback to summary
public void dup()

duplicate top element

ensureStackNotEmptyback to summary
private int ensureStackNotEmpty(List<ClassNode> stack)
getStackLengthback to summary
public int getStackLength()
getTopOperandback to summary
public ClassNode getTopOperand()
isTwoSlotTypeback to summary
private static boolean isTwoSlotType(ClassNode type)

returns true for long and double

jumpback to summary
public Label jump(int ifIns)
jumpback to summary
public void jump(int ifIns, Label label)
loadback to summary
public void load(ClassNode type, int idx)
loadOrStoreVariableback to summary
public void loadOrStoreVariable(BytecodeVariable variable, boolean useReferenceDirectly)
newInstanceback to summary
private static void newInstance(MethodVisitor mv, Object value)
popback to summary
public void pop()

remove operand stack top element using bytecode pop

popDownToback to summary
public void popDownTo(int elements)
popWithMessageback to summary
private ClassNode popWithMessage(int last)
pushback to summary
public void push(ClassNode type)

push operand on stack

pushBoolback to summary
public void pushBool(boolean inclusive)
pushConstantback to summary
public void pushConstant(ConstantExpression expression)

load the constant on the operand stack.

pushDynamicNameback to summary
public void pushDynamicName(Expression name)
pushPrimitiveConstantback to summary
private static void pushPrimitiveConstant(final MethodVisitor mv, final Object value, final ClassNode type)
removeback to summary
public void remove(int amount)

Remove amount elements from the operand stack, without using pop. For example after a method invocation

replaceback to summary
public void replace(ClassNode type)

replace top level element with new element of given type

replaceback to summary
public void replace(ClassNode type, int n)

replace n top level elements with new element of given type

storeVarback to summary
public void storeVar(BytecodeVariable variable)
swapback to summary
public void swap()

swap two top level operands

throwExceptionForNoStackElementback to summary
private void throwExceptionForNoStackElement(int size, ClassNode targetType, boolean coerce)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.