fix compilation: insert procedures at front, ltvm: use 0 as default entrypoint
This commit is contained in:
parent
5c2a610d31
commit
6b577e91f8
4 changed files with 126 additions and 135 deletions
ltcc/src
|
@ -77,9 +77,9 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
compiler = compiler.compile_expr(&ast);
|
||||
compiler = compiler.compile_expr(&ast, true);
|
||||
let diagnostics = compiler.diagnostics.clone();
|
||||
let (exports, proc_code) = compiler.get_bytecode(false);
|
||||
let (exports, proc_code) = compiler.get_bytecode();
|
||||
|
||||
for (region, message) in diagnostics {
|
||||
crate::diagnostic::print_diagnostic(
|
||||
|
@ -89,8 +89,7 @@ fn main() {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
eprintln!("{} {}", "Compiled".green(), path.bold());
|
||||
eprintln!("{} {}\n{}", "Compiled".green(), path.bold(), "---------------".green());
|
||||
for (name, def) in exports.iter() {
|
||||
eprintln!("export {}:", name.yellow().bold());
|
||||
let mut t = def.get_type(&mut main_scope);
|
||||
|
@ -106,11 +105,12 @@ fn main() {
|
|||
|
||||
/* link assembly-program to symbols
|
||||
*/
|
||||
eprintln!("generated bytecode ({})", proc_code.len() );
|
||||
for (i,l) in tisc::assembler::disassemble(&proc_code).iter().enumerate() {
|
||||
eprintln!("{} .... {}", i,l);
|
||||
}
|
||||
linker.add_procedure(path.as_str(), proc_code);
|
||||
linker.add_procedure_front(path.as_str(), proc_code);
|
||||
|
||||
main_scope.write().unwrap().update_link_addresses(
|
||||
&path,
|
||||
&linker
|
||||
);
|
||||
}
|
||||
Err( (region, parse_error) ) => {
|
||||
crate::diagnostic::print_diagnostic(
|
||||
|
@ -125,6 +125,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
eprintln!("write output file {}", args.output);
|
||||
let obj_file = tisc::linker::ObjectFile {
|
||||
symbols: Arc::into_inner(main_scope).unwrap().into_inner().unwrap()
|
||||
|
@ -135,12 +136,12 @@ fn main() {
|
|||
if export {
|
||||
match link_addr {
|
||||
tisc::LinkAddr::Absolute(w) => {
|
||||
eprintln!("add symbol {} -> {}", symbol, w);
|
||||
// eprintln!("add symbol {} -> {}", symbol, w);
|
||||
Some(( symbol, w ))
|
||||
}
|
||||
tisc::LinkAddr::Relative{ symbol: b, offset } => {
|
||||
let addr = linker.get_link_addr(&b).unwrap_or(-1);
|
||||
eprintln!("relative symbol {} -> {}({})+{}", symbol, b, addr, offset);
|
||||
// eprintln!("relative symbol {} -> {}({})+{}", symbol, b, addr, offset);
|
||||
Some((symbol, addr + offset ))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue