diff options
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index ab5ef514f..5d49ad900 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2943,12 +2943,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { void handleSignature(HeapType curr, Name name = Name()) { Signature sig = curr.getSignature(); - bool hasSupertype = !name.is() && !!curr.getSuperType(); - if (hasSupertype) { - o << "(func_subtype"; - } else { - o << "(func"; - } + o << "(func"; if (name.is()) { o << " $" << name; if (currModule && currModule->features.hasGC()) { @@ -2978,10 +2973,6 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { } o << ')'; } - if (hasSupertype) { - o << ' '; - printSupertypeOr(curr, "func"); - } o << ")"; } void handleFieldBody(const Field& field) { @@ -3004,27 +2995,13 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { } } void handleArray(HeapType curr) { - bool hasSupertype = !!curr.getSuperType(); - if (hasSupertype) { - o << "(array_subtype "; - } else { - o << "(array "; - } + o << "(array "; handleFieldBody(curr.getArray().element); - if (hasSupertype) { - o << ' '; - printSupertypeOr(curr, "data"); - } o << ')'; } void handleStruct(HeapType curr) { - bool hasSupertype = !!curr.getSuperType(); const auto& fields = curr.getStruct().fields; - if (hasSupertype) { - o << "(struct_subtype "; - } else { - o << "(struct "; - } + o << "(struct "; auto sep = ""; for (Index i = 0; i < fields.size(); i++) { o << sep << "(field "; @@ -3037,13 +3014,17 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { o << ')'; sep = " "; } - if (hasSupertype) { - o << ' '; - printSupertypeOr(curr, "data"); - } o << ')'; } void handleHeapType(HeapType type) { + bool hasSuper = false; + // TODO: Consider finality once we support that. + if (auto super = type.getSuperType()) { + hasSuper = true; + o << "(sub "; + TypeNamePrinter(o, currModule).print(*super); + o << ' '; + } if (type.isSignature()) { handleSignature(type); } else if (type.isArray()) { @@ -3053,6 +3034,9 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { } else { o << type; } + if (hasSuper) { + o << ')'; + } } void visitExport(Export* curr) { o << '('; |