com.saxonica.bytecode.util
Class GeneratedMethodInfo

java.lang.Object
  extended by com.saxonica.bytecode.util.GeneratedMethodInfo

public class GeneratedMethodInfo
extends Object

Information about the current method whose bytecode is being generated


Nested Class Summary
static class GeneratedMethodInfo.LocalSlotInfo
           
 
Field Summary
 Generator currentGenerator
           
 boolean debug
           
 Set<LabelInfo> labelMap
           
 List<GeneratedMethodInfo.LocalSlotInfo> slotList
           
 
Constructor Summary
GeneratedMethodInfo()
           
 
Method Summary
 int allocateLocal(Class theClass)
          Allocate a local bytecode variable.
 void checkLabels()
          Check (on completion of the method) that all labels that have been used have also been marked
 int getContextVariablePosition()
           
 int getSequenceReceiverPosition()
           
 LabelInfo getTailCallLabel()
          Get the label to act as the target of a jump for a self-recursive tail call.
 Stack<LabelInfo> getXslIterateBreakLabelStack()
          Get the stack of labels representing entry points to xsl:iterate instructions within this method
 Stack<LabelInfo> getXslIterateLoopLabelStack()
          Get the stack of labels representing entry points to xsl:iterate instructions within this method
 boolean isContextVariableAnArgument()
           
 LabelInfo newLabel(String name)
          Allocate a new label within the method
 void placeLabel(LabelInfo labelInfo)
          Place a label at the current position in the bytecode
 LabelInfo placeNewLabel(String name)
          Place a new label at the current position in the bytecode
 void popContextVariableInfo()
           
 void popSequenceReceiverInfo()
           
 void pushContextVariableInfo(int position, boolean isArgument)
           
 void pushSequenceReceiverInfo(int position)
           
 void releaseLocal(int slotNumber)
          Return a local variable to the pool for reuse
 void setTailCallLabel(LabelInfo label)
          Supply the label to act as the target of a jump for a self-recursive tail call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentGenerator

public Generator currentGenerator

debug

public boolean debug

labelMap

public Set<LabelInfo> labelMap

slotList

public List<GeneratedMethodInfo.LocalSlotInfo> slotList
Constructor Detail

GeneratedMethodInfo

public GeneratedMethodInfo()
Method Detail

pushContextVariableInfo

public void pushContextVariableInfo(int position,
                                    boolean isArgument)

pushSequenceReceiverInfo

public void pushSequenceReceiverInfo(int position)

popContextVariableInfo

public void popContextVariableInfo()

popSequenceReceiverInfo

public void popSequenceReceiverInfo()

getContextVariablePosition

public int getContextVariablePosition()

getSequenceReceiverPosition

public int getSequenceReceiverPosition()

isContextVariableAnArgument

public boolean isContextVariableAnArgument()

newLabel

public LabelInfo newLabel(String name)
Allocate a new label within the method

Parameters:
name - a diagnostic name for the label, used if errors are reported
Returns:
the constructed label information

placeLabel

public void placeLabel(LabelInfo labelInfo)
Place a label at the current position in the bytecode

Parameters:
labelInfo - the label to be placed (marked)
Throws:
AssertionError - if the label has already been marked

placeNewLabel

public LabelInfo placeNewLabel(String name)
Place a new label at the current position in the bytecode

Parameters:
name - the name of the label
Returns:
the Label that has been placed
Throws:
AssertionError - if the label has already been marked

checkLabels

public void checkLabels()
Check (on completion of the method) that all labels that have been used have also been marked

Throws:
AssertionError - if this is not the case

getXslIterateLoopLabelStack

public Stack<LabelInfo> getXslIterateLoopLabelStack()
Get the stack of labels representing entry points to xsl:iterate instructions within this method

Returns:
the stack of labels

getXslIterateBreakLabelStack

public Stack<LabelInfo> getXslIterateBreakLabelStack()
Get the stack of labels representing entry points to xsl:iterate instructions within this method

Returns:
the stack of labels

allocateLocal

public int allocateLocal(Class theClass)
Allocate a local bytecode variable. Reuse an existing slot if available

Parameters:
theClass - the class of value to be held in the local variable
Returns:
the slot number on the stack to be used for the variable

releaseLocal

public void releaseLocal(int slotNumber)
Return a local variable to the pool for reuse

Parameters:
slotNumber - the slot number to be released for reuse

setTailCallLabel

public void setTailCallLabel(LabelInfo label)
Supply the label to act as the target of a jump for a self-recursive tail call. Before jumping to this label, the code implementing the function call must adjust the stack frame to make sure that it contains the parameters for the new call.

Parameters:
label - the target label for a tail call loop (or null if there is to be no tail call)

getTailCallLabel

public LabelInfo getTailCallLabel()
Get the label to act as the target of a jump for a self-recursive tail call. Before jumping to this label, the code implementing the function call must adjust the stack frame to make sure that it contains the parameters for the new call.

Returns:
the designated label (which will be null if not in the body of a tail-recursive function)


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.