36#include <gtest/gtest.h>
49 "import \"math.aw\";\n"
50 "let answer = add(40, 2);\n"});
63 Compiler_Driver_Action::Parse_Only));
81 const auto * merged =
driver.find_artifact(
"ast");
83 EXPECT_NE(merged->text.find(
"Function(add)"), std::string::npos);
84 EXPECT_NE(merged->text.find(
"Let(answer)"), std::string::npos);
85 EXPECT_LT(merged->text.find(
"Function(add)"), merged->text.find(
"Let(answer)"));
98 Compiler_Driver_Action::Run));
105 " add = Function(add)\n"
106 " answer = Int(42)\n");
108 const auto * hir =
driver.find_artifact(
"hir");
110 EXPECT_NE(hir->text.find(
"HIRModule"), std::string::npos);
111 EXPECT_NE(hir->text.find(
"Function(add): fn(Int, Int) -> Int"),
114 const auto * globals =
driver.find_artifact(
"run.globals");
123 Compiler_Driver_Action::Emit_Bytecode));
133 options.c_backend_options.emit_main =
true;
137 Compiler_Driver_Action::Emit_C));
151 inputs.
append({
"main.aw",
"let answer = missing(1);\n"});
156 EXPECT_NE(
driver.diagnostics_text().find(
"SEM002"), std::string::npos);
160 const auto * diagnostics =
driver.find_artifact(
"diagnostics");
162 EXPECT_NE(diagnostics->text.find(
"undeclared identifier"), std::string::npos);
169 "import \"missing.aw\";\n"
170 "let answer = 1;\n"});
175 EXPECT_NE(
driver.diagnostics_text().find(
"DRV001"), std::string::npos);
176 EXPECT_NE(
driver.diagnostics_text().find(
"cannot resolve import 'missing.aw'"),
183 inputs.
append({
"a.aw",
"import \"b.aw\";\nlet a = 1;\n"});
184 inputs.append({
"b.aw",
"import \"a.aw\";\nlet b = 2;\n"});
189 EXPECT_NE(
driver.diagnostics_text().find(
"DRV002"), std::string::npos);
190 EXPECT_NE(
driver.diagnostics_text().find(
"cyclic import"), std::string::npos);
197 "let crash = 1 / 0;\n"});
213 EXPECT_NE(
messages->text.find(
"run: HIR runtime execution failed: RUN007 division by zero"),
End-to-end multi-file driver for the compiler-support pipeline.
Reusable orchestration object for compiler pipeline experiments.
T & append()
Allocate a new entry to the end of array.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
Compiler_Driver_Action
High-level actions supported by compiler pipeline drivers.
const char * compiler_driver_action_name(const Compiler_Driver_Action action) noexcept
Returns the canonical external spelling for one driver action.
bool compiler_parse_driver_action(std::string_view text, Compiler_Driver_Action &action) noexcept
Parses one canonical driver action spelling.
static struct argp_option options[]
std::string module_name
Prefix used to derive stable C identifiers.
Immutable configuration shared by all runs of one driver object.
Compiler_C_Backend_Options c_backend_options
Backend-C emission options used by emit-c.