wip infer_type

This commit is contained in:
Michael Sippel 2024-10-04 02:57:26 +02:00
parent 2ac69a7b12
commit d295243dd0
Signed by: senvas
GPG key ID: F96CF119C34B64A6
3 changed files with 331 additions and 16 deletions
ltcc/src

View file

@ -51,7 +51,21 @@ fn main() {
match ltcore::parser::parse_expr( &mut main_scope, &mut program_tokens ) {
Ok( mut ast ) => {
let (exports, diagnostics, proc_code) = ProcedureCompiler::new(&main_scope)
let mut compiler = ProcedureCompiler::new(&main_scope);
match compiler.infer_type(&mut ast) {
Ok(mut t) => {
t = t.normalize();
t = t.param_normalize();
let mut tc = compiler.symbols.clone();
eprintln!("Expr has type:\n================\n{}\n================\n", t.sugar(&mut tc).pretty(&mut tc, 0));
}
Err(e) => {
eprintln!("{} [{:?}]", "Type Error".red(), e);
}
}
let (exports, diagnostics, proc_code) = compiler
.compile(&ast)
.into_asm(&path);
@ -65,7 +79,12 @@ fn main() {
eprintln!("{} {}", "Compiled".green(), path.bold());
for (name, def) in exports.iter() {
eprintln!("export {}: {:?}", name.yellow().bold(), def);
eprintln!("export {}:", name.yellow().bold());
let mut t = def.get_type(&mut main_scope);
t = t.normalize();
t = t.param_normalize();
let mut tc = main_scope.clone();
eprintln!( "{}", t.sugar(&mut tc).pretty(&tc,0) );
}
main_scope.write().unwrap().import(