diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-09-06 14:05:17 -0500 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-09-06 14:05:17 -0500 |
| commit | 7b67ab3d6fbc74c95f35b992286cb98492c8b433 (patch) | |
| tree | f72f431afaa17033a9651fbbc989bd7ec34813de | |
| parent | 739421c86f5fabfef5c765beea7741a7409976d7 (diff) | |
| download | sloth-7b67ab3d6fbc74c95f35b992286cb98492c8b433.tar.gz | |
restructured filetree
| -rwxr-xr-x | build.sh | 6 | ||||
| -rw-r--r-- | examples/guessing.sloth | 2 | ||||
| -rwxr-xr-x | out/arguments | bin | 0 -> 22704 bytes | |||
| -rwxr-xr-x | out/cgol | bin | 0 -> 22856 bytes | |||
| -rwxr-xr-x | out/chatbot | bin | 0 -> 22704 bytes | |||
| -rwxr-xr-x | out/guessing | bin | 0 -> 22704 bytes | |||
| -rwxr-xr-x | out/hello | bin | 0 -> 22704 bytes | |||
| -rwxr-xr-x | out/mandelbrot | bin | 0 -> 22704 bytes | |||
| -rwxr-xr-x | out/mutable | bin | 0 -> 22704 bytes | |||
| -rwxr-xr-x | out/read | bin | 0 -> 22704 bytes | |||
| -rwxr-xr-x | out/system | bin | 0 -> 22744 bytes | |||
| -rw-r--r-- | sloth/src/codegen/mod.rs | 1 | ||||
| -rw-r--r-- | std/stdsocket.c | 9 | ||||
| -rw-r--r-- | test.c | 19 | ||||
| -rwxr-xr-x | test.sh | 3 |
15 files changed, 12 insertions, 28 deletions
@@ -1,12 +1,12 @@ # Build Sloth cargo build -rm output.o FILENAME="$1" # Compile standard library ./target/debug/sloth std/extern.sloth std/stdmath.sloth std/stdio.sloth $FILENAME # Generate binary -clang --verbose -lm output.o std/stdio.c std/stdlib.c std/stdmath.c -o "${FILENAME%.sloth}" +clang -lm output.o std/stdio.c std/stdlib.c std/stdmath.c -o "${FILENAME%.sloth}" # Move file -mv "${FILENAME%.sloth}" . +mv "${FILENAME%.sloth}" out/ +rm output.o diff --git a/examples/guessing.sloth b/examples/guessing.sloth index ef680c9..cfb293d 100644 --- a/examples/guessing.sloth +++ b/examples/guessing.sloth @@ -1,5 +1,5 @@ fn main() Int { - var computer: Int = randGen(1, 10); + val computer: Int = randGen(1, 10); var tries: Int = 0; var correct: Bool = false; diff --git a/out/arguments b/out/arguments Binary files differnew file mode 100755 index 0000000..a10a61d --- /dev/null +++ b/out/arguments diff --git a/out/cgol b/out/cgol Binary files differnew file mode 100755 index 0000000..81f3505 --- /dev/null +++ b/out/cgol diff --git a/out/chatbot b/out/chatbot Binary files differnew file mode 100755 index 0000000..5e91811 --- /dev/null +++ b/out/chatbot diff --git a/out/guessing b/out/guessing Binary files differnew file mode 100755 index 0000000..f568da8 --- /dev/null +++ b/out/guessing diff --git a/out/hello b/out/hello Binary files differnew file mode 100755 index 0000000..77671c3 --- /dev/null +++ b/out/hello diff --git a/out/mandelbrot b/out/mandelbrot Binary files differnew file mode 100755 index 0000000..61e73a6 --- /dev/null +++ b/out/mandelbrot diff --git a/out/mutable b/out/mutable Binary files differnew file mode 100755 index 0000000..415e15e --- /dev/null +++ b/out/mutable diff --git a/out/read b/out/read Binary files differnew file mode 100755 index 0000000..7acb399 --- /dev/null +++ b/out/read diff --git a/out/system b/out/system Binary files differnew file mode 100755 index 0000000..958ee1a --- /dev/null +++ b/out/system diff --git a/sloth/src/codegen/mod.rs b/sloth/src/codegen/mod.rs index 7678856..ca7598c 100644 --- a/sloth/src/codegen/mod.rs +++ b/sloth/src/codegen/mod.rs @@ -71,7 +71,6 @@ impl<'ctx> Codegen<'ctx> { for stmt in stmts { self.codegen_stmt(stmt); - self.current_func.unwrap().print_to_stderr(); } } diff --git a/std/stdsocket.c b/std/stdsocket.c index 94d2ebe..0a47f97 100644 --- a/std/stdsocket.c +++ b/std/stdsocket.c @@ -1,4 +1,3 @@ -#include "stdlib.c" #include <netinet/in.h> #include <stdbool.h> #include <stdio.h> @@ -66,6 +65,14 @@ char *recvsock(int soc) { return buf; } +size_t +strlen(const char *str) +{ + const char *s; + for (s = str; *s; ++s); + return(s - str); +} + void sendsock(char *msg, int soc) { send(soc, msg, strlen(msg), 0); } void closesock(int soc, bool server) { @@ -1,19 +0,0 @@ -#include <stdio.h> - -void print(char* x) { - printf("%s", x); -} -void printfl(float x) { - printf("%f", x); -} -void printdeez(int x) { - printf("%d", x); -} - -int as_int(float x) { - return (int) x; -} - -void termpos(int x, int y) { - printf("\x1b[%d;%dH", x, y); -} diff --git a/test.sh b/test.sh deleted file mode 100755 index 59dae87..0000000 --- a/test.sh +++ /dev/null @@ -1,3 +0,0 @@ -cargo run examples/hello.sloth -clang output.o test.c -o output -./output |
