Package com.strobel.decompiler.ast
Class AstBuilder
- java.lang.Object
-
- com.strobel.decompiler.ast.AstBuilder
-
public final class AstBuilder extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAstBuilder.ByteCodeprivate static classAstBuilder.FinallyInliningprivate static classAstBuilder.HandlerInfoprivate static classAstBuilder.StackSlotprivate static classAstBuilder.SubroutineInfoprivate static classAstBuilder.VariableInfoprivate static classAstBuilder.VariableSlot
-
Field Summary
Fields Modifier and Type Field Description private MethodBody_bodyprivate ControlFlowGraph_cfgprivate DecompilerContext_contextprivate java.util.List<ExceptionHandler>_exceptionHandlersprivate CoreMetadataFactory_factoryprivate InstructionCollection_instructionsprivate java.util.Map<ExceptionHandler,AstBuilder.ByteCode>_loadExceptionsprivate boolean_optimizeprivate java.util.Map<Instruction,Instruction>_originalInstructionMapprivate java.util.Set<Instruction>_removedprivate static AstCode[]CODESprivate static AstBuilder.ByteCode[]EMPTY_DEFINITIONSprivate static AstBuilder.StackSlot[]EMPTY_STACKprivate static java.util.logging.LoggerLOGprivate static Predicate<Node>NOT_A_LABEL_OR_NOP
-
Constructor Summary
Constructors Constructor Description AstBuilder()
-
Method Summary
-
-
-
Field Detail
-
LOG
private static final java.util.logging.Logger LOG
-
CODES
private static final AstCode[] CODES
-
EMPTY_STACK
private static final AstBuilder.StackSlot[] EMPTY_STACK
-
EMPTY_DEFINITIONS
private static final AstBuilder.ByteCode[] EMPTY_DEFINITIONS
-
_loadExceptions
private final java.util.Map<ExceptionHandler,AstBuilder.ByteCode> _loadExceptions
-
_removed
private final java.util.Set<Instruction> _removed
-
_originalInstructionMap
private java.util.Map<Instruction,Instruction> _originalInstructionMap
-
_cfg
private ControlFlowGraph _cfg
-
_instructions
private InstructionCollection _instructions
-
_exceptionHandlers
private java.util.List<ExceptionHandler> _exceptionHandlers
-
_body
private MethodBody _body
-
_optimize
private boolean _optimize
-
_context
private DecompilerContext _context
-
_factory
private CoreMetadataFactory _factory
-
-
Method Detail
-
build
public static java.util.List<Node> build(MethodBody body, boolean optimize, DecompilerContext context)
-
isGetClassInvocation
private static boolean isGetClassInvocation(Instruction p)
-
removeGetClassCallsForInvokeDynamic
private void removeGetClassCallsForInvokeDynamic()
-
inlineSubroutines
private void inlineSubroutines()
-
inlineSubroutine
private boolean inlineSubroutine(AstBuilder.SubroutineInfo subroutine, Instruction reference)
-
remapHandlersForInlinedSubroutine
private void remapHandlersForInlinedSubroutine(Instruction jump, Instruction start, Instruction end)
-
duplicateHandlersForInlinedSubroutine
private void duplicateHandlersForInlinedSubroutine(AstBuilder.SubroutineInfo subroutine, java.util.Map<Instruction,Instruction> oldToNew)
-
remapJumps
private void remapJumps(java.util.Map<Instruction,Instruction> remappedJumps)
-
callsOtherSubroutine
private boolean callsOtherSubroutine(AstBuilder.SubroutineInfo subroutine, java.util.List<AstBuilder.SubroutineInfo> subroutines)
-
findSubroutines
private java.util.List<AstBuilder.SubroutineInfo> findSubroutines()
-
findNode
private static ControlFlowNode findNode(ControlFlowGraph cfg, Instruction instruction)
-
findDominatedNodes
private static java.util.Set<ControlFlowNode> findDominatedNodes(ControlFlowGraph cfg, ControlFlowNode head, boolean diveIntoHandlers, java.util.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
private static java.util.Map<Instruction,ControlFlowNode> createNodeMap(ControlFlowGraph cfg)
-
remapHandlers
private static java.util.List<ExceptionHandler> remapHandlers(java.util.List<ExceptionHandler> handlers, InstructionCollection instructions)
-
copyInstructions
private static InstructionCollection copyInstructions(java.util.List<Instruction> instructions)
-
pruneExceptionHandlers
private void pruneExceptionHandlers()
-
removeEmptyCatchBlockBodies
private void removeEmptyCatchBlockBodies()
-
ensureDesiredProtectedRanges
private void ensureDesiredProtectedRanges()
-
alignFinallyBlocksWithSiblingCatchBlocks
private void alignFinallyBlocksWithSiblingCatchBlocks()
-
mergeSharedHandlers
private void mergeSharedHandlers()
-
trimAggressiveCatchBlocks
private void trimAggressiveCatchBlocks()
-
removeSelfHandlingFinallyHandlers
private void removeSelfHandlingFinallyHandlers()
-
trimAggressiveFinallyBlocks
private void trimAggressiveFinallyBlocks()
-
findHandlerNode
private static ControlFlowNode findHandlerNode(ControlFlowGraph cfg, ExceptionHandler handler)
-
findInnermostExceptionHandler
private ExceptionHandler findInnermostExceptionHandler(int offsetInTryBlock, ExceptionHandler exclude)
-
closeTryHandlerGaps
private void closeTryHandlerGaps()
-
removeTryIntersectionsWithPreviousCatch
private void removeTryIntersectionsWithPreviousCatch()
-
findFirstHandler
private static ExceptionHandler findFirstHandler(InstructionBlock tryBlock, java.util.Collection<ExceptionHandler> handlers)
-
findHandlers
private static java.util.List<ExceptionHandler> findHandlers(InstructionBlock tryBlock, java.util.Collection<ExceptionHandler> handlers)
-
findDuplicateHandlers
private static java.util.List<ExceptionHandler> findDuplicateHandlers(ExceptionHandler handler, java.util.Collection<ExceptionHandler> handlers)
-
performStackAnalysis
private java.util.List<AstBuilder.ByteCode> performStackAnalysis()
-
mappedInstruction
private static Instruction mappedInstruction(java.util.Map<Instruction,Instruction> map, Instruction instruction)
-
createModifiedStack
private static AstBuilder.StackSlot[] createModifiedStack(AstBuilder.ByteCode byteCode, StackMappingVisitor stackMapper)
-
convertLocalVariables
private void convertLocalVariables(AstBuilder.ByteCode[] parameterDefinitions, java.util.List<AstBuilder.ByteCode> body)
-
processVariableUnoptimized
private java.util.List<AstBuilder.VariableInfo> processVariableUnoptimized(MethodDefinition method, int slot, java.util.List<AstBuilder.ByteCode> definitions, java.util.List<AstBuilder.ByteCode> references, VariableDefinition vDef)
-
mightBeBoolean
private boolean mightBeBoolean(AstBuilder.VariableInfo info)
-
mergeVariableType
private TypeReference mergeVariableType(java.util.List<AstBuilder.VariableInfo> info)
-
getStackType
private JvmType getStackType(TypeReference type)
-
variablesMatch
private boolean variablesMatch(VariableReference v1, VariableReference v2)
-
makeVariableLookup
private static java.util.Map<java.lang.String,VariableDefinition> makeVariableLookup(VariableDefinitionCollection variables)
-
key
private static java.lang.String key(VariableDefinition variable)
-
convertToAst
private java.util.List<Node> convertToAst(java.util.List<AstBuilder.ByteCode> body, java.util.Set<ExceptionHandler> exceptionHandlers, int startIndex, MutableInteger endIndex)
-
updateExceptionVariable
private void updateExceptionVariable(CatchBlock catchBlock, ExceptionHandler handler)
-
convertToAst
private java.util.List<Node> convertToAst(java.util.List<AstBuilder.ByteCode> body)
-
createFrame
private static Frame createFrame(AstBuilder.StackSlot[] stack, AstBuilder.VariableSlot[] locals)
-
-