mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
fix type handling for NUL values with GC support
This commit is contained in:
parent
77d81e3f13
commit
856194dbce
@ -1395,7 +1395,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
break;
|
||||
case NULL:
|
||||
opCode = REF_NULL;
|
||||
type = options.useGC() ? ValueType.eqref : ValueType.externref;
|
||||
type = options.useGC() ? type : ValueType.externref;
|
||||
break;
|
||||
default:
|
||||
throw new Error( "Unknown operator: " + op );
|
||||
|
@ -98,8 +98,7 @@ class WasmOutputStream extends LittleEndianOutputStream {
|
||||
public void writeRefValueType( AnyType type ) throws IOException {
|
||||
if( type.isRefType() ) {
|
||||
if( options.useGC() ) {
|
||||
//TODO writeValueType( ValueType.ref_type );
|
||||
type = ValueType.eqref;
|
||||
writeValueType( ValueType.optref );
|
||||
} else {
|
||||
type = ValueType.externref;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
||||
case 0: // nop
|
||||
break;
|
||||
case 1: // aconst_null
|
||||
addStructInstruction( StructOperator.NULL, null, null, codePos, lineNumber );
|
||||
addStructInstruction( StructOperator.NULL, "java/lang/Object", null, codePos, lineNumber );
|
||||
break;
|
||||
case 2: // iconst_m1
|
||||
case 3: // iconst_0
|
||||
|
@ -64,10 +64,10 @@ class WasmStructInstruction extends WasmInstruction {
|
||||
* @param types
|
||||
* the type manager
|
||||
*/
|
||||
WasmStructInstruction( @Nullable StructOperator op, @Nullable String typeName, @Nullable NamedStorageType fieldName, int javaCodePos, int lineNumber, TypeManager types ) {
|
||||
WasmStructInstruction( @Nullable StructOperator op, @Nonnull String typeName, @Nullable NamedStorageType fieldName, int javaCodePos, int lineNumber, TypeManager types ) {
|
||||
super( javaCodePos, lineNumber );
|
||||
this.op = op;
|
||||
this.type = typeName == null ? null : types.valueOf( typeName );
|
||||
this.type = types.valueOf( typeName );
|
||||
this.fieldName = fieldName;
|
||||
if( type != null && fieldName != null ) {
|
||||
type.useFieldName( fieldName );
|
||||
|
@ -861,8 +861,12 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
operation = "struct.set";
|
||||
break;
|
||||
case NULL:
|
||||
operation = options.useGC() ? "ref.null eq" : "ref.null extern";
|
||||
type = null;
|
||||
if( options.useGC() ) {
|
||||
operation = "ref.null";
|
||||
} else {
|
||||
operation = "ref.null extern";
|
||||
type = null;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error( "Unknown operator: " + op );
|
||||
|
Loading…
x
Reference in New Issue
Block a user