class Wasmer::GlobalType

Overview

GlobalType classifies global variables, which hold a value and can either be mutable or immutable. See Also: Specification: https://webassembly.github.io/spec/core/syntax/types.html#global-types

Included Modules

Defined in:

wasmer/global.cr

Constructors

Instance Method Summary

Instance methods inherited from module Wasmer::WithExternType

to_externtype : ExternType to_externtype

Constructor Detail

def self.new(val_type : ValueType, mutability : GlobalMutability) #

Instantiates a new GlobalType from a ValueType and GlobalMutability

val_type = ValueType.new(Wasmer::I32)
global_type = GlobalType.new(val_type, Wasmer::Immutable)

[View source]

Instance Method Detail

def mutability : GlobalMutability #

Returns the GlobalType's GlobalMutability

val_type = ValueType.new(Wasmer::I32)
global_type = GlobalType.new(val_type, Wasmer::Immutable)
puts global_type.mutability # => const

[View source]
def mutable? #

[View source]
def to_externtype : ExternType #

Converts this GlobalType into an Externype

val_type = ValueType.new(Wasmer::I32)
global_type = GlobalType.new(val_type, Wasmer::Immutable)
extern_type = global_type.to_externtype

[View source]
def value_type : ValueType #

Returns the GlobalType's ValueType

val_type = ValueType.new(Wasmer::I32)
global_type = GlobalType.new(val_type, Wasmer::Immutable)
puts global_type.value_type.kind # => i32

[View source]