View Source Orb.InstructionSequence (Orb v0.0.37)

Summary

Functions

Concatenates instructions in the second with those in first.

Creates a sequence of instructions from a list.

Functions

Concatenates instructions in the second with those in first.

Examples

iex> Orb.InstructionSequence.concat(Orb.InstructionSequence.empty(), Orb.InstructionSequence.empty())
Orb.InstructionSequence.empty()

iex> Orb.InstructionSequence.concat(nil, nil)
Orb.InstructionSequence.empty()

iex> Orb.InstructionSequence.concat(Orb.InstructionSequence.new([Orb.Instruction.i32(:const, 1)]), Orb.InstructionSequence.new([Orb.Instruction.f32(:const, 2.0)]))
%Orb.InstructionSequence{push_type: {:i32, :f32}, body: [
  Orb.Instruction.i32(:const, 1),
  Orb.Instruction.f32(:const, 2.0)
]}

iex> Orb.InstructionSequence.concat(Orb.InstructionSequence.new([Orb.Instruction.i32(:const, 1)]), nil)
%Orb.InstructionSequence{push_type: :i32, body: [
  Orb.Instruction.i32(:const, 1)
]}

Creates a sequence of instructions from a list.

Examples

iex> Orb.InstructionSequence.new([Orb.InstructionSequence.empty()])
Orb.InstructionSequence.empty()

iex> Orb.InstructionSequence.new([Orb.Instruction.i32(:const, 1)])
%Orb.InstructionSequence{push_type: :i32, body: [
  Orb.Instruction.i32(:const, 1)
]}

iex> Orb.InstructionSequence.new([%Orb.Nop{}])
%Orb.InstructionSequence{push_type: nil, body: [
  %Orb.Nop{}
]}

iex> Orb.InstructionSequence.new([Orb.Instruction.i32(:const, 1), Orb.Instruction.f32(:const, 2.0)])
%Orb.InstructionSequence{push_type: {:i32, :f32}, body: [
  Orb.Instruction.i32(:const, 1),
  Orb.Instruction.f32(:const, 2.0),
]}

iex> Orb.InstructionSequence.new([Orb.Control.Return.new(Orb.Instruction.i32(:const, 1))])
%Orb.InstructionSequence{push_type: nil, body: [
  Orb.Control.Return.new(Orb.Instruction.i32(:const, 1))
]}
Link to this function

new(push_type, instructions, opts \\ [])

View Source