This commit is contained in:
Erin 2023-06-09 15:42:13 +02:00 committed by ondra05
parent 82160af7af
commit 642488cb64

View file

@ -92,8 +92,8 @@ macro_rules! expect_matches {
pub fn assembly(code: &str, buf: &mut Vec<u8>) -> Result<(), Error> { pub fn assembly(code: &str, buf: &mut Vec<u8>) -> Result<(), Error> {
struct Assembler<'a> { struct Assembler<'a> {
lexer: Lexer<'a, Token>, lexer: Lexer<'a, Token>,
buf: &'a mut Vec<u8>, buf: &'a mut Vec<u8>,
lblmap: HashMap<Spur, u64>, lblmap: HashMap<Spur, u64>,
subset: HashSet<usize>, subset: HashSet<usize>,
} }
@ -165,7 +165,7 @@ pub fn assembly(code: &str, buf: &mut Vec<u8>) -> Result<(), Error> {
let imm = match imm { let imm = match imm {
Token::Integer(n) => n.to_le_bytes(), Token::Integer(n) => n.to_le_bytes(),
Token::Symbol(s) => { Token::Symbol(s) => {
self.subset.insert(self.buf.len() - 1); self.subset.insert(self.buf.len());
s.into_usize().to_le_bytes() s.into_usize().to_le_bytes()
} }
_ => unreachable!(), _ => unreachable!(),
@ -188,8 +188,8 @@ pub fn assembly(code: &str, buf: &mut Vec<u8>) -> Result<(), Error> {
let imm = match imm { let imm = match imm {
Token::Integer(n) => n.to_le_bytes(), Token::Integer(n) => n.to_le_bytes(),
Token::Symbol(s) => { Token::Symbol(s) => {
self.subset.insert(self.buf.len() - 1); self.subset.insert(self.buf.len());
(s.into_inner().get() as usize).to_le_bytes() s.into_usize().to_le_bytes()
} }
_ => unreachable!(), _ => unreachable!(),
}; };