#import "Print_Vars";
Prints the source text, value and type of expressions: print_vars(x, y) writes one line per
variable, like x = 7 (s32). print_vars_to writes into a String_Builder, log_vars logs.
count := 3;
print_vars(count);Procedures#
(builder: *String_Builder, config: Print_Vars_Config, name_width: s64, value_width: s64, name: string, value: string, type: Type)
(code: Code) -> string
The source text of code, rendered at compile time.
(builder: *String_Builder, $args: ..Code, loc := #caller_location)
Appends one line per expression to builder, each with the expression's source text, its value
and its type, lined up in columns.
x: s32 = 7;
y: s32 = 22;
builder: String_Builder;
defer free_buffers(*builder);
print_vars_to(*builder, x, y);
text := builder_to_string(*builder);
defer free(text);
assert(text == "x = 7 (s32)\ny = 22 (s32)\n");↗($args: ..Code, loc := #caller_location)
Prints each expression's source text, value and type, one line apiece. Each expression is evaluated once.
width := 640;
print_vars(width, width * 2);
// width = 640 (s64)
// (width * 2) = 1280 (s64)↗($args: ..Code, loc := #caller_location)
Like print_vars, but sends the lines through log.
Types#
:: struct
How print_vars lays out a line: which of the name, value and type appear, the text around each,
and how the columns are aligned.
- control_flags: enum_flags u32 { PRINT_NAME :: 0x1; PRINT_VALUE :: 0x2; PRINT_TYPE :: 0x4; }
- before_name: := ""
- after_name: := " = "
- before_value: := ""
- after_value: := " ("
- before_type: := ""
- after_type: := ")"
- line_separator: := "\n"
- name_indentation: := Indentation.LEFT_JUSTIFIED
- value_indentation: := Indentation.LEFT_JUSTIFIED