Skip to content

Commit

Permalink
lib: fix code segment encoding in assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Apr 13, 2024
1 parent 4729208 commit a08387f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/isa/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum BytecodeError {
Write(WriteError),

/// put operation does not contain number (when it was deserialized, the data segment was
/// shorter then the number value offset to read)
/// shorter than the number value offset to read)
PutNoNumber,
}

Expand Down
5 changes: 4 additions & 1 deletion src/library/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use strict_encoding::{StrictDeserialize, StrictSerialize};

#[cfg(feature = "ascii-armor")]
pub use self::_armor::LibArmorError;
use super::{Cursor, Read};
use super::{Cursor, Read, WriteError};
use crate::data::ByteStr;
use crate::isa::{Bytecode, BytecodeError, ExecStep, Instr, InstructionSet};
use crate::library::segs::IsaSeg;
Expand Down Expand Up @@ -238,6 +238,7 @@ mod _armor {
pub enum AssemblerError {
/// Error assembling code and data segments
#[from]
#[from(WriteError)]
Bytecode(BytecodeError),

/// Error assembling library segment
Expand Down Expand Up @@ -287,7 +288,9 @@ impl Lib {
for instr in code.iter() {
instr.encode(&mut writer)?;
}
let pos = writer.pos();
let data_segment = SmallBlob::from_collection_unsafe(writer.into_data_segment().to_vec());
code_segment.adjust_len(pos);
let code_segment = SmallBlob::from_collection_unsafe(code_segment.to_vec());

Ok(Lib { isae: Isa::isa_ids(), libs: libs_segment, code: code_segment, data: data_segment })
Expand Down

0 comments on commit a08387f

Please sign in to comment.