mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
woopsie
This commit is contained in:
parent
1697a1d93f
commit
e19e468545
|
@ -62,11 +62,13 @@ impl Codegen {
|
||||||
"write" => { format!("write({}){}\n" , self.gen_ir(&args[0], false), semicolon!()) },
|
"write" => { format!("write({}){}\n" , self.gen_ir(&args[0], false), semicolon!()) },
|
||||||
"write_file" => { format!("writeFile({}, {}){}\n", self.gen_ir(&args[0], false), self.gen_ir(&args[1], false), semicolon!()) },
|
"write_file" => { format!("writeFile({}, {}){}\n", self.gen_ir(&args[0], false), self.gen_ir(&args[1], false), semicolon!()) },
|
||||||
"read" => { format!("read({}){}\n" , self.gen_ir(&args[0], false), semicolon!()) },
|
"read" => { format!("read({}){}\n" , self.gen_ir(&args[0], false), semicolon!()) },
|
||||||
"read_file" => { format!("readFile({}){}\n" , self.gen_ir(&args[0], false), semicolon!()) }
|
"read_file" => { format!("readFile({}){}\n" , self.gen_ir(&args[0], false), semicolon!()) },
|
||||||
"emit" => { format!("{}", self.gen_ir(&args[0], false).trim_start_matches('"').trim_end_matches('"')) },
|
"emit" => { format!("{}", self.gen_ir(&args[0], false).trim_start_matches('"').trim_end_matches('"')) },
|
||||||
|
|
||||||
"get" => { format!("{}[{}]", self.gen_ir(&args[0], false), self.gen_ir(&args[1], false)) },
|
"get" => { format!("{}[{}]", self.gen_ir(&args[0], false), self.gen_ir(&args[1], false)) },
|
||||||
"len" => { format!("{}.length", self.gen_ir(&args[0], false)) },
|
"len" => { format!("{}.length", self.gen_ir(&args[0], false)) },
|
||||||
|
|
||||||
|
"throw" => { format!("throw new Error({}){}", self.gen_ir(&args[0], false), semicolon!()) },
|
||||||
_ => unreachable!(format!("Unknown intrinsic: {}", name)) // Shoul be handled by lowering
|
_ => unreachable!(format!("Unknown intrinsic: {}", name)) // Shoul be handled by lowering
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use parser::Expr;
|
use parser::Expr;
|
||||||
|
|
||||||
const INTRINSICS: [&str; 7] = [
|
const INTRINSICS: [&str; 8] = [
|
||||||
"write",
|
"write",
|
||||||
"read",
|
"read",
|
||||||
"write_file",
|
"write_file",
|
||||||
|
@ -9,6 +9,7 @@ const INTRINSICS: [&str; 7] = [
|
||||||
"emit",
|
"emit",
|
||||||
"get",
|
"get",
|
||||||
"len",
|
"len",
|
||||||
|
"throw",
|
||||||
];
|
];
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
3
example/err/throw.hz
Normal file
3
example/err/throw.hz
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fun main: void = do
|
||||||
|
@throw("woopsie");
|
||||||
|
end;
|
Loading…
Reference in a new issue