diff --git a/include/vast/repl/state.hpp b/include/vast/repl/state.hpp index bc40fa2316..cc1f0ee4b8 100644 --- a/include/vast/repl/state.hpp +++ b/include/vast/repl/state.hpp @@ -33,7 +33,7 @@ namespace vast::repl { // // Tower related state // - tw::location_info li; + tw::location_info_t location_info; std::optional< tw::default_tower > tower; std::unordered_map< std::string, tw::link_ptr > links; diff --git a/tools/vast-repl/command.cpp b/tools/vast-repl/command.cpp index 1e21a1ef8c..5ee947abc5 100644 --- a/tools/vast-repl/command.cpp +++ b/tools/vast-repl/command.cpp @@ -12,12 +12,21 @@ namespace cmd { // TODO: Really naive way to visualize. void render_link(const tw::link_ptr &ptr) { + auto flag = mlir::OpPrintingFlags().skipRegions(); + + auto render_op = [&](operation op) -> llvm::raw_fd_ostream & { + op->print(llvm::outs(), flag); + return llvm::outs(); + }; + auto render = [&](operation op) { - llvm::outs() << *op << "\n"; - for (auto c : ptr->children(op)) - llvm::outs() << "\t => " << *c << "\n"; + render_op(op) << "\n"; + for (auto c : ptr->children(op)) { + llvm::outs() << "\t => "; + render_op(c) << "\n"; + } }; - ptr->from().mod->walk< mlir::WalkOrder::PreOrder >(render); + ptr->parent().mod->walk< mlir::WalkOrder::PreOrder >(render); } void check_source(const state_t &state) { @@ -178,7 +187,7 @@ namespace cmd { throw_error("failed to parse pass pipeline"); } } - auto link = state.tower->apply(top, state.li, pm); + auto link = state.tower->apply(top, state.location_info, pm); state.links.emplace(link_name, std::move(link)); } diff --git a/tools/vast-repl/state.cpp b/tools/vast-repl/state.cpp new file mode 100644 index 0000000000..5c96390526 --- /dev/null +++ b/tools/vast-repl/state.cpp @@ -0,0 +1,17 @@ +// Copyright (c) 2024-present, Trail of Bits, Inc. + +#include "vast/repl/state.hpp" + +VAST_RELAX_WARNINGS +VAST_UNRELAX_WARNINGS + +namespace vast::repl { + + void state_t::raise_tower(owning_module_ref mod) { + tower.emplace(ctx, li, std::move(mod)); + } + + vast_module state_t::current_module() { + return tower->top().mod; + } +} // namespace vast::repl::codegen