-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline functions redo #95
Inline functions redo #95
Conversation
Initial commit
…builtins on the qbe backend
src/command/run.rs
Outdated
Target::Qbe => { | ||
let dir_path = "./"; // TODO: Use this for changind build directory | ||
let filename = in_file.file_stem().unwrap().to_str().unwrap(); | ||
let ssa_path = format!("{dir_path}{}.ssa", filename); | ||
let asm_path = format!("{dir_path}{}.s", filename); | ||
let exe_path = format!("{dir_path}{}.exe", filename); | ||
|
||
let mut ssa_file = OpenOptions::new() | ||
.read(true) | ||
.write(true) | ||
.create(true) | ||
.open(&ssa_path).unwrap(); | ||
let buff = *buf; | ||
ssa_file.write_all(&buff).unwrap(); | ||
|
||
|
||
// SSA to ASM | ||
Command::new("qbe") | ||
.arg(&ssa_path) | ||
.arg("-o") | ||
.arg(&asm_path) | ||
.spawn().unwrap(); | ||
|
||
// ASM to EXE | ||
Command::new("gcc") | ||
.arg(&asm_path) | ||
.arg("-o") | ||
.arg(&exe_path) | ||
.spawn().unwrap(); | ||
|
||
// Run the EXE | ||
Command::new(exe_path) | ||
.spawn().unwrap(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in a different PR as it's not a requirement for the shorthand returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't mind the addition here. Saves time and trouble. ✌️
I get an fn main() {
println(greet("World"))
}
fn greet(name: string) = "Hello " + name Could you add some tests to the I created a parser test that I used to debug the error: #[test]
fn test_parse_inline_function() {
let raw = "
fn main() = 1
";
let tokens = tokenize(raw).unwrap();
let tree = parse(tokens, Some(raw.to_string()), "".into());
assert!(tree.is_ok())
} I didn't have enough time to investigate this further though. Trying again later. |
bd5503e
to
c28422d
Compare
Okay, it seems like the error is an issue with how the |
I think this is ready to merge. Thanks @hexaredecimal for your work, I love this feature! |
I have followed your advice and implemented inline functions from the parser. I also added a function/method for creating hints. I had some time on my hands so I also decide to start working on the run command for qbe. I'm thinking of refactoring the code to a function to reduce the code size of the match expression.