wip infer_type
This commit is contained in:
parent
2ac69a7b12
commit
d295243dd0
3 changed files with 331 additions and 16 deletions
ltcc/src
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue