Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make python methods public rust functions #18

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/clarirs_py/src/ast/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ impl Base {
#[pymethods]
impl Base {
#[getter]
fn name(&self) -> Option<&str> {
pub fn name(&self) -> Option<&str> {
self.name.as_deref()
}

#[getter]
fn _encoded_name(&self) -> Option<&[u8]> {
pub fn _encoded_name(&self) -> Option<&[u8]> {
self.encoded_name.as_deref()
}

#[getter]
fn _errored(&self) -> Py<PySet> {
pub fn _errored(&self) -> Py<PySet> {
self.errored.clone()
}
}
Expand Down
30 changes: 15 additions & 15 deletions crates/clarirs_py/src/ast/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ impl Bool {
#[pymethods]
impl Bool {
#[getter]
fn op(&self) -> String {
pub fn op(&self) -> String {
self.inner.op().to_opstring()
}

#[getter]
fn args(&self, py: Python) -> Result<Vec<PyObject>, ClaripyError> {
pub fn args(&self, py: Python) -> Result<Vec<PyObject>, ClaripyError> {
self.inner.op().extract_py_args(py)
}

#[getter]
fn variables(&self, py: Python) -> Result<Py<PyFrozenSet>, ClaripyError> {
pub fn variables(&self, py: Python) -> Result<Py<PyFrozenSet>, ClaripyError> {
Ok(PyFrozenSet::new_bound(
py,
self.inner
Expand All @@ -81,12 +81,12 @@ impl Bool {
}

#[getter]
fn symbolic(&self) -> bool {
pub fn symbolic(&self) -> bool {
self.inner.symbolic()
}

#[getter]
fn annotations(&self, py: Python) -> PyResult<Vec<PyObject>> {
pub fn annotations(&self, py: Python) -> PyResult<Vec<PyObject>> {
let pickle_loads = py.import_bound("pickle")?.getattr("loads")?;
self.inner
.get_annotations()
Expand All @@ -96,28 +96,28 @@ impl Bool {
.collect()
}

fn hash(&self) -> u64 {
pub fn hash(&self) -> u64 {
self.inner.hash()
}

#[getter]
fn depth(&self) -> u32 {
pub fn depth(&self) -> u32 {
self.inner.depth()
}

fn is_leaf(&self) -> bool {
pub fn is_leaf(&self) -> bool {
self.inner.depth() == 1
}

fn is_true(&self) -> bool {
pub fn is_true(&self) -> bool {
self.inner.is_true()
}

fn is_false(&self) -> bool {
pub fn is_false(&self) -> bool {
self.inner.is_false()
}

fn annotate(&self, py: Python, annotation: Bound<PyAny>) -> Result<Py<Bool>, ClaripyError> {
pub fn annotate(&self, py: Python, annotation: Bound<PyAny>) -> Result<Py<Bool>, ClaripyError> {
let pickle_dumps = py.import_bound("pickle")?.getattr("dumps")?;
let annotation_bytes = pickle_dumps
.call1((&annotation,))?
Expand All @@ -134,25 +134,25 @@ impl Bool {
)
}

fn __invert__(&self, py: Python) -> Result<Py<Bool>, ClaripyError> {
pub fn __invert__(&self, py: Python) -> Result<Py<Bool>, ClaripyError> {
Bool::new(py, &GLOBAL_CONTEXT.not(&self.inner)?)
}

fn __and__(&self, py: Python, other: CoerceBool) -> Result<Py<Bool>, ClaripyError> {
pub fn __and__(&self, py: Python, other: CoerceBool) -> Result<Py<Bool>, ClaripyError> {
Bool::new(
py,
&GLOBAL_CONTEXT.and(&self.inner, &<CoerceBool as Into<BoolAst>>::into(other))?,
)
}

fn __or__(&self, py: Python, other: CoerceBool) -> Result<Py<Bool>, ClaripyError> {
pub fn __or__(&self, py: Python, other: CoerceBool) -> Result<Py<Bool>, ClaripyError> {
Bool::new(
py,
&GLOBAL_CONTEXT.or(&self.inner, &<CoerceBool as Into<BoolAst>>::into(other))?,
)
}

fn __xor__(&self, py: Python, other: CoerceBool) -> Result<Py<Bool>, ClaripyError> {
pub fn __xor__(&self, py: Python, other: CoerceBool) -> Result<Py<Bool>, ClaripyError> {
Bool::new(
py,
&GLOBAL_CONTEXT.xor(&self.inner, &<CoerceBool as Into<BoolAst>>::into(other))?,
Expand Down
Loading
Loading