b581da41f8
* add `setFnTest`, `setFnVisible`, `setFnStaticEval`, `setFnNoInline` builtin functions to replace previous directive functionality * add `coldcc` and `nakedcc` as keywords which can be used as part of a function prototype. * `setDebugSafety` builtin can be used to set debug safety features at a per block scope level. * closes #169
32 lines
548 B
Zig
32 lines
548 B
Zig
const assert = @import("std").debug.assert;
|
|
|
|
var read_count: u64 = 0;
|
|
|
|
fn readOnce() -> %u64 {
|
|
read_count += 1;
|
|
return read_count;
|
|
}
|
|
|
|
error InvalidDebugInfo;
|
|
|
|
enum FormValue {
|
|
Address: u64,
|
|
Other: bool,
|
|
}
|
|
|
|
fn doThing(form_id: u64) -> %FormValue {
|
|
@setFnStaticEval(this, false);
|
|
|
|
return switch (form_id) {
|
|
17 => FormValue.Address { %return readOnce() },
|
|
else => error.InvalidDebugInfo,
|
|
}
|
|
}
|
|
|
|
fn switchProngReturnsErrorEnum() {
|
|
@setFnTest(this, true);
|
|
|
|
%%doThing(17);
|
|
assert(read_count == 1);
|
|
}
|