aboutsummaryrefslogtreecommitdiff
path: root/interpreter/code.c
diff options
context:
space:
mode:
authorCamil Staps2016-10-07 21:21:40 +0200
committerCamil Staps2016-10-07 21:21:40 +0200
commitf8e50700cd0eb93154f5c025ef20d428986b856c (patch)
treee239bc8748edf2b1b80bf532dd46b6ddb5ab8614 /interpreter/code.c
parentResolve #12, don't show code keyword in debug graph (diff)
Cleanup (resolves #9)
Diffstat (limited to 'interpreter/code.c')
-rw-r--r--interpreter/code.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/interpreter/code.c b/interpreter/code.c
index ddd8402..b20b2ba 100644
--- a/interpreter/code.c
+++ b/interpreter/code.c
@@ -7,7 +7,7 @@
#include "mem.h"
#include "print.h"
-void fill_node_int(struct node** node, int i) {
+void fill_node_int(struct node **node, int i) {
unsigned int used_count = (*node)->used_count;
free_node(*node, used_count, 0);
(*node)->kind = NODE_INT;
@@ -16,11 +16,11 @@ void fill_node_int(struct node** node, int i) {
use_node(*node, used_count);
}
-void fill_node_bool(struct node** node, int i) {
+void fill_node_bool(struct node **node, int i) {
fill_node_int(node, i ? 1 : 0);
}
-void fill_node_name(struct node** node, char* s) {
+void fill_node_name(struct node **node, char *s) {
unsigned int used_count = (*node)->used_count;
free_node(*node, used_count, 0);
(*node)->kind = NODE_NAME;
@@ -29,11 +29,11 @@ void fill_node_name(struct node** node, char* s) {
use_node(*node, used_count);
}
-void code_time(struct node** result) {
+void code_time(struct node **result) {
fill_node_int(result, (int) time(NULL));
}
-void code_trace(struct node** result, struct node *p, struct node *r) {
+void code_trace(struct node **result, struct node *p, struct node *r) {
print_node(p);
printf("\n");
use_node(r, (*result)->used_count);
@@ -41,63 +41,63 @@ void code_trace(struct node** result, struct node *p, struct node *r) {
*result = r;
}
-void code_add(struct node** result, struct node* a, struct node* b) {
+void code_add(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "add on non-ints");
else
fill_node_int(result, *((int*) b->var1) + *((int*) a->var1));
}
-void code_mul(struct node** result, struct node* a, struct node* b) {
+void code_mul(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "mul on non-ints");
else
fill_node_int(result, *((int*) a->var1) * *((int*) b->var1));
}
-void code_sub(struct node** result, struct node* a, struct node* b) {
+void code_sub(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "sub on non-ints");
else
fill_node_int(result, *((int*) b->var1) - *((int*) a->var1));
}
-void code_eq(struct node** result, struct node* a, struct node* b) {
+void code_eq(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "eq on non-ints");
else
fill_node_bool(result, *((int*) a->var1) == *((int*) b->var1));
}
-void code_gt(struct node** result, struct node* a, struct node* b) {
+void code_gt(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "gt on non-ints");
else
fill_node_bool(result, *((int*) a->var1) > *((int*) b->var1));
}
-void code_ge(struct node** result, struct node* a, struct node* b) {
+void code_ge(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "ge on non-ints");
else
fill_node_bool(result, *((int*) a->var1) >= *((int*) b->var1));
}
-void code_lt(struct node** result, struct node* a, struct node* b) {
+void code_lt(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "lt on non-ints");
else
fill_node_bool(result, *((int*) a->var1) < *((int*) b->var1));
}
-void code_le(struct node** result, struct node* a, struct node* b) {
+void code_le(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "le on non-ints");
else
fill_node_bool(result, *((int*) a->var1) <= *((int*) b->var1));
}
-void code_ne(struct node** result, struct node* a, struct node* b) {
+void code_ne(struct node **result, struct node *a, struct node *b) {
if (a->kind != NODE_INT || b->kind != NODE_INT)
fill_node_name(result, "ne on non-ints");
else
@@ -105,8 +105,8 @@ void code_ne(struct node** result, struct node* a, struct node* b) {
}
struct code_mapping {
- char* name;
- void* f;
+ char *name;
+ void *f;
unsigned char arity;
};
@@ -125,7 +125,7 @@ static struct code_mapping code_table[] = {
{ NULL }
};
-unsigned char code_find(char* name, void** function) {
+unsigned char code_find(char *name, void **function) {
struct code_mapping *entry = code_table;
while (entry) {
if (!strcmp(name, entry->name)) {
@@ -140,7 +140,7 @@ unsigned char code_find(char* name, void** function) {
}
#ifdef _FUSPEL_DEBUG
-char *code_find_name(void* f) {
+char *code_find_name(void *f) {
struct code_mapping *entry = code_table;
while (entry) {
if (f == entry->f)