Modules

Program_Print

moduleSource

Available on macOS, Linux, Windows, Wasm

#import "Program_Print";

Turns compiler code nodes back into Jai source text.

Example↗
Compiler :: #import "Compiler";
left := Compiler.make_integer_literal(-13);
right := Compiler.make_integer_literal(29);
sum: Compiler.Code_Binary_Operator;
sum.kind = .BINARY_OPERATOR;
sum.operator_type = cast(Compiler.Operator_Type) #char "+";
sum.left = left;
sum.right = right;

builder: String_Builder;
init_string_builder(*builder);
assert(print_expression(*builder, *sum));
assert(builder_to_string(*builder) == "(-13 + 29)");

Procedures#

Returns a metaprogram plugin that writes the loaded program back out as source, one pp_<file>.txt per file. Set its workspace and forward each message to its message procedure.

Compiler :: #import "Compiler";
plugin := get_plugin();
plugin.workspace = Compiler.compiler_create_workspace("print");
↗

This one is only checked to compile, not run.