summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-02-09 12:51:50 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-02-09 12:51:50 -0500
commit30f1ae4c7e0c07a722f1fa4d770409246ed9788c (patch)
tree57ef6212dcb0d250381654c620c2f7fcea4297dc /std
parent03a74d7b41e3abce86f9465a6a4994edb5c37e5b (diff)
made cgen pass arrays by value
Diffstat (limited to 'std')
-rw-r--r--std/io.toc24
1 files changed, 14 insertions, 10 deletions
diff --git a/std/io.toc b/std/io.toc
index 51cfd76..fac4921 100644
--- a/std/io.toc
+++ b/std/io.toc
@@ -38,16 +38,20 @@ puti ::= fn(x: int) {
toc_putchar('-');
// NOTE: don't do x = -x; here to make sure I64_MIN works
}
- abs ::= fn(x: int) int { if x < 0 { -x } else { x } };
- scan_digit := 1000000000000000000;
- started := false;
- while scan_digit > 0 {
- digit := abs((x / scan_digit) % 10);
- if digit > 0 { started = true; }
- if started {
- toc_putchar((('0' as int) + digit) as char);
+ if x == 0 {
+ toc_putchar('0');
+ } else {
+ abs ::= fn(x: int) int { if x < 0 { -x } else { x } };
+ scan_digit := 1000000000000000000;
+ started := false;
+ while scan_digit > 0 {
+ digit := abs((x / scan_digit) % 10);
+ if digit > 0 { started = true; }
+ if started {
+ toc_putchar((('0' as int) + digit) as char);
+ }
+ scan_digit /= 10;
}
- scan_digit /= 10;
}
toc_putchar('\n');
-}; \ No newline at end of file
+};