1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Error during [unify](super::unify).
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum LunifyError {
/// The specified instruction layout is not valid. This can happen when size
/// limitations are not respected, when operand types are specified more
/// than once, or when the B and C operands are not adjacent.
InvalidInstructionLayout,
/// The provided byte code does not start with the signature `\[27]Lua`.
IncorrectSignature,
/// The version of Lua that the byte code was compiled for is not supported
/// by Lunify.
UnsupportedVersion(u8),
/// The specified format does not specify a valid endianness.
InvaildEndianness(u8),
/// The instruction memory layout is not supported by Lunify. This error can
/// only occur in Lua 5.0.
UnsupportedInstructionFormat([u8; 4]),
/// The pointer width of the system that the byte code was compiled for is
/// not supported by Lunify.
UnsupportedSizeTWidth(u8),
/// The integer width of the system that the byte code was compiled for is
/// not supported by Lunify.
UnsupportedIntegerWidth(u8),
/// The instruction width of the system that the byte code was compiled for
/// is not supported by Lunify.
UnsupportedInstructionWidth(u8),
/// The number width of the system that the byte code was compiled for
/// is not supported by Lunify.
UnsupportedNumberWidth(u8),
/// The byte code contains an instruction that is not recognized by Lunify.
InvalidOpcode(u64),
/// The byte code contains a constant with a type that is not recognized by
/// Lunify.
InvalidConstantType(u8),
/// The byte code contains a number with a non-integral value that can't be
/// represented when `is_number_integral` is set to true.
FloatPrecisionLoss,
/// The byte code contains an integral value that is too big to be
/// represented when `is_number_integral` is set to false.
IntegerOverflow,
/// The byte code is truncated.
InputTooShort,
/// The byte code has access padding.
InputTooLong,
/// The byte code generated by converting is using stack values that are
/// bigger than Lua 5.1 `MAXSTACK`.
StackTooLarge(u64),
/// The byte code generated by converting to Lua 5.1 needs to store a value
/// in an operand that exceed the maximum possible value.
ValueTooBigForOperand,
/// The Lua 5.0 `FORLOOP` instruction specified a positive jump, even though
/// we expect it to always be negative.
UnexpectedForwardJump,
}