pub enum IrError {
Show 17 variants
UnsupportedSchemaVersion {
found: u32,
expected: u32,
},
UnknownValue {
instr: u32,
value: u32,
},
UnknownBlock {
instr: u32,
block: u32,
},
MissingTerminator {
block: u32,
expected: &'static str,
},
MisplacedTerminator {
block: u32,
instr: u32,
},
WrongTier {
instr: u32,
kind: &'static str,
},
OperandShape {
instr: u32,
detail: &'static str,
},
DuplicateInstrId {
id: u32,
},
DuplicateBlockId {
id: u32,
},
NonFiniteFloat {
instr: u32,
},
RepeatsOutOfRange {
count: u64,
},
PathIndexOutOfRange {
instr: u32,
index: u64,
},
MultipleUses {
instr: u32,
value: u32,
},
BlockObservedTwice {
block: u32,
},
ExpectedLoad {
instr: u32,
lhs: u32,
},
NegatedExists {
instr: u32,
},
WrongBlockKind {
block: u32,
expected: &'static str,
},
}Expand description
A way a Program can be malformed.
Variants§
UnsupportedSchemaVersion
The program’s schema_version is not one this build understands.
UnknownValue
An instruction referenced a value that is not defined earlier in its block.
UnknownBlock
Observe targeted a missing block, or one that is not a comparison block.
MissingTerminator
A block does not end in the terminator its kind requires.
Fields
MisplacedTerminator
A terminator appeared somewhere other than the end of its block.
WrongTier
An op appeared in a block of the wrong kind.
OperandShape
A Compare’s operand shape does not match its operator.
DuplicateInstrId
Two instructions share an id.
DuplicateBlockId
Two blocks share an id.
NonFiniteFloat
A float that STIX pattern syntax cannot express.
The patterning language has no notation for NaN or infinity, so such a
value could never be rendered back to text.
RepeatsOutOfRange
A Repeats count is larger than the pattern lexer can read back.
The lexer reads integer literals as i64, so REPEATS <n> TIMES parses
only for n <= i64::MAX. A larger count would render to text that does
not parse. Zero is accepted by the grammar and so is accepted here.
PathIndexOutOfRange
A Load path has a list index larger than the pattern lexer can read back.
The lexer reads integer literals as i64, so [n] in a path parses only
for n <= i64::MAX. A larger index would render to text that does not parse.
MultipleUses
One value is consumed by more than one operand.
Pattern text has no way to name a shared value, so a shared
subexpression would have to be re-rendered once per use — making output
exponential in the number of instructions. Requiring each value to have
at most one consumer keeps every value expression a tree, which is what
render already assumes.
This covers values only. A comparison block is not a value; its reuse
is bounded separately, by IrError::BlockObservedTwice.
BlockObservedTwice
A comparison block is the target of more than one Observe.
Observe names a block rather than a value, so the single-use rule does
not cover it. Pattern text cannot name a shared block either: each
Observe is rendered as its own copy of the block, so sharing one block
among k observes makes output grow with k times the block’s size —
quadratic in the program. Requiring each block to be observed at most
once keeps rendered size linear. lower already
allocates one block per observation.
ExpectedLoad
A Compare’s left-hand side is not a Load.
The renderer takes the compared object path from the Load it names; any
other instruction leaves the path missing from the rendered text.
NegatedExists
An EXISTS comparison is marked negated.
The grammar has no negated form of EXISTS, so the negation could not be
rendered and would be silently dropped.
WrongBlockKind
A block has the wrong BlockKind for its position.
Trait Implementations§
impl Eq for IrError
Source§impl Error for IrError
impl Error for IrError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()