use valid JavaScript names for the JavaScriplt creator functions

This commit is contained in:
Volker Berlin 2020-01-05 21:41:19 +01:00
parent 6fa864b9fc
commit 783d22fa50

View File

@ -108,17 +108,26 @@ class WasmStructInstruction extends WasmInstruction {
break;
case SET:
AnyType fieldType = fieldName.getType();
functionName = new JavaScriptSyntheticFunctionName( "NonGC", "set_" + fieldType, () -> "(a,v,i) => a[i]=v", ValueType.anyref, fieldType, ValueType.i32, null, null );
functionName = new JavaScriptSyntheticFunctionName( "NonGC", "set_" + validJsName( fieldType ), () -> "(a,v,i) => a[i]=v", ValueType.anyref, fieldType, ValueType.i32, null, null );
break;
case GET:
fieldType = fieldName.getType();
functionName = new JavaScriptSyntheticFunctionName( "NonGC", "get_" + fieldType, () -> "(a,i) => a[i]", ValueType.anyref, ValueType.i32, null, fieldType );
functionName = new JavaScriptSyntheticFunctionName( "NonGC", "get_" + validJsName( fieldType ), () -> "(a,i) => a[i]", ValueType.anyref, ValueType.i32, null, fieldType );
break;
default:
}
return functionName;
}
/**
* Get a valid JavaScript name.
* @param type the type
* @return the identifier that is valid
*/
private static String validJsName( AnyType type ) {
return type instanceof StructType ? "anyref" : type.toString();
}
/**
* Get the StructOperator
*