Use fluent style.

This commit is contained in:
Stephen Chung
2022-12-09 10:04:44 +08:00
parent a391f26920
commit 3d5908480a
6 changed files with 92 additions and 101 deletions

View File

@@ -126,24 +126,17 @@ impl Engine {
global.embedded_module_resolver = ast.resolver().cloned();
}
let statements = ast.statements();
let result = if !statements.is_empty() {
self.eval_global_statements(global, caches, scope, statements)
.map(|_| ())
} else {
Ok(())
};
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let mut this = crate::Dynamic::NULL;
let node = &crate::ast::Stmt::Noop(crate::Position::NONE);
self.run_debugger(global, caches, scope, &mut this, node)?;
}
result
self.eval_global_statements(global, caches, scope, ast.statements())
.and_then(|_| {
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let mut this = crate::Dynamic::NULL;
let node = &crate::ast::Stmt::Noop(crate::Position::NONE);
self.run_debugger(global, caches, scope, &mut this, node)?;
}
Ok(())
})
}
}