forked from M-Labs/nac3
1
0
Fork 0

nac3artiq: return bytes in compile_method_to_mem

This commit is contained in:
Sebastien Bourdeauducq 2021-11-06 14:29:23 +08:00
parent 37eae090e5
commit 016cbf2b90
1 changed files with 3 additions and 3 deletions

View File

@ -9,7 +9,7 @@ use inkwell::{
OptimizationLevel,
};
use pyo3::prelude::*;
use pyo3::{exceptions, types::PyList};
use pyo3::{exceptions, types::PyList, types::PyBytes};
use nac3parser::{
ast::{self, StrRef},
parser::{self, parse_program},
@ -495,11 +495,11 @@ impl Nac3 {
method_name: &str,
args: Vec<&PyAny>,
py: Python,
) -> PyResult<Vec<u8>> {
) -> PyResult<PyObject> {
let filename_path = self.working_directory.path().join("module.elf");
let filename = filename_path.to_str().unwrap();
self.compile_method_to_file(obj, method_name, args, filename, py)?;
Ok(fs::read(filename).unwrap())
Ok(PyBytes::new(py, &fs::read(filename).unwrap()).into())
}
}