final DecompilerContext context = new DecompilerContext();
context.setCurrentMethod(method);
context.setCurrentType(method.getDeclaringType());
final Block methodAst = new Block();
output.writeLine(" {");
output.indent();
try {
methodAst.getBody().addAll(AstBuilder.build(body, _inlineVariables, context));
if (_abortBeforeStep != null) {
AstOptimizer.optimize(context, methodAst, _abortBeforeStep);
}
final Set<Variable> allVariables = new LinkedHashSet<>();
for (final Expression e : methodAst.getSelfAndChildrenRecursive(Expression.class)) {
final Object operand = e.getOperand();
if (operand instanceof Variable && !((Variable) operand).isParameter()) {
allVariables.add((Variable) operand);
}
}
if (!allVariables.isEmpty()) {
for (final Variable variable : allVariables) {
output.writeDefinition(variable.getName(), variable);
final TypeReference type = variable.getType();
if (type != null) {
output.write(" : ");
DecompilerHelpers.writeType(output, type, NameSyntax.SHORT_TYPE_NAME);
}
if (variable.isGenerated()) {
output.write(" [generated]");
}
output.writeLine();
}
output.writeLine();
}
methodAst.writeTo(output);
}
catch (Throwable t) {
writeError(output, t);
}
finally {