From c987f95cecfdd1df69e400939629dcf93c76d65f Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 27 Sep 2024 13:06:23 +0100 Subject: [PATCH] ~: Make all the source files headers and mark prototypes as inline (works for some reason) --- flamingo/common.h | 40 ++++++++++++------------- flamingo/{env.c => env.h} | 2 +- flamingo/flamingo.c | 4 +-- flamingo/grammar/access.h | 2 +- flamingo/grammar/assert.h | 2 +- flamingo/grammar/assignment.h | 6 ++-- flamingo/grammar/binary_expr.h | 2 +- flamingo/grammar/block.h | 2 +- flamingo/grammar/call.h | 2 +- flamingo/grammar/function_declaration.h | 6 ++-- flamingo/grammar/identifier.h | 4 +-- flamingo/grammar/import.h | 2 +- flamingo/grammar/literal.h | 2 +- flamingo/grammar/print.h | 2 +- flamingo/grammar/return.h | 4 +-- flamingo/grammar/var_decl.h | 4 +-- flamingo/{scope.c => scope.h} | 2 +- flamingo/{val.c => val.h} | 0 flamingo/{var.c => var.h} | 0 19 files changed, 44 insertions(+), 44 deletions(-) rename flamingo/{env.c => env.h} (99%) rename flamingo/{scope.c => scope.h} (98%) rename flamingo/{val.c => val.h} (100%) rename flamingo/{var.c => var.h} (100%) diff --git a/flamingo/common.h b/flamingo/common.h index c767973..28a6df0 100644 --- a/flamingo/common.h +++ b/flamingo/common.h @@ -33,34 +33,34 @@ static inline int parse_function_declaration(flamingo_t* flamingo, TSNode node, // Environment prototypes. -static flamingo_env_t* env_alloc(void); -static flamingo_scope_t* env_parent_scope(flamingo_env_t* env); -static flamingo_scope_t* env_cur_scope(flamingo_env_t* env); -static void env_gently_attach_scope(flamingo_env_t* env, flamingo_scope_t* scope); -static flamingo_scope_t* env_gently_detach_scope(flamingo_env_t* env); -static flamingo_scope_t* env_push_scope(flamingo_env_t* env); -static void env_pop_scope(flamingo_env_t* env); -static flamingo_var_t* env_find_var(flamingo_env_t* env, char const* key, size_t key_size); +static inline flamingo_env_t* env_alloc(void); +static inline flamingo_scope_t* env_parent_scope(flamingo_env_t* env); +static inline flamingo_scope_t* env_cur_scope(flamingo_env_t* env); +static inline void env_gently_attach_scope(flamingo_env_t* env, flamingo_scope_t* scope); +static inline flamingo_scope_t* env_gently_detach_scope(flamingo_env_t* env); +static inline flamingo_scope_t* env_push_scope(flamingo_env_t* env); +static inline void env_pop_scope(flamingo_env_t* env); +static inline flamingo_var_t* env_find_var(flamingo_env_t* env, char const* key, size_t key_size); // Scope prototypes. -static flamingo_scope_t* scope_alloc(void); -static void scope_free(flamingo_scope_t* scope); -static flamingo_var_t* scope_add_var(flamingo_scope_t* scope, char const* key, size_t key_size); -static flamingo_var_t* scope_shallow_find_var(flamingo_scope_t* scope, char const* key, size_t key_size); +static inline flamingo_scope_t* scope_alloc(void); +static inline void scope_free(flamingo_scope_t* scope); +static inline flamingo_var_t* scope_add_var(flamingo_scope_t* scope, char const* key, size_t key_size); +static inline flamingo_var_t* scope_shallow_find_var(flamingo_scope_t* scope, char const* key, size_t key_size); // Variable prototypes. -static void var_set_val(flamingo_var_t* var, flamingo_val_t* val); +static inline void var_set_val(flamingo_var_t* var, flamingo_val_t* val); // Value prototypes. -static flamingo_val_t* val_incref(flamingo_val_t* val); -static flamingo_val_t* val_init(flamingo_val_t* val); -static char const* val_type_str(flamingo_val_t* val); -static char const* val_role_str(flamingo_val_t* val); -static flamingo_val_t* val_alloc(void); -static void val_free(flamingo_val_t* val); -static flamingo_val_t* val_decref(flamingo_val_t* val); +static inline flamingo_val_t* val_incref(flamingo_val_t* val); +static inline flamingo_val_t* val_init(flamingo_val_t* val); +static inline char const* val_type_str(flamingo_val_t* val); +static inline char const* val_role_str(flamingo_val_t* val); +static inline flamingo_val_t* val_alloc(void); +static inline void val_free(flamingo_val_t* val); +static inline flamingo_val_t* val_decref(flamingo_val_t* val); #define error(...) (flamingo_raise_error(__VA_ARGS__)) diff --git a/flamingo/env.c b/flamingo/env.h similarity index 99% rename from flamingo/env.c rename to flamingo/env.h index 59411c2..f83eb5a 100644 --- a/flamingo/env.c +++ b/flamingo/env.h @@ -4,7 +4,7 @@ #pragma once #include -#include +#include #include #include diff --git a/flamingo/flamingo.c b/flamingo/flamingo.c index 351a056..4cf4d0d 100644 --- a/flamingo/flamingo.c +++ b/flamingo/flamingo.c @@ -11,9 +11,9 @@ #include "runtime/lib.c" #include -#include #include -#include +#include +#include typedef struct { TSParser* parser; diff --git a/flamingo/grammar/access.h b/flamingo/grammar/access.h index de53794..1966527 100644 --- a/flamingo/grammar/access.h +++ b/flamingo/grammar/access.h @@ -6,7 +6,7 @@ #include "expr.h" #include -#include +#include static int access_find_var(flamingo_t* flamingo, TSNode node, flamingo_var_t** var, flamingo_val_t** accessed_val) { assert(var != NULL); diff --git a/flamingo/grammar/assert.h b/flamingo/grammar/assert.h index cfc52f2..7529101 100644 --- a/flamingo/grammar/assert.h +++ b/flamingo/grammar/assert.h @@ -6,7 +6,7 @@ #include "expr.h" #include -#include +#include static int parse_assert(flamingo_t* flamingo, TSNode node) { assert(ts_node_child_count(node) == 2); diff --git a/flamingo/grammar/assignment.h b/flamingo/grammar/assignment.h index ae02a1f..9ecf32f 100644 --- a/flamingo/grammar/assignment.h +++ b/flamingo/grammar/assignment.h @@ -7,9 +7,9 @@ #include "expr.h" #include -#include -#include -#include +#include +#include +#include static int parse_assignment(flamingo_t* flamingo, TSNode node) { assert(strcmp(ts_node_type(node), "assignment") == 0); diff --git a/flamingo/grammar/binary_expr.h b/flamingo/grammar/binary_expr.h index 666a411..df0fa4a 100644 --- a/flamingo/grammar/binary_expr.h +++ b/flamingo/grammar/binary_expr.h @@ -6,7 +6,7 @@ #include "expr.h" #include -#include +#include #include diff --git a/flamingo/grammar/block.h b/flamingo/grammar/block.h index 35f60af..d0a9923 100644 --- a/flamingo/grammar/block.h +++ b/flamingo/grammar/block.h @@ -6,7 +6,7 @@ #include "statement.h" #include -#include +#include static int parse_block(flamingo_t* flamingo, TSNode node, flamingo_scope_t** inner_scope) { assert(strcmp(ts_node_type(node), "block") == 0); diff --git a/flamingo/grammar/call.h b/flamingo/grammar/call.h index 3b9b180..b7910e3 100644 --- a/flamingo/grammar/call.h +++ b/flamingo/grammar/call.h @@ -5,7 +5,7 @@ #include "block.h" #include "expr.h" -#include +#include #include diff --git a/flamingo/grammar/function_declaration.h b/flamingo/grammar/function_declaration.h index 3e9c8fb..0392208 100644 --- a/flamingo/grammar/function_declaration.h +++ b/flamingo/grammar/function_declaration.h @@ -4,9 +4,9 @@ #pragma once #include -#include -#include -#include +#include +#include +#include static int parse_function_declaration(flamingo_t* flamingo, TSNode node, flamingo_fn_kind_t kind) { size_t const child_count = ts_node_child_count(node); diff --git a/flamingo/grammar/identifier.h b/flamingo/grammar/identifier.h index c049c2a..7fa52f3 100644 --- a/flamingo/grammar/identifier.h +++ b/flamingo/grammar/identifier.h @@ -4,8 +4,8 @@ #pragma once #include -#include -#include +#include +#include static int parse_identifier(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) { assert(strcmp(ts_node_type(node), "identifier") == 0); diff --git a/flamingo/grammar/import.h b/flamingo/grammar/import.h index 16afc79..d15d1df 100644 --- a/flamingo/grammar/import.h +++ b/flamingo/grammar/import.h @@ -5,7 +5,7 @@ #include -#include +#include #include #include diff --git a/flamingo/grammar/literal.h b/flamingo/grammar/literal.h index 480c1b7..f6ed3e2 100644 --- a/flamingo/grammar/literal.h +++ b/flamingo/grammar/literal.h @@ -4,7 +4,7 @@ #pragma once #include -#include +#include static int parse_literal(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) { assert(strcmp(ts_node_type(node), "literal") == 0); diff --git a/flamingo/grammar/print.h b/flamingo/grammar/print.h index cc7f68d..af8ecf3 100644 --- a/flamingo/grammar/print.h +++ b/flamingo/grammar/print.h @@ -6,7 +6,7 @@ #include "expr.h" #include -#include +#include #include diff --git a/flamingo/grammar/return.h b/flamingo/grammar/return.h index f97584a..d0cad10 100644 --- a/flamingo/grammar/return.h +++ b/flamingo/grammar/return.h @@ -6,8 +6,8 @@ #include "expr.h" #include -#include -#include +#include +#include static int parse_return(flamingo_t* flamingo, TSNode node) { assert(ts_node_child_count(node) == 1 || ts_node_child_count(node) == 2); diff --git a/flamingo/grammar/var_decl.h b/flamingo/grammar/var_decl.h index 30afbbc..87eccf3 100644 --- a/flamingo/grammar/var_decl.h +++ b/flamingo/grammar/var_decl.h @@ -6,8 +6,8 @@ #include "expr.h" #include -#include -#include +#include +#include static int parse_var_decl(flamingo_t* flamingo, TSNode node) { size_t const child_count = ts_node_named_child_count(node); diff --git a/flamingo/scope.c b/flamingo/scope.h similarity index 98% rename from flamingo/scope.c rename to flamingo/scope.h index 0448e80..eb0613a 100644 --- a/flamingo/scope.c +++ b/flamingo/scope.h @@ -4,7 +4,7 @@ #pragma once #include -#include +#include #include #include diff --git a/flamingo/val.c b/flamingo/val.h similarity index 100% rename from flamingo/val.c rename to flamingo/val.h diff --git a/flamingo/var.c b/flamingo/var.h similarity index 100% rename from flamingo/var.c rename to flamingo/var.h