feat: code generation for simple choice statements, testing machinery
This commit is contained in:
parent
fac5a968e3
commit
ee26be6254
13 changed files with 304 additions and 70 deletions
|
|
@ -490,6 +490,8 @@ pub const LoadOptions = struct {
|
|||
dump_writer: ?*std.Io.Writer = null,
|
||||
stderr_writer: *std.Io.Writer,
|
||||
use_color: bool = true,
|
||||
dump_ast: bool = false,
|
||||
dump_ir: bool = false,
|
||||
};
|
||||
|
||||
pub fn selectChoiceIndex(story: *Story, index: usize) !void {
|
||||
|
|
@ -508,11 +510,13 @@ pub fn loadFromString(
|
|||
const arena = arena_allocator.allocator();
|
||||
const ast = try Ast.parse(gpa, arena, source_bytes, "<STDIN>", 0);
|
||||
|
||||
if (options.dump_writer) |w| {
|
||||
try w.writeAll("=== AST ===\n");
|
||||
try ast.render(gpa, w, .{
|
||||
.use_color = options.use_color,
|
||||
});
|
||||
if (options.dump_ast) {
|
||||
if (options.dump_writer) |w| {
|
||||
try w.writeAll("=== AST ===\n");
|
||||
try ast.render(gpa, w, .{
|
||||
.use_color = options.use_color,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (ast.errors.len > 0) {
|
||||
try ast.renderErrors(gpa, options.stderr_writer, .{
|
||||
|
|
@ -532,10 +536,12 @@ pub fn loadFromString(
|
|||
return error.CompilationFailed;
|
||||
}
|
||||
|
||||
if (options.dump_writer) |w| {
|
||||
try w.writeAll("=== Semantic IR ===\n");
|
||||
try sem_ir.dumpInfo(w);
|
||||
try sem_ir.render(gpa, w);
|
||||
if (options.dump_ir) {
|
||||
if (options.dump_writer) |w| {
|
||||
try w.writeAll("=== Semantic IR ===\n");
|
||||
try sem_ir.dumpInfo(w);
|
||||
try sem_ir.render(gpa, w);
|
||||
}
|
||||
}
|
||||
|
||||
var compiled = try Sema.compile(gpa, &sem_ir);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue