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

Refactor engine structure #273

Merged
merged 27 commits into from
Oct 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
add filtering to the readable globals function
mattwparas committed Oct 23, 2024

Verified

This commit was signed with the committer’s verified signature.
commit 4d55fcceedffdbcc7e6aa54a3430ad7eca086ca5
68 changes: 10 additions & 58 deletions crates/steel-core/src/steel_vm/engine.rs
Original file line number Diff line number Diff line change
@@ -1503,6 +1503,8 @@ impl Engine {

// TODO: Remove duplicates!
pub fn readable_globals(&self, after_offset: usize) -> Vec<InternedString> {
let mut seen = HashSet::new();

self.virtual_machine
.compiler
.read()
@@ -1519,68 +1521,18 @@ impl Engine {
&& !resolved.starts_with("__module")
&& !resolved.ends_with("__doc__")
})
.filter_map(|x| {
if seen.contains(x) {
None
} else {
seen.insert(x);
Some(x)
}
})
.copied()
.collect()
}

// pub fn get_exported_module_functions(&self, path: PathBuf) -> impl Iterator<Item = InternedString> {

// }

// Attempts to disassemble the given expression into a series of bytecode dumps
// pub fn disassemble(&mut self, expr: &str) -> Result<String> {
// let constants = self.constants();
// self.compiler
// .emit_debug_instructions(expr, constants)
// .map(|x| {
// x.into_iter()
// .map(|i| crate::core::instructions::disassemble(&i))
// .join("\n\n")
// })
// }

// pub fn execute_without_callbacks(
// &mut self,
// bytecode: Rc<[DenseInstruction]>,
// constant_map: &ConstantMap,
// ) -> Result<SteelVal> {
// self.virtual_machine
// .execute::<DoNotUseCallback>(bytecode, constant_map, &[])
// }

/// Execute bytecode with a constant map directly.
// pub fn execute(
// &mut self,
// bytecode: Rc<[DenseInstruction]>,
// constant_map: ConstantMap,
// ) -> Result<SteelVal> {
// self.virtual_machine
// .execute(bytecode, constant_map, Rc::from([]))
// }

/// Emit the bytecode directly, with a path provided.
// pub fn emit_instructions_with_path(
// &mut self,
// exprs: &str,
// path: PathBuf,
// ) -> Result<Vec<Vec<DenseInstruction>>> {
// let constants = self.constants();
// self.compiler
// .emit_instructions(exprs, Some(path), constants)
// }

// /// Emit instructions directly, without a path for error messaging.
// pub fn emit_instructions(&mut self, exprs: &str) -> Result<Vec<Vec<DenseInstruction>>> {
// let constants = self.constants();
// self.compiler.emit_instructions(exprs, None, constants)
// }

/// Execute a program directly, returns a vector of `SteelVal`s corresponding to each expr in the `Program`.
// pub fn execute_program(&mut self, program: Program) -> Result<Vec<SteelVal>> {
// self.virtual_machine
// .execute_program::<UseCallback, ApplyContract>(program)
// }

// Generate dynamically linked files, containing all of the necessary information
// This means - compiling all macros as well.
fn load_raw_program(&mut self, mut program: RawProgramWithSymbols) {
Loading