Starting to add code for vm
This commit is contained in:
parent
6f8c89af37
commit
801896bcc6
24
src/main.rs
24
src/main.rs
@ -20,6 +20,9 @@ use language::{ProgrammingLanguage, LanguageInterface, LLVMCodeString, Evaluatio
|
|||||||
|
|
||||||
mod llvm_wrap;
|
mod llvm_wrap;
|
||||||
|
|
||||||
|
mod virtual_machine;
|
||||||
|
use virtual_machine::{run_vm, run_assembler};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let languages: Vec<Box<LanguageInterface>> =
|
let languages: Vec<Box<LanguageInterface>> =
|
||||||
vec![
|
vec![
|
||||||
@ -44,7 +47,19 @@ fn main() {
|
|||||||
|
|
||||||
if option_matches.opt_present("h") {
|
if option_matches.opt_present("h") {
|
||||||
println!("{}", program_options().usage("Schala metainterpreter"));
|
println!("{}", program_options().usage("Schala metainterpreter"));
|
||||||
std::process::exit(1);
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if option_matches.opt_present("m") {
|
||||||
|
let file_name = option_matches.free.get(1);
|
||||||
|
run_vm(file_name);
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if option_matches.opt_present("a") {
|
||||||
|
let file_name = option_matches.free.get(1);
|
||||||
|
run_assembler(file_name);
|
||||||
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let language_names: Vec<String> = languages.iter().map(|lang| {lang.get_language_name()}).collect();
|
let language_names: Vec<String> = languages.iter().map(|lang| {lang.get_language_name()}).collect();
|
||||||
@ -91,9 +106,16 @@ fn program_options() -> getopts::Options {
|
|||||||
options.optflag("h",
|
options.optflag("h",
|
||||||
"help",
|
"help",
|
||||||
"Show help text");
|
"Show help text");
|
||||||
|
options.optflag("m",
|
||||||
|
"virtual-machine",
|
||||||
|
"Start up a virtual machine instead of an interpreter");
|
||||||
|
options.optflag("a",
|
||||||
|
"assembler",
|
||||||
|
"Assemble file into bytecode");
|
||||||
options
|
options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn run_noninteractive<'a, T: ProgrammingLanguage>(filename: &str, _language: &T, trace_evaluation: bool, compile: bool) {
|
fn run_noninteractive<'a, T: ProgrammingLanguage>(filename: &str, _language: &T, trace_evaluation: bool, compile: bool) {
|
||||||
let mut source_file = File::open(&Path::new(filename)).unwrap();
|
let mut source_file = File::open(&Path::new(filename)).unwrap();
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
|
9
src/virtual_machine/mod.rs
Normal file
9
src/virtual_machine/mod.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pub fn run_vm(file_name: Option<&String>) {
|
||||||
|
println!("Running in VM mode");
|
||||||
|
println!("yy: {:?}", file_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_assembler(file_name: Option<&String>) {
|
||||||
|
println!("Assembling file");
|
||||||
|
println!("yy: {:?}", file_name);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user