value property

Object? get value

The current value.

Implementation

Object? get value => scoped((arena) {
  final out = arena<c.wasmtime_val_t>();
  c.wasmtime_global_get(store.context, _native(arena), out);
  final kind = WasmValueKind.fromCKind(out.ref.kind);
  final value = toDartValue(store, kind, readValue(out));
  unrootValue(out);
  return value;
});
set value (Object? newValue)

Sets the value. Throws for an immutable global.

Implementation

set value(Object? newValue) => scoped((arena) {
  final kind = type.content;
  final slot = arena<c.wasmtime_val_t>();
  writeValue(slot, kind, toNativeValue(kind, newValue));
  throwIfError(c.wasmtime_global_set(store.context, _native(arena), slot));
});