implements ref.null

This commit is contained in:
Volker Berlin 2018-12-14 20:47:53 +01:00
parent ba118b8531
commit 1b09c5fd8c
2 changed files with 25 additions and 6 deletions

View File

@ -826,10 +826,16 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
case SET:
opCode = STRUCT_SET;
break;
case NULL:
opCode = REF_NULL;
type = null;
break;
default:
throw new Error( "Unknown operator: " + op );
}
codeStream.writeOpCode( opCode );
codeStream.writeValueType( type );
if( type != null ) {
codeStream.writeValueType( type );
}
}
}

View File

@ -400,21 +400,34 @@ public class TextModuleWriter extends ModuleWriter {
String operation;
switch( op ) {
case NEW:
operation = "new";
operation = "struct.new";
break;
case NEW_DEFAULT:
operation = "new_default";
operation = "struct.new_default";
break;
case GET:
operation = "get";
operation = "struct.get";
break;
case SET:
operation = "set";
operation = "struct.set";
break;
case NULL:
operation = "ref.null";
type = null;
break;
default:
throw new Error( "Unknown operator: " + op );
}
newline( methodOutput );
methodOutput.append( "struct." ).append( operation ).append( ' ' ).append( type );
methodOutput.append( operation );
if( type != null ) {
int typeCode = type.getCode();
methodOutput.append( ' ' );
if( typeCode < 0 ) {
methodOutput.append( type );
} else {
methodOutput.append( typeCode );
}
}
}
}