diff options
Diffstat (limited to 'src/tokens/bytecode.rs')
-rw-r--r-- | src/tokens/bytecode.rs | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/tokens/bytecode.rs b/src/tokens/bytecode.rs deleted file mode 100644 index 9ac340e..0000000 --- a/src/tokens/bytecode.rs +++ /dev/null @@ -1,49 +0,0 @@ -use crate::*; - - -pub struct Bytecode { - pub words: Vec<Word>, - pub errors: Vec<BytecodeError>, -} - -#[derive(Clone, Copy)] -pub struct Word { - pub bits: usize, - pub value: usize, -} - -impl std::fmt::Display for Word { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - for i in (0..self.bits).rev() { - let is_first_bit = i+1 == self.bits; - if !is_first_bit && (i+1) % 4 == 0 { - write!(f, "_")?; - } - match (self.value >> i) & 1 { - 0 => write!(f, "0")?, - _ => write!(f, "1")?, - } - } - if self.bits == 0 { - write!(f, "0")?; - } - return Ok(()); - } -} - -pub struct BytecodeError { - pub source: SourceSpan, - pub variant: BytecodeErrorVariant, -} - -pub enum BytecodeErrorVariant { - DefinitionNotFound(String), - DuplicateLabelDefinition(String), - /// pin, real - PinnedAddressBacktrack(usize, usize), - /// expected, received - ValueTooLarge(usize, usize), - StackUnderflow, - MultipleReturnValues, - NoReturnValue, -} |