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: case SET:
opCode = STRUCT_SET; opCode = STRUCT_SET;
break; break;
case NULL:
opCode = REF_NULL;
type = null;
break;
default: default:
throw new Error( "Unknown operator: " + op ); throw new Error( "Unknown operator: " + op );
} }
codeStream.writeOpCode( opCode ); 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; String operation;
switch( op ) { switch( op ) {
case NEW: case NEW:
operation = "new"; operation = "struct.new";
break; break;
case NEW_DEFAULT: case NEW_DEFAULT:
operation = "new_default"; operation = "struct.new_default";
break; break;
case GET: case GET:
operation = "get"; operation = "struct.get";
break; break;
case SET: case SET:
operation = "set"; operation = "struct.set";
break;
case NULL:
operation = "ref.null";
type = null;
break; break;
default: default:
throw new Error( "Unknown operator: " + op ); throw new Error( "Unknown operator: " + op );
} }
newline( methodOutput ); 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 );
}
}
} }
} }