diff options
| author | gingerBill <bill@gingerbill.org> | 2018-08-30 12:10:16 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-08-30 12:10:16 +0100 |
| commit | 6a3697279ca1f71a14e270252b40352bbd2a2a2d (patch) | |
| tree | 60a068ed4fa960658e699a4801d8915c79dcb194 | |
| parent | c19ec5d65de84f70d87a20316b9c0278c149fb7c (diff) | |
Place assertf and printf to package fmt
| -rw-r--r-- | core/fmt/fmt.odin | 21 | ||||
| -rw-r--r-- | core/runtime/core.odin | 26 |
2 files changed, 21 insertions, 26 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index f7529a51f..a267e9ef1 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -192,6 +192,27 @@ bprintf :: proc(buf: []byte, fmt: string, args: ..any) -> string { } +assertf :: proc "contextless" (condition: bool, fmt: string, args: ..any, loc := #caller_location) -> bool { + if !condition { + p := context.assertion_failure_proc; + if p == nil { + p = runtime.default_assertion_failure_proc; + } + message := tprintf(fmt, ..args); + p("Runtime assertion", message, loc); + } + return condition; +} + +panicf :: proc "contextless" (fmt: string, args: ..any, loc := #caller_location) { + p := context.assertion_failure_proc; + if p == nil { + p = runtime.default_assertion_failure_proc; + } + message := tprintf(fmt, ..args); + p("Panic", message, loc); +} + diff --git a/core/runtime/core.odin b/core/runtime/core.odin index d4018b5e6..24f94f8b3 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -5,7 +5,6 @@ package runtime import "core:os" import "core:mem" -import "core:fmt" // Naming Conventions: // In general, Ada_Case for types and snake_case for values @@ -575,31 +574,6 @@ panic :: proc "contextless" (message: string, loc := #caller_location) { } -@(builtin) -assertf :: proc "contextless" (condition: bool, format: string, args: ..any, loc := #caller_location) -> bool { - if !condition { - p := context.assertion_failure_proc; - if p == nil { - p = default_assertion_failure_proc; - } - message := fmt.tprintf(format, ..args); - p("Runtime assertion", message, loc); - } - return condition; -} - -@(builtin) -panicf :: proc "contextless" (format: string, args: ..any, loc := #caller_location) { - p := context.assertion_failure_proc; - if p == nil { - p = default_assertion_failure_proc; - } - message := fmt.tprintf(format, ..args); - p("Panic", message, loc); -} - - - // Dynamic Array |