Ship v0.1.0: dedicated debug host, view outline, code-as-docs README.
Add marqdo debug (breakpoints/step/locals), restore view as docs with function search, and emphasize OKF-aligned knowledge-base direction. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ea17ae1074
commit
54a507d906
16 files changed
+2136
-85
No files matched your search
+27
-1
@@ -11,11 +11,12 @@ use crate::builtin::{
|
||||
builtin_at, builtin_int, builtin_join, builtin_len, builtin_split, builtin_str, builtin_trim,
|
||||
builtin_type,
|
||||
};
|
||||
use crate::debug::emit_trace;
|
||||
use crate::debug::{emit_trace, DebugController};
|
||||
use crate::diagnostics::{bail_at, Span};
|
||||
use crate::host::{call_host, HostContext, HostFn};
|
||||
use crate::input_feed::InputFeed;
|
||||
use crate::value::Value;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct Interpreter {
|
||||
pub path: Option<PathBuf>,
|
||||
@@ -25,6 +26,7 @@ pub struct Interpreter {
|
||||
current_span: Span,
|
||||
input: InputFeed,
|
||||
host: HostContext,
|
||||
debug: Option<Arc<DebugController>>,
|
||||
}
|
||||
|
||||
struct Env {
|
||||
@@ -62,6 +64,7 @@ impl Interpreter {
|
||||
current_span: Span::new(1, 1),
|
||||
input: InputFeed::new(false, Vec::new()),
|
||||
host: HostContext::for_run(path, Default::default(), Vec::new()),
|
||||
debug: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +77,7 @@ impl Interpreter {
|
||||
current_span: Span::new(1, 1),
|
||||
input: InputFeed::new(true, Vec::new()),
|
||||
host: HostContext::for_capture(path, Default::default()),
|
||||
debug: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +91,11 @@ impl Interpreter {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_debug(mut self, debug: Arc<DebugController>) -> Self {
|
||||
self.debug = Some(debug);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn take_plots(&mut self) -> Vec<crate::host::PlotArtifact> {
|
||||
std::mem::take(&mut self.host.plots)
|
||||
}
|
||||
@@ -184,6 +193,12 @@ impl Interpreter {
|
||||
env: &mut Env,
|
||||
stmt: &Stmt,
|
||||
) -> Result<Option<Value>> {
|
||||
let span = stmt_span(stmt);
|
||||
self.current_span = span;
|
||||
if let Some(dbg) = &self.debug {
|
||||
dbg.on_stmt(span.line, &fun.name, &env.vars, &self.captured_stdout)
|
||||
.map_err(|m| self.err(m))?;
|
||||
}
|
||||
match stmt {
|
||||
Stmt::Assign { name, value, span, .. } => {
|
||||
self.current_span = *span;
|
||||
@@ -697,3 +712,14 @@ fn cmp_ord(l: &Value, r: &Value, f: impl Fn(std::cmp::Ordering) -> bool) -> Resu
|
||||
_ => bail!("comparison needs two ints/nums or two texts"),
|
||||
}
|
||||
}
|
||||
|
||||
fn stmt_span(stmt: &Stmt) -> Span {
|
||||
match stmt {
|
||||
Stmt::Assign { span, .. }
|
||||
| Stmt::Return { span, .. }
|
||||
| Stmt::Call { span, .. }
|
||||
| Stmt::Branch { span, .. }
|
||||
| Stmt::While { span, .. }
|
||||
| Stmt::ForEach { span, .. } => *span,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user