Compare commits
1 Commits
a79286113e
...
35aa055693
Author | SHA1 | Date |
---|---|---|
David Mak | 35aa055693 |
|
@ -1,3 +1,4 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -11,6 +12,10 @@
|
|||
#error "Unsupported platform - Platform is not 32-bit or 64-bit"
|
||||
#endif
|
||||
|
||||
void output_bool(const bool x) {
|
||||
puts(x ? "True" : "False");
|
||||
}
|
||||
|
||||
void output_int32(const int32_t x) {
|
||||
printf("%d\n", x);
|
||||
}
|
||||
|
@ -31,7 +36,7 @@ void output_float64(const double x) {
|
|||
printf("%f\n", x);
|
||||
}
|
||||
void output_asciiart(const int32_t x) {
|
||||
const char* chars = " .,-:;i+hHM$*#@ ";
|
||||
static const char *chars = " .,-:;i+hHM$*#@ ";
|
||||
if (x < 0) {
|
||||
putchar('\n');
|
||||
} else {
|
||||
|
|
|
@ -58,6 +58,7 @@ def patch(module):
|
|||
elif name == "output_float64":
|
||||
return output_float
|
||||
elif name in {
|
||||
"output_bool",
|
||||
"output_int32",
|
||||
"output_int64",
|
||||
"output_int32_list",
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
@extern
|
||||
def output_bool(x: bool):
|
||||
...
|
||||
|
||||
@extern
|
||||
def output_int32(x: int32):
|
||||
...
|
||||
|
@ -30,6 +34,10 @@ def output_asciiart(x: int32):
|
|||
def output_str(x: str):
|
||||
...
|
||||
|
||||
def test_output_bool():
|
||||
output_bool(True)
|
||||
output_bool(False)
|
||||
|
||||
def test_output_int32():
|
||||
output_int32(-128)
|
||||
|
||||
|
@ -63,6 +71,7 @@ def test_output_str_family():
|
|||
output_str("hello world")
|
||||
|
||||
def run() -> int32:
|
||||
test_output_bool()
|
||||
test_output_int32()
|
||||
test_output_int64()
|
||||
test_output_uint32()
|
||||
|
|
Loading…
Reference in New Issue