Skip to content

Commit 8348a7a

Browse files
committed
fmt
1 parent f4c79b5 commit 8348a7a

File tree

8 files changed

+19
-17
lines changed

8 files changed

+19
-17
lines changed

jingle/src/error.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use jingle_sleigh::{JingleSleighError, PcodeOperation};
12
#[cfg(feature = "pyo3")]
23
use pyo3::exceptions::PyRuntimeError;
34
#[cfg(feature = "pyo3")]
45
use pyo3::PyErr;
5-
use jingle_sleigh::{JingleSleighError, PcodeOperation};
66
use thiserror::Error;
77

88
#[derive(Debug, Error)]
@@ -23,11 +23,14 @@ pub enum JingleError {
2323
ZeroSizedVarnode,
2424
#[error("Cannot write values into constant space.")]
2525
ConstantWrite,
26-
#[error("Attempt to read an indirect value from the constant space. While this can be modeled, it's almost definitely unintended.")]
26+
#[error("Attempt to read an indirect value from the constant space. While this can be modeled, \
27+
it's almost definitely unintended.")]
2728
IndirectConstantRead,
28-
#[error("Attempted to perform a write of a bitvector to a VarNode with leftover space. This is a sleigh bug.")]
29+
#[error("Attempted to perform a write of a bitvector to a VarNode with leftover space. This is \
30+
a sleigh bug.")]
2931
MismatchedWordSize,
30-
#[error("Attempted to perform a write to a space using the wrong size of address. This is a sleigh bug.")]
32+
#[error("Attempted to perform a write to a space using the wrong size of address. This is a \
33+
sleigh bug.")]
3134
MismatchedAddressSize,
3235
#[error("Jingle does not yet model this instruction")]
3336
UnmodeledInstruction(Box<PcodeOperation>),

jingle_python/script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
j = sleigh.make_jingle_context()
55
state = State(j)
66

7-
print(state.register("RAX") == state.ram(0x8000_0000, 8))
7+
print(state.ram(0,30))

jingle_python/src/bitvec.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
use pyo3::{Bound, IntoPyObject, PyAny, PyObject, PyResult, Python, ToPyObject};
21
use pyo3::prelude::PyAnyMethods;
32
use pyo3::types::PyModule;
3+
use pyo3::{Bound, IntoPyObject, PyAny, PyObject, PyResult, Python, ToPyObject};
44
use z3::ast::{Ast, BV};
55

6-
76
pub fn adapt_bv<'a>(bv: BV) -> PyResult<PyObject> {
87
Python::with_gil(|py| {
98
let z3_mod = PyModule::import(py, "z3")?;
109
let ref_class = z3_mod.getattr("BitVecRef")?.into_pyobject(py)?;
1110
let ast_class = z3_mod.getattr("Ast")?.into_pyobject(py)?;
1211
let ctypes = PyModule::import(py, "ctypes")?;
1312
let ptr_type = ctypes.getattr("c_void_p")?;
14-
let args = ( bv.get_z3_ast() as usize);
13+
let args = (bv.get_z3_ast() as usize);
1514
let ptr = ptr_type.call1((args,))?;
1615

1716
let ast_obj = ast_class.call1((args,))?.to_object(py);
18-
let a = ref_class.call1( (ptr,))?.to_object(py);
17+
let a = ref_class.call1((ptr,))?.to_object(py);
1918
Ok(a)
2019
})
21-
}
20+
}

jingle_python/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
mod bitvec;
12
mod instruction;
23
mod jingle_context;
34
mod sleigh_context;
45
mod state;
5-
mod bitvec;
66

77
use crate::instruction::PythonInstruction;
88
use crate::sleigh_context::LoadedSleighContextWrapper;
9+
use crate::state::PythonState;
910
use ::jingle::sleigh::{IndirectVarNode, PcodeOperation, VarNode};
1011
use pyo3::prelude::*;
1112
use sleigh_context::create_sleigh_context;
@@ -14,7 +15,6 @@ use std::ffi::CString;
1415
use std::mem;
1516
use z3::Context;
1617
use z3_sys::Z3_context;
17-
use crate::state::PythonState;
1818

1919
thread_local! {
2020
pub static CONTEXT: RefCell<Z3_context> = RefCell::new(std::ptr::null_mut());
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

jingle_sleigh/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[cfg(feature = "pyo3")]
2-
use pyo3::exceptions::{PyRuntimeError};
2+
use pyo3::exceptions::PyRuntimeError;
33
#[cfg(feature = "pyo3")]
44
use pyo3::PyErr;
55
use thiserror::Error;
@@ -46,7 +46,7 @@ impl From<JingleSleighError> for std::fmt::Error {
4646
}
4747
}
4848

49-
#[cfg(feature="pyo3")]
49+
#[cfg(feature = "pyo3")]
5050
impl From<JingleSleighError> for PyErr {
5151
fn from(value: JingleSleighError) -> Self {
5252
PyRuntimeError::new_err(value.to_string())

jingle_sleigh/src/instruction.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::{ArchInfoProvider, OpCode};
88
use serde::{Deserialize, Serialize};
99
use std::fmt::{Display, Formatter};
1010

11-
1211
/// A rust representation of a SLEIGH assembly instruction
1312
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
1413
pub struct Instruction {

jingle_sleigh/src/pcode/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ pub use crate::ffi::opcode::OpCode;
1919
use crate::pcode::display::PcodeOperationDisplay;
2020
use crate::varnode::{IndirectVarNode, VarNode};
2121
use crate::{ArchInfoProvider, GeneralizedVarNode};
22-
use serde::{Deserialize, Serialize};
23-
use std::fmt::Debug;
2422
#[cfg(feature = "pyo3")]
2523
use pyo3::pyclass;
24+
use serde::{Deserialize, Serialize};
25+
use std::fmt::Debug;
2626

2727
#[cfg_attr(feature = "pyo3", pyclass)]
2828
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]

0 commit comments

Comments
 (0)