Skip to content

Commit

Permalink
interpreter: Convert returned instance into exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Oct 16, 2023
1 parent d9f5e75 commit f6fd839
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions interpreter/jinko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod repl;

use colored::Colorize;

use fire::instance::Instance;
use fire::Interpret;
use flatten::{FlattenAst, FlattenData};
use include_code::IncludeCode;
Expand All @@ -22,6 +23,7 @@ use jinko::value::{JkBool, JkFloat, JkInt};
use args::Args;
#[cfg(feature = "repl")]
use repl::Repl;
use std::process;
use std::{fs, path::Path};
use symbol::Symbol;
use typecheck::TypeCheck;
Expand Down Expand Up @@ -148,9 +150,14 @@ fn experimental_pipeline(input: &str, file: &Path) -> InteractResult {
let fir = x_try!(fir.type_check());
let result = fir.interpret();

dbg!(result);
let exit_code = match result {
// convert `true` to `0` and `false` to `1`
Some(Instance::Bool(b)) => !b as i32,
Some(Instance::Int(inner)) => inner as i32,
_ => 0,
};

todo!("unfinished experimental pipeline: use result as exit code and display it")
process::exit(exit_code);
}

fn handle_input(args: &Args, file: &Path) -> InteractResult {
Expand Down

0 comments on commit f6fd839

Please sign in to comment.