diff --git a/build.sh b/build.sh index f6ad2e3..2bdd204 100755 --- a/build.sh +++ b/build.sh @@ -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 new file mode 100755 index 0000000..a10a61d Binary files /dev/null and b/out/arguments differ diff --git a/out/cgol b/out/cgol new file mode 100755 index 0000000..81f3505 Binary files /dev/null and b/out/cgol differ diff --git a/out/chatbot b/out/chatbot new file mode 100755 index 0000000..5e91811 Binary files /dev/null and b/out/chatbot differ diff --git a/out/guessing b/out/guessing new file mode 100755 index 0000000..f568da8 Binary files /dev/null and b/out/guessing differ diff --git a/out/hello b/out/hello new file mode 100755 index 0000000..77671c3 Binary files /dev/null and b/out/hello differ diff --git a/out/mandelbrot b/out/mandelbrot new file mode 100755 index 0000000..61e73a6 Binary files /dev/null and b/out/mandelbrot differ diff --git a/out/mutable b/out/mutable new file mode 100755 index 0000000..415e15e Binary files /dev/null and b/out/mutable differ diff --git a/out/read b/out/read new file mode 100755 index 0000000..7acb399 Binary files /dev/null and b/out/read differ diff --git a/out/system b/out/system new file mode 100755 index 0000000..958ee1a Binary files /dev/null and b/out/system differ 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 #include #include @@ -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) { diff --git a/test.c b/test.c deleted file mode 100644 index 1bf5e4f..0000000 --- a/test.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -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