Skip to content

Commit

Permalink
fb_console: remember to resolve bindings in Ginkgo AST
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacWoods committed Sep 2, 2024
1 parent 7d86cce commit d78bbb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions ginkgo/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ impl<'a> Interpreter<'a> {
}
}

#[derive(Debug)]
pub struct Environment {
parent: Option<Arc<RefCell<Environment>>>,
bindings: BTreeMap<String, Value>,
Expand Down
8 changes: 7 additions & 1 deletion user/fb_console/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use gfxconsole::{Format, Framebuffer, GfxConsole, Pixel, Rgb32};
use ginkgo::{
ast::BindingResolver,
interpreter::{Interpreter, Value},
parse::Parser,
};
Expand Down Expand Up @@ -66,6 +67,7 @@ fn spawn_framebuffer(
let (output_sender, output_receiver) = thingbuf::mpsc::channel(16);

let mut interpreter = Interpreter::new();
let mut resolver = BindingResolver::new();
let mut current_line = String::new();

interpreter.define_native_function("print", |params| {
Expand Down Expand Up @@ -95,9 +97,13 @@ fn spawn_framebuffer(
needs_redraw = true;

if key == '\n' {
let stmts = Parser::new(&current_line).parse().unwrap();
let mut stmts = Parser::new(&current_line).parse().unwrap();
current_line.clear();

for mut statement in &mut stmts {
resolver.resolve_bindings(&mut statement);
}

let mut result = None;
for statement in stmts {
if let Some(value) = interpreter.eval_stmt(statement) {
Expand Down

0 comments on commit d78bbb1

Please sign in to comment.