Skip to content

Commit

Permalink
Add inline cpp frontend.
Browse files Browse the repository at this point in the history
  • Loading branch information
egorpugin committed Apr 18, 2024
1 parent eb387ce commit 51f5fca
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/sw/driver/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,23 @@ std::vector<std::unique_ptr<Input>> Driver::detectInputs(const path &p, InputTyp

for (auto &c : comments)
{
if (c.starts_with("//cpp") || c.starts_with("// cpp"))
{
auto fn = path{SW_BINARY_DIR} / "spec" / p.stem() += std::format("_{}.cpp", std::hash<path>()(p));
write_file_if_different(fn, c);

SpecificationFiles f;
f.addFile("sw.cpp", fn, c);
auto spec = std::make_unique<Specification>(f);
auto i = std::make_unique<SpecFileInput>(swctx, *this, std::move(spec));
i->fe_type = FrontendType::Sw;
i->source_dir = p.parent_path();
LOG_TRACE(logger, "using inline " << toString(i->fe_type) << " frontend for input " << p);
inputs.push_back(std::move(i));

return inputs;
}

try
{
SpecificationFiles f;
Expand Down

0 comments on commit 51f5fca

Please sign in to comment.