Fix blocks not being printed when wrapped in AssignmentExpressions
This commit is contained in:
Родитель
c55d5b98da
Коммит
f8249a5ef0
|
@ -141,17 +141,17 @@ namespace WasmLib.Decompilation
|
|||
}
|
||||
|
||||
// TODO: support comments
|
||||
if (expression is GenericExpression ge && ge.Block1 != null) {
|
||||
if (expression is IHasBlocks blocks && blocks.Block1 != null) {
|
||||
output.WriteLine(new string('\t', tabCount) + stringRepresentation + " {");
|
||||
|
||||
OutputAsCode(ge.Block1, output, tabCount + 1, varCounts);
|
||||
OutputAsCode(blocks.Block1, output, tabCount + 1, varCounts);
|
||||
|
||||
if (ge.Block2 == null) {
|
||||
if (blocks.Block2 == null) {
|
||||
output.WriteLine(new string('\t', tabCount) + "}");
|
||||
}
|
||||
else {
|
||||
output.WriteLine(new string('\t', tabCount) + "} else {");
|
||||
OutputAsCode(ge.Block2, output, tabCount + 1, varCounts);
|
||||
OutputAsCode(blocks.Block2, output, tabCount + 1, varCounts);
|
||||
output.WriteLine(new string('\t', tabCount) + "}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
using Rivers;
|
||||
using WasmLib.FileFormat;
|
||||
using WasmLib.Utils;
|
||||
|
||||
namespace WasmLib.Decompilation.SourceCode
|
||||
{
|
||||
public class AssignmentExpression : IExpression
|
||||
public class AssignmentExpression : IExpression, IHasBlocks
|
||||
{
|
||||
public IExpression BaseExpression { get; }
|
||||
public VariableReferenceExpression Reference { get; }
|
||||
public string Name { get; }
|
||||
public Graph? Block1 => (BaseExpression as IHasBlocks)?.Block1;
|
||||
public Graph? Block2 => (BaseExpression as IHasBlocks)?.Block2;
|
||||
|
||||
public AssignmentExpression(IExpression baseExpression, ValueKind type, int index)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ using WasmLib.Utils;
|
|||
|
||||
namespace WasmLib.Decompilation.SourceCode
|
||||
{
|
||||
public class GenericExpression : IExpression
|
||||
public class GenericExpression : IExpression, IHasBlocks
|
||||
{
|
||||
public IntermediateInstruction BaseInstruction { get; }
|
||||
public IExpression[]? Parameters { get; }
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
using Rivers;
|
||||
|
||||
namespace WasmLib.Decompilation.SourceCode
|
||||
{
|
||||
public interface IHasBlocks
|
||||
{
|
||||
Graph? Block1 { get; }
|
||||
Graph? Block2 { get; }
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче