Skip to content

Host Globals aren't working #131

@cristian-5

Description

@cristian-5

Version 0.0.8

I tried to make a global so I can access it from the module but it appears the initializer of GlobalInstance is inaccessible. It might be because it's not marked as public and since it has a internal(set) member it's deduced to be internal. On a side-note, for this I needed to import both WasmParser and WasmTypes which I think it's a bit excessive.

let runtime = Runtime(hostModules: [ "env": HostModule(globals: [
    "myvalue": GlobalInstance(
        globalType: GlobalType(mutability: .constant, valueType: .f32),
        initialValue: Value.fromFloat32(5.5)
    )
]) ])
Screenshot 2024-10-01 at 10 56 37 AM

EDIT 1 - Circular Logic - version based on: 4aff9cc

Everything is completely different in the actual code, in fact, it's still impossible to make a global because circular logic: Global needs to be initialized with Store which you can only get by first making a Runtime which asks for your HostModules in which you need to put your Globals. In other words, it's an infinite loop of dependecies.

Please help, I just need to import a global variable in my webassembly module 😭

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