Skip to content

Accessing Store globals #157

@Jflick58

Description

@Jflick58

Hello, I’ve built a wasm-powered replacement for the exec() function here and wasmtime has been invaluable!

That being said, I had a quick question - once I set a global value, how do I access the globals that I have set? Is it only through function execution?

Sample code:

            # Check if the value is of a supported type
            if isinstance(value, (int, float)):
                # Determine the Wasmtime type based on the Python type
                if isinstance(value, int):
                    value_type = ValType.i32()
                elif isinstance(value, float):
                    value_type = ValType.f64()

                # Create a mutable global instance with the Python value
                global_type = GlobalType(value_type, mutable=True)
                global_var = Global(store, global_type, value)

The data function of the Store class returns None for me. Would appreciate some guidance, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions