Dump AST and IR immediately after handling a file
This commit is contained in:
parent
ec751ec6c2
commit
393db4b912
1 changed files with 16 additions and 23 deletions
|
|
@ -183,6 +183,15 @@ int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
filenames.push_back(argv[arg]);
|
filenames.push_back(argv[arg]);
|
||||||
auto root = parser::parse(filenames.back());
|
auto root = parser::parse(filenames.back());
|
||||||
|
|
||||||
|
if (dump_ast)
|
||||||
|
{
|
||||||
|
std::cout << "Input file " << filenames.back() << " AST dump:\n\n";
|
||||||
|
if (auto function_definition = std::get_if<ast::function_definition>(parsed.back().get()))
|
||||||
|
ast::print(std::cout, *function_definition->statements);
|
||||||
|
std::cout << "\n" << std::flush;
|
||||||
|
}
|
||||||
|
|
||||||
ast::resolve_identifiers(root);
|
ast::resolve_identifiers(root);
|
||||||
ast::check_and_infer_types(root);
|
ast::check_and_infer_types(root);
|
||||||
ast::validate(root);
|
ast::validate(root);
|
||||||
|
|
@ -190,6 +199,13 @@ int main(int argc, char ** argv)
|
||||||
|
|
||||||
ir_compiled.emplace_back();
|
ir_compiled.emplace_back();
|
||||||
ir::compile(ir_compiled.back(), parsed.back());
|
ir::compile(ir_compiled.back(), parsed.back());
|
||||||
|
|
||||||
|
if (dump_ir)
|
||||||
|
{
|
||||||
|
std::cout << "Input file " << filenames.back() << " IR dump:\n\n";
|
||||||
|
ir::print(std::cout, ir_compiled.back());
|
||||||
|
std::cout << "\n" << std::flush;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (ast::parse_error const & error)
|
catch (ast::parse_error const & error)
|
||||||
{
|
{
|
||||||
|
|
@ -229,29 +245,6 @@ int main(int argc, char ** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dump_ast)
|
|
||||||
{
|
|
||||||
for (std::size_t i = 0; i < filenames.size(); ++i)
|
|
||||||
{
|
|
||||||
std::cout << "Input file " << filenames[i] << " AST dump:\n\n";
|
|
||||||
if (auto function_definition = std::get_if<ast::function_definition>(parsed[i].get()))
|
|
||||||
ast::print(std::cout, *function_definition->statements);
|
|
||||||
std::cout << "\n";
|
|
||||||
}
|
|
||||||
std::cout << std::flush;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dump_ir)
|
|
||||||
{
|
|
||||||
for (std::size_t i = 0; i < filenames.size(); ++i)
|
|
||||||
{
|
|
||||||
std::cout << "Input file " << filenames[i] << " IR dump:\n\n";
|
|
||||||
ir::print(std::cout, ir_compiled[i]);
|
|
||||||
std::cout << "\n";
|
|
||||||
}
|
|
||||||
std::cout << std::flush;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jit)
|
if (jit)
|
||||||
{
|
{
|
||||||
// TODO: treat all input files as modules combined into a single program
|
// TODO: treat all input files as modules combined into a single program
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue