Package org.codehaus.groovy.classgen.asm
Class BytecodeVariable
java.lang.Object
org.codehaus.groovy.classgen.asm.BytecodeVariable
Represents compile time variable metadata while compiling a method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BytecodeVariableSentinel metadata for the implicitsuperreceiver.static final BytecodeVariableSentinel metadata for the implicitthisreceiver. -
Constructor Summary
ConstructorsConstructorDescriptionBytecodeVariable(int index, ClassNode type, String name, int prevCurrent) Creates bytecode metadata for a local variable slot. -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseRange(org.objectweb.asm.Label end) Ends the currently open local-variable-table range at the given label, recording it for later emission.List<org.objectweb.asm.Label[]>org.objectweb.asm.LabelintgetIndex()getName()intorg.objectweb.asm.LabelgetType()booleanbooleanisHolder()booleanvoidreopenRange(org.objectweb.asm.Label start) Starts a new local-variable-table range at the given label after acloseRange(org.objectweb.asm.Label).voidsetDynamicTyped(boolean dynamicTyped) Marks whether the variable should be treated as dynamically typed.voidsetEndLabel(org.objectweb.asm.Label endLabel) Sets the end label used for local-variable table metadata.voidsetHolder(boolean holder) Marks whether this variable must be stored through a holder object.voidsetStartLabel(org.objectweb.asm.Label startLabel) Sets the start label used for local-variable table metadata.voidUpdates the tracked variable type.toString()
-
Field Details
-
THIS_VARIABLE
Sentinel metadata for the implicitthisreceiver. -
SUPER_VARIABLE
Sentinel metadata for the implicitsuperreceiver.
-
-
Constructor Details
-
BytecodeVariable
Creates bytecode metadata for a local variable slot.- Parameters:
index- the JVM local-variable indextype- the variable typename- the variable nameprevCurrent- the previous current-variable index
-
-
Method Details
-
getIndex
public int getIndex()- Returns:
- the stack index for this variable
-
getName
- Returns:
- the source-level variable name
-
getType
- Returns:
- the variable type
-
setType
Updates the tracked variable type.- Parameters:
type- the new variable type
-
getPrevIndex
public int getPrevIndex()- Returns:
- the previous current-variable index
-
isDynamicTyped
public boolean isDynamicTyped()- Returns:
- whether the variable uses dynamic typing
-
setDynamicTyped
public void setDynamicTyped(boolean dynamicTyped) Marks whether the variable should be treated as dynamically typed.- Parameters:
dynamicTyped-trueif the variable is dynamically typed
-
isHolder
public boolean isHolder()- Returns:
- is this local variable shared in other scopes (and so must use a ValueHolder)
-
setHolder
public void setHolder(boolean holder) Marks whether this variable must be stored through a holder object.- Parameters:
holder-trueif the variable is closure-shared
-
getStartLabel
public org.objectweb.asm.Label getStartLabel()- Returns:
- the start label used for local-variable table metadata
-
setStartLabel
public void setStartLabel(org.objectweb.asm.Label startLabel) Sets the start label used for local-variable table metadata.- Parameters:
startLabel- the starting label
-
getEndLabel
public org.objectweb.asm.Label getEndLabel()- Returns:
- the end label used for local-variable table metadata
-
setEndLabel
public void setEndLabel(org.objectweb.asm.Label endLabel) Sets the end label used for local-variable table metadata.- Parameters:
endLabel- the ending label
-
closeRange
public void closeRange(org.objectweb.asm.Label end) Ends the currently open local-variable-table range at the given label, recording it for later emission. Used when flow scoping hides this variable (GROOVY-12242); a laterreopenRange(org.objectweb.asm.Label)starts a new range if the variable becomes visible again.- Parameters:
end- the label at which visibility ends; ignored ifnullor if no range is open
-
reopenRange
public void reopenRange(org.objectweb.asm.Label start) Starts a new local-variable-table range at the given label after acloseRange(org.objectweb.asm.Label). The end label is reset to the start and extended by subsequent scope pops; a range that is never extended has zero width and is not emitted.- Parameters:
start- the label at which visibility resumes; ignored ifnullor if no range was closed
-
isRangeClosed
public boolean isRangeClosed()- Returns:
- whether the current local-variable-table range has been closed without being reopened (the variable is hidden by flow scoping)
-
getClosedRanges
- Returns:
- the completed local-variable-table ranges as {start, end} label pairs, oldest first; empty for variables never hidden
-
toString
-