From a888c09bd54de77fb2004754a0e14ce14a906232 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 23 Feb 2024 11:32:47 -0500 Subject: more changes --- matrix-bin/src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'matrix-bin/src/main.rs') diff --git a/matrix-bin/src/main.rs b/matrix-bin/src/main.rs index 72972c6..909ee77 100644 --- a/matrix-bin/src/main.rs +++ b/matrix-bin/src/main.rs @@ -1,6 +1,6 @@ use std::{path::PathBuf, io::{self, Read, IsTerminal}, fs}; use clap::Parser as ArgParser; -use matrix::{compiler::{Compiler, CompilerBuilder}, vm::Vm, parse::{Parser, ParserBuilder}}; +use matrix::{compiler::{Compiler, CompilerBuilder}, vm::Vm, parse::{Parser, ParserBuilder}, value::Value}; use repl::Repl; mod repl; @@ -50,24 +50,24 @@ impl<'a> State<'a> { let parser = ParserBuilder::new() .optimize(!args.disable_optimizations) .build(); - let vm = Vm::new(); + let mut vm = Vm::new(); let compiler = CompilerBuilder::new() .repl(repl) .debug(args.debug) .names(vm.names()) + .globals(vm.global_names()) .build(); + matrix_stdlib::load(&mut vm); + (Self { parser, vm, compiler, repl }, file) } - pub fn execute(&mut self, code: String) -> matrix::Result<()> { + pub fn execute(&mut self, code: String) -> matrix::Result { let ast = self.parser.parse(code)?; let fun = self.compiler.compile(&ast)?; let val = self.vm.run(fun)?; - if self.repl { - println!("{val}"); - } - Ok(()) + Ok(val) } } -- cgit v1.2.3-freya