Class VariableDeclarations
java.lang.Object
net.covers1624.coffeegrinder.bytecode.InsnVisitor<None,None>
net.covers1624.coffeegrinder.bytecode.SimpleInsnVisitor<None>
net.covers1624.coffeegrinder.bytecode.transform.transformers.VariableDeclarations
- All Implemented Interfaces:
MethodTransformer,Transformer
A variable is in scope, if the parent of the declaration (IStoreInstruction) is an ancestor of the usage
and the declaration has a lower child index in the common ancestor than the usage
Split variables with an aliased declaration in-scope are merged. Created by covers1624 on 15/9/21.
-
Field Summary
Fields inherited from class net.covers1624.coffeegrinder.bytecode.SimpleInsnVisitor
NONE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Instructionfind the first declaration point, the first ancestor which is a child of a block (which may be this instruction, or a parent)voidtransform(MethodDecl function, MethodTransformContext ctx) Transform theMethodDecl.static InstructionunifyUsages(Instruction decl, Instruction usage) Finds a suitable declaration location such that usage is in scope with the previous declaration.visitLocalReference(LocalReference localRef, None ctx) Methods inherited from class net.covers1624.coffeegrinder.bytecode.SimpleInsnVisitor
visitDefaultMethods inherited from class net.covers1624.coffeegrinder.bytecode.InsnVisitor
visitArrayElementReference, visitArrayLen, visitAssert, visitBinary, visitBlock, visitBlockContainer, visitBranch, visitCheckCast, visitClassDecl, visitCompare, visitComparison, visitCompoundAssignment, visitContinue, visitDeadCode, visitDoWhileLoop, visitFieldDecl, visitFieldReference, visitForEachLoop, visitForLoop, visitIfInstruction, visitInstanceOf, visitInvoke, visitInvokeDynamic, visitLdcBoolean, visitLdcChar, visitLdcClass, visitLdcNull, visitLdcNumber, visitLdcString, visitLeave, visitLoad, visitLoadThis, visitLocalVariable, visitLogicAnd, visitLogicNot, visitLogicOr, visitMethodDecl, visitMethodReference, visitMonitorEnter, visitMonitorExit, visitNew, visitNewArray, visitNewObject, visitNop, visitPostIncrement, visitReturn, visitStore, visitSwitch, visitSwitchSection, visitSwitchTable, visitSynchronized, visitTernary, visitThrow, visitTryCatch, visitTryCatchHandler, visitTryFinally, visitTryWithResources, visitWhileLoop, visitYieldMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.covers1624.coffeegrinder.bytecode.transform.Transformer
getName, stepType
-
Constructor Details
-
VariableDeclarations
public VariableDeclarations()
-
-
Method Details
-
transform
Description copied from interface:MethodTransformerTransform theMethodDecl.- Specified by:
transformin interfaceMethodTransformer- Parameters:
function- The function to transform.ctx- TheMethodTransformContext.
-
unifyUsages
Finds a suitable declaration location such that usage is in scope with the previous declaration. Assumes that decl is 'before' usage- Parameters:
decl- The previous declaration for a variableusage- An instruction which requires the declaration to be in scope- Returns:
decl, ifdeclis in scope, otherwise a common ancestor of bothdeclandusage, which is a child of a block (so a declaration could be inserted before it)
-
selectDeclarableParent
find the first declaration point, the first ancestor which is a child of a block (which may be this instruction, or a parent) -
visitLocalReference
- Overrides:
visitLocalReferencein classInsnVisitor<None,None>
-