diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-06-15 00:07:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-15 00:07:55 -0400 |
commit | e0a8f40f65b178556f6fcbed778923a36dca64e3 (patch) | |
tree | 745c0eaa14e6d53c4be19a5095401bec2dd7c3c2 /src/passes/Print.cpp | |
parent | aec8d12282b5279b80e79f21d54491db5d55278e (diff) | |
download | binaryen-e0a8f40f65b178556f6fcbed778923a36dca64e3.tar.gz binaryen-e0a8f40f65b178556f6fcbed778923a36dca64e3.tar.bz2 binaryen-e0a8f40f65b178556f6fcbed778923a36dca64e3.zip |
Parsing and emitting nominal types (#3933)
Adds a `--nominal` option to switch the type machinery from equirecursive to
nominal. Implements binary and text parsing and emitting of nominal types using
new type constructor opcodes and an `(extends $super)` text syntax extension.
When not in nominal mode, these extensions will still be parsed but will not
have any effect and will not be used when emitting.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 47db029ab..dbe4f2557 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2496,7 +2496,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { } o << ')'; } - void handleHeapType(HeapType type) { + void handleHeapType(HeapType type, Module* module) { if (type.isSignature()) { handleSignature(type.getSignature()); } else if (type.isArray()) { @@ -2506,6 +2506,12 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { } else { o << type; } + HeapType super; + if (type.getSuperType(super)) { + o << " (extends "; + TypeNamePrinter(o, module).print(super); + o << ')'; + } } void visitExport(Export* curr) { o << '('; @@ -2889,7 +2895,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { printMedium(o, "type") << ' '; TypeNamePrinter(o, curr).print(type); o << ' '; - handleHeapType(type); + handleHeapType(type, curr); o << ")" << maybeNewLine; } ModuleUtils::iterImportedMemories( |