Add support for Wat instruction struct.set

This commit is contained in:
Volker Berlin 2022-09-28 16:02:55 +02:00
parent d9e78ef414
commit 4a802a8b15
No known key found for this signature in database
GPG Key ID: 988423EF815BE4CB

View File

@ -291,6 +291,8 @@ public class WatParser extends WasmCodeBuilder {
i = addMemoryInstruction( MemoryOperator.load8_u, ValueType.i32, tokens, i, lineNumber );
break;
case "struct.get":
case "struct.set":
StructOperator op = "struct.get".equals( tok ) ? StructOperator.GET : StructOperator.SET;
String typeName = get( tokens, ++i );
String fieldName = get( tokens, ++i );
NamedStorageType fieldNameType = null;
@ -306,7 +308,7 @@ public class WatParser extends WasmCodeBuilder {
if( fieldNameType == null ) {
fieldNameType = new NamedStorageType( ValueType.externref, "", fieldName );
}
addStructInstruction( StructOperator.GET, typeName, fieldNameType, javaCodePos, lineNumber );
addStructInstruction( op, typeName, fieldNameType, javaCodePos, lineNumber );
break;
case "array.len":
typeName = get( tokens, ++i );