2019-09-19 00:18:36 +02:00
|
|
|
use crate::ast::InterfaceType;
|
|
|
|
|
2020-02-12 15:59:41 +01:00
|
|
|
/// Represents all the possible WIT instructions.
|
2019-09-19 00:18:36 +02:00
|
|
|
#[derive(PartialEq, Debug)]
|
|
|
|
pub enum Instruction<'input> {
|
2020-02-12 15:59:41 +01:00
|
|
|
/// `arg.get`
|
2019-09-25 23:29:08 +02:00
|
|
|
ArgumentGet { index: u64 },
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `call`
|
2019-09-25 23:29:08 +02:00
|
|
|
Call { function_index: usize },
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `call-export`
|
2019-09-25 23:29:08 +02:00
|
|
|
CallExport { export_name: &'input str },
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `read-utf8`
|
2019-09-19 00:18:36 +02:00
|
|
|
ReadUtf8,
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `write-utf8`
|
2019-09-25 23:29:08 +02:00
|
|
|
WriteUtf8 { allocator_name: &'input str },
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `as-wasm`
|
2019-09-19 00:18:36 +02:00
|
|
|
AsWasm(InterfaceType),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `as-interface`
|
2019-09-19 00:18:36 +02:00
|
|
|
AsInterface(InterfaceType),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `table-ref-add`
|
2019-09-19 00:18:36 +02:00
|
|
|
TableRefAdd,
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `table-ref-get`
|
2019-09-19 00:18:36 +02:00
|
|
|
TableRefGet,
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `call-method`
|
2019-09-19 00:18:36 +02:00
|
|
|
CallMethod(u64),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `make-record`
|
2019-09-19 00:18:36 +02:00
|
|
|
MakeRecord(InterfaceType),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `get-field`
|
2019-09-19 00:18:36 +02:00
|
|
|
GetField(InterfaceType, u64),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `const`
|
2019-09-19 00:18:36 +02:00
|
|
|
Const(InterfaceType, u64),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `fold-seq`
|
2019-09-19 00:18:36 +02:00
|
|
|
FoldSeq(u64),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `add`
|
2019-09-19 00:18:36 +02:00
|
|
|
Add(InterfaceType),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `mem-to-seq`
|
2019-09-19 00:18:36 +02:00
|
|
|
MemToSeq(InterfaceType, &'input str),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `load`
|
2019-09-19 00:18:36 +02:00
|
|
|
Load(InterfaceType, &'input str),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `seq.new`
|
2019-09-19 00:18:36 +02:00
|
|
|
SeqNew(InterfaceType),
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `list.push`
|
2019-09-19 00:18:36 +02:00
|
|
|
ListPush,
|
2020-02-12 15:59:41 +01:00
|
|
|
|
|
|
|
/// `repeat-until`
|
|
|
|
RepeatUntil(u64, u64),
|
2019-09-19 00:18:36 +02:00
|
|
|
}
|