From fb9b22fa4621e30eb78b7813a46456b66d8b9849 Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Wed, 1 Dec 2021 14:43:11 +0100 Subject: [PATCH] reorganized files --- build.sh | 30 +++++++++++++++------------- src/main.c | 2 ++ src/{runtime => }/o_builtins.c | 4 ++-- src/{runtime => objects}/o_closure.c | 5 +---- src/objects/objects.h | 1 + src/runtime/runtime.h | 2 -- 6 files changed, 22 insertions(+), 22 deletions(-) rename src/{runtime => }/o_builtins.c (98%) rename src/{runtime => objects}/o_closure.c (88%) diff --git a/build.sh b/build.sh index 0d66a63..71ce94d 100755 --- a/build.sh +++ b/build.sh @@ -14,15 +14,16 @@ gcc -c src/utils/promise.c -o temp/utils/promise.o $FLAGS gcc -c src/utils/bucketlist.c -o temp/utils/bucketlist.o $FLAGS mkdir temp/objects -gcc -c src/objects/heap.c -o temp/objects/heap.o $FLAGS -gcc -c src/objects/o_int.c -o temp/objects/o_int.o $FLAGS -gcc -c src/objects/o_map.c -o temp/objects/o_map.o $FLAGS -gcc -c src/objects/o_list.c -o temp/objects/o_list.o $FLAGS -gcc -c src/objects/o_none.c -o temp/objects/o_none.o $FLAGS -gcc -c src/objects/o_bool.c -o temp/objects/o_bool.o $FLAGS -gcc -c src/objects/o_float.c -o temp/objects/o_float.o $FLAGS -gcc -c src/objects/o_string.c -o temp/objects/o_string.o $FLAGS -gcc -c src/objects/objects.c -o temp/objects/objects.o $FLAGS +gcc -c src/objects/heap.c -o temp/objects/heap.o $FLAGS +gcc -c src/objects/o_int.c -o temp/objects/o_int.o $FLAGS +gcc -c src/objects/o_map.c -o temp/objects/o_map.o $FLAGS +gcc -c src/objects/o_list.c -o temp/objects/o_list.o $FLAGS +gcc -c src/objects/o_none.c -o temp/objects/o_none.o $FLAGS +gcc -c src/objects/o_bool.c -o temp/objects/o_bool.o $FLAGS +gcc -c src/objects/o_float.c -o temp/objects/o_float.o $FLAGS +gcc -c src/objects/o_string.c -o temp/objects/o_string.o $FLAGS +gcc -c src/objects/o_closure.c -o temp/objects/o_closure.o $FLAGS +gcc -c src/objects/objects.c -o temp/objects/objects.o $FLAGS mkdir temp/compiler gcc -c src/compiler/parse.c -o temp/compiler/parse.o $FLAGS @@ -35,11 +36,11 @@ gcc -c src/common/executable.c -o temp/common/executable.o $FLAGS mkdir temp/runtime gcc -c src/runtime/runtime_error.c -o temp/runtime/runtime_error.o $FLAGS gcc -c src/runtime/runtime.c -o temp/runtime/runtime.o $FLAGS -gcc -c src/runtime/o_builtins.c -o temp/runtime/o_builtins.o $FLAGS -gcc -c src/runtime/o_closure.c -o temp/runtime/o_closure.o $FLAGS gcc -c src/runtime/o_nfunc.c -o temp/runtime/o_nfunc.o $FLAGS gcc -c src/runtime/o_func.c -o temp/runtime/o_func.o $FLAGS +gcc -c src/o_builtins.c -o temp/o_builtins.o $FLAGS + rm -rf build mkdir build @@ -68,7 +69,9 @@ ar rcs build/libnoja-runtime.a \ gcc tests/src/test-parse.c -o build/test-parse $FLAGS -Lbuild/ -lnoja-compile -lxjson gcc tests/src/test-objects.c -o build/test-objects $FLAGS -Lbuild/ -lnoja-objects -gcc src/main.c src/debug.c \ +gcc src/main.c \ + src/debug.c \ + temp/o_builtins.o \ temp/utils/hash.o \ temp/utils/stack.o \ temp/utils/source.o \ @@ -79,10 +82,9 @@ gcc src/main.c src/debug.c \ temp/objects/o_list.o \ temp/objects/o_bool.o \ temp/objects/o_string.o \ + temp/objects/o_closure.o \ temp/runtime/runtime.o \ temp/runtime/runtime_error.o \ - temp/runtime/o_builtins.o \ - temp/runtime/o_closure.o \ temp/runtime/o_nfunc.o \ temp/runtime/o_func.o \ temp/common/executable.o \ diff --git a/src/main.c b/src/main.c index 6891691..fde0a52 100644 --- a/src/main.c +++ b/src/main.c @@ -14,6 +14,8 @@ * $ noja -f -o */ +Object *Object_NewBuiltinsMap(Runtime *runtime, Heap *heap, Error *err); + typedef enum { RUN, HELP, PARSE, VERSION, DISASSEMBLY } Action; typedef struct { diff --git a/src/runtime/o_builtins.c b/src/o_builtins.c similarity index 98% rename from src/runtime/o_builtins.c rename to src/o_builtins.c index c7ba38a..5a4341d 100644 --- a/src/runtime/o_builtins.c +++ b/src/o_builtins.c @@ -2,8 +2,8 @@ #include #include #include -#include "runtime.h" -#include "../utils/defs.h" +#include "runtime/runtime.h" +#include "utils/defs.h" static Object *select_(Object *self, Object *key, Heap *heap, Error *err); static int count(Object *self); diff --git a/src/runtime/o_closure.c b/src/objects/o_closure.c similarity index 88% rename from src/runtime/o_closure.c rename to src/objects/o_closure.c index 737fa4f..df53ca9 100644 --- a/src/runtime/o_closure.c +++ b/src/objects/o_closure.c @@ -1,8 +1,5 @@ -// NOTE: This data structure doesn't strictly depend on -// the runtime, so it could be moved to src/objects. - #include "../utils/defs.h" -#include "../objects/objects.h" +#include "objects.h" typedef struct ClosureObject ClosureObject; diff --git a/src/objects/objects.h b/src/objects/objects.h index 4198aef..a2b8c19 100644 --- a/src/objects/objects.h +++ b/src/objects/objects.h @@ -86,6 +86,7 @@ Object* Object_Prev (Object *iter, Heap *heap, Error *err); Object* Object_NewMap(int num, Heap *heap, Error *error); Object* Object_NewList(int capacity, Heap *heap, Error *error); Object* Object_NewNone(Heap *heap, Error *error); +Object* Object_NewClosure(Object *parent, Object *new_map, Heap *heap, Error *error); Object* Object_FromInt (long long int val, Heap *heap, Error *error); Object* Object_FromBool (_Bool val, Heap *heap, Error *error); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index ca5cda5..c617456 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -25,8 +25,6 @@ void Snapshot_Print(Snapshot *snapshot, FILE *fp); Object *run(Runtime *runtime, Error *error, Executable *exe, int index, Object *closure, Object **argv, int argc); -Object *Object_NewClosure(Object *parent, Object *new_map, Heap *heap, Error *error); -Object *Object_NewBuiltinsMap(Runtime *runtime, Heap *heap, Error *err); Object* Object_FromNativeFunction(Runtime *runtime, Object *(*callback)(Runtime*, Object**, unsigned int, Error*), int argc, Heap *heap, Error *error); Object *Object_FromNojaFunction(Runtime *runtime, Executable *exe, int index, int argc, Object *closure, Heap *heap, Error *error); #endif \ No newline at end of file