aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNic Gaffney <gaffney_nic@protonmail.com>2023-09-06 14:05:17 -0500
committerNic Gaffney <gaffney_nic@protonmail.com>2023-09-06 14:05:17 -0500
commit7b67ab3d6fbc74c95f35b992286cb98492c8b433 (patch)
treef72f431afaa17033a9651fbbc989bd7ec34813de
parent739421c86f5fabfef5c765beea7741a7409976d7 (diff)
downloadsloth-7b67ab3d6fbc74c95f35b992286cb98492c8b433.tar.gz
restructured filetree
-rwxr-xr-xbuild.sh6
-rw-r--r--examples/guessing.sloth2
-rwxr-xr-xout/argumentsbin0 -> 22704 bytes
-rwxr-xr-xout/cgolbin0 -> 22856 bytes
-rwxr-xr-xout/chatbotbin0 -> 22704 bytes
-rwxr-xr-xout/guessingbin0 -> 22704 bytes
-rwxr-xr-xout/hellobin0 -> 22704 bytes
-rwxr-xr-xout/mandelbrotbin0 -> 22704 bytes
-rwxr-xr-xout/mutablebin0 -> 22704 bytes
-rwxr-xr-xout/readbin0 -> 22704 bytes
-rwxr-xr-xout/systembin0 -> 22744 bytes
-rw-r--r--sloth/src/codegen/mod.rs1
-rw-r--r--std/stdsocket.c9
-rw-r--r--test.c19
-rwxr-xr-xtest.sh3
15 files changed, 12 insertions, 28 deletions
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
--- /dev/null
+++ b/out/arguments
Binary files differ
diff --git a/out/cgol b/out/cgol
new file mode 100755
index 0000000..81f3505
--- /dev/null
+++ b/out/cgol
Binary files differ
diff --git a/out/chatbot b/out/chatbot
new file mode 100755
index 0000000..5e91811
--- /dev/null
+++ b/out/chatbot
Binary files differ
diff --git a/out/guessing b/out/guessing
new file mode 100755
index 0000000..f568da8
--- /dev/null
+++ b/out/guessing
Binary files differ
diff --git a/out/hello b/out/hello
new file mode 100755
index 0000000..77671c3
--- /dev/null
+++ b/out/hello
Binary files differ
diff --git a/out/mandelbrot b/out/mandelbrot
new file mode 100755
index 0000000..61e73a6
--- /dev/null
+++ b/out/mandelbrot
Binary files differ
diff --git a/out/mutable b/out/mutable
new file mode 100755
index 0000000..415e15e
--- /dev/null
+++ b/out/mutable
Binary files differ
diff --git a/out/read b/out/read
new file mode 100755
index 0000000..7acb399
--- /dev/null
+++ b/out/read
Binary files differ
diff --git a/out/system b/out/system
new file mode 100755
index 0000000..958ee1a
--- /dev/null
+++ b/out/system
Binary files 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 <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) {
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 <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