Put all debug prints behind debug-assertions
This commit is contained in:
parent
0e5f12e0e2
commit
5b5ec48b8d
@ -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 && \
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<mir::Module, ReidError> {
|
||||
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<String, ReidError> {
|
||||
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();
|
||||
|
||||
|
@ -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))
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
import std::print;
|
||||
|
||||
fn main() -> u16 {
|
||||
fn main() {
|
||||
let hello = "hello world";
|
||||
|
||||
print(hello);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user