class CrystalRobots::Compiler::WASM_Emitter

Defined in:

compiler/wasm_emitter.cr

Constant Summary

FunctionType = 96

http://webassembly.github.io/spec/core/binary/types.html#function-types

MagicModuleHeader = Bytes[0, 'a'.ord, 's'.ord, 'm'.ord]

https://webassembly.github.io/spec/core/binary/modules.html#binary-module

ModuleVersion = Bytes[1, 0, 0, 0]

Constructors

Instance Method Summary

Constructor Detail

def self.new(ast : Program) #

Instance Method Detail

def codeFromAst(ast : Program) #

def codeSection(ast : Program) #

the code section contains vectors of functions https://webassembly.github.io/spec/core/binary/modules.html#binary-codesec


def createSection(type : Section, data : Bytes) #

def encodeString(string : String) : Bytes #

https://webassembly.github.io/spec/core/binary/values.html#names


def encodeVector(data : Bytes) : Bytes #

https://webassembly.github.io/spec/core/binary/conventions.html#binary-vec Vectors are encoded with their length followed by their element sequence


def exportSection #

the export section is a vector of exported functions


def funcSection #

the function section is a vector of type indices that indicate the type of each function in the code section


def importSection #

def signedLEB128(n : Int32) : Bytes #

def to_wasm #

Helpful tool for exploring - https://webassembly.github.io/wabt/demo/wat2wasm/


def typeSection #

Function types are vectors of parameters and return types. Currently WebAssembly only supports single return values the type section is a vector of function types


def unsignedLEB128(n : UInt32 | Int32) : Bytes #

https://en.wikipedia.org/wiki/LEB128