Wasmer PHP

GlobalType

Global types classify global variables, which hold a value and can either be mutable or immutable.

<?php declare(strict_types=1);

use Wasm\Type\{GlobalType, ValType};

$valtype = Type\ValType::new(Type\ValType::KIND_I32);
$const = Type\GlobalType::new($valtype);

$valtype = Type\ValType::new(Type\ValType::KIND_I32);
$var = Type\GlobalType::new($valtype, Type\GlobalType::MUTABILITY_VAR);
Tags
see
https://webassembly.github.io/spec/core/syntax/types.html#global-types

WebAssembly Specification - Global Types

Table of Contents

MUTABILITY_CONST  = WASM_CONST
MUTABILITY_VAR  = WASM_VAR
__construct()  : mixed
Create a Wasm\Type\GlobalType from a `wasm_globaltype_t` resource.
asExternType()  : ExternType
content()  : ValType
inner()  : resource
Return the inner global type resource.
mutability()  : int
Return the global type's mutability.
new()  : self

Constants

MUTABILITY_CONST

public mixed MUTABILITY_CONST = WASM_CONST

MUTABILITY_VAR

public mixed MUTABILITY_VAR = WASM_VAR

Methods

__construct()

Create a Wasm\Type\GlobalType from a `wasm_globaltype_t` resource.

public __construct( $globaltype) : mixed
Parameters
$globaltype :

resource a wasm_globaltype_t resource

Tags
throws
InvalidArgumentException

If the $globaltype argument is not a valid wasm_globaltype_t resource

Return values
mixed

inner()

Return the inner global type resource.

public inner() : resource
Return values
resource

A wasm_globaltype_t resource

mutability()

Return the global type's mutability.

public mutability() : int
Return values
int

new()

public static new(ValType $type[, int|null $mutability = null ]) : self
Parameters
$type : ValType
$mutability : int|null = null
Tags
throws
InvalidArgumentException

If the $mutability is not a valid mutability

Return values
self

Search results