diff --git a/libtest.sh b/libtest.sh index c5bf6c8..925df65 100755 --- a/libtest.sh +++ b/libtest.sh @@ -6,7 +6,7 @@ # Do note this file is extremely simply for my own personal convenience export .env -cargo run --example cli $1 && \ +cargo run --release --example cli $1 && \ # clang hello.o -o main && \ ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 \ -o main /usr/lib/crt1.o hello.o -lc && \ diff --git a/reid-llvm-lib/src/compile.rs b/reid-llvm-lib/src/compile.rs index 51786b1..0c433c8 100644 --- a/reid-llvm-lib/src/compile.rs +++ b/reid-llvm-lib/src/compile.rs @@ -246,7 +246,7 @@ impl FunctionHolder { if self.data.flags.is_extern { LLVMSetLinkage(own_function.value_ref, LLVMLinkage::LLVMExternalLinkage); - // Use "available internally" if the other kind of extern + // TODO Use "available internally" if the other kind of extern return; } diff --git a/reid/src/lib.rs b/reid/src/lib.rs index 74d43c2..2ae89d7 100644 --- a/reid/src/lib.rs +++ b/reid/src/lib.rs @@ -38,6 +38,7 @@ //! - ~~Extern functions~~ (DONE) //! - ~~Strings~~ (DONE) //! - Loops +//! - Debug Symbols //! ``` use std::path::PathBuf; @@ -79,6 +80,7 @@ pub fn compile_module( ) -> Result { let tokens = lexer::tokenize(source)?; + #[cfg(debug_assertions)] dbg!(&tokens); let mut token_stream = TokenStream::from(&tokens); @@ -101,12 +103,13 @@ pub fn compile_module( } pub fn perform_all_passes(context: &mut mir::Context) -> Result<(), ReidError> { - let state = context.pass(&mut LinkerPass); #[cfg(debug_assertions)] - { - dbg!(&context); - println!("{}", &context); - } + println!("{}", &context); + + let state = context.pass(&mut LinkerPass); + + #[cfg(debug_assertions)] + println!("{:?}\n{}", &context, &context); if !state.errors.is_empty() { return Err(ReidError::LinkerErrors(state.errors)); @@ -115,23 +118,22 @@ pub fn perform_all_passes(context: &mut mir::Context) -> Result<(), ReidError> { let refs = TypeRefs::default(); let state = context.pass(&mut TypeInference { refs: &refs }); + #[cfg(debug_assertions)] - { - dbg!(&state, &refs); - dbg!(&context); - println!("{}", &context); - } + dbg!(&state, &refs); + #[cfg(debug_assertions)] + println!("{}", &context); if !state.errors.is_empty() { return Err(ReidError::TypeInferenceErrors(state.errors)); } let state = context.pass(&mut TypeCheck { refs: &refs }); + #[cfg(debug_assertions)] - { - dbg!(&state); - println!("{}", &context); - } + dbg!(&state); + #[cfg(debug_assertions)] + println!("{}", &context); if !state.errors.is_empty() { return Err(ReidError::TypeCheckErrors(state.errors)); @@ -156,14 +158,14 @@ pub fn compile(source: &str, path: PathBuf) -> Result { path.parent().unwrap().to_owned(), ); - println!("{}", &mir_context); - perform_all_passes(&mut mir_context)?; let mut context = Context::new(); let codegen_modules = mir_context.codegen(&mut context); + #[cfg(debug_assertions)] dbg!(&codegen_modules); + let compiled = codegen_modules.compile(); compiled.output(); diff --git a/reid/src/token_stream.rs b/reid/src/token_stream.rs index e112d21..4f0ebd0 100644 --- a/reid/src/token_stream.rs +++ b/reid/src/token_stream.rs @@ -130,6 +130,7 @@ impl<'a, 'b> TokenStream<'a, 'b> { match T::parse(clone) { Ok(res) => { + #[cfg(debug_assertions)] dbg!(&res); let new_pos = ref_pos.max(self.position); Ok((res, new_pos)) diff --git a/reid_src/hello_world.reid b/reid_src/hello_world.reid index 0c5bf41..ce7bb35 100644 --- a/reid_src/hello_world.reid +++ b/reid_src/hello_world.reid @@ -1,10 +1,9 @@ import std::print; -fn main() -> u16 { +fn main() { let hello = "hello world"; print(hello); - return 0; }