diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-17 12:58:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 12:58:21 +0200 |
commit | 2841eddaabc7a5e24517e043a1aab8adc6d5c1e4 (patch) | |
tree | 17f8ed3d71237c4860fc07f7ba9bdc4d9691b76b /src/passes/Print.cpp | |
parent | e1d74ef2acdd88f06b9e58f91f30bb56b9a26fe8 (diff) | |
download | binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.tar.gz binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.tar.bz2 binaryen-2841eddaabc7a5e24517e043a1aab8adc6d5c1e4.zip |
Refactor Host expression to MemorySize and MemoryGrow (#3137)
Aligns the internal representations of `memory.size` and `memory.grow` with other more recent memory instructions by removing the legacy `Host` expression class and adding separate expression classes for `MemorySize` and `MemoryGrow`. Simplifies related APIs, but is also a breaking API change.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 15ab97098..916615e07 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1430,16 +1430,8 @@ struct PrintExpressionContents } void visitDrop(Drop* curr) { printMedium(o, "drop"); } void visitReturn(Return* curr) { printMedium(o, "return"); } - void visitHost(Host* curr) { - switch (curr->op) { - case MemorySize: - printMedium(o, "memory.size"); - break; - case MemoryGrow: - printMedium(o, "memory.grow"); - break; - } - } + void visitMemorySize(MemorySize* curr) { printMedium(o, "memory.size"); } + void visitMemoryGrow(MemoryGrow* curr) { printMedium(o, "memory.grow"); } void visitRefNull(RefNull* curr) { printMedium(o, "ref.null "); o << curr->type.getHeapType(); @@ -1577,7 +1569,9 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { o << ')'; } void printFullLine(Expression* expression) { - !minify && doIndent(o, indent); + if (!minify) { + doIndent(o, indent); + } if (full) { o << "[" << expression->type << "] "; } @@ -1945,20 +1939,17 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { printFullLine(curr->value); decIndent(); } - void visitHost(Host* curr) { + void visitMemorySize(MemorySize* curr) { o << '('; PrintExpressionContents(currFunction, o).visit(curr); - switch (curr->op) { - case MemoryGrow: { - incIndent(); - printFullLine(curr->operands[0]); - decIndent(); - break; - } - case MemorySize: { - o << ')'; - } - } + o << ')'; + } + void visitMemoryGrow(MemoryGrow* curr) { + o << '('; + PrintExpressionContents(currFunction, o).visit(curr); + incIndent(); + printFullLine(curr->delta); + decIndent(); } void visitRefNull(RefNull* curr) { o << '('; |