diff --git a/src/de/inetsoftware/jwebassembly/module/WasmStructInstruction.java b/src/de/inetsoftware/jwebassembly/module/WasmStructInstruction.java index c4a1caf..e0cf8ac 100644 --- a/src/de/inetsoftware/jwebassembly/module/WasmStructInstruction.java +++ b/src/de/inetsoftware/jwebassembly/module/WasmStructInstruction.java @@ -81,11 +81,13 @@ class WasmStructInstruction extends WasmInstruction { switch( op ) { case NEW: case NEW_DEFAULT: - functionName = new JavaScriptSyntheticFunctionName( "NonGC", "new_" + getSciptTypeName(), () -> "{}", null, type ); + functionName = new JavaScriptSyntheticFunctionName( "NonGC", "new_" + type.getName().replace( '/', '_' ), () -> { + return "() => {return {0:0}}"; //TODO default values of fields and then use Object.seal() + }, null, type ); break; case SET: AnyType fieldType = fieldName.getType(); - functionName = new JavaScriptSyntheticFunctionName( "NonGC", "set_" + fieldType, () -> "(a,i,v) => a[i]=v", ValueType.anyref, ValueType.i32, fieldType, null, null ); + functionName = new JavaScriptSyntheticFunctionName( "NonGC", "set_" + fieldType, () -> "(a,v,i) => a[i]=v", ValueType.anyref, ValueType.i32, fieldType, null, null ); break; case GET: fieldType = fieldName.getType(); @@ -96,10 +98,6 @@ class WasmStructInstruction extends WasmInstruction { return functionName; } - private String getSciptTypeName() { - return type.getName().replace( '/', '_' ); - } - /** * Get the StructOperator *