Skip to content

Commit

Permalink
some doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebenfield committed Nov 14, 2024
1 parent 0cbdf63 commit db26db5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ use leo_errors::{CompilerError, InterpreterHalt, LeoError, Result, emitter::Hand
mod cursor;
use cursor::*;

/// Contains the state of interpretation, in the form of the `Cursor`,
/// as well as information needed to interact with the user, like
/// the breakpoints.
pub struct Interpreter {
cursor: Cursor<'static>,
cursor_initial: Cursor<'static>,
Expand All @@ -54,15 +57,15 @@ pub struct Breakpoint {
pub enum InterpreterAction {
LeoInterpretInto(String),
LeoInterpretOver(String),
Breakpoint(Breakpoint),
Into,
Over,
Step,
Breakpoint(Breakpoint),
Run,
}

impl Interpreter {
pub fn new<'a, P: 'a + AsRef<Path>>(source_files: impl IntoIterator<Item = &'a P>) -> Result<Self> {
fn new<'a, P: 'a + AsRef<Path>>(source_files: impl IntoIterator<Item = &'a P>) -> Result<Self> {
Self::new_impl(&mut source_files.into_iter().map(|p| p.as_ref()))
}

Expand Down Expand Up @@ -186,7 +189,7 @@ impl Interpreter {
Ok(ret.value)
}

pub fn view_current(&self) -> Option<impl Display> {
fn view_current(&self) -> Option<impl Display> {
if let Some(span) = self.current_span() {
if span != Default::default() {
return with_session_globals(|s| s.source_map.contents_of_span(span));
Expand All @@ -200,7 +203,7 @@ impl Interpreter {
})
}

pub fn view_current_in_context(&self) -> Option<impl Display> {
fn view_current_in_context(&self) -> Option<impl Display> {
let span = self.current_span()?;
if span == Default::default() {
return None;
Expand Down Expand Up @@ -273,6 +276,8 @@ fn parse_breakpoint(s: &str) -> Option<Breakpoint> {
None
}

/// Loading all the Leo source files indicated and open the interpreter
/// to commands from the user.
pub fn interpret(filenames: &[PathBuf]) -> Result<()> {
let mut interpreter = Interpreter::new(filenames.iter())?;
let mut buffer = String::new();
Expand Down

0 comments on commit db26db5

Please sign in to comment.