Skip to content

Commit

Permalink
~: Make all the source files headers and mark prototypes as inline (w…
Browse files Browse the repository at this point in the history
…orks for some reason)
  • Loading branch information
obiwac committed Sep 27, 2024
1 parent d5a2542 commit c987f95
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 44 deletions.
40 changes: 20 additions & 20 deletions flamingo/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
2 changes: 1 addition & 1 deletion flamingo/env.c → flamingo/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#pragma once

#include <common.h>
#include <scope.c>
#include <scope.h>

#include <assert.h>
#include <stdlib.h>
Expand Down
4 changes: 2 additions & 2 deletions flamingo/flamingo.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include "runtime/lib.c"

#include <common.h>
#include <env.c>
#include <grammar/statement.h>
#include <scope.c>
#include <env.h>
#include <scope.h>

typedef struct {
TSParser* parser;
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/access.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "expr.h"

#include <common.h>
#include <scope.c>
#include <scope.h>

static int access_find_var(flamingo_t* flamingo, TSNode node, flamingo_var_t** var, flamingo_val_t** accessed_val) {
assert(var != NULL);
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "expr.h"

#include <common.h>
#include <val.c>
#include <val.h>

static int parse_assert(flamingo_t* flamingo, TSNode node) {
assert(ts_node_child_count(node) == 2);
Expand Down
6 changes: 3 additions & 3 deletions flamingo/grammar/assignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include "expr.h"

#include <common.h>
#include <scope.c>
#include <val.c>
#include <var.c>
#include <scope.h>
#include <val.h>
#include <var.h>

static int parse_assignment(flamingo_t* flamingo, TSNode node) {
assert(strcmp(ts_node_type(node), "assignment") == 0);
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/binary_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "expr.h"

#include <common.h>
#include <val.c>
#include <val.h>

#include <math.h>

Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "statement.h"

#include <common.h>
#include <env.c>
#include <env.h>

static int parse_block(flamingo_t* flamingo, TSNode node, flamingo_scope_t** inner_scope) {
assert(strcmp(ts_node_type(node), "block") == 0);
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "block.h"
#include "expr.h"
#include <scope.c>
#include <scope.h>

#include <common.h>

Expand Down
6 changes: 3 additions & 3 deletions flamingo/grammar/function_declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#pragma once

#include <common.h>
#include <env.c>
#include <scope.c>
#include <val.c>
#include <env.h>
#include <scope.h>
#include <val.h>

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);
Expand Down
4 changes: 2 additions & 2 deletions flamingo/grammar/identifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#pragma once

#include <common.h>
#include <env.c>
#include <val.c>
#include <env.h>
#include <val.h>

static int parse_identifier(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) {
assert(strcmp(ts_node_type(node), "identifier") == 0);
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/import.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <common.h>

#include <env.c>
#include <env.h>

#include <errno.h>
#include <sys/stat.h>
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/literal.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#pragma once

#include <common.h>
#include <val.c>
#include <val.h>

static int parse_literal(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) {
assert(strcmp(ts_node_type(node), "literal") == 0);
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "expr.h"

#include <common.h>
#include <val.c>
#include <val.h>

#include <inttypes.h>

Expand Down
4 changes: 2 additions & 2 deletions flamingo/grammar/return.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "expr.h"

#include <common.h>
#include <env.c>
#include <val.c>
#include <env.h>
#include <val.h>

static int parse_return(flamingo_t* flamingo, TSNode node) {
assert(ts_node_child_count(node) == 1 || ts_node_child_count(node) == 2);
Expand Down
4 changes: 2 additions & 2 deletions flamingo/grammar/var_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "expr.h"

#include <common.h>
#include <env.c>
#include <scope.c>
#include <env.h>
#include <scope.h>

static int parse_var_decl(flamingo_t* flamingo, TSNode node) {
size_t const child_count = ts_node_named_child_count(node);
Expand Down
2 changes: 1 addition & 1 deletion flamingo/scope.c → flamingo/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#pragma once

#include <common.h>
#include <val.c>
#include <val.h>

#include <assert.h>
#include <stdlib.h>
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit c987f95

Please sign in to comment.