blob: abaa2d1f9922c82dd454f77082413d28368e96f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package wasm
import (
"github.com/tetratelabs/wazero/api"
"github.com/tetratelabs/wazero/internal/internalapi"
)
// constantGlobal wraps GlobalInstance to implement api.Global.
type constantGlobal struct {
internalapi.WazeroOnlyType
g *GlobalInstance
}
// Type implements api.Global.
func (g constantGlobal) Type() api.ValueType {
return g.g.Type.ValType
}
// Get implements api.Global.
func (g constantGlobal) Get() uint64 {
ret, _ := g.g.Value()
return ret
}
// String implements api.Global.
func (g constantGlobal) String() string {
return g.g.String()
}
// mutableGlobal extends constantGlobal to allow updates.
type mutableGlobal struct {
internalapi.WazeroOnlyType
g *GlobalInstance
}
// Type implements api.Global.
func (g mutableGlobal) Type() api.ValueType {
return g.g.Type.ValType
}
// Get implements api.Global.
func (g mutableGlobal) Get() uint64 {
ret, _ := g.g.Value()
return ret
}
// String implements api.Global.
func (g mutableGlobal) String() string {
return g.g.String()
}
// Set implements the same method as documented on api.MutableGlobal.
func (g mutableGlobal) Set(v uint64) {
g.g.SetValue(v, 0)
}
|