Skip to main content

Wasm

Description:

  A record that provides WASM related functions.

executeMainFileAsync

Type: Function.

Description:

  Executes the main WASM file (e.g. init.wasm) asynchronously.

Signature:

executeMainFileAsync: function(self: Wasm, filename: string): boolean

Parameters:

ParameterTypeDescription
filenamestringThe name of the main WASM file.

Returns:

Return TypeDescription
booleanWhether the main WASM file was executed successfully.

buildWaAsync

Type: Function.

Description:

  Builds the WASM file (e.g. init.wasm) from a Wa-lang project asynchronously.

Signature:

buildWaAsync: function(self: Wasm, fullPath: string): string

Usage:

thread(function()
local result = Wasm:buildWaAsync("/path/to/wa-lang/project/")
if result == "" then
print("Built successfully!")
else
print("Failed to build, due to " .. result)
end
end)

Parameters:

ParameterTypeDescription
fullPathstringThe full path of the Wa-lang project.

Returns:

Return TypeDescription
stringThe WASM file building result.

formatWaAsync

Type: Function.

Description:

  Formats a Wa-lang code file asynchronously.

Signature:

formatWaAsync: function(self: Wasm, fullPath: string): string

Usage:

thread(function()
local result = Wasm:formatWaAsync("/path/to/wa-lang/code/file.wa")
if success == "" then
print("Failed to format")
else
print("Formated code:" .. result)
end
end)

Parameters:

ParameterTypeDescription
fullPathstringThe full path of the Wa-lang code file.

Returns:

Return TypeDescription
stringThe Wa-lang code file formatting result.

clear

Type: Function.

Description:

  Clears the running WASM module and stops the runtime.

Signature:

clear: function(self: Wasm)