Skip to content

Commit

Permalink
check locals borrows
Browse files Browse the repository at this point in the history
  • Loading branch information
dragazo committed Nov 14, 2023
1 parent f5e9c3e commit 629e395
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "netsblox-vm"
version = "0.2.19"
version = "0.2.20"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = ["Devin Jean <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<'gc, C: CustomTypes<S>, S: System<C>> Process<'gc, C, S> {
///
/// The process transitions to the idle state (see [`Process::is_running`]) upon failing with [`Err`] or succeeding with [`ProcessStep::Terminate`].
///
/// This function is not re-entrant, so calling it from the mutable handle of, e.g., [`Config`] will likely lead to panics.
/// This function is not re-entrant, so recursively calling it from the mutable handle of, e.g., [`Config`] will likely lead to panics.
pub fn step(&mut self, mc: &Mutation<'gc>) -> Result<ProcessStep<'gc, C, S>, ExecError<C, S>> {
if !self.is_running() {
return Ok(ProcessStep::Idle);
Expand Down
9 changes: 5 additions & 4 deletions src/std_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ impl<C: CustomTypes<StdSystem<C>>> StdSystem<C> {

#[cfg(debug_assertions)]
fn check_runtime_borrows<'gc>(mc: &Mutation<'gc>, proc: &mut Process<'gc, C, Self>) {
fn check_symbols<'gc, C: CustomTypes<StdSystem<C>>>(mc: &Mutation<'gc>, symbols: &mut SymbolTable<'gc, C, StdSystem<C>>) {
fn check_symbols<'gc, C: CustomTypes<StdSystem<C>>>(mc: &Mutation<'gc>, symbols: &SymbolTable<'gc, C, StdSystem<C>>) {
for symbol in symbols {
match &*symbol.1.get() {
Value::Bool(_) | Value::Number(_) | Value::String(_) | Value::Audio(_) | Value::Image(_) | Value::Native(_) => (),
Expand All @@ -416,15 +416,16 @@ impl<C: CustomTypes<StdSystem<C>>> StdSystem<C> {
}
}
fn check_entity<'gc, C: CustomTypes<StdSystem<C>>>(mc: &Mutation<'gc>, entity: &mut Entity<'gc, C, StdSystem<C>>) {
check_symbols(mc, &mut entity.fields);
check_symbols(mc, &entity.fields);
if let Some(original) = entity.original {
check_entity(mc, &mut *original.borrow_mut(mc));
}
}

let mut global_context = proc.global_context.borrow_mut(mc);
check_symbols(mc, &mut global_context.globals);
let global_context = proc.global_context.borrow_mut(mc);
check_symbols(mc, &global_context.globals);
for entry in proc.get_call_stack() {
check_symbols(mc, &entry.locals);
check_entity(mc, &mut entry.entity.borrow_mut(mc));
}
for entity in global_context.entities.iter() {
Expand Down

0 comments on commit 629e395

Please sign in to comment.