some improvements for GC

This commit is contained in:
Volker Berlin 2020-09-17 21:07:09 +02:00
parent 1fc21e4033
commit de55f414b0

View File

@ -318,8 +318,8 @@ public class TextModuleWriter extends ModuleWriter {
if( !type.isRefType() ) { if( !type.isRefType() ) {
output.append( type.toString() ); output.append( type.toString() );
} else if( options.useGC() ) { } else if( options.useGC() ) {
output.append( ValueType.eqref.toString() ); //output.append( ValueType.eqref.toString() );
//TODO output.append( "(optref " ).append( normalizeName( type.toString() ) ).append( ')' ); output.append( "(ref null " ).append( normalizeName( type.toString() ) ).append( ')' );
} else { } else {
output.append( ValueType.externref.toString() ); output.append( ValueType.externref.toString() );
} }
@ -527,7 +527,7 @@ public class TextModuleWriter extends ModuleWriter {
* @throws IOException * @throws IOException
* if an I/O error occurs. * if an I/O error occurs.
*/ */
private static void writeDefaultValue( Appendable output, AnyType type ) throws IOException { private void writeDefaultValue( Appendable output, AnyType type ) throws IOException {
if( type instanceof ValueType ) { if( type instanceof ValueType ) {
ValueType valueType = (ValueType)type; ValueType valueType = (ValueType)type;
switch( valueType ) { switch( valueType ) {
@ -548,7 +548,7 @@ public class TextModuleWriter extends ModuleWriter {
throw new WasmException( "Not supported storage type: " + type, -1 ); throw new WasmException( "Not supported storage type: " + type, -1 );
} }
} else { } else {
output.append( "ref.null extern" ); output.append( "ref.null " ).append( options.useGC() ? normalizeName( type.toString() ) : "extern" );
} }
} }