Remove Dynamic::NULL, use .as_deref_mut() for this_ptr.

This commit is contained in:
Stephen Chung
2022-12-20 16:52:55 +08:00
parent 99080be91d
commit babc0b5466
16 changed files with 235 additions and 255 deletions

View File

@@ -219,17 +219,11 @@ impl Engine {
let orig_lib_len = global.lib.len();
let mut orig_tag = None;
if let Some(value) = options.tag {
orig_tag = Some(mem::replace(&mut global.tag, value));
}
let orig_tag = options.tag.map(|v| mem::replace(&mut global.tag, v));
let mut this_ptr = options.this_ptr;
global.lib.push(ast.shared_lib().clone());
let mut no_this_ptr = Dynamic::NULL;
let this_ptr = options.this_ptr.unwrap_or(&mut no_this_ptr);
#[cfg(not(feature = "no_module"))]
let orig_embedded_module_resolver = std::mem::replace(
&mut global.embedded_module_resolver,
@@ -264,7 +258,7 @@ impl Engine {
global,
caches,
scope,
this_ptr,
this_ptr.as_deref_mut(),
None,
fn_def,
args,
@@ -279,7 +273,7 @@ impl Engine {
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let node = &crate::ast::Stmt::Noop(Position::NONE);
self.run_debugger(global, caches, scope, this_ptr, node)?;
self.run_debugger(global, caches, scope, this_ptr.as_deref_mut(), node)?;
}
#[cfg(not(feature = "no_module"))]

View File

@@ -250,9 +250,8 @@ impl Engine {
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let mut this_ptr = Dynamic::NULL;
let node = &crate::ast::Stmt::Noop(Position::NONE);
self.run_debugger(global, caches, scope, &mut this_ptr, node)?;
self.run_debugger(global, caches, scope, None, node)?;
}
Ok(r)
})

View File

@@ -131,9 +131,8 @@ impl Engine {
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let mut this_ptr = crate::Dynamic::NULL;
let node = &crate::ast::Stmt::Noop(crate::Position::NONE);
self.run_debugger(global, caches, scope, &mut this_ptr, node)?;
self.run_debugger(global, caches, scope, None, node)?;
}
Ok(())
})