FunctionBody

FunctionBody

data class FunctionBody

For validating Instructions within a WasmFunction body or Expression.

See ValidationContext.

Fields

Name Description
val types: AstNodeIndex<Type>
val functions: AstNodeIndex<TypeUse>
val tables: AstNodeIndex<TableType>
val memories: AstNodeIndex<MemoryType>
val globals: AstNodeIndex<GlobalType>
val locals: AstNodeIndex<ValueType>
val labels: AstNodeIndex<ResultType>
val stack: List<ValueType>
val returnType: ResultType?

Constructors

<init>

constructor(types: AstNodeIndex<Type>, functions: AstNodeIndex<TypeUse>, tables: AstNodeIndex<TableType>, memories: AstNodeIndex<MemoryType>, globals: AstNodeIndex<GlobalType>, locals: AstNodeIndex<ValueType>, labels: AstNodeIndex<ResultType>, stack: List<ValueType>, returnType: ResultType?)

For validating Instructions within a WasmFunction body or Expression.

See ValidationContext.

Parameters

Name Description
types: AstNodeIndex<Type>
functions: AstNodeIndex<TypeUse>
tables: AstNodeIndex<TableType>
memories: AstNodeIndex<MemoryType>
globals: AstNodeIndex<GlobalType>
locals: AstNodeIndex<ValueType>
labels: AstNodeIndex<ResultType>
stack: List<ValueType>
returnType: ResultType?

Methods

peekStack

fun peekStack(): ValueType?

Returns the ValueType at the top of the stack without popping it.

ReturnValue

Name Description
ValueType?

pushStack

fun pushStack(valueType: ValueType): FunctionBody

Returns a new FunctionBody, with the given valueType pushed onto the stack.

Parameters

Name Description
valueType: ValueType

ReturnValue

Name Description
FunctionBody

popStack

fun popStack(): Pair<ValueType?, FunctionBody>

Returns the top ValueType from the stack, and a new FunctionBody with that top item removed.

ReturnValue

Name Description
Pair<ValueType?, FunctionBody>

popStack

fun popStack(count: Int): Pair, FunctionBody><List<ValueType>, FunctionBody>

Returns the top counts from the stack, and a new FunctionBody with those items removed.

Parameters

Name Description
count: Int

ReturnValue

Name Description
Pair, FunctionBody><List<ValueType>, FunctionBody>

prependLabel

fun prependLabel(identifier: Label, label: ResultType): FunctionBody

Prepends a ResultType onto the labels list with the given identifier.

Parameters

Name Description
identifier: Label
label: ResultType

ReturnValue

Name Description
FunctionBody

prependLabel

fun prependLabel(label: ResultType): FunctionBody

Prepends a ResultType onto the labels list.

Parameters

Name Description
label: ResultType

ReturnValue

Name Description
FunctionBody