Also write prefix ref_type in the local variable declaration.

This commit is contained in:
Volker Berlin 2019-04-21 10:45:17 +02:00
parent 2be6f1a3be
commit e037de5646
3 changed files with 5 additions and 1 deletions

View File

@ -467,6 +467,9 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
localsStream.writeVaruint32( locals.size() );
for( AnyType valueType : locals ) {
localsStream.writeVaruint32( 1 ); // TODO optimize, write the count of same types.
if( valueType.getCode() >= 0 ) {
localsStream.writeValueType( ValueType.ref_type );
}
localsStream.writeValueType( valueType );
}
WasmOutputStream functionsStream = function.functionsStream = new WasmOutputStream();

View File

@ -60,7 +60,7 @@ class StructTypeEntry extends TypeEntry {
for( NamedStorageType field : this.fields ) {
stream.writeVarint( 1 ); // 0 - immutable; 1 - mutable
if( field.type.getCode() > 0 ) {
stream.writeVaruint32( 0x6E );
stream.writeValueType( ValueType.ref_type );
}
stream.writeValueType( field.type );
}

View File

@ -27,6 +27,7 @@ public enum ValueType implements AnyType {
i16(-0x06), //TODO dummy value for https://github.com/WebAssembly/gc
anyfunc(-0x10),
anyref(-0x11),
ref_type(-0x12 ), // 0x6E https://github.com/lars-t-hansen/moz-gc-experiments/blob/master/version2.md
except_ref(-0x18), // https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md
func(-0x20),
struct(-0x30),