Does not write the type eqref to the output if GC is not enabled

This commit is contained in:
Volker Berlin 2021-05-02 13:54:11 +02:00
parent 2d7b7f2f50
commit 5d2a3805db
2 changed files with 25 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2017 - 2020 Volker Berlin (i-net software)
* Copyright 2017 - 2021 Volker Berlin (i-net software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -84,6 +84,13 @@ class WasmOutputStream extends LittleEndianOutputStream {
* if an I/O error occurs.
*/
public void writeValueType( AnyType type ) throws IOException {
if( !type.isRefType() && !options.useGC() ) {
switch( (ValueType)type ) {
case eqref:
type = ValueType.externref;
break;
}
}
writeVarint( type.getCode() );
}

View File

@ -362,7 +362,23 @@ public class TextModuleWriter extends ModuleWriter {
*/
private void writeTypeName( Appendable output, AnyType type ) throws IOException {
if( !type.isRefType() ) {
String name = type == ValueType.u16 ? "i16" : type == ValueType.bool ? "i8" : type.toString();
String name;
switch( (ValueType)type ) {
case u16:
name = "i16";
break;
case bool:
name = "i8";
break;
case eqref:
if( !options.useGC() ) {
name = ValueType.externref.toString();
break;
}
//$FALL-THROUGH$
default:
name = type.toString();
}
output.append( name );
} else if( options.useGC() ) {
//output.append( ValueType.eqref.toString() );