Skip to content

Commit

Permalink
external functions: FLAMINGO_FN_KIND_PROTO -> `FLAMINGO_FN_KIND_EXT…
Browse files Browse the repository at this point in the history
…ERN`
  • Loading branch information
obiwac committed Sep 16, 2024
1 parent e7377d7 commit 76259a2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion flamingo/flamingo.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef enum {
typedef enum {
FLAMINGO_FN_KIND_FUNCTION,
FLAMINGO_FN_KIND_CLASS,
FLAMINGO_FN_KIND_PROTO, // XXX Maybe a better name for this is '*_EXTERN'?
FLAMINGO_FN_KIND_EXTERN,
} flamingo_fn_kind_t;

typedef void* flamingo_ts_node_t; // Opaque type, because user shouldn't have to include Tree-sitter stuff in their namespace (or concern themselves with Tree-sitter at all for that matter).
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int parse_call(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) {
TSNode* const body = callable->fn.body;
flamingo_scope_t* inner_scope;

if (callable->fn.kind == FLAMINGO_FN_KIND_PROTO) {
if (callable->fn.kind == FLAMINGO_FN_KIND_EXTERN) {
if (flamingo->external_fn_cb == NULL) {
return error(flamingo, "cannot call external function without a external function callback being set");
}
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 @@ -20,7 +20,7 @@ static int parse_function_declaration(flamingo_t* flamingo, TSNode node, flaming
case FLAMINGO_FN_KIND_CLASS:
thing = "class";
break;
case FLAMINGO_FN_KIND_PROTO:
case FLAMINGO_FN_KIND_EXTERN:
thing = "external prototype";
break;
default:
Expand Down Expand Up @@ -72,7 +72,7 @@ static int parse_function_declaration(flamingo_t* flamingo, TSNode node, flaming

TSNode body;

if (kind != FLAMINGO_FN_KIND_PROTO) {
if (kind != FLAMINGO_FN_KIND_EXTERN) {
body = ts_node_child_by_field_name(node, "body", 4);
char const* const body_type = ts_node_type(body);

Expand Down Expand Up @@ -124,7 +124,7 @@ static int parse_function_declaration(flamingo_t* flamingo, TSNode node, flaming
// Assign body node.
// Prototypes by definition don't have bodies.

if (kind != FLAMINGO_FN_KIND_PROTO) {
if (kind != FLAMINGO_FN_KIND_EXTERN) {
var->val->fn.body = malloc(sizeof body);
memcpy(var->val->fn.body, &body, sizeof body);
}
Expand Down
2 changes: 1 addition & 1 deletion flamingo/grammar/statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int parse_statement(flamingo_t* flamingo, TSNode node) {
}

else if (strcmp(type, "proto") == 0) {
return parse_function_declaration(flamingo, child, FLAMINGO_FN_KIND_PROTO);
return parse_function_declaration(flamingo, child, FLAMINGO_FN_KIND_EXTERN);
}

else if (strcmp(type, "expression") == 0) {
Expand Down
2 changes: 1 addition & 1 deletion flamingo/val.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static char const* val_type_str(flamingo_val_t* val) {
return "string";
case FLAMINGO_VAL_KIND_FN:
switch (val->fn.kind) {
case FLAMINGO_FN_KIND_PROTO:
case FLAMINGO_FN_KIND_EXTERN:
return "external function";
case FLAMINGO_FN_KIND_FUNCTION:
return "function";
Expand Down

0 comments on commit 76259a2

Please sign in to comment.