veewee / ext-wasm

Run webassembly from PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigation: can we deliver wasm meta-data for generating autocompletion

veewee opened this issue · comments

See:

/**
 * @property int $one
 * @property int $some
 * @method int get_one()
 * @method int get_some()
 * @method int set_some(int $param)
 */
final class MyInstanceDecorator extends Wasm\WasmInstance {
  public function __construct() {
    parent::__construct(
      <<<'EOWAT'
      (module
        (global $one (export "one") i32 (i32.const 1))
        (global $some (export "some") (mut i32) (i32.const 0))
        (func (export "get_one") (result i32) (global.get $one))
        (func (export "get_some") (result i32) (global.get $some))
        (func (export "set_some") (param i32) (global.set $some (local.get 0))))
      EOWAT
    );
  }
}

❗ Currently decorating the WasmInstance like this throws an exception. This probably needs to be fixed in the rs-php-ext project.

It would be nice if we can provide $instance->getMetaData() that gives us all the raw information to build the @method and @property.
That way, we could build a code-generator that gives us autocompletable and staticly analyzer safe PHP code.

The goal of this issue is solely to provide the meta data. Doing something with it seems more appropriate for doing in a separate PHP-based package.