mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
fix the new polyfill array functions
This commit is contained in:
parent
6d2a90785c
commit
02b2d9fcbb
@ -103,19 +103,19 @@ class WasmArrayInstruction extends WasmInstruction {
|
|||||||
ArrayType arrayType = types.arrayType( type );
|
ArrayType arrayType = types.arrayType( type );
|
||||||
functionName = new JavaScriptSyntheticFunctionName( "NonGC_", "array_new_" + validJsName( type ), () -> {
|
functionName = new JavaScriptSyntheticFunctionName( "NonGC_", "array_new_" + validJsName( type ), () -> {
|
||||||
// create the default values of a new type
|
// create the default values of a new type
|
||||||
return new StringBuilder( "()=>Object.seal({0:" ) // fix count of elements
|
return new StringBuilder( "(l)=>Object.seal({0:" ) // fix count of elements
|
||||||
.append( arrayType.getClassIndex() ) // .vtable
|
.append( arrayType.getClassIndex() ) // .vtable
|
||||||
.append( ",1:0,2:" ) // .hashCode
|
.append( ",1:0,2:" ) // .hashCode
|
||||||
.append( cmd ) // the array data
|
.append( cmd ) // the array data
|
||||||
.append( "})" ) //
|
.append( "})" ) //
|
||||||
.toString();
|
.toString();
|
||||||
}, null, ValueType.externref );
|
}, ValueType.i32, null, ValueType.externref );
|
||||||
break;
|
break;
|
||||||
case GET:
|
case GET:
|
||||||
functionName = new JavaScriptSyntheticFunctionName( "NonGC_", "array_get_" + validJsName( functionType ), () -> "(a,i)=>a[2][i]", ValueType.externref, ValueType.i32, null, functionType );
|
functionName = new JavaScriptSyntheticFunctionName( "NonGC_", "array_get_" + validJsName( functionType ), () -> "(a,i)=>a[2][i]", ValueType.externref, ValueType.i32, null, functionType );
|
||||||
break;
|
break;
|
||||||
case SET:
|
case SET:
|
||||||
functionName = new JavaScriptSyntheticFunctionName( "NonGC_", "array_set_" + validJsName( functionType ), () -> "(a,v,i)=>a[2][i]=v", ValueType.externref, functionType, ValueType.i32, null, null );
|
functionName = new JavaScriptSyntheticFunctionName( "NonGC_", "array_set_" + validJsName( functionType ), () -> "(a,i,v)=>a[2][i]=v", ValueType.externref, functionType, ValueType.i32, null, null );
|
||||||
break;
|
break;
|
||||||
case LEN:
|
case LEN:
|
||||||
functionName = new JavaScriptSyntheticFunctionName( "NonGC_", "array_len", () -> "(a)=>a[2].length", ValueType.externref, null, ValueType.i32 );
|
functionName = new JavaScriptSyntheticFunctionName( "NonGC_", "array_len", () -> "(a)=>a[2].length", ValueType.externref, null, ValueType.i32 );
|
||||||
@ -147,7 +147,11 @@ class WasmArrayInstruction extends WasmInstruction {
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void writeTo( @Nonnull ModuleWriter writer ) throws IOException {
|
public void writeTo( @Nonnull ModuleWriter writer ) throws IOException {
|
||||||
writer.writeArrayOperator( op, type );
|
if( functionName != null ) { // nonGC
|
||||||
|
writer.writeFunctionCall( functionName, null );
|
||||||
|
} else {
|
||||||
|
writer.writeArrayOperator( op, type );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user