@@ -353,6 +353,7 @@ public class JavaScriptEnvironment: ComponentBase {
353353 }
354354 registerObjectGroup ( . jsWebAssemblyCompileOptions)
355355 registerObjectGroup ( . jsWebAssemblyModuleConstructor)
356+ registerObjectGroup ( . jsWebAssemblyGlobalConstructor)
356357 registerObjectGroup ( . jsWebAssemblyModule)
357358 registerObjectGroup ( . jsWebAssembly)
358359 registerObjectGroup ( . jsWasmGlobal)
@@ -919,6 +920,13 @@ public extension ILType {
919920 + . object( ofGroup: " WebAssemblyModuleConstructor " , withProperties: [ ] ,
920921 withMethods: [ " customSections " , " imports " , " exports " ] )
921922
923+ static let jsWasmGlobal = ILType . object ( ofGroup: " WasmGlobal " , withProperties: [ " value " ] ,
924+ withMethods: [ " valueOf " ] )
925+
926+ static let jsWebAssemblyGlobalConstructor =
927+ ILType . constructor ( [ . plain( . object( ) ) , . jsAnything] => . jsWasmGlobal)
928+ + . object( ofGroup: " WebAssemblyGlobalConstructor " , withProperties: [ ] , withMethods: [ ] )
929+
922930 // The JavaScript WebAssembly.Table object of the given variant, i.e. FuncRef or ExternRef
923931 static let wasmTable = ILType . object ( ofGroup: " WasmTable " , withProperties: [ " length " ] , withMethods: [ " get " , " grow " , " set " ] )
924932
@@ -1730,13 +1738,21 @@ public extension ObjectGroup {
17301738 ]
17311739 )
17321740
1741+ static let jsWebAssemblyGlobalConstructor = ObjectGroup (
1742+ name: " WebAssemblyGlobalConstructor " ,
1743+ instanceType: . jsWebAssemblyGlobalConstructor,
1744+ properties: [ : ] ,
1745+ methods: [ : ]
1746+ )
1747+
17331748 static let jsWebAssembly = ObjectGroup (
17341749 name: " WebAssembly " ,
17351750 instanceType: nil ,
17361751 properties: [
17371752 // TODO(mliedtke): Add properties like Global, Memory, ...
17381753 " JSTag " : . object( ofGroup: " WasmTag " , withWasmType: WasmTagType ( [ . wasmExternRef] , isJSTag: true ) ) ,
17391754 " Module " : . jsWebAssemblyModuleConstructor,
1755+ " Global " : . jsWebAssemblyGlobalConstructor,
17401756 ] ,
17411757 overloads: [
17421758 " compile " : wasmBufferTypes. map {
@@ -1760,12 +1776,12 @@ public extension ObjectGroup {
17601776 /// ObjectGroup modelling JavaScript WebAssembly Global objects.
17611777 static let jsWasmGlobal = ObjectGroup (
17621778 name: " WasmGlobal " ,
1763- instanceType: . object ( ofGroup : " WasmGlobal " , withProperties : [ " value " ] ) ,
1779+ instanceType: . jsWasmGlobal ,
17641780 properties: [
17651781 // TODO: Try using precise JS types based on the global's underlying valuetype (e.g. float for f32 and f64).
17661782 " value " : . jsAnything
17671783 ] ,
1768- methods: [ : ]
1784+ methods: [ " valueOf " : [ ] => . jsAnything ]
17691785 )
17701786
17711787 /// ObjectGroup modelling JavaScript WebAssembly Memory objects.
0 commit comments