Package com.strobel.decompiler.ast
Class AstBuilder
java.lang.Object
com.strobel.decompiler.ast.AstBuilder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
private static final class
private static final class
private static final class
private static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MethodBody
private ControlFlowGraph
private DecompilerContext
private List
<ExceptionHandler> private CoreMetadataFactory
private InstructionCollection
private final Map
<ExceptionHandler, AstBuilder.ByteCode> private boolean
private Map
<Instruction, Instruction> private final Set
<Instruction> private static final AstCode[]
private static final AstBuilder.ByteCode[]
private static final AstBuilder.StackSlot[]
private static final Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
build
(MethodBody body, boolean optimize, DecompilerContext context) private boolean
callsOtherSubroutine
(AstBuilder.SubroutineInfo subroutine, List<AstBuilder.SubroutineInfo> subroutines) private void
private void
convertLocalVariables
(AstBuilder.ByteCode[] parameterDefinitions, List<AstBuilder.ByteCode> body) convertToAst
(List<AstBuilder.ByteCode> body) convertToAst
(List<AstBuilder.ByteCode> body, Set<ExceptionHandler> exceptionHandlers, int startIndex, MutableInteger endIndex) private static InstructionCollection
copyInstructions
(List<Instruction> instructions) private static Frame
createFrame
(AstBuilder.StackSlot[] stack, AstBuilder.VariableSlot[] locals) private static AstBuilder.StackSlot[]
createModifiedStack
(AstBuilder.ByteCode byteCode, StackMappingVisitor stackMapper) private static Map
<Instruction, ControlFlowNode> private void
duplicateHandlersForInlinedSubroutine
(AstBuilder.SubroutineInfo subroutine, Map<Instruction, Instruction> oldToNew) private void
private static Set
<ControlFlowNode> findDominatedNodes
(ControlFlowGraph cfg, ControlFlowNode head, boolean diveIntoHandlers, Set<ControlFlowNode> terminals) private static List
<ExceptionHandler> findDuplicateHandlers
(ExceptionHandler handler, Collection<ExceptionHandler> handlers) private static ExceptionHandler
findFirstHandler
(InstructionBlock tryBlock, Collection<ExceptionHandler> handlers) private static ControlFlowNode
findHandlerNode
(ControlFlowGraph cfg, ExceptionHandler handler) private static List
<ExceptionHandler> findHandlers
(InstructionBlock tryBlock, Collection<ExceptionHandler> handlers) private ExceptionHandler
findInnermostExceptionHandler
(int offsetInTryBlock, ExceptionHandler exclude) private static ControlFlowNode
findInnermostExceptionHandlerNode
(ControlFlowGraph cfg, int offsetInTryBlock, boolean finallyOnly) private static ControlFlowNode
findNode
(ControlFlowGraph cfg, Instruction instruction) private List
<AstBuilder.SubroutineInfo> private JvmType
getStackType
(TypeReference type) private boolean
inlineSubroutine
(AstBuilder.SubroutineInfo subroutine, Instruction reference) private void
private static boolean
private static String
key
(VariableDefinition variable) private static Map
<String, VariableDefinition> makeVariableLookup
(VariableDefinitionCollection variables) private static Instruction
mappedInstruction
(Map<Instruction, Instruction> map, Instruction instruction) private void
private TypeReference
private boolean
private static boolean
opCodesMatch
(Instruction tail1, Instruction tail2, int count, Function<Instruction, Instruction> previous) private List
<AstBuilder.ByteCode> private List
<AstBuilder.VariableInfo> processVariableUnoptimized
(MethodDefinition method, int slot, List<AstBuilder.ByteCode> definitions, List<AstBuilder.ByteCode> references, VariableDefinition vDef) private void
private static List
<ExceptionHandler> remapHandlers
(List<ExceptionHandler> handlers, InstructionCollection instructions) private void
remapHandlersForInlinedSubroutine
(Instruction jump, Instruction start, Instruction end) private void
remapJumps
(Map<Instruction, Instruction> remappedJumps) private void
private void
private void
private void
private static boolean
shouldIncludeExceptionalExit
(ControlFlowGraph cfg, ControlFlowNode head, ControlFlowNode node) private void
private void
private void
updateExceptionVariable
(CatchBlock catchBlock, ExceptionHandler handler) private boolean
-
Field Details
-
LOG
-
CODES
-
EMPTY_STACK
-
EMPTY_DEFINITIONS
-
_loadExceptions
-
_removed
-
_originalInstructionMap
-
_cfg
-
_instructions
-
_exceptionHandlers
-
_body
-
_optimize
private boolean _optimize -
_context
-
_factory
-
NOT_A_LABEL_OR_NOP
-
-
Constructor Details
-
AstBuilder
public AstBuilder()
-
-
Method Details
-
build
-
isGetClassInvocation
-
removeGetClassCallsForInvokeDynamic
private void removeGetClassCallsForInvokeDynamic() -
inlineSubroutines
private void inlineSubroutines() -
inlineSubroutine
-
remapHandlersForInlinedSubroutine
private void remapHandlersForInlinedSubroutine(Instruction jump, Instruction start, Instruction end) -
duplicateHandlersForInlinedSubroutine
private void duplicateHandlersForInlinedSubroutine(AstBuilder.SubroutineInfo subroutine, Map<Instruction, Instruction> oldToNew) -
remapJumps
-
callsOtherSubroutine
private boolean callsOtherSubroutine(AstBuilder.SubroutineInfo subroutine, List<AstBuilder.SubroutineInfo> subroutines) -
findSubroutines
-
findNode
-
findDominatedNodes
private static Set<ControlFlowNode> findDominatedNodes(ControlFlowGraph cfg, ControlFlowNode head, boolean diveIntoHandlers, Set<ControlFlowNode> terminals) -
shouldIncludeExceptionalExit
private static boolean shouldIncludeExceptionalExit(ControlFlowGraph cfg, ControlFlowNode head, ControlFlowNode node) -
findInnermostExceptionHandlerNode
private static ControlFlowNode findInnermostExceptionHandlerNode(ControlFlowGraph cfg, int offsetInTryBlock, boolean finallyOnly) -
opCodesMatch
private static boolean opCodesMatch(Instruction tail1, Instruction tail2, int count, Function<Instruction, Instruction> previous) -
createNodeMap
-
remapHandlers
private static List<ExceptionHandler> remapHandlers(List<ExceptionHandler> handlers, InstructionCollection instructions) -
copyInstructions
-
pruneExceptionHandlers
private void pruneExceptionHandlers() -
removeEmptyCatchBlockBodies
private void removeEmptyCatchBlockBodies() -
ensureDesiredProtectedRanges
private void ensureDesiredProtectedRanges() -
alignFinallyBlocksWithSiblingCatchBlocks
private void alignFinallyBlocksWithSiblingCatchBlocks() -
trimAggressiveCatchBlocks
private void trimAggressiveCatchBlocks() -
removeSelfHandlingFinallyHandlers
private void removeSelfHandlingFinallyHandlers() -
trimAggressiveFinallyBlocks
private void trimAggressiveFinallyBlocks() -
findHandlerNode
-
findInnermostExceptionHandler
private ExceptionHandler findInnermostExceptionHandler(int offsetInTryBlock, ExceptionHandler exclude) -
closeTryHandlerGaps
private void closeTryHandlerGaps() -
removeTryIntersectionsWithPreviousCatch
private void removeTryIntersectionsWithPreviousCatch() -
findFirstHandler
private static ExceptionHandler findFirstHandler(InstructionBlock tryBlock, Collection<ExceptionHandler> handlers) -
findHandlers
private static List<ExceptionHandler> findHandlers(InstructionBlock tryBlock, Collection<ExceptionHandler> handlers) -
findDuplicateHandlers
private static List<ExceptionHandler> findDuplicateHandlers(ExceptionHandler handler, Collection<ExceptionHandler> handlers) -
performStackAnalysis
-
mappedInstruction
private static Instruction mappedInstruction(Map<Instruction, Instruction> map, Instruction instruction) -
createModifiedStack
private static AstBuilder.StackSlot[] createModifiedStack(AstBuilder.ByteCode byteCode, StackMappingVisitor stackMapper) -
convertLocalVariables
private void convertLocalVariables(AstBuilder.ByteCode[] parameterDefinitions, List<AstBuilder.ByteCode> body) -
processVariableUnoptimized
private List<AstBuilder.VariableInfo> processVariableUnoptimized(MethodDefinition method, int slot, List<AstBuilder.ByteCode> definitions, List<AstBuilder.ByteCode> references, VariableDefinition vDef) -
mightBeBoolean
-
mergeVariableType
-
getStackType
-
variablesMatch
-
makeVariableLookup
private static Map<String,VariableDefinition> makeVariableLookup(VariableDefinitionCollection variables) -
key
-
convertToAst
private List<Node> convertToAst(List<AstBuilder.ByteCode> body, Set<ExceptionHandler> exceptionHandlers, int startIndex, MutableInteger endIndex) -
updateExceptionVariable
-
convertToAst
-
createFrame
-