diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..19d42d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +testapp +libgravity.so +obj/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7c3c257 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +SRC=src +OBJ=obj + +CC=gcc +CFLAGS=-Wall -Wextra -pedantic -std=c99 -pedantic-errors + +TARGET=libgravity.so +TEST_TARGET=testapp + +SRCS=$(wildcard $(SRC)/*.c) +OBJS=$(patsubst $(SRC)/%.c,$(OBJ)/%.o,$(SRCS)) + +$(TARGET): $(OBJS) + $(CC) -shared $(OBJS) -o $(TARGET) + +$(OBJ)/%.o: $(SRC)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +$(TEST_TARGET): test.c $(TARGET) + $(CC) test.c -lgravity -L. -o $(TEST_TARGET) + +test: $(TEST_TARGET) + +setup: + mkdir -p $(OBJ) + +clean: + rm $(TARGET) + rm $(TEST_TARGET) + rm -r $(OBJ)/*.o + +install: $(TARGET) + sudo cp $(TARGET) /usr/local/lib/ + +.PHONY: setup clean test install \ No newline at end of file diff --git a/include/gravity/core.h b/include/gravity/core.h new file mode 100644 index 0000000..7c2455f --- /dev/null +++ b/include/gravity/core.h @@ -0,0 +1,12 @@ +#ifndef __GRAVITY_CORE_H +#define __GRAVITY_CORE_H + +// === STRUCT DEFINITIONS === // +typedef struct GravityOpaqueModule* GravityModule; +// ========================== // + +// === FUNCTION DEFINITIONS === // +GravityModule gravityCreateModule(); +// ============================ // + +#endif \ No newline at end of file diff --git a/src/function.h b/src/function.h new file mode 100644 index 0000000..8c4cd8b --- /dev/null +++ b/src/function.h @@ -0,0 +1,8 @@ +#ifndef __GRAVITY_FUNCTION_H +#define __GRAVITY_FUNCTION_H + +typedef struct { + +} GravityIRFunction; + +#endif \ No newline at end of file diff --git a/src/module.c b/src/module.c new file mode 100644 index 0000000..3d2cee9 --- /dev/null +++ b/src/module.c @@ -0,0 +1,10 @@ +#include "module.h" + +GravityOpaqueModule* gravityCreateModule() { + GravityOpaqueModule* newModule = malloc(sizeof(GravityOpaqueModule)); + if (newModule == NULL) return NULL; + + + + return newModule; +} \ No newline at end of file diff --git a/src/module.h b/src/module.h new file mode 100644 index 0000000..363d371 --- /dev/null +++ b/src/module.h @@ -0,0 +1,12 @@ +#ifndef __GRAVITY_MODULE_H +#define __GRAVITY_MODULE_H + +#include + +typedef struct { + int hi; +} GravityOpaqueModule; + +GravityOpaqueModule* gravityCreateModule(); + +#endif \ No newline at end of file diff --git a/test.c b/test.c new file mode 100644 index 0000000..5df481d --- /dev/null +++ b/test.c @@ -0,0 +1,9 @@ +#include "include/gravity/core.h" +#include + +int main() { + GravityModule module = gravityCreateModule(); + printf("module: %p\n", module); + + return 0; +} \ No newline at end of file diff --git a/tests/ir/add.gir b/tests/ir/add.gir new file mode 100644 index 0000000..2b448af --- /dev/null +++ b/tests/ir/add.gir @@ -0,0 +1,12 @@ +; types: +; u8 - u64 +; i8 - i64 +; f, d +; void +; ptr + +fn add (i32 num1, i32 num2) i32 { +add_entry: + sum = addi num1, num2 + ret sum +} \ No newline at end of file